Add C-n and C-p key bindings to switch windows
parent
740cb9f687
commit
c06a457461
|
@ -1,4 +1,4 @@
|
|||
.Dd February 22, 2019
|
||||
.Dd February 23, 2019
|
||||
.Dt CATGIRL 1
|
||||
.Os
|
||||
.
|
||||
|
@ -292,6 +292,10 @@ The color numbers are as follows:
|
|||
.Bl -tag -width "PageDown" -compact
|
||||
.It Ic C-l
|
||||
Redraw the UI.
|
||||
.It Ic C-n
|
||||
Switch to the next window.
|
||||
.It Ic C-p
|
||||
Swittch to the previous window.
|
||||
.It Ic M-m
|
||||
Insert a blank line in the window.
|
||||
.It Ic M- Ns Ar n
|
||||
|
|
2
chat.h
2
chat.h
|
@ -122,7 +122,7 @@ void uiExit(int status);
|
|||
|
||||
void uiPrompt(bool nickChanged);
|
||||
void uiShowTag(struct Tag tag);
|
||||
void uiShowNum(int num);
|
||||
void uiShowNum(int num, bool relative);
|
||||
void uiCloseTag(struct Tag tag);
|
||||
|
||||
enum UIHeat {
|
||||
|
|
3
input.c
3
input.c
|
@ -146,9 +146,10 @@ static void inputWindow(struct Tag tag, char *params) {
|
|||
uiLog(tag, UIHot, L"/window requires a name or number");
|
||||
return;
|
||||
}
|
||||
bool relative = (params[0] == '+' || params[0] == '-');
|
||||
int num = strtol(params, ¶ms, 0);
|
||||
if (!params[0]) {
|
||||
uiShowNum(num);
|
||||
uiShowNum(num, relative);
|
||||
} else {
|
||||
struct Tag name = tagFind(params);
|
||||
if (name.id != TagNone.id) {
|
||||
|
|
20
ui.c
20
ui.c
|
@ -354,18 +354,15 @@ void uiShowTag(struct Tag tag) {
|
|||
uiPrompt(false);
|
||||
}
|
||||
|
||||
void uiShowNum(int num) {
|
||||
struct Window *win = NULL;
|
||||
void uiShowNum(int num, bool relative) {
|
||||
struct Window *win = (relative ? windows.active : windows.head);
|
||||
if (num < 0) {
|
||||
for (win = windows.tail; win; win = win->prev) {
|
||||
if (!++num) break;
|
||||
}
|
||||
for (; win; win = win->prev) if (!num++) break;
|
||||
} else {
|
||||
for (win = windows.head; win; win = win->next) {
|
||||
if (!num--) break;
|
||||
}
|
||||
for (; win; win = win->next) if (!num--) break;
|
||||
}
|
||||
if (win) windowShow(win);
|
||||
if (!win) return;
|
||||
windowShow(win);
|
||||
uiStatus();
|
||||
uiPrompt(false);
|
||||
}
|
||||
|
@ -470,7 +467,7 @@ static void keyChar(wchar_t ch) {
|
|||
}
|
||||
if (meta) {
|
||||
meta = false;
|
||||
if (ch >= L'0' && ch <= L'9') uiShowNum(ch - L'0');
|
||||
if (ch >= L'0' && ch <= L'9') uiShowNum(ch - L'0', false);
|
||||
if (!win) return;
|
||||
switch (ch) {
|
||||
break; case L'b': edit(win->tag, EditBackWord, 0);
|
||||
|
@ -485,6 +482,9 @@ static void keyChar(wchar_t ch) {
|
|||
if (ch == CTRL(L'L')) clearok(curscr, true);
|
||||
if (!win) return;
|
||||
switch (ch) {
|
||||
break; case CTRL(L'N'): uiShowNum(+1, true);
|
||||
break; case CTRL(L'P'): uiShowNum(-1, true);
|
||||
|
||||
break; case CTRL(L'A'): edit(win->tag, EditHome, 0);
|
||||
break; case CTRL(L'B'): edit(win->tag, EditLeft, 0);
|
||||
break; case CTRL(L'D'): edit(win->tag, EditDelete, 0);
|
||||
|
|
Loading…
Reference in New Issue