aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-08-09 18:39:25 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-08-09 18:39:25 +0200
commitcd2133a5f66b42f992a9a1b92bbbce11dc26b941 (patch)
treedb6a079f1711e73e1e1785c19c30cf9289877311
parentc585e8e498ec6f9c423ab8ea07cf853ee5b05fbe (diff)
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.
-rw-r--r--dmenu.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/dmenu.c b/dmenu.c
index 65f25ce..98507d9 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -360,9 +360,11 @@ keypress(XKeyEvent *ev)
360 utf8, utf8, win, CurrentTime); 360 utf8, utf8, win, CurrentTime);
361 return; 361 return;
362 case XK_Left: 362 case XK_Left:
363 case XK_KP_Left:
363 movewordedge(-1); 364 movewordedge(-1);
364 goto draw; 365 goto draw;
365 case XK_Right: 366 case XK_Right:
367 case XK_KP_Right:
366 movewordedge(+1); 368 movewordedge(+1);
367 goto draw; 369 goto draw;
368 case XK_Return: 370 case XK_Return:
@@ -400,6 +402,7 @@ insert:
400 insert(buf, len); 402 insert(buf, len);
401 break; 403 break;
402 case XK_Delete: 404 case XK_Delete:
405 case XK_KP_Delete:
403 if (text[cursor] == '\0') 406 if (text[cursor] == '\0')
404 return; 407 return;
405 cursor = nextrune(+1); 408 cursor = nextrune(+1);
@@ -410,6 +413,7 @@ insert:
410 insert(NULL, nextrune(-1) - cursor); 413 insert(NULL, nextrune(-1) - cursor);
411 break; 414 break;
412 case XK_End: 415 case XK_End:
416 case XK_KP_End:
413 if (text[cursor] != '\0') { 417 if (text[cursor] != '\0') {
414 cursor = strlen(text); 418 cursor = strlen(text);
415 break; 419 break;
@@ -429,6 +433,7 @@ insert:
429 cleanup(); 433 cleanup();
430 exit(1); 434 exit(1);
431 case XK_Home: 435 case XK_Home:
436 case XK_KP_Home:
432 if (sel == matches) { 437 if (sel == matches) {
433 cursor = 0; 438 cursor = 0;
434 break; 439 break;
@@ -437,6 +442,7 @@ insert:
437 calcoffsets(); 442 calcoffsets();
438 break; 443 break;
439 case XK_Left: 444 case XK_Left:
445 case XK_KP_Left:
440 if (cursor > 0 && (!sel || !sel->left || lines > 0)) { 446 if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
441 cursor = nextrune(-1); 447 cursor = nextrune(-1);
442 break; 448 break;
@@ -445,18 +451,21 @@ insert:
445 return; 451 return;
446 /* fallthrough */ 452 /* fallthrough */
447 case XK_Up: 453 case XK_Up:
454 case XK_KP_Up:
448 if (sel && sel->left && (sel = sel->left)->right == curr) { 455 if (sel && sel->left && (sel = sel->left)->right == curr) {
449 curr = prev; 456 curr = prev;
450 calcoffsets(); 457 calcoffsets();
451 } 458 }
452 break; 459 break;
453 case XK_Next: 460 case XK_Next:
461 case XK_KP_Next:
454 if (!next) 462 if (!next)
455 return; 463 return;
456 sel = curr = next; 464 sel = curr = next;
457 calcoffsets(); 465 calcoffsets();
458 break; 466 break;
459 case XK_Prior: 467 case XK_Prior:
468 case XK_KP_Prior:
460 if (!prev) 469 if (!prev)
461 return; 470 return;
462 sel = curr = prev; 471 sel = curr = prev;
@@ -473,6 +482,7 @@ insert:
473 sel->out = 1; 482 sel->out = 1;
474 break; 483 break;
475 case XK_Right: 484 case XK_Right:
485 case XK_KP_Right:
476 if (text[cursor] != '\0') { 486 if (text[cursor] != '\0') {
477 cursor = nextrune(+1); 487 cursor = nextrune(+1);
478 break; 488 break;
@@ -481,6 +491,7 @@ insert:
481 return; 491 return;
482 /* fallthrough */ 492 /* fallthrough */
483 case XK_Down: 493 case XK_Down:
494 case XK_KP_Down:
484 if (sel && sel->right && (sel = sel->right) == next) { 495 if (sel && sel->right && (sel = sel->right) == next) {
485 curr = next; 496 curr = next;
486 calcoffsets(); 497 calcoffsets();