From 3a1ef5d9ebbb16104ef811b67b6f8768871b37f9 Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Sun, 10 Jun 2007 18:00:26 +0000 Subject: Make /window goto start searching at the window after the active one and stop at the one before, bug #332. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4550 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/window-commands.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/fe-common') diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c index 8ffeb046..7c4a4ee2 100644 --- a/src/fe-common/core/window-commands.c +++ b/src/fe-common/core/window-commands.c @@ -279,6 +279,33 @@ static WINDOW_REC *window_highest_activity(WINDOW_REC *window) return max_win; } +static WINDOW_REC *window_find_item_cycle(SERVER_REC *server, const char *name) +{ + WINDOW_REC *rec, *win; + GSList *tmp; + + win = NULL; + + tmp = g_slist_find(windows, active_win); + tmp = tmp->next; + for (;; tmp = tmp->next) { + if (tmp == NULL) + tmp = windows; + + if (tmp->data == active_win) + break; + + rec = tmp->data; + + if (window_item_find_window(rec, server, name) != NULL) { + win = rec; + break; + } + } + + return win; +} + /* SYNTAX: WINDOW GOTO active|| */ static void cmd_window_goto(const char *data) { @@ -298,8 +325,13 @@ static void cmd_window_goto(const char *data) if (g_strcasecmp(target, "active") == 0) window = window_highest_activity(active_win); - else - window = window_find_item(active_win->active_server, target); + else { + window = window_find_name(target); + if (window == NULL && active_win->active_server != NULL) + window = window_find_item_cycle(active_win->active_server, target); + if (window == NULL) + window = window_find_item_cycle(NULL, target); + } if (window != NULL) window_set_active(window); -- cgit v1.2.3