diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-28 14:41:58 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-28 14:41:58 -0500 |
commit | fb2a0b9998a599f9e8a9a1e911fd43345778f6ef (patch) | |
tree | 5c3ebf1b7afa1654ad1f9e9db7d765378044e3c8 /node.c | |
parent | 5662c988fa199d071fdfd9e9defd8e09a3486b0c (diff) |
:split-swap
Diffstat (limited to 'node.c')
-rw-r--r-- | node.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -137,8 +137,7 @@ static void node_close(Ted *ted, u16 node_idx) { // make sure we don't set the active node to a split while (!new_active_node->tabs) new_active_node = &ted->nodes[new_active_node->split_a]; - ted->active_node = new_active_node; - ted->active_buffer = &ted->buffers[ted->active_node->tabs[ted->active_node->active_tab]]; + ted_node_switch(ted, new_active_node); } } } @@ -390,7 +389,21 @@ static void node_split(Ted *ted, Node *node, bool vertical) { node->split_vertical = vertical; node->split_pos = 0.5f; if (node == ted->active_node) - ted->active_node = &ted->nodes[right_idx]; + ted_node_switch(ted, &ted->nodes[right_idx]); + } + } +} + +// swap to the other side of a split +static void node_split_swap(Ted *ted) { + assert(ted->active_node); + u16 active_node_idx = (u16)(ted->active_node - ted->nodes); + Node *parent = &ted->nodes[node_parent(ted, active_node_idx)]; + if (parent) { + if (parent->split_a == active_node_idx) { + ted_node_switch(ted, &ted->nodes[parent->split_b]); + } else { + ted_node_switch(ted, &ted->nodes[parent->split_a]); } } } |