summaryrefslogtreecommitdiff
path: root/ted-base.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-28 20:40:52 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-28 20:40:52 -0500
commit31b5649b131695300f39563640c4af8f0d3032cb (patch)
tree71f4c2d2c0b2e56a36e7c86f250869c6daa16eda /ted-base.c
parent0e57122ecfd554131fd6ad54fcbb556733bf6c88 (diff)
more tabs
Diffstat (limited to 'ted-base.c')
-rw-r--r--ted-base.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ted-base.c b/ted-base.c
index a9cf725..371096f 100644
--- a/ted-base.c
+++ b/ted-base.c
@@ -95,6 +95,7 @@ static i32 ted_new_buffer(Ted *ted) {
for (i32 i = 0; i < TED_MAX_BUFFERS; ++i) {
if (!buffers_used[i]) {
buffers_used[i] = true;
+ buffer_create(&ted->buffers[i], ted);
return i;
}
}
@@ -125,14 +126,19 @@ static WarnUnusedResult TextBuffer *ted_open_file(Ted *ted, char const *filename
ted_seterr(ted, "Too many buffers open!");
return NULL;
} else {
- arr_add(ted->active_node->tabs, (u16)new_buffer_index);
- TextBuffer *new_buffer = &ted->buffers[new_buffer_index];
- if (buffer_load_file(new_buffer, filename)) {
- ted->active_buffer = new_buffer;
- return new_buffer;
+ Node *node = ted->active_node;
+ if (arr_len(node->tabs) < TED_MAX_TABS) {
+ arr_add(node->tabs, (u16)new_buffer_index);
+ TextBuffer *new_buffer = &ted->buffers[new_buffer_index];
+ if (node->tabs && buffer_load_file(new_buffer, filename)) {
+ ted->active_buffer = new_buffer;
+ node->active_tab = (u16)(arr_len(node->tabs) - 1);
+ return new_buffer;
+ }
} else {
- return NULL;
+ ted_seterr(ted, "Too many tabs.");
}
+ return NULL;
}
}