--- config.def.h | 1 + dmenu.1 | 8 ++++++++ dmenu.c | 18 +++++++++++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index dcffd38..9a65a47 100644 --- a/config.def.h +++ b/config.def.h _AT_@ -2,6 +2,7 @@ /* Default settings; can be overriden by command line. */ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ +static int reversed = 0; /* -r option; if 1, prompt appears under the list */ /* -fn option overrides fonts[0]; default X11 font or font set */ static const char *fonts[] = { "monospace:size=10" diff --git a/dmenu.1 b/dmenu.1 index d3ab805..c6938db 100644 --- a/dmenu.1 +++ b/dmenu.1 _AT_@ -6,6 +6,7 @@ dmenu \- dynamic menu .RB [ \-b ] .RB [ \-f ] .RB [ \-i ] +.RB [ \-r ] .RB [ \-l .RB [ \-m .IR monitor ] _AT_@ -48,6 +49,13 @@ X until stdin reaches end\-of\-file. .B \-i dmenu matches menu items case insensitively. .TP +.B \-r +reverses the list and puts the prompt under it (looks nice with +.B \-b +and +.B \-l +). +.TP .BI \-l " lines" dmenu lists items vertically, with the given number of lines. .TP diff --git a/dmenu.c b/dmenu.c index e0c2f80..62eb762 100644 --- a/dmenu.c +++ b/dmenu.c _AT_@ -120,30 +120,36 @@ drawmenu(void) int curpos; struct item *item; int x = 0, y = 0, h = bh, w; + int inputy = reversed ? lines * h : 0; drw_setscheme(drw, &scheme[SchemeNorm]); drw_rect(drw, 0, 0, mw, mh, 1, 1, 1); if (prompt && *prompt) { drw_setscheme(drw, &scheme[SchemeSel]); - drw_text(drw, x, 0, promptw, bh, prompt, 0); + drw_text(drw, x, inputy, promptw, bh, prompt, 0); x += promptw; } /* draw input field */ w = (lines > 0 || !matches) ? mw - x : inputw; drw_setscheme(drw, &scheme[SchemeNorm]); - drw_text(drw, x, 0, w, bh, text, 0); + drw_text(drw, x, inputy, w, bh, text, 0); if ((curpos = TEXTNW(text, cursor) + bh / 2 - 2) < w) { drw_setscheme(drw, &scheme[SchemeNorm]); - drw_rect(drw, x + curpos + 2, 2, 1, bh - 4, 1, 1, 0); + drw_rect(drw, x + curpos + 2, inputy + 2, 1, bh - 4, 1, 1, 0); } if (lines > 0) { /* draw vertical list */ + if (reversed) + y = lines * h; w = mw - x; for (item = curr; item != next; item = item->right) { - y += h; + if (reversed) + y -= h; + else + y += h; if (item == sel) drw_setscheme(drw, &scheme[SchemeSel]); else if (item->out) _AT_@ -610,7 +616,7 @@ setup(void) static void usage(void) { - fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + fputs("usage: dmenu [-b] [-f] [-i] [-r] [-l lines] [-p prompt] [-fn font][-m monitor]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); exit(1); } _AT_@ -629,6 +635,8 @@ main(int argc, char *argv[]) topbar = 0; else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = 1; + else if (!strcmp(argv[i], "-r")) /* reverses the list and puts the prompt under it */ + reversed = 1; else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; -- 2.7.0 --------------060502090809090505020701--Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Sun Feb 21 2016 - 14:48:10 CET