From 195f819847952188fecec07c0959d631538eba3b Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Wed, 13 Sep 2006 22:54:38 +0000 Subject: [PATCH] Modify scrollback clear to accept the same arguments as clear. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4348 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-text/textbuffer-commands.c | 34 ++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/fe-text/textbuffer-commands.c b/src/fe-text/textbuffer-commands.c index 7797eca2..3636510b 100644 --- a/src/fe-text/textbuffer-commands.c +++ b/src/fe-text/textbuffer-commands.c @@ -99,10 +99,37 @@ static void cmd_scrollback(const char *data, SERVER_REC *server, command_runsub("scrollback", data, server, item); } -/* SYNTAX: SCROLLBACK CLEAR */ -static void cmd_scrollback_clear(void) +/* SYNTAX: SCROLLBACK CLEAR [-all] [] */ +static void cmd_scrollback_clear(const char *data) { - textbuffer_view_remove_all_lines(WINDOW_GUI(active_win)->view); + WINDOW_REC *window; + GHashTable *optlist; + char *refnum; + void *free_arg; + GSList *tmp; + + g_return_if_fail(data != NULL); + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS, + "scrollback clear", &optlist, &refnum)) return; + + if (g_hash_table_lookup(optlist, "all") != NULL) { + /* clear all windows */ + for (tmp = windows; tmp != NULL; tmp = tmp->next) { + window = tmp->data; + textbuffer_view_remove_all_lines(WINDOW_GUI(window)->view); + } + } else if (*refnum != '\0') { + /* clear specified window */ + window = window_find_refnum(atoi(refnum)); + if (window != NULL) + textbuffer_view_remove_all_lines(WINDOW_GUI(window)->view); + } else { + /* clear active window */ + textbuffer_view_remove_all_lines(WINDOW_GUI(active_win)->view); + } + + cmd_params_free(free_arg); } static void scrollback_goto_line(int linenum) @@ -338,6 +365,7 @@ void textbuffer_commands_init(void) #endif command_set_options("clear", "all"); + command_set_options("scrollback clear", "all"); signal_add("away mode changed", (SIGNAL_FUNC) sig_away_changed); }