From bdd5dab27c61a268f56cc8c25ae88a881da9df03 Mon Sep 17 00:00:00 2001 From: Andreev Gregory <1@example.com> Date: Mon, 3 Mar 2025 16:20:18 +0300 Subject: [PATCH] Applied gridnav patch (for dmenu 5.0 but it worked so who cares) on top of grid patch --- dmenu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/dmenu.c b/dmenu.c index d79b6bb..a741f86 100644 --- a/dmenu.c +++ b/dmenu.c @@ -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;