diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-25 19:52:40 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-25 19:52:40 -0500 |
commit | d453eedc5282074af83375532e8edcb68ada3300 (patch) | |
tree | 204b9f87cf187e03e856d1c997a3fb6d300e761f | |
parent | 2baf965c7db4a3640cd120e050c61aa7de67448b (diff) |
started tab moving
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | ted.c | 3 | ||||
-rw-r--r-- | ted.h | 4 |
3 files changed, 8 insertions, 3 deletions
@@ -323,7 +323,7 @@ int main(int argc, char **argv) { { u16 buffer_index = (u16)ted_new_buffer(ted); - assert(buffer_index == 0); + assert(buffer_index == 1); TextBuffer *buffer = &ted->buffers[buffer_index]; buffer_create(buffer, ted); ted->active_buffer = buffer; @@ -331,7 +331,7 @@ int main(int argc, char **argv) { assert(node_index == 0); Node *node = ted->active_node = &ted->nodes[node_index]; node->tabs = NULL; - arr_add(node->tabs, 0); + arr_add(node->tabs, buffer_index); char path[TED_PATH_MAX]; @@ -94,7 +94,8 @@ static void ted_load_fonts(Ted *ted) { // returns the index of an available buffer, or -1 if none are available static i32 ted_new_buffer(Ted *ted) { bool *buffers_used = ted->buffers_used; - for (i32 i = 0; i < TED_MAX_BUFFERS; ++i) { + for (i32 i = 1; // start from 1, so as not to use the null buffer + i < TED_MAX_BUFFERS; ++i) { if (!buffers_used[i]) { buffers_used[i] = true; buffer_create(&ted->buffers[i], ted); @@ -280,6 +280,9 @@ typedef struct Ted { SDL_Cursor *cursor_arrow, *cursor_ibeam, *cursor_resize_h, *cursor_resize_v; SDL_Cursor *cursor; // which cursor to use this frame + // index of buffer whose tab user is dragging around, 0 for none. + u16 dragging_tab; + // if not NULL, points to the node whose split the user is currently resizing. Node *resizing_split; @@ -304,6 +307,7 @@ typedef struct Ted { char tags_dir[TED_PATH_MAX]; // where we are reading tags from bool nodes_used[TED_MAX_NODES]; Node nodes[TED_MAX_NODES]; + // NOTE: the buffer at index 0 is reserved as a "null buffer" and should not be used. bool buffers_used[TED_MAX_BUFFERS]; TextBuffer buffers[TED_MAX_BUFFERS]; char window_title[256]; |