diff options
author | 2012-07-12 13:10:31 -0400 | |
---|---|---|
committer | 2012-07-12 13:10:31 -0400 | |
commit | c799f9f9c793cd28c7b567b5aa7f0eb6205a9d83 (patch) | |
tree | a946815e52b5efbf22bfa5aa224c120a8356f057 | |
parent | aa1f0aa829c0580e11e3afd0226b76fb3dd64089 (diff) | |
download | textadept-c799f9f9c793cd28c7b567b5aa7f0eb6205a9d83.tar.gz textadept-c799f9f9c793cd28c7b567b5aa7f0eb6205a9d83.zip |
Fixed bug with running commands in the ncurses command entry; src/textadept.c
CDK appears to have a bug in that it cannot register an 'Enter' keypress if
KEY_TAB is bound. Compensate by binding KEY_ENTER to run the command.
-rw-r--r-- | src/textadept.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/textadept.c b/src/textadept.c index 5088557f..53b1b7ab 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -517,10 +517,14 @@ static int lfind__newindex(lua_State *L) { #if NCURSES /** - * Signal for the 'tab' key being pressed in the Command Entry. + * Signal for a keypress inside the Command Entry. */ -static int c_keypress(EObjectType _, void*__, void*___, chtype ____) { - return (lL_event(lua, "command_entry_keypress", LUA_TNUMBER, '\t', -1), TRUE); +static int c_keypress(EObjectType _, void *object, void *__, chtype key) { + if (key == KEY_ENTER) { + fcopy(&command_text, getCDKEntryValue((CDKENTRY *)object)); + lL_event(lua, "command_entry_command", LUA_TSTRING, command_text, -1); + } else lL_event(lua, "command_entry_keypress", LUA_TNUMBER, '\t', -1); + return key == KEY_TAB; } #endif @@ -540,12 +544,10 @@ static int lce_focus(lua_State *L) { command_entry = newCDKEntry(screen, LEFT, TOP, NULL, NULL, A_NORMAL, '_', vMIXED, 0, 0, 256, FALSE, FALSE); bindCDKObject(vENTRY, command_entry, KEY_TAB, c_keypress, NULL); + bindCDKObject(vENTRY, command_entry, KEY_ENTER, c_keypress, NULL); setCDKEntryValue(command_entry, command_text); curs_set(1); - if (activateCDKEntry(command_entry, NULL)) { - fcopy(&command_text, getCDKEntryValue(command_entry)); - lL_event(lua, "command_entry_command", LUA_TSTRING, command_text, -1); - } + activateCDKEntry(command_entry, NULL); curs_set(0); destroyCDKEntry(command_entry), command_entry = NULL; delwin(screen->window), destroyCDKScreen(screen); |