[hackers] [dmenu] add support for more keypad keys || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Mon, 9 Aug 2021 18:41:35 +0200 (CEST)

commit cd2133a5f66b42f992a9a1b92bbbce11dc26b941
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Mon Aug 9 18:39:25 2021 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Mon Aug 9 18:39:25 2021 +0200

    add support for more keypad keys
    
    The keypad Enter key was already supported. On some keyboard layouts like my
    laptop the page-up and page-down key is more comfortable to use.
    This adds a few lines but no complexity.

diff --git a/dmenu.c b/dmenu.c
index 65f25ce..98507d9 100644
--- a/dmenu.c
+++ b/dmenu.c
_AT_@ -360,9 +360,11 @@ keypress(XKeyEvent *ev)
                                           utf8, utf8, win, CurrentTime);
                         return;
                 case XK_Left:
+ case XK_KP_Left:
                         movewordedge(-1);
                         goto draw;
                 case XK_Right:
+ case XK_KP_Right:
                         movewordedge(+1);
                         goto draw;
                 case XK_Return:
_AT_@ -400,6 +402,7 @@ insert:
                         insert(buf, len);
                 break;
         case XK_Delete:
+ case XK_KP_Delete:
                 if (text[cursor] == '\0')
                         return;
                 cursor = nextrune(+1);
_AT_@ -410,6 +413,7 @@ insert:
                 insert(NULL, nextrune(-1) - cursor);
                 break;
         case XK_End:
+ case XK_KP_End:
                 if (text[cursor] != '\0') {
                         cursor = strlen(text);
                         break;
_AT_@ -429,6 +433,7 @@ insert:
                 cleanup();
                 exit(1);
         case XK_Home:
+ case XK_KP_Home:
                 if (sel == matches) {
                         cursor = 0;
                         break;
_AT_@ -437,6 +442,7 @@ insert:
                 calcoffsets();
                 break;
         case XK_Left:
+ case XK_KP_Left:
                 if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
                         cursor = nextrune(-1);
                         break;
_AT_@ -445,18 +451,21 @@ insert:
                         return;
                 /* fallthrough */
         case XK_Up:
+ case XK_KP_Up:
                 if (sel && sel->left && (sel = sel->left)->right == curr) {
                         curr = prev;
                         calcoffsets();
                 }
                 break;
         case XK_Next:
+ case XK_KP_Next:
                 if (!next)
                         return;
                 sel = curr = next;
                 calcoffsets();
                 break;
         case XK_Prior:
+ case XK_KP_Prior:
                 if (!prev)
                         return;
                 sel = curr = prev;
_AT_@ -473,6 +482,7 @@ insert:
                         sel->out = 1;
                 break;
         case XK_Right:
+ case XK_KP_Right:
                 if (text[cursor] != '\0') {
                         cursor = nextrune(+1);
                         break;
_AT_@ -481,6 +491,7 @@ insert:
                         return;
                 /* fallthrough */
         case XK_Down:
+ case XK_KP_Down:
                 if (sel && sel->right && (sel = sel->right) == next) {
                         curr = next;
                         calcoffsets();
Received on Mon Aug 09 2021 - 18:41:35 CEST

This archive was generated by hypermail 2.3.0 : Mon Aug 09 2021 - 18:48:32 CEST