From d303c6efb0ee91d6adfae977908ff63c18f51e96 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 11 Nov 2021 16:42:02 -0800 Subject: pass lua_State into editor --- src/kilo.c | 6 +++--- src/lua.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kilo.c b/src/kilo.c index e8cb618..35aa577 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -1164,7 +1164,7 @@ void editorMoveCursor(int key) { * is typing stuff on the terminal. */ #define KILO_QUIT_TIMES 3 int Quit = 0; -void editorProcessKeypress(int fd) { +void editorProcessKeypress(lua_State* L, int fd) { int c = editorReadKey(fd); switch(c) { case ENTER: @@ -1255,14 +1255,14 @@ void initEditor(void) { signal(SIGWINCH, handleSigWinCh); } -void edit(char* filename, char* message) { +void edit(lua_State* L, char* filename, char* message) { initEditor(); editorOpen(filename); enableRawMode(STDIN_FILENO); editorSetStatusMessage(message); while(!Quit) { editorRefreshScreen(); - editorProcessKeypress(STDIN_FILENO); + editorProcessKeypress(L, STDIN_FILENO); } disableRawMode(STDIN_FILENO); } diff --git a/src/lua.c b/src/lua.c index 2b94349..1040fac 100644 --- a/src/lua.c +++ b/src/lua.c @@ -353,14 +353,14 @@ void save_image(lua_State *L) { /* death and rebirth */ char *Script_name = NULL; char **Argv = NULL; -extern void edit(char *filename, const char *status); +extern void edit(lua_State *L, char *filename, const char *status); void switch_to_editor(lua_State *L, const char *message) { endwin(); if (Script_name) - edit(Script_name, message); + edit(L, Script_name, message); else { write_definition_to_file(L, "main", "teliva_editbuffer"); - edit("teliva_editbuffer", ""); + edit(L, "teliva_editbuffer", ""); char new_contents[8192] = {0}; read_contents(L, "teliva_editbuffer", new_contents); update_definition(L, "main", new_contents); -- cgit 1.4.1-2-gfad0