diff options
author | James Booth <boothj5@gmail.com> | 2012-02-26 20:09:39 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-26 20:09:39 +0000 |
commit | 76c6e49dc78d8f55b68c26ef577e25af514d1005 (patch) | |
tree | 317383d824e15dac77ce282733e09bba162e199d /input_win.c | |
parent | 61b2a0803b6e8d7d901b63b8c9e22d117ea776d1 (diff) | |
download | profani-tty-76c6e49dc78d8f55b68c26ef577e25af514d1005.tar.gz |
Allow left/right movement in input window
Diffstat (limited to 'input_win.c')
-rw-r--r-- | input_win.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/input_win.c b/input_win.c index 564c76ca..80db4d74 100644 --- a/input_win.c +++ b/input_win.c @@ -59,7 +59,7 @@ void inp_block(void) wtimeout(inp_win, -1); } -void inp_poll_char(int *ch, char command[], int *size) +void inp_poll_char(int *ch, char *command, int *size) { int inp_y = 0; int inp_x = 0; @@ -80,11 +80,29 @@ void inp_poll_char(int *ch, char command[], int *size) wdelch(inp_win); (*size)--; } - } - // else if not error or newline, show it and store it - else if (*ch != ERR && + // left arrow + } else if (*ch == KEY_LEFT) { + getyx(inp_win, inp_y, inp_x); + if (inp_x > 1) { + wmove(inp_win, inp_y, inp_x-1); + } + + // right arrow + } else if (*ch == KEY_RIGHT) { + getyx(inp_win, inp_y, inp_x); + if (inp_x < *size + 1) { + wmove(inp_win, inp_y, inp_x+1); + } + + // else if not error, newline or special key, + // show it and store it + } else if (*ch != ERR && *ch != '\n' && + *ch != KEY_LEFT && + *ch != KEY_RIGHT && + *ch != KEY_UP && + *ch != KEY_DOWN && *ch != KEY_F(1) && *ch != KEY_F(2) && *ch != KEY_F(3) && |