summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-26 11:47:47 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-26 11:47:47 -0500
commita63ae9425561f3d2197c5d220be89fe92900adec (patch)
tree93665626fc2efa8a6227fb9ed46a8f3b64cc2aac
parentd453eedc5282074af83375532e8edcb68ada3300 (diff)
fixed some menu-related bugs
-rw-r--r--buffer.c5
-rw-r--r--main.c2
-rw-r--r--menu.c67
3 files changed, 41 insertions, 33 deletions
diff --git a/buffer.c b/buffer.c
index cb44eb4..ca58772 100644
--- a/buffer.c
+++ b/buffer.c
@@ -61,7 +61,10 @@ char const *buffer_get_filename(TextBuffer *buffer) {
}
bool buffer_is_untitled(TextBuffer *buffer) {
- return streq(buffer->filename, TED_UNTITLED);
+ if (buffer->filename)
+ return streq(buffer->filename, TED_UNTITLED);
+ else
+ return false;
}
// add this edit to the undo history
diff --git a/main.c b/main.c
index ebec863..02580f0 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,7 @@
// @TODO:
// - move tabs between nodes
+// - :split-swap
+// - fix: ctrl+f something, then switch to another tab (hl rects still showing up)
// - Windows installation
// - on crash, output backtrace to log
diff --git a/menu.c b/menu.c
index 89fafd0..96c2ebc 100644
--- a/menu.c
+++ b/menu.c
@@ -1,4 +1,38 @@
+static void menu_close(Ted *ted) {
+ TextBuffer *buffer = ted->active_buffer = ted->prev_active_buffer;
+ ted->prev_active_buffer = NULL;
+ if (buffer) {
+ buffer->scroll_x = ted->prev_active_buffer_scroll.x;
+ buffer->scroll_y = ted->prev_active_buffer_scroll.y;
+ }
+ switch (ted->menu) {
+ case MENU_NONE: assert(0); break;
+ case MENU_OPEN:
+ case MENU_SAVE_AS:
+ file_selector_free(&ted->file_selector);
+ buffer_clear(&ted->line_buffer);
+ break;
+ case MENU_WARN_UNSAVED:
+ ted->warn_unsaved = 0;
+ *ted->warn_unsaved_names = 0;
+ break;
+ case MENU_ASK_RELOAD:
+ *ted->ask_reload = 0;
+ break;
+ case MENU_GOTO_DEFINITION:
+ tag_selector_close(ted);
+ break;
+ case MENU_GOTO_LINE:
+ buffer_clear(&ted->line_buffer);
+ break;
+ }
+ ted->menu = MENU_NONE;
+ ted->selector_open = NULL;
+}
+
static void menu_open(Ted *ted, Menu menu) {
+ if (ted->menu)
+ menu_close(ted);
if (ted->find) find_close(ted);
ted->menu = menu;
TextBuffer *prev_buf = ted->prev_active_buffer = ted->active_buffer;
@@ -12,6 +46,7 @@ static void menu_open(Ted *ted, Menu menu) {
case MENU_NONE: assert(0); break;
case MENU_OPEN:
ted->active_buffer = &ted->line_buffer;
+ ted->file_selector.create_menu = false;
break;
case MENU_SAVE_AS:
ted->active_buffer = &ted->line_buffer;
@@ -33,38 +68,6 @@ static void menu_open(Ted *ted, Menu menu) {
}
}
-static void menu_close(Ted *ted) {
- TextBuffer *buffer = ted->active_buffer = ted->prev_active_buffer;
- ted->prev_active_buffer = NULL;
- if (buffer) {
- buffer->scroll_x = ted->prev_active_buffer_scroll.x;
- buffer->scroll_y = ted->prev_active_buffer_scroll.y;
- }
- switch (ted->menu) {
- case MENU_NONE: assert(0); break;
- case MENU_OPEN:
- case MENU_SAVE_AS:
- file_selector_free(&ted->file_selector);
- buffer_clear(&ted->line_buffer);
- break;
- case MENU_WARN_UNSAVED:
- ted->warn_unsaved = 0;
- *ted->warn_unsaved_names = 0;
- break;
- case MENU_ASK_RELOAD:
- *ted->ask_reload = 0;
- break;
- case MENU_GOTO_DEFINITION:
- tag_selector_close(ted);
- break;
- case MENU_GOTO_LINE:
- buffer_clear(&ted->line_buffer);
- break;
- }
- ted->menu = MENU_NONE;
- ted->selector_open = NULL;
-}
-
static void menu_escape(Ted *ted) {
if (*ted->warn_overwrite) {
// just close "are you sure you want to overwrite?"