diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2006-09-13 22:54:38 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2006-09-13 22:54:38 +0000 |
commit | 195f819847952188fecec07c0959d631538eba3b (patch) | |
tree | da675e52acf127fd65d2dc1e34bc8874ab1d667f /src | |
parent | 9b675ca03fd92a6e392673333b17884c9f677059 (diff) | |
download | irssi-195f819847952188fecec07c0959d631538eba3b.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-text/textbuffer-commands.c | 34 |
1 files 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] [<refnum>] */ +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); } |