dmenu-noxz

[fork] suckless dmenu - personal fork
git clone git://git.noxz.tech/dmenu-noxz
Log | Files | Refs | README | LICENSE

commit 94633a77175c1f0dadc52109d5c0dfaddcc314d6
parent 5a079c6e6c9a99900d7a4351227593c6c4a26d88
Author: Chris Noxz <chris@noxz.tech>
Date:   Tue,  9 Jun 2020 10:28:28 +0200

Apply patch for match count

Diffstat:
Mdmenu.c | 20++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/dmenu.c b/dmenu.c @@ -38,6 +38,7 @@ struct item { }; static char text[BUFSIZ] = ""; +static char matched[BUFSIZ] = ""; static char *embed; static int bh, mw, mh; static int inputw = 0, promptw, passwd=0; @@ -171,6 +172,17 @@ drawitem(struct item *item, int x, int y, int w) } static void +recalculatematched() +{ + unsigned int m = 0, t = 0; + struct item *item; + if (matchend) + for (item = matchend, m++; item && item->left; item = item->left, m++); + for (item = items; item && item->text; item++, t++); + snprintf(matched, BUFSIZ, "%d/%d", m, t); +} + +static void drawmenu(void) { unsigned int curpos; @@ -203,6 +215,7 @@ drawmenu(void) drw_rect(drw, x + curpos, 2 + (bh-fh)/2, 2, fh - 4, 1, 0); } + recalculatematched(); if (lines > 0) { /* draw vertical list */ for (item = curr; item != next; item = item->right) @@ -217,13 +230,16 @@ 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(">") - TEXTW(matched))); if (next) { w = TEXTW(">"); drw_setscheme(drw, scheme[SchemeNorm]); - drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0); + drw_text(drw, mw - w - TEXTW(matched), 0, w, bh, lrpad / 2, ">", 0); } } + drw_setscheme(drw, scheme[SchemeNorm]); + drw_text(drw, mw - TEXTW(matched), 0, TEXTW(matched), bh, lrpad / 2, matched, 0); drw_map(drw, win, 0, 0, mw, mh); }