From 72e253264a266514fe2709d6152e06745b3a2b39 Mon Sep 17 00:00:00 2001 From: NPScript Date: Wed, 3 Mar 2021 14:53:48 +0100 Subject: beautify dmenu --- config.h | 3 +++ dmenu.c | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index ffa5701..6bd4312 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* Default settings; can be overriden by command line. */ +#include 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 diff --git a/dmenu.c b/dmenu.c index 4556432..143c90d 100644 --- a/dmenu.c +++ b/dmenu.c @@ -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))) { -- cgit v1.2.3-70-g09d2