summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-03-15 21:05:40 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-03-15 21:05:40 +0000
commitdb7c60b9a560f7371c37d59f106fbc395923eff3 (patch)
treebb542fb47508db15e03f73aff230e90e3caccb05 /src
parent6fda90e72b3d7681071b00d50b7e429251e1899b (diff)
downloadirssi-db7c60b9a560f7371c37d59f106fbc395923eff3.zip
/WINDOW CLOSE [<first> [<last>] - you can close multiple windows once now.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1396 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/window-commands.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c
index bb56c5e8..17cf65e5 100644
--- a/src/fe-common/core/window-commands.c
+++ b/src/fe-common/core/window-commands.c
@@ -59,12 +59,46 @@ static void cmd_window_new(const char *data, void *server, WI_ITEM_REC *item)
window_change_server(window, server);
}
-/* SYNTAX: WINDOW CLOSE */
+/* SYNTAX: WINDOW CLOSE [<first> [<last>] */
static void cmd_window_close(const char *data)
{
- /* destroy window unless it's the last one */
- if (windows->next != NULL)
- window_destroy(active_win);
+ GSList *tmp, *destroys;
+ char *first, *last;
+ int first_num, last_num;
+ void *free_arg;
+
+ if (!cmd_get_params(data, &free_arg, 2, &first, &last))
+ return;
+
+ if ((*first != '\0' && !is_numeric(first, '\0')) ||
+ ((*last != '\0') && !is_numeric(last, '\0'))) {
+ cmd_params_free(free_arg);
+ return;
+ }
+
+ first_num = *first == '\0' ? active_win->refnum : atoi(first);
+ last_num = *last == '\0' ? active_win->refnum : atoi(last);
+
+ /* get list of windows to destroy */
+ destroys = NULL;
+ for (tmp = windows; tmp != NULL; tmp = tmp->next) {
+ WINDOW_REC *rec = tmp->data;
+
+ if (rec->refnum >= first_num && rec->refnum <= last_num)
+ destroys = g_slist_append(destroys, rec);
+ }
+
+ /* really destroy the windows */
+ while (destroys != NULL) {
+ WINDOW_REC *rec = destroys->data;
+
+ if (windows->next != NULL)
+ window_destroy(rec);
+
+ destroys = g_slist_remove(destroys, rec);
+ }
+
+ cmd_params_free(free_arg);
}
/* SYNTAX: WINDOW REFNUM <number> */