aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2013-04-08 23:14:48 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2013-04-08 23:14:48 -0400
commite8c201b14c90deb703a9b3ace74f6189fe429e39 (patch)
treefba114fde480bccab4b3686a8673a625589e24b3
parent349cc6da144cd6faafa1b7d65c955c513abafdd2 (diff)
downloadtextadept-e8c201b14c90deb703a9b3ace74f6189fe429e39.tar.gz
textadept-e8c201b14c90deb703a9b3ace74f6189fe429e39.zip
Make "command_entry_keypress" event more consistent with "keypress" in curses.
-rw-r--r--doc/14_Appendix.md2
-rw-r--r--src/textadept.c14
2 files changed, 12 insertions, 4 deletions
diff --git a/doc/14_Appendix.md b/doc/14_Appendix.md
index a9d80510..d24e8c4e 100644
--- a/doc/14_Appendix.md
+++ b/doc/14_Appendix.md
@@ -142,6 +142,8 @@ in its editing component Scintilla:
default. For some terminals, you may need to set a lexer style's `bold`
attribute in order to use the light color variant.
* Scroll bars are not supported.
+* Some key sequences are not recognized by the terminal or have unexpected key
+* codes.
* Some styles settings like font name, font size, and italic do not display
properly (terminals use one only font, size and variant).
* Viewing whitespace does not show the "Tab" character arrows
diff --git a/src/textadept.c b/src/textadept.c
index 6a41b5a2..1e913aae 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -554,7 +554,13 @@ static int c_keypress(EObjectType _, void *object, void *data, chtype key) {
if (key == KEY_ENTER) {
fcopy(&command_text, getCDKEntryValue((CDKENTRY *)object));
ret = lL_event(lua, "command_entry_command", LUA_TSTRING, command_text, -1);
- } else ret = !lL_event(lua, "command_entry_keypress", LUA_TNUMBER, key, -1);
+ } else {
+ int ctrl = key < 0x20 && key != 9 && key != 10 && key != 13 && key != 27;
+ if (ctrl) key = tolower(key ^ 0x40);
+ // TODO: F1-F12.
+ ret = !lL_event(lua, "command_entry_keypress", LUA_TNUMBER, key,
+ LUA_TBOOLEAN, FALSE, LUA_TBOOLEAN, ctrl, -1);
+ }
scintilla_refresh(focused_view), drawCDKEntry((CDKENTRY *)object, FALSE);
return key == KEY_TAB || ret;
}
@@ -2385,9 +2391,9 @@ int main(int argc, char **argv) {
else if (key.type == TERMKEY_TYPE_KEYSYM &&
key.code.sym >= 0 && key.code.sym <= TERMKEY_SYM_END)
c = keysyms[key.code.sym];
- shift = (key.modifiers & TERMKEY_KEYMOD_SHIFT) ? TRUE : FALSE;
- ctrl = (key.modifiers & TERMKEY_KEYMOD_CTRL) ? TRUE : FALSE;
- alt = (key.modifiers & TERMKEY_KEYMOD_ALT) ? TRUE : FALSE;
+ shift = key.modifiers & TERMKEY_KEYMOD_SHIFT;
+ ctrl = key.modifiers & TERMKEY_KEYMOD_CTRL;
+ alt = key.modifiers & TERMKEY_KEYMOD_ALT;
#endif
if (!lL_event(lua, "keypress", LUA_TNUMBER, c, LUA_TBOOLEAN, shift,
LUA_TBOOLEAN, ctrl, LUA_TBOOLEAN, alt, -1))