diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-03 14:30:48 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-03 14:30:48 -0500 |
commit | d5488ef5c47878e04045a91d204cf1ccbdd9cd05 (patch) | |
tree | 23d11ed78e0cf33776f810e285aada539c4f1f28 | |
parent | c59429d28718c1aae581f023d33466580118b0fc (diff) |
:tab-move-left/right
-rw-r--r-- | command.c | 17 | ||||
-rw-r--r-- | command.h | 4 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | node.c | 10 | ||||
-rw-r--r-- | ted.cfg | 4 |
5 files changed, 32 insertions, 7 deletions
@@ -268,15 +268,24 @@ void command_execute(Ted *ted, Command c, i64 argument) { } } break; case CMD_TAB_NEXT: - if (ted->active_node) node_tab_next(ted, ted->active_node, argument); + if (node) node_tab_next(ted, node, argument); break; case CMD_TAB_PREV: - if (ted->active_node) node_tab_prev(ted, ted->active_node, argument); + if (node) node_tab_prev(ted, node, argument); break; case CMD_TAB_SWITCH: - if (ted->active_node) node_tab_switch(ted, ted->active_node, argument); + if (node) node_tab_switch(ted, node, argument); break; - + case CMD_TAB_MOVE_LEFT: { + u16 active_tab = node->active_tab; + if (active_tab > 0) + node_tabs_swap(node, active_tab, active_tab - 1); + } break; + case CMD_TAB_MOVE_RIGHT: { + u16 active_tab = node->active_tab; + if (active_tab + 1 < arr_len(node->tabs)) + node_tabs_swap(node, active_tab, active_tab + 1); + } break; case CMD_FIND: if (buffer) find_open(ted, false); @@ -61,6 +61,8 @@ ENUM_U16 { CMD_TAB_SWITCH, // argument = index of tab (starting at 0) CMD_TAB_NEXT, CMD_TAB_PREV, + CMD_TAB_MOVE_LEFT, + CMD_TAB_MOVE_RIGHT, CMD_TEXT_SIZE_INCREASE, CMD_TEXT_SIZE_DECREASE, @@ -141,6 +143,8 @@ static CommandName const command_names[] = { {"tab-switch", CMD_TAB_SWITCH}, {"tab-next", CMD_TAB_NEXT}, {"tab-prev", CMD_TAB_PREV}, + {"tab-move-left", CMD_TAB_MOVE_LEFT}, + {"tab-move-right", CMD_TAB_MOVE_RIGHT}, {"increase-text-size", CMD_TEXT_SIZE_INCREASE}, {"decrease-text-size", CMD_TEXT_SIZE_DECREASE}, {"view-only", CMD_VIEW_ONLY}, @@ -1,9 +1,11 @@ // @TODO: +// - run shell command (i.e. not just `make`) +// - completion + // - more instructions (basic stuff + how to open config) // - update screenshot in README // - test windows 7 -// - completion #include "base.h" no_warn_start @@ -27,6 +27,16 @@ static void node_tab_switch(Ted *ted, Node *node, i64 tab) { } } +// swap the position of two tabs +static void node_tabs_swap(Node *node, u16 tab1, u16 tab2) { + assert(tab1 < arr_len(node->tabs) && tab2 < arr_len(node->tabs)); + if (node->active_tab == tab1) node->active_tab = tab2; + else if (node->active_tab == tab2) node->active_tab = tab1; + u16 tmp = node->tabs[tab1]; + node->tabs[tab1] = node->tabs[tab2]; + node->tabs[tab2] = tmp; +} + static void node_free(Node *node) { arr_free(node->tabs); memset(node, 0, sizeof *node); @@ -79,8 +79,6 @@ Ctrl+Shift+Backspace = :backspace-word # scrolling PageUp = :page-up PageDown = :page-down -Ctrl+PageUp = 10 :page-up -Ctrl+PageDown = 10 :page-down Ctrl+o = :open Ctrl+n = :new @@ -101,6 +99,8 @@ Ctrl+Shift+p = :command-selector Ctrl+w = :tab-close Ctrl+PageUp = :tab-prev Ctrl+PageDown = :tab-next +Ctrl+Shift+PageUp = :tab-move-left +Ctrl+Shift+PageDown = :tab-move-right Alt+1 = 0 :tab-switch Alt+2 = 1 :tab-switch Alt+3 = 2 :tab-switch |