sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dmenu-gridnav-5.0.diff (1417B)


      1 diff --git a/dmenu.c b/dmenu.c
      2 index 7361377..fcec79b 100644
      3 --- a/dmenu.c
      4 +++ b/dmenu.c
      5 @@ -317,6 +317,8 @@ keypress(XKeyEvent *ev)
      6  	int len;
      7  	KeySym ksym;
      8  	Status status;
      9 +	int i, offscreen = 0;
     10 +	struct item *tmpsel;
     11  
     12  	len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
     13  	switch (status) {
     14 @@ -443,6 +445,27 @@ insert:
     15  		calcoffsets();
     16  		break;
     17  	case XK_Left:
     18 +		if (columns > 1) {
     19 +			if (!sel)
     20 +				return;
     21 +			tmpsel = sel;
     22 +			for (i = 0; i < lines; i++) {
     23 +				if (!tmpsel->left || tmpsel->left->right != tmpsel) {
     24 +					if (offscreen)
     25 +						break;
     26 +					return;
     27 +				}
     28 +				if (tmpsel == curr)
     29 +					offscreen = 1;
     30 +				tmpsel = tmpsel->left;
     31 +			}
     32 +			sel = tmpsel;
     33 +			if (offscreen) {
     34 +				curr = prev;
     35 +				calcoffsets();
     36 +			}
     37 +			break;
     38 +		}
     39  		if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
     40  			cursor = nextrune(-1);
     41  			break;
     42 @@ -479,6 +502,27 @@ insert:
     43  			sel->out = 1;
     44  		break;
     45  	case XK_Right:
     46 +		if (columns > 1) {
     47 +			if (!sel)
     48 +				return;
     49 +			tmpsel = sel;
     50 +			for (i = 0; i < lines; i++) {
     51 +				if (!tmpsel->right ||  tmpsel->right->left != tmpsel) {
     52 +					if (offscreen)
     53 +						break;
     54 +					return;
     55 +				}
     56 +				tmpsel = tmpsel->right;
     57 +				if (tmpsel == next)
     58 +					offscreen = 1;
     59 +			}
     60 +			sel = tmpsel;
     61 +			if (offscreen) {
     62 +				curr = next;
     63 +				calcoffsets();
     64 +			}
     65 +			break;
     66 +		}
     67  		if (text[cursor] != '\0') {
     68  			cursor = nextrune(+1);
     69  			break;