From 8be4cd1f2731ebec069c5848148b6748f318ea98 Mon Sep 17 00:00:00 2001 From: "Jesse R. Adams" Date: Wed, 25 Sep 2013 12:51:54 -0700 Subject: [PATCH] Adding irssi style Alt-Left/Right window navigation --- src/ui/console.c | 2 ++ src/ui/inputwin.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/ui/console.c b/src/ui/console.c index 17e97ca3..192edfc4 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1289,6 +1289,8 @@ cons_navigation_help(void) cons_show(""); cons_show("Alt-1 : This console window."); cons_show("Alt-2..Alt-0 : Chat windows."); + cons_show("Alt-LEFT : Previous chat window"); + cons_show("Alt-RIGHT : Next chat window"); cons_show("F1 : This console window."); cons_show("F2..F10 : Chat windows."); cons_show("UP, DOWN : Navigate input history."); diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 598911cd..dc8e994a 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -40,6 +40,7 @@ #include "log.h" #include "profanity.h" #include "ui/ui.h" +#include "ui/windows.h" #include "xmpp/xmpp.h" #define _inp_win_refresh() prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1) @@ -559,6 +560,8 @@ _handle_alt_key(char *input, int *size, int key) { int end_del = getcurx(inp_win); int start_del = end_del; + int current = wins_get_current_num(); + int new; switch (key) { @@ -592,6 +595,24 @@ _handle_alt_key(char *input, int *size, int key) case '0': ui_switch_win(0); break; + case KEY_LEFT: + if (current == 0) { + new = 9; + } else { + new = current - 1; + } + + ui_switch_win(new); + break; + case KEY_RIGHT: + if (current == 9) { + new = 0; + } else { + new = current + 1; + } + + ui_switch_win(new); + break; case 263: case 127: input[*size] = '\0';