This commit is contained in:
Robert Bisewski 2018-03-20 09:30:56 +00:00 committed by GitHub
commit ec92f8fe0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"
@ -1277,6 +1278,28 @@ 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;
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;
@ -1287,8 +1310,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);