summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-05 22:22:03 -0400
committerpommicket <pommicket@gmail.com>2023-08-05 22:22:03 -0400
commit61fcf4a14199486cc8bd7538ca236ac8fb93c0bb (patch)
tree882cc9871ea1068c265ccdc308f18e08199667dd
parentbcb5589f17f755b965dec49af3232a5a69a8e68f (diff)
remove next menu bullshit
-rw-r--r--menu.c18
-rw-r--r--ted.c4
-rw-r--r--ted.h4
3 files changed, 16 insertions, 10 deletions
diff --git a/menu.c b/menu.c
index f4759d6..f9101ac 100644
--- a/menu.c
+++ b/menu.c
@@ -2,7 +2,7 @@
#include "ted-internal.h"
-static void menu_close_with_next(Ted *ted, Menu next) {
+void menu_close(Ted *ted) {
ted_switch_to_buffer(ted, ted->prev_active_buffer);
TextBuffer *buffer = ted->active_buffer;
ted->prev_active_buffer = NULL;
@@ -18,10 +18,8 @@ static void menu_close_with_next(Ted *ted, Menu next) {
buffer_clear(&ted->line_buffer);
break;
case MENU_WARN_UNSAVED:
- if (next != MENU_WARN_UNSAVED) {
- ted->warn_unsaved = 0;
- *ted->warn_unsaved_names = 0;
- }
+ ted->warn_unsaved = 0;
+ *ted->warn_unsaved_names = 0;
break;
case MENU_ASK_RELOAD:
*ted->ask_reload = 0;
@@ -50,13 +48,13 @@ static void menu_close_with_next(Ted *ted, Menu next) {
ted->selector_open = NULL;
}
-void menu_close(Ted *ted) {
- menu_close_with_next(ted, 0);
-}
-
void menu_open(Ted *ted, Menu menu) {
+ if (ted->menu == menu)
+ return;
+
if (ted->menu)
- menu_close_with_next(ted, menu);
+ menu_close(ted);
+
if (ted->find) find_close(ted);
autocomplete_close(ted);
ted->menu = menu;
diff --git a/ted.c b/ted.c
index ea28f13..f3cd7a3 100644
--- a/ted.c
+++ b/ted.c
@@ -42,6 +42,10 @@ TextBuffer *ted_get_active_buffer(Ted *ted) {
return ted->active_buffer;
}
+TextBuffer *ted_get_active_buffer_behind_menu(Ted *ted) {
+ return ted->prev_active_buffer;
+}
+
void ted_set_window_title(Ted *ted, const char *title) {
strbuf_cpy(ted->window_title, title);
}
diff --git a/ted.h b/ted.h
index 10e1bca..80c6fdd 100644
--- a/ted.h
+++ b/ted.h
@@ -867,6 +867,10 @@ bool tag_goto(Ted *ted, const char *tag);
void die(PRINTF_FORMAT_STRING const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2);
/// returns the current active buffer, or NULL if no buffer is active.
TextBuffer *ted_get_active_buffer(Ted *ted);
+/// if a menu is open, returns the buffer that was open before the menu was opened.
+///
+/// returns NULL if no menu is open or no buffer was open before the menu was opened.
+TextBuffer *ted_get_active_buffer_behind_menu(Ted *ted);
/// set title of ted window
void ted_set_window_title(Ted *ted, const char *title);
/// returns `true` if the given SDL key code is down