diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lcurseslib.c | 12 | ||||
-rw-r--r-- | src/lua.c | 13 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/lcurseslib.c b/src/lcurseslib.c index a6eeaa1..5a5b8b0 100644 --- a/src/lcurseslib.c +++ b/src/lcurseslib.c @@ -112,21 +112,15 @@ static int Pcolor_pair (lua_State *L) } -extern char **Argv; -extern char *Script_name; -extern void edit(char *filename, const char *message); +extern void switch_to_editor(const char *message); static int Pgetch (lua_State *L) { int c = wgetch(stdscr); if (c == ERR) return 0; if (c == 24) /* ctrl-x */ exit(0); - if (c == 5) { /* ctrl-e */ - /* death and rebirth */ - endwin(); - edit(Script_name, ""); - execv(Argv[0], Argv); - } + if (c == 5) /* ctrl-e */ + switch_to_editor(""); /* handle other standard menu hotkeys here */ lua_pushinteger(L, c); return 1; diff --git a/src/lua.c b/src/lua.c index 1c7cdfd..34fcd13 100644 --- a/src/lua.c +++ b/src/lua.c @@ -74,16 +74,23 @@ static int report (lua_State *L, int status) { } +/* death and rebirth */ char *Script_name = NULL; char **Argv = NULL; extern void edit(char *filename, const char *status); +void switch_to_editor(const char *message) { + endwin(); + edit(Script_name, message); + execv(Argv[0], Argv); + /* never returns */ +} + + static int show_error_in_editor (lua_State *L, int status) { if (status && !lua_isnil(L, -1)) { const char *msg = lua_tostring(L, -1); if (msg == NULL) msg = "(error object is not a string)"; - endwin(); - edit(Script_name, msg); - execv(Argv[0], Argv); + switch_to_editor(msg); } return status; } |