diff options
| author | pml68 <contact@pml68.dev> | 2025-09-17 23:30:41 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-09-17 23:30:41 +0200 |
| commit | 57402bad3f311e8b7473d64ab88df94f967ca364 (patch) | |
| tree | 686d350d0614d35e4146391290061a74585a9096 | |
| parent | chore: sync dmenu with upstream (diff) | |
| download | suckless-setup-57402bad3f311e8b7473d64ab88df94f967ca364.tar.gz | |
feat(dmenu): add inlinePrompt patch
| -rw-r--r-- | dmenu/config.def.h | 2 | ||||
| -rw-r--r-- | dmenu/config.h | 2 | ||||
| -rw-r--r-- | dmenu/dmenu.c | 26 | ||||
| -rw-r--r-- | dmenu/patches/dmenu-inlinePrompt-20250821-d893c63.diff | 73 |
4 files changed, 91 insertions, 12 deletions
diff --git a/dmenu/config.def.h b/dmenu/config.def.h index a6a06b8..032fbfd 100644 --- a/dmenu/config.def.h +++ b/dmenu/config.def.h @@ -14,12 +14,14 @@ static const char *colors[SchemeLast][2] = { [SchemeNorm] = {"#e0def4", "#191724"}, [SchemeSel] = {"#e0def4", "#575e6e"}, [SchemeOut] = {"#e0def4", "#dde1e7"}, + [SchemePrompt] = {"#908caa", "#191724"}, }; static const unsigned int alphas[SchemeLast][2] = { [SchemeNorm] = {OPAQUE, alpha}, [SchemeSel] = {OPAQUE, alpha}, [SchemeOut] = {OPAQUE, alpha}, + [SchemePrompt] = {OPAQUE, alpha}, }; /* -l and -g options; controls number of lines and columns in grid if > 0 */ diff --git a/dmenu/config.h b/dmenu/config.h index a6a06b8..032fbfd 100644 --- a/dmenu/config.h +++ b/dmenu/config.h @@ -14,12 +14,14 @@ static const char *colors[SchemeLast][2] = { [SchemeNorm] = {"#e0def4", "#191724"}, [SchemeSel] = {"#e0def4", "#575e6e"}, [SchemeOut] = {"#e0def4", "#dde1e7"}, + [SchemePrompt] = {"#908caa", "#191724"}, }; static const unsigned int alphas[SchemeLast][2] = { [SchemeNorm] = {OPAQUE, alpha}, [SchemeSel] = {OPAQUE, alpha}, [SchemeOut] = {OPAQUE, alpha}, + [SchemePrompt] = {OPAQUE, alpha}, }; /* -l and -g options; controls number of lines and columns in grid if > 0 */ diff --git a/dmenu/dmenu.c b/dmenu/dmenu.c index 9ff0211..d8540f2 100644 --- a/dmenu/dmenu.c +++ b/dmenu/dmenu.c @@ -36,7 +36,7 @@ #define OPAQUE 0xffu /* enums */ -enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeOut, SchemePrompt, SchemeLast }; /* color schemes */ struct item { char *text; @@ -170,21 +170,23 @@ static void drawmenu(void) { drw_setscheme(drw, scheme[SchemeNorm]); drw_rect(drw, 0, 0, mw, mh, 1, 1); - if (prompt && *prompt) { - drw_setscheme(drw, scheme[SchemeSel]); - x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0); - } - /* draw input field */ w = (lines > 0 || !matches) ? mw - x : inputw; - drw_setscheme(drw, scheme[SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); - - curpos = TEXTW(text) - TEXTW(&text[cursor]); - if ((curpos += lrpad / 2 - 1) < w) { + if (text[0] == '\0' && prompt && *prompt) { + drw_setscheme(drw, scheme[SchemePrompt]); + /* If vertical list: use full width (w), else just promptw */ + drw_text(drw, x, 0, (lines > 0 ? w : promptw), bh, lrpad / 2, prompt, 0); + } else { drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); + drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); } + if (text[0] != '\0') { + curpos = TEXTW(text) - TEXTW(&text[cursor]); + if ((curpos += lrpad / 2 - 1) < w) { + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, x + curpos, 1, 2, bh - 4, 1, 0); + } + } if (lines > 0) { /* draw grid */ int i = 0; diff --git a/dmenu/patches/dmenu-inlinePrompt-20250821-d893c63.diff b/dmenu/patches/dmenu-inlinePrompt-20250821-d893c63.diff new file mode 100644 index 0000000..7daac5c --- /dev/null +++ b/dmenu/patches/dmenu-inlinePrompt-20250821-d893c63.diff @@ -0,0 +1,73 @@ +From 5a2f518818431f74f291facf2c5503735b85e5a9 Mon Sep 17 00:00:00 2001 +From: Daan Blom <contact@daanblom.com> +Date: Thu, 21 Aug 2025 12:13:03 +0200 +Subject: [PATCH] Show prompt as placeholder inside input field instead of + before it + +--- + config.def.h | 1 + + dmenu.c | 25 ++++++++++++++----------- + 2 files changed, 15 insertions(+), 11 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1edb647..c4c8b72 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -12,6 +12,7 @@ static const char *colors[SchemeLast][2] = { + [SchemeNorm] = { "#bbbbbb", "#222222" }, + [SchemeSel] = { "#eeeeee", "#005577" }, + [SchemeOut] = { "#000000", "#00ffff" }, ++ [SchemePrompt] = { "#444444", "#222222" }, + }; + /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ + static unsigned int lines = 0; +diff --git a/dmenu.c b/dmenu.c +index fd49549..a58a28b 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -25,7 +25,7 @@ + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) + + /* enums */ +-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ ++enum { SchemeNorm, SchemeSel, SchemeOut, SchemePrompt, SchemeLast }; /* color schemes */ + + struct item { + char *text; +@@ -152,21 +152,24 @@ drawmenu(void) + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, 0, 0, mw, mh, 1, 1); + +- if (prompt && *prompt) { +- drw_setscheme(drw, scheme[SchemeSel]); +- x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0); +- } +- /* draw input field */ + w = (lines > 0 || !matches) ? mw - x : inputw; +- drw_setscheme(drw, scheme[SchemeNorm]); +- drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + +- curpos = TEXTW(text) - TEXTW(&text[cursor]); +- if ((curpos += lrpad / 2 - 1) < w) { ++ if (text[0] == '\0' && prompt && *prompt) { ++ drw_setscheme(drw, scheme[SchemePrompt]); ++ /* If vertical list: use full width (w), else just promptw */ ++ drw_text(drw, x, 0, (lines > 0 ? w : promptw), bh, lrpad / 2, prompt, 0); ++ } else { + drw_setscheme(drw, scheme[SchemeNorm]); +- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); ++ drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + } + ++ if (text[0] != '\0') { ++ curpos = TEXTW(text) - TEXTW(&text[cursor]); ++ if ((curpos += lrpad / 2 - 1) < w) { ++ drw_setscheme(drw, scheme[SchemeNorm]); ++ drw_rect(drw, x + curpos, 1, 2, bh - 4, 1, 0); ++ } ++ } + if (lines > 0) { + /* draw vertical list */ + for (item = curr; item != next; item = item->right) +-- +2.50.1 |
