diff options
author | NPScript <nathan@reinerweb.ch> | 2021-03-03 14:53:48 +0100 |
---|---|---|
committer | NPScript <nathan@reinerweb.ch> | 2021-03-03 14:53:48 +0100 |
commit | 72e253264a266514fe2709d6152e06745b3a2b39 (patch) | |
tree | 33bc66572c4377ffc52d7900bfa8ff65365eed14 | |
parent | b44a11bafac0bd2665e2c4f08573d9a8f4fdf3f5 (diff) |
beautify dmenu
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | dmenu.c | 21 |
2 files changed, 17 insertions, 7 deletions
@@ -1,6 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* Default settings; can be overriden by command line. */ +#include <endian.h> static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ /* -fn option overrides fonts[0]; default X11 font or font set */ static const char *fonts[] = { @@ -16,6 +17,8 @@ static const char *colors[SchemeLast][2] = { /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ static unsigned int lines = 20; static unsigned int gapxx = 10; +static unsigned int border = 10; +static unsigned int borderline = 1; /* * Characters not considered part of a word while deleting words @@ -133,28 +133,35 @@ drawmenu(void) struct item *item; int x = 0, y = 0, w; - drw_setscheme(drw, scheme[SchemeNorm]); + drw_setscheme(drw, scheme[SchemeSel]); drw_rect(drw, 0, 0, mw, mh, 1, 1); + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, borderline, borderline, mw - 2 * borderline, mh - 2 * borderline, 1, 1); + drw_setscheme(drw, scheme[SchemeSel]); + drw_rect(drw, 0, bh + border, mw, 1, 1, 1); + drw_setscheme(drw, scheme[SchemeNorm]); if (prompt && *prompt) { drw_setscheme(drw, scheme[SchemeSel]); - x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0); + x = drw_text(drw, x + border, border, promptw, bh, lrpad / 2, prompt, 0); } /* draw input field */ w = (lines > 0 || !matches) ? mw - x : inputw; + w -= 2 * border; drw_setscheme(drw, scheme[SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + drw_text(drw, x + border, border / 2, w, bh, lrpad / 2, text, 0); curpos = TEXTW(text) - TEXTW(&text[cursor]); if ((curpos += lrpad / 2 - 1) < w) { drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); + drw_rect(drw, x + curpos + border + 2, border, 2, bh - border / 2 - 4, 1, 0); } if (lines > 0) { /* draw vertical list */ + y += 2 * border; for (item = curr; item != next; item = item->right) - drawitem(item, x, y += bh, mw - x); + drawitem(item, x + border, y += bh, mw - x - 2 * border); } else if (matches) { /* draw horizontal list */ x += inputw; @@ -608,9 +615,9 @@ setup(void) utf8 = XInternAtom(dpy, "UTF8_STRING", False); /* calculate menu geometry */ - bh = drw->fonts->h + 2; + bh = drw->fonts->h + 2 * border / 2; lines = MAX(lines, 0); - mh = (lines + 1) * bh; + mh = (lines + 1) * bh + 3 * border; #ifdef XINERAMA i = 0; if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { |