[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 1daac66 2/2: Add macOS character-palette (bug#29837
From: |
Alan Third |
Subject: |
[Emacs-diffs] master 1daac66 2/2: Add macOS character-palette (bug#29837) |
Date: |
Sun, 7 Jan 2018 15:39:05 -0500 (EST) |
branch: master
commit 1daac66a6eedbcbfa32ab920b5c579872d989517
Author: Alan Third <address@hidden>
Commit: Alan Third <address@hidden>
Add macOS character-palette (bug#29837)
* lisp/ns-win.el (ns-do-show-character-palette): New function.
* src/nsfns.m (Sns_show_character_palette): New function.
* src/nsterm.m (EmacsView::insertText): Handle NSAttributedString.
---
lisp/term/ns-win.el | 8 ++++++++
src/nsfns.m | 14 ++++++++++++++
src/nsterm.m | 11 +++++++++--
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index c9534b7..aa3113b 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -144,6 +144,8 @@ The properties returned may include `top', `left',
`height', and `width'."
(define-key global-map [?\s-z] 'undo)
(define-key global-map [?\s-|] 'shell-command-on-region)
(define-key global-map [s-kp-bar] 'shell-command-on-region)
+(define-key global-map [C-s- ] 'ns-do-show-character-palette)
+(define-key key-translation-map [C-s-268632064] [C-s- ])
;; (as in Terminal.app)
(define-key global-map [s-right] 'ns-next-frame)
(define-key global-map [s-left] 'ns-prev-frame)
@@ -575,6 +577,12 @@ the last file dropped is selected."
(interactive)
(ns-emacs-info-panel))
+(declare-function ns-show-character-palette "nsfns.m" ())
+
+(defun ns-do-show-character-palette ()
+ (interactive)
+ (ns-show-character-palette))
+
(defun ns-next-frame ()
"Switch to next visible frame."
(interactive)
diff --git a/src/nsfns.m b/src/nsfns.m
index 3ede63f..c8b3024 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -3135,6 +3135,19 @@ position (0, 0) of the selected frame's terminal. */)
(pt.y - screen.frame.origin.y)));
}
+DEFUN ("ns-show-character-palette",
+ Fns_show_character_palette,
+ Sns_show_character_palette, 0, 0, 0,
+ doc: /* Show the macOS character palette. */)
+ (void)
+{
+ struct frame *f = SELECTED_FRAME ();
+ EmacsView *view = FRAME_NS_VIEW (f);
+ [NSApp orderFrontCharacterPalette:view];
+
+ return Qnil;
+}
+
/* ==========================================================================
Class implementations
@@ -3326,6 +3339,7 @@ be used as the image of the icon representing the frame.
*/);
defsubr (&Sns_frame_restack);
defsubr (&Sns_set_mouse_absolute_pixel_position);
defsubr (&Sns_mouse_absolute_pixel_position);
+ defsubr (&Sns_show_character_palette);
defsubr (&Sx_display_mm_width);
defsubr (&Sx_display_mm_height);
defsubr (&Sx_display_screens);
diff --git a/src/nsterm.m b/src/nsterm.m
index 3f59e33..b80d832 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6283,11 +6283,18 @@ not_in_argv (NSString *arg)
by doCommandBySelector: deleteBackward: */
- (void)insertText: (id)aString
{
- NSString *s = aString;
- NSUInteger len = [s length];
+ NSString *s;
+ NSUInteger len;
NSTRACE ("[EmacsView insertText:]");
+ if ([aString isKindOfClass:[NSAttributedString class]])
+ s = [aString string];
+ else
+ s = aString;
+
+ len = [s length];
+
if (NS_KEYLOG)
NSLog (@"insertText '%@'\tlen = %lu", aString, (unsigned long) len);
processingCompose = NO;