diff --git a/README.md b/README.md index 2e1b0e6..52801dc 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://tools.suckless.org/dmenu/](https://tools.suckless.org/dmenu/) ### Changelog: +2020-08-08 - Added the symbols patch + 2020-08-05 - Added the grid, highlight, highpriority, dynamic options and numbers patches 2020-06-13 - Added the pango patch @@ -122,6 +124,9 @@ Refer to [https://tools.suckless.org/dmenu/](https://tools.suckless.org/dmenu/) - this patch adds support for text scrolling - it doesn't append '...' for long input anymore as it can handle long text + - [symbols](https://tools.suckless.org/dmenu/patches/symbols/) + - allows the symbols, which are printed in dmenu to indicate that either the input is too long or there are too many options to be shown in dmenu in one line, to be defined + - [vertfull](https://tools.suckless.org/dmenu/patches/vertfull/) - prevents dmenu from indenting items at the same level as the prompt length diff --git a/config.def.h b/config.def.h index ce9ccfc..2e10f8e 100644 --- a/config.def.h +++ b/config.def.h @@ -35,6 +35,10 @@ static const char *prompt = NULL; /* -p option; prompt to the left of #if DYNAMIC_OPTIONS_PATCH static const char *dynamic = NULL; /* -dy option; dynamic command to run on input change */ #endif // DYNAMIC_OPTIONS_PATCH +#if SYMBOLS_PATCH +static const char *symbol_1 = "<"; +static const char *symbol_2 = ">"; +#endif // SYMBOLS_PATCH #if ALPHA_PATCH static const unsigned int baralpha = 0xd0; diff --git a/dmenu.c b/dmenu.c index f233bcb..95ee316 100644 --- a/dmenu.c +++ b/dmenu.c @@ -175,7 +175,11 @@ calcoffsets(void) n = lines * bh; #endif // GRID_PATCH else + #if SYMBOLS_PATCH + n = mw - (promptw + inputw + TEXTW(symbol_1) + TEXTW(symbol_2)); + #else n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">")); + #endif // SYMBOLS_PATCH /* calculate which items will begin the next page and previous page */ for (i = 0, next = curr; next; next = next->right) #if PANGO_PATCH @@ -398,16 +402,28 @@ drawmenu(void) } x += w; for (item = curr; item != next; item = item->right) - #if PANGO_PATCH + #if PANGO_PATCH && SYMBOLS_PATCH + x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(symbol_2) - rpad)); + #elif PANGO_PATCH x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(">") - rpad)); + #elif SYMBOLS_PATCH + x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(symbol_2) - rpad)); #else x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">") - rpad)); #endif // PANGO_PATCH if (next) { + #if SYMBOLS_PATCH + w = TEXTW(symbol_2); + #else w = TEXTW(">"); + #endif // SYMBOLS_PATCH drw_setscheme(drw, scheme[SchemeNorm]); - #if PANGO_PATCH + #if PANGO_PATCH && SYMBOLS_PATCH + drw_text(drw, mw - w - rpad, 0, w, bh, lrpad / 2, symbol_2, 0, True); + #elif PANGO_PATCH drw_text(drw, mw - w - rpad, 0, w, bh, lrpad / 2, ">", 0, True); + #elif SYMBOLS_PATCH + drw_text(drw, mw - w, 0, w, bh, lrpad / 2, symbol_2, 0); #else drw_text(drw, mw - w - rpad, 0, w, bh, lrpad / 2, ">", 0); #endif // PANGO_PATCH diff --git a/patches.def.h b/patches.def.h index 758f5e2..e9d175e 100644 --- a/patches.def.h +++ b/patches.def.h @@ -172,6 +172,12 @@ */ #define SCROLL_PATCH 0 +/* This patch allows the symbols, which are printed in dmenu to indicate that either the input + * is too long or there are too many options to be shown in dmenu in one line, to be defined. + * https://tools.suckless.org/dmenu/patches/symbols/ + */ +#define SYMBOLS_PATCH 0 + /* This patch prevents dmenu from indenting items at the same level as the prompt length. * https://tools.suckless.org/dmenu/patches/vertfull/ */