From 454c346cb4e3eedca615d3d4e4e49eb37068bd75 Mon Sep 17 00:00:00 2001 From: Robert Bisewski Date: Fri, 20 Oct 2017 18:58:27 +0000 Subject: [PATCH 1/2] initial solution to lastlog, could use some testing --- src/fe-text/textbuffer-view.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index cb066f5e..44ec9cc3 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -21,6 +21,7 @@ #define G_LOG_DOMAIN "TextBufferView" #include "module.h" +#include "levels.h" #include "textbuffer-view.h" #include "signals.h" #include "utf8.h" @@ -1236,6 +1237,24 @@ void textbuffer_view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) textbuffer_remove(view->buffer, line); } +void textbuffer_view_remove_line_from_lastlog(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) +{ + unsigned char update_counter; + + g_return_if_fail(view != NULL); + g_return_if_fail(line != NULL); + + signal_emit("gui lastlog textbuffer line removed", 3, view, line, line->prev); + + // set the cache update counter + update_counter = view->cache->update_counter+1; + view_remove_cache(view, line, update_counter); + + // remove the lines and reset the y-position + textbuffer_remove(view->buffer, line); + textbuffer_view_init_ypos(view); +} + void textbuffer_view_remove_lines_by_level(TEXT_BUFFER_VIEW_REC *view, int level) { LINE_REC *line, *next; @@ -1246,8 +1265,13 @@ void textbuffer_view_remove_lines_by_level(TEXT_BUFFER_VIEW_REC *view, int level while (line != NULL) { next = line->next; - if (line->info.level & level) - textbuffer_view_remove_line(view, line); + if (line->info.level & level) { + if (level == MSGLEVEL_LASTLOG) { + textbuffer_view_remove_line_from_lastlog(view, line); + } else { + textbuffer_view_remove_line(view, line); + } + } line = next; } textbuffer_view_redraw(view); From c9229f73b359c2a89e9afa1c0781e888396da859 Mon Sep 17 00:00:00 2001 From: Robert Bisewski Date: Sun, 22 Oct 2017 16:09:50 -0500 Subject: [PATCH 2/2] adding TODO to denote the current state of this code --- src/fe-text/textbuffer-view.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c index 44ec9cc3..4b25e0ce 100644 --- a/src/fe-text/textbuffer-view.c +++ b/src/fe-text/textbuffer-view.c @@ -1237,6 +1237,10 @@ void textbuffer_view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) textbuffer_remove(view->buffer, line); } +// TODO: this works better than the existing /lastlog logic, however +// this fails when the log is *much* longer than the screen size, +// so additional logic will be need to handle that; specifically +// consider simply reusing logic from the /clear function void textbuffer_view_remove_line_from_lastlog(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) { unsigned char update_counter;