~pkal/dmenu

c32dfe1094bc2b79e6bfc2b96c95af60d9406055 — Philip K 1 year, 6 months ago 0335e84
Implement navhistory search
1 files changed, 22 insertions(+), 2 deletions(-)

M dmenu.c
M dmenu.c => dmenu.c +22 -2
@@ 40,7 40,7 @@ static int bh, mw, mh;
static int inputw = 0, promptw;
static int lrpad; /* sum of left and right padding */
static size_t cursor;
static struct item *items = NULL;
static struct item *items = NULL, *backup_items;
static struct item *matches, *matchend;
static struct item *prev, *curr, *next, *sel;
static int mon = -1, screen;


@@ 435,7 435,7 @@ static void
keypress(XKeyEvent *ev)
{
	char buf[32];
	int len;
	int len, i;
	KeySym ksym;
	Status status;



@@ 486,6 486,26 @@ keypress(XKeyEvent *ev)
			XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
			                  utf8, utf8, win, CurrentTime);
			return;
		case XK_r:
			if (histfile) {
				if (!backup_items) {
					backup_items = items;
					items = calloc(histsz + 1, sizeof(struct item));
					if (!items) {
						die("cannot allocate memory");
					}

					for (i = 0; i < histsz; i++) {
						items[i].text = history[i];
					}
				} else {
					free(items);
					items = backup_items;
					backup_items = NULL;
				}
			}
			match();
			goto draw;
		case XK_Left:
			movewordedge(-1);
			goto draw;