Allow alt-num to select window

This commit is contained in:
James Booth
2012-11-24 01:57:24 +00:00
parent f7ad1c0335
commit d30d31b57d
4 changed files with 79 additions and 30 deletions

View File

@@ -216,6 +216,12 @@ inp_put_back(void)
prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
}
int
inp_get_next_char(void)
{
return wgetch(inp_win);
}
void
inp_replace_input(char *input, const char * const new_input, int *size)
{
@@ -242,6 +248,7 @@ _handle_edit(const int ch, char *input, int *size)
char *next = NULL;
int inp_y = 0;
int inp_x = 0;
int next_ch;
getmaxyx(stdscr, rows, cols);
getyx(inp_win, inp_y, inp_x);
@@ -249,9 +256,50 @@ _handle_edit(const int ch, char *input, int *size)
switch(ch) {
case 27: // ESC
*size = 0;
inp_clear();
return 1;
// check for ALT-num
next_ch = inp_get_next_char();
if (next_ch != ERR) {
switch (next_ch)
{
case '1':
win_switch_if_active(0);
break;
case '2':
win_switch_if_active(1);
break;
case '3':
win_switch_if_active(2);
break;
case '4':
win_switch_if_active(3);
break;
case '5':
win_switch_if_active(4);
break;
case '6':
win_switch_if_active(5);
break;
case '7':
win_switch_if_active(6);
break;
case '8':
win_switch_if_active(7);
break;
case '9':
win_switch_if_active(8);
break;
case '0':
win_switch_if_active(9);
break;
default:
break;
}
return 1;
} else {
*size = 0;
inp_clear();
return 1;
}
case 127:
case KEY_BACKSPACE: