diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-24 11:48:54 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-24 11:48:54 -0500 |
commit | 94e09c98f3dbef3c041750cc019efbc29e9254e6 (patch) | |
tree | 50bc0bb82825eb495dbebc92478412972da78c45 /command.c | |
parent | 4aa02183b7f317ca1183b4d3e58ec9da166479d6 (diff) |
start split
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -310,20 +310,32 @@ void command_execute(Ted *ted, Command c, i64 argument) { case CMD_SPLIT_HORIZONTAL: case CMD_SPLIT_VERTICAL: - -#if 0 if (node) { if (arr_len(node->tabs) > 1) { // need at least 2 tabs to split i32 left_idx = ted_new_node(ted); i32 right_idx = ted_new_node(ted); - if (left >= 0 && right >= 0) { + if (left_idx >= 0 && right_idx >= 0) { Node *left = &ted->nodes[left_idx]; Node *right = &ted->nodes[right_idx]; - arr_add(right->tabs, ) + u16 active_tab = node->active_tab; + // put active tab on the right + arr_add(right->tabs, node->tabs[active_tab]); + for (u32 i = 0; i < arr_len(node->tabs); ++i) { + if (i != active_tab) { + // put all other tabs on the left + arr_add(left->tabs, node->tabs[i]); + } + } + + arr_clear(node->tabs); + node->split_a = (u16)left_idx; + node->split_b = (u16)right_idx; + node->split_vertical = c == CMD_SPLIT_VERTICAL; + node->split_pos = 0.5f; + ted->active_node = &ted->nodes[right_idx]; } } } - #endif break; } } |