about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-14 00:38:00 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-14 00:38:00 -0800
commitb64a21771e06ae798e0fcdeebc662fc2f2159ed4 (patch)
treeed8326aabfc5ab23d61dd3d620805905806c35d8
parentd9aac118891ff2029245d65ec139394adb9b6c7d (diff)
downloadteliva-b64a21771e06ae798e0fcdeebc662fc2f2159ed4.tar.gz
janky way to cancel browsing
-rw-r--r--src/lua.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lua.c b/src/lua.c
index e08e7ad..7108fa7 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -389,7 +389,8 @@ void editImage (lua_State *L, const char *definition) {
 
 #define BG(i) (COLOR_PAIR((i)+8))
 #define FG(i) (COLOR_PAIR(i))
-void browseImage (lua_State *L) {
+/* return true if submitted */
+int browseImage (lua_State *L) {
   clear();
   luaL_newmetatable(L, "__teliva_call_graph_depth");
   int cgt = lua_gettop(L);
@@ -444,12 +445,14 @@ void browseImage (lua_State *L) {
   }
   lua_settop(L, 0);
   attron(A_REVERSE);
-  mvaddstr(LINES-1, 0, " edit what? ");
+  mvaddstr(LINES-1, 0, " edit what? (hit just Enter to go back) ");
   attroff(A_REVERSE);
   addch(' ');
   char definition[64] = {0};
   getnstr(definition, 60);
-  editImage(L, definition);
+  if (*definition != '\0')
+    editImage(L, definition);
+  return *definition != '\0';
 }
 
 
@@ -462,9 +465,9 @@ void switch_to_editor (lua_State *L, const char *message) {
     init_pair(i+8, -1, i);
   if (Script_name)
     edit(L, Script_name, message);
-  else
-    browseImage(L);
-  cleanup_curses();
+  else if (browseImage(L)) {
+    cleanup_curses();
+  }
   execv(Argv[0], Argv);
   /* never returns */
 }