Mercurial > emacs
diff src/nsterm.m @ 110930:b6cf32bb07a1
Bug#7150: Distinguishing between left and right Alt keys on NextStep/OSX.
* lisp/cus-start.el (all): ns-right-alternate-modifier is new.
* lisp/term/ns-win.el (ns-right-alternate-modifier): New defvar.
(ns-right-option-modifier): New alias for ns-right-alternate-modifier.
(mac-right-option-modifier): New alias for ns-right-option-modifier.
* src/nsterm.m (Qleft): Declare.
(ns_right_alternate_modifier): New variable
(NSRightAlternateKeyMask): New define.
(EV_MODIFIERS): Parse NSRightAlternateKeyMask if
ns_right_alternate_modifier isn't Qleft.
(keyDown): If ns_right_alternate_modifier isn't Qleft, use it
as emacs modifier for NSRightAlternateKeyMask.
(syms_of_nsterm): DEFVAR_LISP ns-right-alternate-modifier.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Mon, 11 Oct 2010 21:18:08 +0200 |
parents | f6f0d450d542 |
children | 2316b868d5be cda2045a5ee8 |
line wrap: on
line diff
--- a/src/nsterm.m Sun Oct 10 21:31:40 2010 +0200 +++ b/src/nsterm.m Mon Oct 11 21:18:08 2010 +0200 @@ -142,13 +142,18 @@ Lisp_Object Vx_toolkit_scroll_bars; static Lisp_Object Qmodifier_value; Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone; -extern Lisp_Object Qcursor_color, Qcursor_type, Qns; +extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft; /* Specifies which emacs modifier should be generated when NS receives the Alternate modifer. May be Qnone or any of the modifier lisp symbols. */ Lisp_Object ns_alternate_modifier; /* Specifies which emacs modifier should be generated when NS receives + the right Alternate modifer. Has same values as ns_alternate_modifier plus + the value Qleft which means whatever value ns_alternate_modifier has. */ +Lisp_Object ns_right_alternate_modifier; + +/* Specifies which emacs modifier should be generated when NS receives the Command modifer. May be any of the modifier lisp symbols. */ Lisp_Object ns_command_modifier; @@ -218,12 +223,17 @@ /* Convert modifiers in a NeXTSTEP event to emacs style modifiers. */ #define NS_FUNCTION_KEY_MASK 0x800000 +#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask) #define EV_MODIFIERS(e) \ ((([e modifierFlags] & NSHelpKeyMask) ? \ hyper_modifier : 0) \ - | (([e modifierFlags] & NSAlternateKeyMask) ? \ + | (!EQ (ns_right_alternate_modifier, Qleft) && \ + (([e modifierFlags] & NSRightAlternateKeyMask) \ + == NSRightAlternateKeyMask) ? \ + parse_solitary_modifier (ns_right_alternate_modifier) : 0) \ + | (([e modifierFlags] & NSAlternateKeyMask) ? \ parse_solitary_modifier (ns_alternate_modifier) : 0) \ - | (([e modifierFlags] & NSShiftKeyMask) ? \ + | (([e modifierFlags] & NSShiftKeyMask) ? \ shift_modifier : 0) \ | (([e modifierFlags] & NSControlKeyMask) ? \ parse_solitary_modifier (ns_control_modifier) : 0) \ @@ -4423,7 +4433,13 @@ emacs_event->modifiers |= parse_solitary_modifier (ns_function_modifier); - if (flags & NSAlternateKeyMask) /* default = meta */ + if (!EQ (ns_right_alternate_modifier, Qleft) + && ((flags & NSRightAlternateKeyMask) == NSRightAlternateKeyMask)) + { + emacs_event->modifiers |= parse_solitary_modifier + (ns_right_alternate_modifier); + } + else if (flags & NSAlternateKeyMask) /* default = meta */ { if ((NILP (ns_alternate_modifier) || EQ (ns_alternate_modifier, Qnone)) && !fnKeysym) @@ -6185,6 +6201,14 @@ at all, allowing it to be used at a lower level for accented character entry."); ns_alternate_modifier = Qmeta; + DEFVAR_LISP ("ns-right-alternate-modifier", &ns_right_alternate_modifier, + "This variable describes the behavior of the right alternate or option key.\n\ +Set to control, meta, alt, super, or hyper means it is taken to be that key.\n\ +Set to left means be the same key as `ns-alternate-modifier'.\n\ +Set to none means that the alternate / option key is not interpreted by Emacs\n\ +at all, allowing it to be used at a lower level for accented character entry."); + ns_right_alternate_modifier = Qleft; + DEFVAR_LISP ("ns-command-modifier", &ns_command_modifier, "This variable describes the behavior of the command key.\n\ Set to control, meta, alt, super, or hyper means it is taken to be that key.");