From d453eedc5282074af83375532e8edcb68ada3300 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Thu, 25 Feb 2021 19:52:40 -0500 Subject: started tab moving --- main.c | 4 ++-- ted.c | 3 ++- ted.h | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 52e5561..ebec863 100644 --- a/main.c +++ b/main.c @@ -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]; diff --git a/ted.c b/ted.c index 5ad3f82..fcc1bb1 100644 --- a/ted.c +++ b/ted.c @@ -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); diff --git a/ted.h b/ted.h index 784001f..f92425f 100644 --- a/ted.h +++ b/ted.h @@ -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]; -- cgit v1.2.3