dmenu-nodefaultsel-20240105-9a6ef61.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dmenu-nodefaultsel-20240105-9a6ef61.diff (1530B)
       ---
            1 From 9a6ef6174ade2913e940d453f81c488b47d365fa Mon Sep 17 00:00:00 2001
            2 From: vishal <vishal340@github.com>
            3 Date: Fri, 5 Jan 2024 16:54:19 +0530
            4 Subject: [PATCH] With this patch dmenu will no longer select the first item by
            5  default and you can use right and left key for bothmoving in text and drop
            6  down. dependencies: grid and gridnav
            7 
            8 ---
            9  dmenu.c | 14 +++++++++++---
           10  1 file changed, 11 insertions(+), 3 deletions(-)
           11 
           12 diff --git a/dmenu.c b/dmenu.c
           13 index 1a76e1b..050073b 100644
           14 --- a/dmenu.c
           15 +++ b/dmenu.c
           16 @@ -282,7 +282,7 @@ match(void)
           17                          matches = lsubstr;
           18                  matchend = substrend;
           19          }
           20 -        curr = sel = matches;
           21 +        curr = matches;
           22          calcoffsets();
           23  }
           24  
           25 @@ -467,8 +467,10 @@ insert:
           26                  break;
           27          case XK_Left:
           28                  if (columns > 1) {
           29 -                        if (!sel)
           30 +                        if (!sel){
           31 +                                system("xdotool key KP_Left");
           32                                  return;
           33 +                        }
           34                          tmpsel = sel;
           35                          for (i = 0; i < lines; i++) {
           36                                  if (!tmpsel->left || tmpsel->left->right != tmpsel) {
           37 @@ -501,6 +503,8 @@ insert:
           38                          curr = prev;
           39                          calcoffsets();
           40                  }
           41 +                else if (sel && !sel->left)
           42 +                        sel = NULL;
           43                  break;
           44          case XK_Next:
           45          case XK_KP_Next:
           46 @@ -528,8 +532,10 @@ insert:
           47                  break;
           48          case XK_Right:
           49                  if (columns > 1) {
           50 -                        if (!sel)
           51 +                        if (!sel) {
           52 +                                system("xdotool key KP_Right");
           53                                  return;
           54 +                        }
           55                          tmpsel = sel;
           56                          for (i = 0; i < lines; i++) {
           57                                  if (!tmpsel->right ||  tmpsel->right->left != tmpsel) {
           58 @@ -562,6 +568,8 @@ insert:
           59                          curr = next;
           60                          calcoffsets();
           61                  }
           62 +                else if (!sel && curr)
           63 +                        sel = curr;
           64                  break;
           65          case XK_Tab:
           66                  if (!sel)
           67 -- 
           68 2.43.0
           69