diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-29 22:33:31 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-29 22:33:31 -0500 |
commit | 55fd631d86769e719f81206901bc1c3fb598fb5e (patch) | |
tree | eca599d625d8d55d03c2d793e5f85d51f712a2c2 /command.c | |
parent | 3cc173dd38e85c751bb1a9f9288ebe974e567ba4 (diff) |
quitting, closing tabs
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -147,17 +147,21 @@ void command_execute(Ted *ted, Command c, i64 argument) { if (buffer) { if (buffer->filename && streq(buffer->filename, TED_UNTITLED)) { // don't worry, this won't catch files called "Untitled"; buffer->filename is the full path. - goto save_as; + command_execute(ted, CMD_SAVE_AS, 1); + return; } buffer_save(buffer); } break; case CMD_SAVE_AS: - save_as: if (buffer && !buffer->is_line_buffer) { menu_open(ted, MENU_SAVE_AS); } break; + case CMD_QUIT: + // @TODO: check for unsaved changes in all buffers + ted->quit = true; + break; case CMD_UNDO: if (buffer) buffer_undo(buffer, argument); break; @@ -189,11 +193,20 @@ void command_execute(Ted *ted, Command c, i64 argument) { } } break; + case CMD_TAB_CLOSE: { + Node *node = ted->active_node; + if (node) { + node_tab_close(ted, node, node->active_tab); + } else { + command_execute(ted, CMD_QUIT, 1); + return; + } + } break; case CMD_TAB_NEXT: - node_tab_next(ted, ted->active_node, argument); + if (ted->active_node) node_tab_next(ted, ted->active_node, argument); break; case CMD_TAB_PREV: - node_tab_prev(ted, ted->active_node, argument); + if (ted->active_node) node_tab_prev(ted, ted->active_node, argument); break; case CMD_ESCAPE: |