allow arrow input
This commit is contained in:
6
main.c
6
main.c
@@ -30,6 +30,9 @@ enum Command {
|
|||||||
|
|
||||||
UP = 'k',
|
UP = 'k',
|
||||||
DOWN = 'j',
|
DOWN = 'j',
|
||||||
|
|
||||||
|
UP_ARROW = KEY_UP,
|
||||||
|
DOWN_ARROW = KEY_DOWN,
|
||||||
};
|
};
|
||||||
|
|
||||||
void clear_todos(void) {
|
void clear_todos(void) {
|
||||||
@@ -57,6 +60,7 @@ void initialize_curses(int *width, int *height) {
|
|||||||
// where no buffering is performed on keyboard input
|
// where no buffering is performed on keyboard input
|
||||||
cbreak();
|
cbreak();
|
||||||
noecho();
|
noecho();
|
||||||
|
keypad(stdscr, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_header(int width) {
|
void draw_header(int width) {
|
||||||
@@ -317,12 +321,14 @@ int main(int argc, char **argv) {
|
|||||||
running = 0;
|
running = 0;
|
||||||
break;
|
break;
|
||||||
case UP:
|
case UP:
|
||||||
|
case UP_ARROW:
|
||||||
current_line--;
|
current_line--;
|
||||||
if (current_line < 0) {
|
if (current_line < 0) {
|
||||||
current_line = 0;
|
current_line = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOWN:
|
case DOWN:
|
||||||
|
case DOWN_ARROW:
|
||||||
current_line++;
|
current_line++;
|
||||||
if (current_line >= arrlen(todos)) {
|
if (current_line >= arrlen(todos)) {
|
||||||
current_line = arrlen(todos) - 1;
|
current_line = arrlen(todos) - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user