summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-28 17:56:32 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-28 17:56:32 -0500
commit3478fbd89a51072bca971b168c3c947e016b6272 (patch)
tree46ced289c4f93f1e5e0ee70443e8ae47966518d7 /main.c
parent238f3ecc526600d5c18fead7820469719027b07c (diff)
started tabs
Diffstat (limited to 'main.c')
-rw-r--r--main.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/main.c b/main.c
index 2e067a0..49e9a00 100644
--- a/main.c
+++ b/main.c
@@ -236,9 +236,16 @@ int main(int argc, char **argv) {
{
- TextBuffer *buffer = &ted->main_buffer;
+ u16 buffer_index = (u16)ted_new_buffer(ted);
+ assert(buffer_index == 0);
+ TextBuffer *buffer = &ted->buffers[buffer_index];
buffer_create(buffer, ted);
ted->active_buffer = buffer;
+ u16 node_index = (u16)ted_new_node(ted);
+ assert(node_index == 0);
+ Node *node = ted->active_node = &ted->nodes[node_index];
+ node->tabs = NULL;
+ arr_add(node->tabs, 0);
if (fs_file_exists(starting_filename)) {
@@ -452,7 +459,7 @@ int main(int argc, char **argv) {
{
float x1 = 50, y1 = 50, x2 = window_width-50, y2 = window_height-50;
- buffer_render(&ted->main_buffer, x1, y1, x2, y2);
+ buffer_render(&ted->buffers[ted->active_node->tabs[0]], x1, y1, x2, y2);
if (text_has_err()) {
ted_seterr(ted, "Couldn't render text: %s", text_get_err());
}
@@ -463,9 +470,12 @@ int main(int argc, char **argv) {
menu_render(ted, menu);
}
- if (buffer_haserr(&ted->main_buffer)) {
- ted_seterr_to_buferr(ted, &ted->main_buffer);
- buffer_clearerr(&ted->main_buffer);
+ for (u16 i = 0; i < TED_MAX_BUFFERS; ++i) {
+ TextBuffer *buffer = &ted->buffers[i];
+ if (buffer_haserr(buffer)) {
+ ted_seterr_to_buferr(ted, buffer);
+ buffer_clearerr(buffer);
+ }
}
// check if there's a new error
@@ -519,7 +529,9 @@ int main(int argc, char **argv) {
#if DEBUG
- buffer_check_valid(&ted->main_buffer);
+ for (u16 i = 0; i < TED_MAX_BUFFERS; ++i)
+ if (ted->buffers_used[i])
+ buffer_check_valid(&ted->buffers[i]);
buffer_check_valid(&ted->line_buffer);
#endif
@@ -535,7 +547,10 @@ int main(int argc, char **argv) {
SDL_GL_DeleteContext(glctx);
SDL_DestroyWindow(window);
SDL_Quit();
- buffer_free(&ted->main_buffer);
+ for (u16 i = 0; i < TED_MAX_BUFFERS; ++i)
+ buffer_free(&ted->buffers[i]);
+ for (u16 i = 0; i < TED_MAX_NODES; ++i)
+ node_free(&ted->nodes[i]);
buffer_free(&ted->line_buffer);
text_font_free(ted->font);
text_font_free(ted->font_bold);