From adc6d3bdd241e1dad6646ae537e7f8020ac4c971 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 26 Feb 2019 23:13:55 -0500 Subject: Add M-/ to switch to previously active window This is also a weechat binding. --- ui.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'ui.c') diff --git a/ui.c b/ui.c index fb4a366..643d627 100644 --- a/ui.c +++ b/ui.c @@ -61,6 +61,7 @@ struct Window { static struct { struct Window *active; + struct Window *other; struct Window *head; struct Window *tail; struct Window *tag[TagsLen]; @@ -126,11 +127,13 @@ static void windowShow(struct Window *win) { touchwin(win->log); windowUnmark(win); } + windows.other = windows.active; windows.active = win; } static void windowClose(struct Window *win) { if (windows.active == win) windowShow(win->next ? win->next : win->prev); + if (windows.other == win) windows.other = NULL; windowRemove(win); delwin(win->log); free(win); @@ -352,12 +355,16 @@ static void uiStatus(void) { wclrtoeol(ui.status); } -void uiShowTag(struct Tag tag) { - windowShow(windowFor(tag)); +static void uiShowWindow(struct Window *win) { + windowShow(win); uiStatus(); uiPrompt(false); } +void uiShowTag(struct Tag tag) { + uiShowWindow(windowFor(tag)); +} + void uiShowNum(int num, bool relative) { struct Window *win = (relative ? windows.active : windows.head); if (num < 0) { @@ -365,10 +372,7 @@ void uiShowNum(int num, bool relative) { } else { for (; win; win = win->next) if (!num--) break; } - if (!win) return; - windowShow(win); - uiStatus(); - uiPrompt(false); + if (win) uiShowWindow(win); } static void uiShowAuto(void) { @@ -379,9 +383,7 @@ static void uiShowAuto(void) { if (!unread && hot->unread) unread = hot; } if (!hot && !unread) return; - windowShow(hot ? hot : unread); - uiStatus(); - uiPrompt(false); + uiShowWindow(hot ? hot : unread); } void uiCloseTag(struct Tag tag) { @@ -465,6 +467,7 @@ static void keyMeta(wchar_t ch) { struct Window *win = windows.active; if (ch >= L'0' && ch <= L'9') uiShowNum(ch - L'0', false); if (ch == L'a') uiShowAuto(); + if (ch == L'/' && windows.other) uiShowWindow(windows.other); if (!win) return; switch (ch) { break; case L'b': edit(win->tag, EditBackWord, 0); -- cgit 1.4.1 Commit message (Expand)Author 2021-11-29Import LibreSSL 3.4.2June McEnroe 2021-10-14Import LibreSSL 3.4.1June McEnroe 2021-09-17Import LibreSSL 3.4.0June McEnroe 2021-08-24Import LibreSSL 3.3.4June McEnroe 2021-05-25Bump version to 3.3.3p1 3.3.3p1June McEnroe 2021-05-25build: Add scripts to EXTRA_DISTJune McEnroe 2021-05-25import: Add missing scripts/wrap-compiler-for-flag-checkJune McEnroe 2021-05-08Import LibreSSL 3.3.3June McEnroe 2021-04-18build: Remove added x509_verify.3 links 3.3.2June McEnroe 2021-04-18tls: Use EC_KEY_set_ex_dataJune McEnroe 2021-04-18Import LibreSSL 3.3.2June McEnroe 2021-03-05Bump version to 3.3.1p1 3.3.1p1June McEnroe 2021-03-05build: Add OpenSSL includes to libcompatJune McEnroe 2020-12-15Import LibreSSL 3.3.1June McEnroe 2020-11-24Import LibreSSL 3.3.0June McEnroe 2020-10-22Import LibreSSL 3.2.2June McEnroe 2020-09-29Import LibreSSL 3.2.1June McEnroe 2020-09-29import: Add m4/ax_add_fortify_source.m4June McEnroe 2020-08-05build: Add README.7 to EXTRA_DIST 3.2.0June McEnroe 2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe