73 lines
1.5 KiB
Diff
73 lines
1.5 KiB
Diff
diff --git a/dmenu.c b/dmenu.c
|
|
index 7361377..76acee6 100644
|
|
--- a/dmenu.c
|
|
+++ b/dmenu.c
|
|
@@ -7,6 +7,7 @@
|
|
#include <strings.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
+#include <stdbool.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xatom.h>
|
|
@@ -317,6 +318,9 @@ keypress(XKeyEvent *ev)
|
|
int len;
|
|
KeySym ksym;
|
|
Status status;
|
|
+ int i;
|
|
+ struct item *tmpsel;
|
|
+ bool offscreen = false;
|
|
|
|
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
|
|
switch (status) {
|
|
@@ -443,6 +447,24 @@ 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)
|
|
+ return;
|
|
+ if (tmpsel == curr)
|
|
+ offscreen = true;
|
|
+ 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 +501,24 @@ 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)
|
|
+ return;
|
|
+ tmpsel = tmpsel->right;
|
|
+ if (tmpsel == next)
|
|
+ offscreen = true;
|
|
+ }
|
|
+ sel = tmpsel;
|
|
+ if (offscreen) {
|
|
+ curr = next;
|
|
+ calcoffsets();
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
if (text[cursor] != '\0') {
|
|
cursor = nextrune(+1);
|
|
break;
|