[dmenu][patch] Inline prompt - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 6b71fb83cf7d0d6bf642d40fc2bac20a289b419f
 (DIR) parent 56e1f9709e453f1619709c2671ebdf6108d357b8
 (HTM) Author: Daan Blom <contact@daanblom.com>
       Date:   Thu, 21 Aug 2025 13:02:55 +0200
       
       [dmenu][patch] Inline prompt
       
       Patch that shows prompt as placeholder inside input field instead of
       before it
       
       Diffstat:
         A tools.suckless.org/dmenu/patches/i… |       0 
         A tools.suckless.org/dmenu/patches/i… |       0 
         A tools.suckless.org/dmenu/patches/i… |      74 +++++++++++++++++++++++++++++++
         A tools.suckless.org/dmenu/patches/i… |      21 +++++++++++++++++++++
       
       4 files changed, 95 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/tools.suckless.org/dmenu/patches/inline-prompt/dmenu-after.png b/tools.suckless.org/dmenu/patches/inline-prompt/dmenu-after.png
       Binary files differ.
 (DIR) diff --git a/tools.suckless.org/dmenu/patches/inline-prompt/dmenu-before.png b/tools.suckless.org/dmenu/patches/inline-prompt/dmenu-before.png
       Binary files differ.
 (DIR) diff --git a/tools.suckless.org/dmenu/patches/inline-prompt/dmenu-inlinePrompt-20250821-d893c63.diff b/tools.suckless.org/dmenu/patches/inline-prompt/dmenu-inlinePrompt-20250821-d893c63.diff
       @@ -0,0 +1,74 @@
       +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
       +
 (DIR) diff --git a/tools.suckless.org/dmenu/patches/inline-prompt/index.md b/tools.suckless.org/dmenu/patches/inline-prompt/index.md
       @@ -0,0 +1,21 @@
       +Inline prompt
       +=============
       +
       +Description
       +-----------
       +Show prompt as placeholder inside input field instead of before it.
       +Added `[SchemePrompt]` in config file to set prompt fore and background color.
       +
       +Before:
       +![dmenu before](dmenu-before.png)
       +
       +After:
       +![dmenu after](dmenu-after.png)
       +
       +Download
       +--------
       +[dmenu-inlinePrompt-20250821-d893c63.diff](dmenu-inlinePrompt-20250821-d893c63.diff) (2025-08-21)
       +
       +Authors
       +-------
       +