summaryrefslogtreecommitdiff
path: root/ted.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-28 21:31:49 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-28 21:31:49 -0500
commitd00c3247691c2f30214bcfeffb1830d725a173b9 (patch)
tree0975ef99b6baac4c41da79af4bc679c0c939ab53 /ted.c
parent410b9b764c4a6c81a3573cf7ca23330d43931829 (diff)
find bugfixes (switch to another buffer after find)
Diffstat (limited to 'ted.c')
-rw-r--r--ted.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ted.c b/ted.c
index 049ed92..95d07e2 100644
--- a/ted.c
+++ b/ted.c
@@ -1,4 +1,5 @@
static void menu_open(Ted *ted, Menu menu);
+static void find_update(Ted *ted, bool force);
// this is a macro so we get -Wformat warnings
#define ted_seterr(ted, ...) \
@@ -92,11 +93,19 @@ static void ted_load_fonts(Ted *ted) {
ted_load_font(ted, "assets/font-bold.ttf", &ted->font_bold);
}
+
// sets the active buffer to this buffer, and updates active_node, etc. accordingly
// you can pass NULL to buffer to make it so no buffer is active.
static void ted_switch_to_buffer(Ted *ted, TextBuffer *buffer) {
+ if (ted->active_buffer == buffer) return;
+
+
ted->active_buffer = buffer;
+ if (ted->find) find_update(ted, true);
+
if (buffer >= ted->buffers && buffer < ted->buffers + TED_MAX_BUFFERS) {
+ ted->prev_active_buffer = buffer;
+
u16 idx = (u16)(buffer - ted->buffers);
// now we need to figure out where this buffer is
bool *nodes_used = ted->nodes_used;
@@ -139,6 +148,8 @@ static void ted_delete_buffer(Ted *ted, u16 index) {
TextBuffer *buffer = &ted->buffers[index];
if (buffer == ted->active_buffer)
ted_switch_to_buffer(ted, NULL); // make sure we don't set the active buffer to something invalid
+ if (buffer == ted->prev_active_buffer)
+ ted->prev_active_buffer = NULL;
buffer_free(buffer);
ted->buffers_used[index] = false;
}
@@ -283,11 +294,3 @@ static bool ted_save_all(Ted *ted) {
static void ted_full_path(Ted *ted, char const *relpath, char *abspath, size_t abspath_size) {
path_full(ted->cwd, relpath, abspath, abspath_size);
}
-
-// are any nodes open?
-static bool ted_anything_open(Ted *ted) {
- for (uint i = 0; i < TED_MAX_NODES; ++i)
- if (ted->nodes_used[i])
- return true;
- return false;
-}