diff options
author | pommicket <pommicket@gmail.com> | 2022-07-29 15:56:32 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-07-29 15:56:32 -0400 |
commit | d9edd1f62fa620d3a8a42c80aec330065b794e14 (patch) | |
tree | 1f19aeabca40196b7987537a7b09f1af30c71c3d | |
parent | efce2c731927adc4aaf26d6cc6c165bbced39eb5 (diff) |
fixed double ctrl+q problem
-rw-r--r-- | command.c | 4 | ||||
-rw-r--r-- | find.c | 2 | ||||
-rw-r--r-- | menu.c | 16 | ||||
-rw-r--r-- | ted.c | 8 | ||||
-rw-r--r-- | ted.cfg | 1 |
5 files changed, 20 insertions, 11 deletions
@@ -211,12 +211,13 @@ void command_execute(Ted *ted, Command c, i64 argument) { break; case CMD_QUIT: // pass argument of 2 to override dialog - if (argument == 2) { + if (argument == 2 || ted->warn_unsaved == CMD_QUIT) { ted->quit = true; } else { *ted->warn_unsaved_names = 0; bool *buffers_used = ted->buffers_used; bool first = true; + for (u16 i = 0; i < TED_MAX_BUFFERS; ++i) { if (buffers_used[i]) { buffer = &ted->buffers[i]; @@ -226,6 +227,7 @@ void command_execute(Ted *ted, Command c, i64 argument) { } } } + if (*ted->warn_unsaved_names) { ted->warn_unsaved = CMD_QUIT; menu_open(ted, MENU_WARN_UNSAVED); @@ -122,7 +122,7 @@ static WarnUnusedResult bool find_match(Ted *ted, BufferPos *pos, u32 *match_sta } // check if the search term needs to be recompiled -static void find_update(Ted *ted, bool force) { +void find_update(Ted *ted, bool force) { TextBuffer *find_buffer = &ted->find_buffer; u32 flags = find_compilation_flags(ted); if (!force @@ -1,4 +1,4 @@ -static void menu_close(Ted *ted) { +static void menu_close_with_next(Ted *ted, Menu next) { ted_switch_to_buffer(ted, ted->prev_active_buffer); TextBuffer *buffer = ted->active_buffer; ted->prev_active_buffer = NULL; @@ -14,8 +14,10 @@ static void menu_close(Ted *ted) { buffer_clear(&ted->line_buffer); break; case MENU_WARN_UNSAVED: - ted->warn_unsaved = 0; - *ted->warn_unsaved_names = 0; + if (next != MENU_WARN_UNSAVED) { + ted->warn_unsaved = 0; + *ted->warn_unsaved_names = 0; + } break; case MENU_ASK_RELOAD: *ted->ask_reload = 0; @@ -40,9 +42,13 @@ static void menu_close(Ted *ted) { ted->selector_open = NULL; } -static void menu_open(Ted *ted, Menu menu) { +void menu_close(Ted *ted) { + menu_close_with_next(ted, 0); +} + +void menu_open(Ted *ted, Menu menu) { if (ted->menu) - menu_close(ted); + menu_close_with_next(ted, menu); if (ted->find) find_close(ted); ted->autocomplete = false; ted->menu = menu; @@ -1,7 +1,7 @@ -static void menu_open(Ted *ted, Menu menu); -static void menu_close(Ted *ted); -static void find_update(Ted *ted, bool force); -static Command command_from_str(char const *str); +void menu_open(Ted *ted, Menu menu); +void menu_close(Ted *ted); +void find_update(Ted *ted, bool force); +Command command_from_str(char const *str); // this is a macro so we get -Wformat warnings #define ted_seterr(ted, ...) \ @@ -29,6 +29,7 @@ auto-reload-config = on build-default-command = make # restore previously opened files when ted is launched? restore-session = on + # search depth for files to generate tags for. # if set to 0, tag generation/regeneration will do nothing tags-max-depth = 2 |