From c799f9f9c793cd28c7b567b5aa7f0eb6205a9d83 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 12 Jul 2012 13:10:31 -0400 Subject: 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. --- src/textadept.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/textadept.c') 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); -- cgit v1.2.3