diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-26 11:47:47 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-26 11:47:47 -0500 |
commit | a63ae9425561f3d2197c5d220be89fe92900adec (patch) | |
tree | 93665626fc2efa8a6227fb9ed46a8f3b64cc2aac /menu.c | |
parent | d453eedc5282074af83375532e8edcb68ada3300 (diff) |
fixed some menu-related bugs
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 67 |
1 files changed, 35 insertions, 32 deletions
@@ -1,4 +1,38 @@ +static void menu_close(Ted *ted) { + TextBuffer *buffer = ted->active_buffer = ted->prev_active_buffer; + ted->prev_active_buffer = NULL; + if (buffer) { + buffer->scroll_x = ted->prev_active_buffer_scroll.x; + buffer->scroll_y = ted->prev_active_buffer_scroll.y; + } + switch (ted->menu) { + case MENU_NONE: assert(0); break; + case MENU_OPEN: + case MENU_SAVE_AS: + file_selector_free(&ted->file_selector); + buffer_clear(&ted->line_buffer); + break; + case MENU_WARN_UNSAVED: + ted->warn_unsaved = 0; + *ted->warn_unsaved_names = 0; + break; + case MENU_ASK_RELOAD: + *ted->ask_reload = 0; + break; + case MENU_GOTO_DEFINITION: + tag_selector_close(ted); + break; + case MENU_GOTO_LINE: + buffer_clear(&ted->line_buffer); + break; + } + ted->menu = MENU_NONE; + ted->selector_open = NULL; +} + static void menu_open(Ted *ted, Menu menu) { + if (ted->menu) + menu_close(ted); if (ted->find) find_close(ted); ted->menu = menu; TextBuffer *prev_buf = ted->prev_active_buffer = ted->active_buffer; @@ -12,6 +46,7 @@ static void menu_open(Ted *ted, Menu menu) { case MENU_NONE: assert(0); break; case MENU_OPEN: ted->active_buffer = &ted->line_buffer; + ted->file_selector.create_menu = false; break; case MENU_SAVE_AS: ted->active_buffer = &ted->line_buffer; @@ -33,38 +68,6 @@ static void menu_open(Ted *ted, Menu menu) { } } -static void menu_close(Ted *ted) { - TextBuffer *buffer = ted->active_buffer = ted->prev_active_buffer; - ted->prev_active_buffer = NULL; - if (buffer) { - buffer->scroll_x = ted->prev_active_buffer_scroll.x; - buffer->scroll_y = ted->prev_active_buffer_scroll.y; - } - switch (ted->menu) { - case MENU_NONE: assert(0); break; - case MENU_OPEN: - case MENU_SAVE_AS: - file_selector_free(&ted->file_selector); - buffer_clear(&ted->line_buffer); - break; - case MENU_WARN_UNSAVED: - ted->warn_unsaved = 0; - *ted->warn_unsaved_names = 0; - break; - case MENU_ASK_RELOAD: - *ted->ask_reload = 0; - break; - case MENU_GOTO_DEFINITION: - tag_selector_close(ted); - break; - case MENU_GOTO_LINE: - buffer_clear(&ted->line_buffer); - break; - } - ted->menu = MENU_NONE; - ted->selector_open = NULL; -} - static void menu_escape(Ted *ted) { if (*ted->warn_overwrite) { // just close "are you sure you want to overwrite?" |