Applied gridnav patch (for dmenu 5.0 but it worked so who cares) on top of grid patch

This commit is contained in:
Andreev Gregory 2025-03-03 16:20:18 +03:00
parent 2168a3f72f
commit bdd5dab27c

44
dmenu.c
View File

@ -317,6 +317,8 @@ keypress(XKeyEvent *ev)
int len;
KeySym ksym;
Status status;
int i, offscreen = 0;
struct item *tmpsel;
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
switch (status) {
@ -443,6 +445,27 @@ insert:
calcoffsets();
break;
case XK_Left:
if (columns > 1) {
if (!sel)
return;
tmpsel = sel;
for (i = 0; i < lines; i++) {
if (!tmpsel->left || tmpsel->left->right != tmpsel) {
if (offscreen)
break;
return;
}
if (tmpsel == curr)
offscreen = 1;
tmpsel = tmpsel->left;
}
sel = tmpsel;
if (offscreen) {
curr = prev;
calcoffsets();
}
break;
}
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
cursor = nextrune(-1);
break;
@ -479,6 +502,27 @@ insert:
sel->out = 1;
break;
case XK_Right:
if (columns > 1) {
if (!sel)
return;
tmpsel = sel;
for (i = 0; i < lines; i++) {
if (!tmpsel->right || tmpsel->right->left != tmpsel) {
if (offscreen)
break;
return;
}
tmpsel = tmpsel->right;
if (tmpsel == next)
offscreen = 1;
}
sel = tmpsel;
if (offscreen) {
curr = next;
calcoffsets();
}
break;
}
if (text[cursor] != '\0') {
cursor = nextrune(+1);
break;