summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-29 22:33:31 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-29 22:33:31 -0500
commit55fd631d86769e719f81206901bc1c3fb598fb5e (patch)
treeeca599d625d8d55d03c2d793e5f85d51f712a2c2 /command.c
parent3cc173dd38e85c751bb1a9f9288ebe974e567ba4 (diff)
quitting, closing tabs
Diffstat (limited to 'command.c')
-rw-r--r--command.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/command.c b/command.c
index 5c7cfe0..5acd922 100644
--- a/command.c
+++ b/command.c
@@ -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: