commit ea09a1d99ecd3fb58e80452f18b90d6db1a694a1
parent 09ee259a709a75e0e6cd633fcfd01a6d34ed01d3
Author: kocotian <kocotian@kocotian.pl>
Date: Sat, 2 Jan 2021 14:44:31 +0100
like in my dwm - lines
Diffstat:
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -3,7 +3,7 @@
static int instant = 0;
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
-static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
+static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {
"monospace:size=8",
@@ -12,10 +12,12 @@ static const char *fonts[] = {
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {
/* fg bg */
- [SchemeNorm] = { "#aaaaaa", "#222222" },
- [SchemeSel] = { "#ffffff", "#222222" },
- [SchemePrpt] = { "#ffffff", "#444444" },
- [SchemeOut] = { "#000000", "#00ffff" },
+ [SchemeNorm] = { "#aaaaaa", "#222222" },
+ [SchemeSel] = { "#ffffff", "#444444" },
+ [SchemePrpt] = { "#ffffff", "#444444" },
+ [SchemeLnNorm] = { "#444444", "#444444" },
+ [SchemeLnSel] = { "#d79921", "#d79921" },
+ [SchemeOut] = { "#000000", "#00ffff" },
};
/* -l and -g options; controls number of lines and columns in grid if > 0 */
static unsigned int lines = 0;
diff --git a/dmenu.c b/dmenu.c
@@ -28,7 +28,9 @@
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
/* enums */
-enum { SchemeNorm, SchemeSel, SchemeOut, SchemePrpt, SchemeLast }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemePrpt,
+ SchemeLnNorm, SchemeLnSel, SchemeOut,
+ SchemeLast }; /* color schemes */
struct item {
char *text;
@@ -118,8 +120,9 @@ cistrstr(const char *s, const char *sub)
}
static int
-drawitem(struct item *item, int x, int y, int w)
+drawitem(struct item *item, int x, int y, int w, int noline)
{
+ int ret;
if (item == sel)
drw_setscheme(drw, scheme[SchemeSel]);
else if (item->out)
@@ -127,7 +130,14 @@ drawitem(struct item *item, int x, int y, int w)
else
drw_setscheme(drw, scheme[SchemeNorm]);
- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
+ ret = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
+
+ if (!noline)
+ drw_setscheme(drw, scheme[item == sel ? SchemeLnSel : SchemeLnNorm]);
+ drw_rect(drw, x + 1, y, w - 2, 2,
+ 1, 1);
+
+ return ret;
}
static void
@@ -163,8 +173,11 @@ drawmenu(void)
item,
x + ((i / lines) * ((mw - x) / columns)),
y + (((i % lines) + 1) * bh),
- (mw - x) / columns
+ (mw - x) / columns, 1
);
+ drw_setscheme(drw, scheme[SchemeLnSel]);
+ drw_rect(drw, 1, 0, mw - 2, 2,
+ 1, 1);
} else if (matches) {
/* draw horizontal list */
x += inputw;
@@ -175,7 +188,7 @@ drawmenu(void)
}
x += w;
for (item = curr; item != next; item = item->right)
- x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">")));
+ x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">")), 0);
if (next) {
w = TEXTW(">");
drw_setscheme(drw, scheme[SchemeNorm]);