From: Alan Third Date: Sun, 24 Dec 2017 15:40:03 +0000 (+0000) Subject: Add macOS character-palette (bug#29837) X-Git-Tag: emacs-27.0.90~5914 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1daac66a6eedbcbfa32ab920b5c579872d989517;p=emacs.git 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. --- diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index c9534b7bb81..aa3113bd340 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 3ede63f9854..c8b30246268 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 3f59e33c7b1..b80d832ee0b 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;