OSDN Git Service

Add decision of special key for main-gcu to inkey_special()
authorhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 4 Mar 2013 13:40:59 +0000 (13:40 +0000)
committerhabu <habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 4 Mar 2013 13:40:59 +0000 (13:40 +0000)
src/util.c

index 0da8e97..8935a34 100644 (file)
@@ -5423,6 +5423,22 @@ int inkey_special(bool numpad_cursor)
                {TRUE, "KP_1]", SKEY_BOTTOM},
                {FALSE, NULL, 0},
        };
+
+       static const struct {
+               cptr keyname;
+               int keycode;
+       } gcu_special_key_list[] = {
+               {"A", SKEY_UP},
+               {"B", SKEY_DOWN},
+               {"C", SKEY_RIGHT},
+               {"D", SKEY_LEFT},
+               {"1~", SKEY_TOP},
+               {"4~", SKEY_BOTTOM},
+               {"5~", SKEY_PGUP},
+               {"6~", SKEY_PGDOWN},
+               {NULL, 0},
+       };
+
        char buf[1024];
        cptr str = buf;
        char key;
@@ -5511,6 +5527,19 @@ int inkey_special(bool numpad_cursor)
                }
        }
 
+       if (prefix(str, "\\e["))
+       {
+               str += 3;
+
+               for (i = 0; gcu_special_key_list[i].keyname; i++)
+               {
+                       if (streq(str, gcu_special_key_list[i].keyname))
+                       {
+                               return gcu_special_key_list[i].keycode;
+                       }
+               }
+       }
+
        /* No special key found? */
 
        /* Don't bother with this trigger no more */