list widget selection
[oftp] / src / unix / input.c
index 6cb91d8..92c1dcc 100644 (file)
@@ -5,7 +5,6 @@
 
 int init_input(void)
 {
-       nodelay(stdscr, TRUE);
        return 0;
 }
 
@@ -13,10 +12,44 @@ void cleanup_input(void)
 {
 }
 
+static int convkey(int key)
+{
+       switch(key) {
+       case KEY_DC:
+               return KB_DEL;
+       case KEY_IC:
+               return KB_INS;
+       case KEY_UP:
+               return KB_UP;
+       case KEY_DOWN:
+               return KB_DOWN;
+       case KEY_LEFT:
+               return KB_LEFT;
+       case KEY_RIGHT:
+               return KB_RIGHT;
+       case KEY_HOME:
+               return KB_HOME;
+       case KEY_END:
+               return KB_END;
+       case KEY_PPAGE:
+               return KB_PGUP;
+       case KEY_NPAGE:
+               return KB_PGDN;
+       default:
+               break;
+       }
+       if(key < 128) {
+               return key;
+       }
+       return -1;
+}
+
 int poll_input(union event *ev)
 {
        ev->type = EV_KEY;
-       ev->key.key = getch();
+       if((ev->key.key = convkey(getch())) == -1) {
+               return 0;
+       }
        return 1;
 }