Mercurial > emacs
diff src/macterm.c @ 57783:4cb8cebc3255
2004-10-28 Will <will@glozer.net>
* macterm.c: allow user to assign key modifiers to the Mac Option
key via a 'mac-option-modifier' variable.
author | John Wiegley <johnw@newartisans.com> |
---|---|
date | Fri, 29 Oct 2004 00:00:43 +0000 |
parents | 0867872551d9 |
children | c936fa56eb60 4056279af756 e24e2e78deda |
line wrap: on
line diff
--- a/src/macterm.c Thu Oct 28 23:35:13 2004 +0000 +++ b/src/macterm.c Fri Oct 29 00:00:43 2004 +0000 @@ -228,6 +228,10 @@ extern int extra_keyboard_modifiers; +/* The keysyms to use for the various modifiers. */ + +static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; + static Lisp_Object Qvendor_specific_keysyms; #if 0 @@ -6988,6 +6992,9 @@ /* True if using command key as meta key. */ Lisp_Object Vmac_command_key_is_meta; +/* Modifier associated with the option key, or nil for normal behavior. */ +Lisp_Object Vmac_option_modifier; + /* True if the ctrl and meta keys should be reversed. */ Lisp_Object Vmac_reverse_ctrl_meta; @@ -7069,6 +7076,12 @@ result |= meta_modifier; if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) result |= alt_modifier; + if (!NILP (Vmac_option_modifier) && (mods & optionKey)) { + Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value); + if (!NILP(val)) + result |= XUINT(val); + } + return result; } @@ -8549,7 +8562,18 @@ unsigned long some_state = 0; inev.code = KeyTranslate (kchr_ptr, new_keycode, &some_state) & 0xff; - } + } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey)) + { + /* When using the option key as an emacs modifier, convert + the pressed key code back to one without the Mac option + modifier applied. */ + int new_modifiers = er.modifiers & ~optionKey; + int new_keycode = keycode | new_modifiers; + Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); + unsigned long some_state = 0; + inev.code = KeyTranslate (kchr_ptr, new_keycode, + &some_state) & 0xff; + } else inev.code = er.message & charCodeMask; inev.kind = ASCII_KEYSTROKE_EVENT; @@ -9248,6 +9272,14 @@ x_error_message_string = Qnil; #endif + Qmodifier_value = intern ("modifier-value"); + Qalt = intern ("alt"); + Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); + Qhyper = intern ("hyper"); + Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); + Qsuper = intern ("super"); + Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); + Fprovide (intern ("mac-carbon"), Qnil); staticpro (&Qreverse); @@ -9304,6 +9336,12 @@ Otherwise the option key is used. */); Vmac_command_key_is_meta = Qt; + DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier, + doc: /* Modifier to use for the Mac alt/option key. The value can +be alt, hyper, or super for the respective modifier. If the value is +nil then the key will act as the normal Mac option modifier. */); + Vmac_option_modifier = Qnil; + DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, doc: /* Non-nil means that the control and meta keys are reversed. This is useful for non-standard keyboard layouts. */);