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.
This commit is contained in:
Alan Third 2017-12-24 15:40:03 +00:00
parent 9a220bbd94
commit 1daac66a6e
3 changed files with 31 additions and 2 deletions

View file

@ -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)

View file

@ -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);

View file

@ -6283,11 +6283,18 @@ flag set (this is probably a bug in the OS).
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;