diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-01-25 21:42:31 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-01-25 21:44:01 -0800 |
commit | 91d47faf233c0b463a34ca9de507b9fd4adf4011 (patch) | |
tree | a4468fe138fa1351b0bd4a05d7075837698c153e | |
parent | 84d76b11fa7422d85615d7df0b218359569eae34 (diff) | |
download | teliva-91d47faf233c0b463a34ca9de507b9fd4adf4011.tar.gz |
disable Lua colors in prose
-rw-r--r-- | src/kilo.c | 56 | ||||
-rw-r--r-- | src/teliva.c | 8 |
2 files changed, 54 insertions, 10 deletions
diff --git a/src/kilo.c b/src/kilo.c index 33988f6..0692164 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -146,13 +146,11 @@ char *Lua_HL_keywords[] = { /* Here we define an array of syntax highlights by extensions, keywords, * comments delimiters. */ -struct editorSyntax HLDB[] = { - { - Lua_HL_keywords, - "--", /* line comment */ - "--[[", /* multiline comment start */ - "--]]" /* multline comment stop */ - } +struct editorSyntax LuaSyntax = { + Lua_HL_keywords, + "--", /* line comment */ + "--[[", /* multiline comment start */ + "--]]" /* multline comment stop */ }; #define HLDB_ENTRIES (sizeof(HLDB)/sizeof(HLDB[0])) @@ -1202,7 +1200,6 @@ static void initEditor(void) { E.row = NULL; E.dirty = 0; E.filename = NULL; - E.syntax = &HLDB[0]; } /* return true if user chose to back into the big picture view */ @@ -1210,6 +1207,7 @@ int edit(lua_State* L, char* filename) { Quit = 0; Back_to_big_picture = 0; initEditor(); + E.syntax = &LuaSyntax; editorOpen(filename); attrset(A_NORMAL); clear(); @@ -1226,6 +1224,24 @@ int edit(lua_State* L, char* filename) { return Back_to_big_picture; } +/* Like editFrom(), but no highlighting, no callers. */ +int editProse(lua_State* L, char* filename) { + Quit = 0; + Back_to_big_picture = 0; + initEditor(); + editorOpen(filename); + while(!Quit) { + /* update on resize */ + E.startcol = LINE_NUMBER_SPACE; + E.cols = COLS-LINE_NUMBER_SPACE; + E.startrow = CALLERS_SPACE; + E.endrow = LINES-MENU_SPACE; + editorRefreshScreen(editorMenu); + editorProcessKeypress(L); + } + return Back_to_big_picture; +} + static void editorNonCodeMenu(void) { attrset(A_REVERSE); for (int x = 0; x < COLS; ++x) @@ -1282,6 +1298,7 @@ void editFilePermissions(char* filename) { Quit = 0; Back_to_big_picture = 0; initEditor(); + E.syntax = &LuaSyntax; E.startcol = LINE_NUMBER_SPACE; E.startrow = 1; /* space for function header */ E.endrow = 10; /* nudge people to keep function short */ @@ -1305,6 +1322,7 @@ int editFrom(lua_State* L, char* filename, int rowoff, int coloff, int cy, int c Quit = 0; Back_to_big_picture = 0; initEditor(); + E.syntax = &LuaSyntax; E.rowoff = rowoff; E.coloff = coloff; E.cy = cy; @@ -1325,6 +1343,28 @@ int editFrom(lua_State* L, char* filename, int rowoff, int coloff, int cy, int c return Back_to_big_picture; } +/* Like editFrom(), but no highlighting, no callers. */ +int editProseFrom(lua_State* L, char* filename, int rowoff, int coloff, int cy, int cx) { + Quit = 0; + Back_to_big_picture = 0; + initEditor(); + E.rowoff = rowoff; + E.coloff = coloff; + E.cy = cy; + E.cx = cx; + editorOpen(filename); + while(!Quit) { + /* update on resize */ + E.startcol = LINE_NUMBER_SPACE; + E.cols = COLS-LINE_NUMBER_SPACE; + E.startrow = CALLERS_SPACE; + E.endrow = LINES-MENU_SPACE; + editorRefreshScreen(editorMenu); + editorProcessKeypress(L); + } + return Back_to_big_picture; +} + int resumeEdit(lua_State* L) { Quit = 0; Back_to_big_picture = 0; diff --git a/src/teliva.c b/src/teliva.c index 8d34754..7e769c9 100644 --- a/src/teliva.c +++ b/src/teliva.c @@ -667,6 +667,7 @@ void draw_callers_of_current_definition(lua_State* L) { extern int resumeEdit(lua_State* L); extern int editFrom(lua_State* L, char* filename, int rowoff, int coloff, int cy, int cx); +extern int editProseFrom(lua_State* L, char* filename, int rowoff, int coloff, int cy, int cx); int restore_editor_view(lua_State* L) { lua_getglobal(L, "__teliva_editor_state"); int editor_state_index = lua_gettop(L); @@ -682,11 +683,12 @@ int restore_editor_view(lua_State* L) { lua_getfield(L, editor_state_index, "cx"); int cx = lua_tointeger(L, -1); lua_settop(L, editor_state_index); - int back_to_big_picture = editFrom(L, "teliva_editor_buffer", rowoff, coloff, cy, cx); if (starts_with(Current_definition, "doc:")) { + int back_to_big_picture = editProseFrom(L, "teliva_editor_buffer", rowoff, coloff, cy, cx); load_editor_buffer_to_current_definition_in_image(L); return back_to_big_picture; } + int back_to_big_picture = editFrom(L, "teliva_editor_buffer", rowoff, coloff, cy, cx); // error handling int oldtop = lua_gettop(L); while (1) { @@ -868,12 +870,14 @@ int load_editor_buffer_to_current_definition_in_image_and_reload(lua_State* L) { /* return true if user chose to back into the big picture view */ /* But only if there are no errors. Otherwise things can get confusing. */ extern int edit(lua_State* L, char* filename); +extern int editProse(lua_State* L, char* filename); static int edit_current_definition(lua_State* L) { - int back_to_big_picture = edit(L, "teliva_editor_buffer"); if (starts_with(Current_definition, "doc:")) { + int back_to_big_picture = editProse(L, "teliva_editor_buffer"); load_editor_buffer_to_current_definition_in_image(L); return back_to_big_picture; } + int back_to_big_picture = edit(L, "teliva_editor_buffer"); // error handling int oldtop = lua_gettop(L); while (1) { |