diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-25 19:34:00 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-25 20:01:40 -0800 |
commit | 4a8691c3dc53a34a730a272c31f8240ed3827001 (patch) | |
tree | 8ba715df2e5623159a922fab87d745ca3d007268 /src/kilo.c | |
parent | f58d5b835426d8b0093c854c9da0a6c101273bff (diff) | |
download | teliva-4a8691c3dc53a34a730a272c31f8240ed3827001.tar.gz |
new shortcut: return to big-picture view
Diffstat (limited to 'src/kilo.c')
-rw-r--r-- | src/kilo.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/kilo.c b/src/kilo.c index 7ddfa39..22cf624 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -103,6 +103,7 @@ static struct editorConfig E; enum KEY_ACTION { KEY_NULL = 0, + CTRL_B = 2, CTRL_C = 3, CTRL_D = 4, CTRL_E = 5, @@ -667,6 +668,7 @@ static void editorMenu(void) { attroff(A_BOLD); } draw_menu_item("^g", "go"); + draw_menu_item("^b", "big picture"); draw_menu_item("^f", "find"); attrset(A_NORMAL); } @@ -1041,7 +1043,8 @@ static void editorGo(lua_State* L) { /* Process events arriving from the standard input, which is, the user * is typing stuff on the terminal. */ -int Quit = 0; +static int Quit = 0; +static int Back_to_big_picture = 0; static void editorProcessKeypress(lua_State* L) { int c = getch(); switch(c) { @@ -1061,6 +1064,12 @@ static void editorProcessKeypress(lua_State* L) { /* Go to a different definition. */ editorGo(L); break; + case CTRL_B: + /* Go to big-picture view. */ + editorSaveToDisk(); + Quit = 1; + Back_to_big_picture = 1; + break; case CTRL_F: editorFind(); break; @@ -1110,7 +1119,10 @@ static void initEditor(void) { E.syntax = &HLDB[0]; } -void edit(lua_State* L, char* filename, const char* message) { +/* return true if user chose to back into the big picture view */ +int edit(lua_State* L, char* filename, const char* message) { + Quit = 0; + Back_to_big_picture = 0; initEditor(); editorOpen(filename); editorSetStatusMessage(message); @@ -1118,13 +1130,16 @@ void edit(lua_State* L, char* filename, const char* message) { editorRefreshScreen(editorMenu); editorProcessKeypress(L); } + return Back_to_big_picture; } -void resumeEdit(lua_State* L) { +int resumeEdit(lua_State* L) { Quit = 0; + Back_to_big_picture = 0; editorSetStatusMessage(Previous_error); while(!Quit) { editorRefreshScreen(editorMenu); editorProcessKeypress(L); } + return Back_to_big_picture; } |