summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command.c17
-rw-r--r--command.h4
-rw-r--r--main.c4
-rw-r--r--node.c10
-rw-r--r--ted.cfg4
5 files changed, 32 insertions, 7 deletions
diff --git a/command.c b/command.c
index 9470dc0..c7276ac 100644
--- a/command.c
+++ b/command.c
@@ -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);
diff --git a/command.h b/command.h
index cfbe2d9..d5d8062 100644
--- a/command.h
+++ b/command.h
@@ -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},
diff --git a/main.c b/main.c
index 923009f..a829736 100644
--- a/main.c
+++ b/main.c
@@ -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
diff --git a/node.c b/node.c
index 4f06bce..be4e676 100644
--- a/node.c
+++ b/node.c
@@ -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);
diff --git a/ted.cfg b/ted.cfg
index a76c899..b38307e 100644
--- a/ted.cfg
+++ b/ted.cfg
@@ -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