mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Generalize window_lastlog_clear in textbuffer_view_remove_lines_by_level.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4419 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
1a195da685
commit
541fa72f46
@ -35,26 +35,6 @@
|
||||
#define DEFAULT_LASTLOG_AFTER 3
|
||||
#define MAX_LINES_WITHOUT_FORCE 1000
|
||||
|
||||
static void window_lastlog_clear(WINDOW_REC *window)
|
||||
{
|
||||
TEXT_BUFFER_VIEW_REC *view;
|
||||
LINE_REC *line, *next;
|
||||
|
||||
term_refresh_freeze();
|
||||
view = WINDOW_GUI(window)->view;
|
||||
line = textbuffer_view_get_lines(view);
|
||||
|
||||
while (line != NULL) {
|
||||
next = line->next;
|
||||
|
||||
if (line->info.level & MSGLEVEL_LASTLOG)
|
||||
textbuffer_view_remove_line(view, line);
|
||||
line = next;
|
||||
}
|
||||
textbuffer_view_redraw(view);
|
||||
term_refresh_thaw();
|
||||
}
|
||||
|
||||
/* Only unknown keys in `optlist' should be levels.
|
||||
Returns -1 if unknown option was given. */
|
||||
int cmd_options_get_level(const char *cmd, GHashTable *optlist)
|
||||
@ -109,7 +89,7 @@ static void show_lastlog(const char *searchtext, GHashTable *optlist,
|
||||
if (level == 0) level = MSGLEVEL_ALL;
|
||||
|
||||
if (g_hash_table_lookup(optlist, "clear") != NULL) {
|
||||
window_lastlog_clear(active_win);
|
||||
textbuffer_view_remove_lines_by_level(WINDOW_GUI(active_win)->view, MSGLEVEL_LASTLOG);
|
||||
if (*searchtext == '\0')
|
||||
return;
|
||||
}
|
||||
|
@ -1201,6 +1201,24 @@ void textbuffer_view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
|
||||
textbuffer_remove(view->buffer, line);
|
||||
}
|
||||
|
||||
void textbuffer_view_remove_lines_by_level(TEXT_BUFFER_VIEW_REC *view, int level)
|
||||
{
|
||||
LINE_REC *line, *next;
|
||||
|
||||
term_refresh_freeze();
|
||||
line = textbuffer_view_get_lines(view);
|
||||
|
||||
while (line != NULL) {
|
||||
next = line->next;
|
||||
|
||||
if (line->info.level & level)
|
||||
textbuffer_view_remove_line(view, line);
|
||||
line = next;
|
||||
}
|
||||
textbuffer_view_redraw(view);
|
||||
term_refresh_thaw();
|
||||
}
|
||||
|
||||
static int g_free_true(void *data)
|
||||
{
|
||||
g_free(data);
|
||||
|
@ -126,6 +126,7 @@ void textbuffer_view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line);
|
||||
void textbuffer_view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line);
|
||||
/* Remove all lines from buffer. */
|
||||
void textbuffer_view_remove_all_lines(TEXT_BUFFER_VIEW_REC *view);
|
||||
void textbuffer_view_remove_lines_by_level(TEXT_BUFFER_VIEW_REC *view, int level);
|
||||
|
||||
/* Set a bookmark in view */
|
||||
void textbuffer_view_set_bookmark(TEXT_BUFFER_VIEW_REC *view,
|
||||
|
Loading…
Reference in New Issue
Block a user