From fceb1a37df623649d191c3c1a881e5b0538b1391 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Tue, 3 Mar 2020 19:39:02 -0500 Subject: Added test suite and API type checking for more helpful error messages. --- core/keys.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'core/keys.lua') diff --git a/core/keys.lua b/core/keys.lua index 35af9bc8..a6a9207a 100644 --- a/core/keys.lua +++ b/core/keys.lua @@ -88,9 +88,9 @@ local M = {} -- ## Key Chains -- -- Key chains are a powerful concept. They allow you to assign multiple key --- bindings to one key sequence. By default, the `Esc` (`⎋` on Mac OSX | `Esc` --- in curses) key cancels a key chain, but you can redefine it via --- [`keys.CLEAR`](). An example key chain looks like: +-- bindings to one key sequence. By default, the `Esc` key cancels a key chain, +-- but you can redefine it via [`keys.CLEAR`](). An example key chain looks +-- like: -- -- keys['aa'] = { -- a = function1, @@ -205,10 +205,13 @@ local function keypress(code, shift, control, alt, meta, caps_lock) 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 - shift = shift and (code >= 256 or code == 9) -- printable chars are uppercased - if OSX and alt and code < 256 then alt = false end -- composed key; ignore alt - local key_seq = (control and CTRL or '')..(alt and ALT or '').. - (meta and OSX and META or '')..(shift and SHIFT or '')..key + -- Since printable characters are uppercased, disable shift. + if shift and code < 256 and code ~= 9 then shift = false end + -- For composed keys on OSX, ignore alt. + if OSX and alt and code < 256 then alt = false end + local key_seq = string.format('%s%s%s%s%s', control and CTRL or '', + alt and ALT or '', meta and OSX and META or '', + shift and SHIFT or '', key) --print(key_seq) ui.statusbar_text = '' -- cgit v1.2.3