summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2007-02-17 15:31:10 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2007-02-17 15:31:10 +0000
commit541fa72f46a95ea506064a868f95d15f1a7cb8f4 (patch)
tree15be2ac5c09ed60df843c54b509c629e30f54426
parent1a195da68510698bce5c525e07478f868cd5e5a1 (diff)
downloadirssi-541fa72f46a95ea506064a868f95d15f1a7cb8f4.zip
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
-rw-r--r--src/fe-text/lastlog.c22
-rw-r--r--src/fe-text/textbuffer-view.c18
-rw-r--r--src/fe-text/textbuffer-view.h1
3 files changed, 20 insertions, 21 deletions
diff --git a/src/fe-text/lastlog.c b/src/fe-text/lastlog.c
index 3919be7e..26fd1611 100644
--- a/src/fe-text/lastlog.c
+++ b/src/fe-text/lastlog.c
@@ -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;
}
diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c
index 175bd4f6..3dca76f3 100644
--- a/src/fe-text/textbuffer-view.c
+++ b/src/fe-text/textbuffer-view.c
@@ -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);
diff --git a/src/fe-text/textbuffer-view.h b/src/fe-text/textbuffer-view.h
index b529ebed..46da808e 100644
--- a/src/fe-text/textbuffer-view.h
+++ b/src/fe-text/textbuffer-view.h
@@ -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,