diff options
-rw-r--r-- | core/events.lua | 1 | ||||
-rw-r--r-- | core/keys.lua | 8 | ||||
-rw-r--r-- | src/textadept.c | 3 |
3 files changed, 9 insertions, 3 deletions
diff --git a/core/events.lua b/core/events.lua index dcaf5716..8cfa6e9f 100644 --- a/core/events.lua +++ b/core/events.lua @@ -153,6 +153,7 @@ local M = {} -- * _`ctrl`_: The "Control" modifier key is held down. -- * _`alt`_: The "Alt"/"Option" modifier key is held down. -- * _`meta`_: The "Command" modifier key on Mac OSX is held down. +-- * _`caps_lock`_: The "Caps Lock" modifier is on. -- @field MARGIN_CLICK (string) -- Emitted when clicking the mouse inside a sensitive margin. -- Arguments: diff --git a/core/keys.lua b/core/keys.lua index 6187b466..27ccfa91 100644 --- a/core/keys.lua +++ b/core/keys.lua @@ -195,9 +195,13 @@ end -- @param control Whether or not the Control modifier is pressed. -- @param alt Whether or not the Alt/option modifier is pressed. -- @param meta Whether or not the Command modifier on Mac OSX is pressed. +-- @param caps_lock Whether or not Caps Lock is enabled. -- @return `true` to stop handling the key; `nil` otherwise. -local function keypress(code, shift, control, alt, meta) - --print(code, M.KEYSYMS[code], shift, control, alt, meta) +local function keypress(code, shift, control, alt, meta, caps_lock) + --print(code, M.KEYSYMS[code], shift, control, alt, meta, caps_lock) + if caps_lock and (shift or control or alt or meta) and code < 256 then + code = string[shift and 'upper' or 'lower'](string.char(code)):byte() + end local key = code < 256 and (not CURSES or (code ~= 7 and code ~= 13)) and string.char(code) or M.KEYSYMS[code] if not key then return end diff --git a/src/textadept.c b/src/textadept.c index 1b5eb203..d9b1ce66 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -1944,7 +1944,8 @@ static void s_notify(Scintilla *view, int _, void *lParam, void*__) { /** Signal for a Scintilla keypress. */ static int s_keypress(GtkWidget*_, GdkEventKey *event, void*__) { return lL_event(lua, "keypress", LUA_TNUMBER, event->keyval, event_mod(SHIFT), - event_mod(CONTROL), event_mod(MOD1), event_mod(META), -1); + event_mod(CONTROL), event_mod(MOD1), event_mod(META), + event_mod(LOCK), -1); } /** Signal for a Scintilla mouse click. */ |