This commit is contained in:
parent
efbb57d339
commit
9a49b92703
46
src/lua.c
46
src/lua.c
|
@ -75,29 +75,6 @@ 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 */
|
||||
}
|
||||
|
||||
|
||||
const char *Previous_error = NULL;
|
||||
static int show_error_in_editor (lua_State *L, int status) {
|
||||
if (status && !lua_isnil(L, -1)) {
|
||||
Previous_error = lua_tostring(L, -1);
|
||||
if (Previous_error == NULL) Previous_error = "(error object is not a string)";
|
||||
switch_to_editor(Previous_error);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static int traceback (lua_State *L) {
|
||||
if (!lua_isstring(L, 1)) /* 'message' not a string? */
|
||||
return 1; /* keep it intact */
|
||||
|
@ -329,6 +306,29 @@ static int handle_image (lua_State *L, char **argv, int n) {
|
|||
}
|
||||
|
||||
|
||||
/* 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 */
|
||||
}
|
||||
|
||||
|
||||
const char *Previous_error = NULL;
|
||||
static int show_error_in_editor (lua_State *L, int status) {
|
||||
if (status && !lua_isnil(L, -1)) {
|
||||
Previous_error = lua_tostring(L, -1);
|
||||
if (Previous_error == NULL) Previous_error = "(error object is not a string)";
|
||||
switch_to_editor(Previous_error);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static int handle_script (lua_State *L, char **argv, int n) {
|
||||
if (has_extension(argv[n], "tlv"))
|
||||
return handle_image(L, argv, n);
|
||||
|
|
Loading…
Reference in New Issue