From 0b365d3e4d5e4a9db125870490ceae2d3c1bb065 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 26 Nov 2021 16:39:20 -0800 Subject: clean up terminal in a specific situation The problem: if ever I hit ctrl-e to go to the big picture view and then hit Esc to go back to running the app, my terminal was messed up after exiting the app. Why did I even have this gunk? Perhaps it dates from the time when kilo was emitting raw escape sequences rather than using ncurses. --- src/lua.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lua.c b/src/lua.c index 528e383..4c6ee62 100644 --- a/src/lua.c +++ b/src/lua.c @@ -525,7 +525,7 @@ void draw_definition_name (const char *definition_name) { } /* return true if submitted */ -int big_picture (lua_State *L) { +void big_picture (lua_State *L) { clear(); luaL_newmetatable(L, "__teliva_call_graph_depth"); int cgt = lua_gettop(L); @@ -643,11 +643,11 @@ int big_picture (lua_State *L) { if (c == KEY_BACKSPACE) { if (qlen != 0) query[--qlen] = '\0'; } else if (c == ESC) { - return 0; + return; } else if (c == ENTER) { int back_to_big_picture = edit_image(L, query); - if (back_to_big_picture) return big_picture(L); // retry while leaking stack - return 1; + if (back_to_big_picture) big_picture(L); // retry while leaking stack + return; } else if (c == CTRL_U) { qlen = 0; query[qlen] = '\0'; @@ -670,9 +670,8 @@ void switch_to_editor (lua_State *L) { for (int i = 0; i < 8; ++i) init_pair(i+8, -1, i); nodelay(stdscr, 0); - int submitted = big_picture(L); - if (submitted) - cleanup_curses(); + big_picture(L); + cleanup_curses(); execv(Argv[0], Argv); /* never returns */ } -- cgit 1.4.1-2-gfad0