mirror of
https://github.com/mintycube/dmenu.git
synced 2024-10-22 12:05:48 +00:00
Adding numbers patch
This commit is contained in:
parent
73d2405635
commit
768b5527ab
@ -15,7 +15,7 @@ Refer to [https://tools.suckless.org/dmenu/](https://tools.suckless.org/dmenu/)
|
|||||||
|
|
||||||
### Changelog:
|
### Changelog:
|
||||||
|
|
||||||
2020-08-05 - Added the grid and dynamic options patches
|
2020-08-05 - Added the grid, dynamic options and numbers patches
|
||||||
|
|
||||||
2020-06-13 - Added the pango patch
|
2020-06-13 - Added the pango patch
|
||||||
|
|
||||||
@ -88,6 +88,9 @@ Refer to [https://tools.suckless.org/dmenu/](https://tools.suckless.org/dmenu/)
|
|||||||
- this means that you can continue feeding dmenu while you type
|
- this means that you can continue feeding dmenu while you type
|
||||||
- the patch is meant to be used along with the incremental patch in order to use stdout to feed stdin
|
- the patch is meant to be used along with the incremental patch in order to use stdout to feed stdin
|
||||||
|
|
||||||
|
- [numbers](https://tools.suckless.org/dmenu/patches/numbers/)
|
||||||
|
- adds text which displays the number of matched and total items in the top right corner of dmenu
|
||||||
|
|
||||||
- [pango](https://github.com/StillANixRookie/dmenu-pango/)
|
- [pango](https://github.com/StillANixRookie/dmenu-pango/)
|
||||||
- adds simple markup for dmenu using pango markup
|
- adds simple markup for dmenu using pango markup
|
||||||
|
|
||||||
|
19
dmenu.c
19
dmenu.c
@ -249,7 +249,7 @@ drawmenu(void)
|
|||||||
unsigned int curpos;
|
unsigned int curpos;
|
||||||
#endif // SCROLL_PATCH
|
#endif // SCROLL_PATCH
|
||||||
struct item *item;
|
struct item *item;
|
||||||
int x = 0, y = 0, w;
|
int x = 0, y = 0, w, rpad = 0;
|
||||||
#if LINE_HEIGHT_PATCH && PANGO_PATCH
|
#if LINE_HEIGHT_PATCH && PANGO_PATCH
|
||||||
int fh = drw->font->h;
|
int fh = drw->font->h;
|
||||||
#elif LINE_HEIGHT_PATCH
|
#elif LINE_HEIGHT_PATCH
|
||||||
@ -340,6 +340,10 @@ drawmenu(void)
|
|||||||
}
|
}
|
||||||
#endif // SCROLL_PATCH
|
#endif // SCROLL_PATCH
|
||||||
|
|
||||||
|
#if NUMBERS_PATCH
|
||||||
|
recalculatenumbers();
|
||||||
|
rpad = TEXTW(numbers);
|
||||||
|
#endif // NUMBERS_PATCH
|
||||||
if (lines > 0) {
|
if (lines > 0) {
|
||||||
#if GRID_PATCH
|
#if GRID_PATCH
|
||||||
/* draw grid */
|
/* draw grid */
|
||||||
@ -391,20 +395,25 @@ drawmenu(void)
|
|||||||
x += w;
|
x += w;
|
||||||
for (item = curr; item != next; item = item->right)
|
for (item = curr; item != next; item = item->right)
|
||||||
#if PANGO_PATCH
|
#if PANGO_PATCH
|
||||||
x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(">")));
|
x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(">") - rpad));
|
||||||
#else
|
#else
|
||||||
x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">")));
|
x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">") - rpad));
|
||||||
#endif // PANGO_PATCH
|
#endif // PANGO_PATCH
|
||||||
if (next) {
|
if (next) {
|
||||||
w = TEXTW(">");
|
w = TEXTW(">");
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
#if PANGO_PATCH
|
#if PANGO_PATCH
|
||||||
drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0, True);
|
drw_text(drw, mw - w - rpad, 0, w, bh, lrpad / 2, ">", 0, True);
|
||||||
#else
|
#else
|
||||||
drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0);
|
drw_text(drw, mw - w - rpad, 0, w, bh, lrpad / 2, ">", 0);
|
||||||
#endif // PANGO_PATCH
|
#endif // PANGO_PATCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if NUMBERS_PATCH
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0);
|
||||||
|
#else
|
||||||
|
#endif // NUMBERS_PATCH
|
||||||
drw_map(drw, win, 0, 0, mw, mh);
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
#if NON_BLOCKING_STDIN_PATCH
|
#if NON_BLOCKING_STDIN_PATCH
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
#if NON_BLOCKING_STDIN_PATCH
|
#if NON_BLOCKING_STDIN_PATCH
|
||||||
#include "nonblockingstdin.c"
|
#include "nonblockingstdin.c"
|
||||||
#endif
|
#endif
|
||||||
|
#if NUMBERS_PATCH
|
||||||
|
#include "numbers.c"
|
||||||
|
#endif
|
||||||
#if XRESOURCES_PATCH
|
#if XRESOURCES_PATCH
|
||||||
#include "xresources.c"
|
#include "xresources.c"
|
||||||
#endif
|
#endif
|
@ -4,3 +4,6 @@
|
|||||||
#if NON_BLOCKING_STDIN_PATCH
|
#if NON_BLOCKING_STDIN_PATCH
|
||||||
#include "nonblockingstdin.h"
|
#include "nonblockingstdin.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if NUMBERS_PATCH
|
||||||
|
#include "numbers.h"
|
||||||
|
#endif
|
16
patch/numbers.c
Normal file
16
patch/numbers.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
static char numbers[NUMBERSBUFSIZE] = "";
|
||||||
|
|
||||||
|
static void
|
||||||
|
recalculatenumbers()
|
||||||
|
{
|
||||||
|
unsigned int numer = 0, denom = 0;
|
||||||
|
struct item *item;
|
||||||
|
if (matchend) {
|
||||||
|
numer++;
|
||||||
|
for (item = matchend; item && item->left; item = item->left)
|
||||||
|
numer++;
|
||||||
|
}
|
||||||
|
for (item = items; item && item->text; item++)
|
||||||
|
denom++;
|
||||||
|
snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom);
|
||||||
|
}
|
4
patch/numbers.h
Normal file
4
patch/numbers.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#define NUMBERSMAXDIGITS 100
|
||||||
|
#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1
|
||||||
|
|
||||||
|
static void recalculatenumbers();
|
@ -97,6 +97,11 @@
|
|||||||
*/
|
*/
|
||||||
#define NON_BLOCKING_STDIN_PATCH 0
|
#define NON_BLOCKING_STDIN_PATCH 0
|
||||||
|
|
||||||
|
/* Adds text which displays the number of matched and total items in the top right corner of dmenu.
|
||||||
|
* https://tools.suckless.org/dmenu/patches/numbers/
|
||||||
|
*/
|
||||||
|
#define NUMBERS_PATCH 0
|
||||||
|
|
||||||
/* This patch adds simple markup for dmenu using pango markup.
|
/* This patch adds simple markup for dmenu using pango markup.
|
||||||
* This depends on the pango library v1.44 or greater.
|
* This depends on the pango library v1.44 or greater.
|
||||||
* You need to uncomment the corresponding lines in config.mk to use the pango libraries
|
* You need to uncomment the corresponding lines in config.mk to use the pango libraries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user