From ad16b98288abe91732217535e308ae445303ab59 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 24 Dec 2017 15:40:03 +0000 Subject: [PATCH] Add macOS character-palette --- lisp/term/ns-win.el | 8 ++++++++ src/nsfns.m | 14 ++++++++++++++ src/nsterm.m | 7 ++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index d512e8e506..7955ae0cb0 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -144,6 +144,8 @@ global-map (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) +;; The key-chord below is C-s-SPC +(define-key global-map [C-s-268632064] 'ns-do-show-character-palette) ;; (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 @@ ns-do-emacs-info-panel (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 05605bf657..402771e2f8 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -3135,6 +3135,19 @@ The position is returned as a cons cell (X . Y) of the (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 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename 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 07ac8f978f..65a9aac4a7 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6284,11 +6284,16 @@ flag set (this is probably a bug in the OS). - (void)insertText: (id)aString { int code; - int len = [(NSString *)aString length]; + int len; int i; NSTRACE ("[EmacsView insertText:]"); + if ([aString isKindOfClass:[NSAttributedString class]]) + aString = [aString string]; + + len = [(NSString *)aString length]; + if (NS_KEYLOG) NSLog (@"insertText '%@'\tlen = %d", aString, len); processingCompose = NO; -- 2.14.3