diff options
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?" |