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
|
.Dt CATGIRL 1
|
||||||
.Os
|
.Os
|
||||||
.
|
.
|
||||||
|
@ -292,6 +292,10 @@ The color numbers are as follows:
|
||||||
.Bl -tag -width "PageDown" -compact
|
.Bl -tag -width "PageDown" -compact
|
||||||
.It Ic C-l
|
.It Ic C-l
|
||||||
Redraw the UI.
|
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
|
.It Ic M-m
|
||||||
Insert a blank line in the window.
|
Insert a blank line in the window.
|
||||||
.It Ic M- Ns Ar n
|
.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 uiPrompt(bool nickChanged);
|
||||||
void uiShowTag(struct Tag tag);
|
void uiShowTag(struct Tag tag);
|
||||||
void uiShowNum(int num);
|
void uiShowNum(int num, bool relative);
|
||||||
void uiCloseTag(struct Tag tag);
|
void uiCloseTag(struct Tag tag);
|
||||||
|
|
||||||
enum UIHeat {
|
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");
|
uiLog(tag, UIHot, L"/window requires a name or number");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool relative = (params[0] == '+' || params[0] == '-');
|
||||||
int num = strtol(params, ¶ms, 0);
|
int num = strtol(params, ¶ms, 0);
|
||||||
if (!params[0]) {
|
if (!params[0]) {
|
||||||
uiShowNum(num);
|
uiShowNum(num, relative);
|
||||||
} else {
|
} else {
|
||||||
struct Tag name = tagFind(params);
|
struct Tag name = tagFind(params);
|
||||||
if (name.id != TagNone.id) {
|
if (name.id != TagNone.id) {
|
||||||
|
|
20
ui.c
20
ui.c
|
@ -354,18 +354,15 @@ void uiShowTag(struct Tag tag) {
|
||||||
uiPrompt(false);
|
uiPrompt(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiShowNum(int num) {
|
void uiShowNum(int num, bool relative) {
|
||||||
struct Window *win = NULL;
|
struct Window *win = (relative ? windows.active : windows.head);
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
for (win = windows.tail; win; win = win->prev) {
|
for (; win; win = win->prev) if (!num++) break;
|
||||||
if (!++num) break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (win = windows.head; win; win = win->next) {
|
for (; win; win = win->next) if (!num--) break;
|
||||||
if (!num--) break;
|
|
||||||
}
|
}
|
||||||
}
|
if (!win) return;
|
||||||
if (win) windowShow(win);
|
windowShow(win);
|
||||||
uiStatus();
|
uiStatus();
|
||||||
uiPrompt(false);
|
uiPrompt(false);
|
||||||
}
|
}
|
||||||
|
@ -470,7 +467,7 @@ static void keyChar(wchar_t ch) {
|
||||||
}
|
}
|
||||||
if (meta) {
|
if (meta) {
|
||||||
meta = false;
|
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;
|
if (!win) return;
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
break; case L'b': edit(win->tag, EditBackWord, 0);
|
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 (ch == CTRL(L'L')) clearok(curscr, true);
|
||||||
if (!win) return;
|
if (!win) return;
|
||||||
switch (ch) {
|
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'A'): edit(win->tag, EditHome, 0);
|
||||||
break; case CTRL(L'B'): edit(win->tag, EditLeft, 0);
|
break; case CTRL(L'B'): edit(win->tag, EditLeft, 0);
|
||||||
break; case CTRL(L'D'): edit(win->tag, EditDelete, 0);
|
break; case CTRL(L'D'): edit(win->tag, EditDelete, 0);
|
||||||
|
|
Loading…
Reference in New Issue