Adding caret patch ref. #23

This commit is contained in:
bakkeby 2023-06-15 09:54:53 +02:00
parent 9e721014cd
commit 690436ef27
4 changed files with 26 additions and 1 deletions

View File

@ -28,6 +28,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/YjT2DD6j
### Changelog:
2023-06-15 - Added the caret width patch
2022-09-05 - Removed the json patch due to maintenance and compatibility reasons, added the
separator patch
@ -78,6 +80,9 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/YjT2DD6j
- [border](http://tools.suckless.org/dmenu/patches/border/)
- adds a border around the dmenu window
- [caret-width](https://github.com/DarkSamus669/dmenu-patches/blob/main/dmenu-caretwidth-5.2.diff)
- makes the caret width configurable and overridable via a command line option
- [case-insensitive](http://tools.suckless.org/dmenu/patches/case-insensitive/)
- makes dmenu case-insensitive by default, replacing the case-insensitive `-i` option with a
case sensitive `-s` option

View File

@ -5,6 +5,9 @@ static int topbar = 1; /* -b option; if 0, dmenu appears a
#if ALPHA_PATCH
static int opacity = 1; /* -o option; if 0, then alpha is disabled */
#endif // ALPHA_PATCH
#if CARET_WIDTH_PATCH
static int caret_width = 2; /* -cw option; set default caret width */
#endif // CARET_WIDTH_PATCH
#if FUZZYMATCH_PATCH
static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
#endif // FUZZYMATCH_PATCH

13
dmenu.c
View File

@ -585,7 +585,11 @@ drawmenu(void)
curpos = TEXTW(text) - TEXTW(&text[cursor]);
if ((curpos += lrpad / 2 - 1) < w) {
drw_setscheme(drw, scheme[SchemeNorm]);
#if LINE_HEIGHT_PATCH
#if CARET_WIDTH_PATCH && LINE_HEIGHT_PATCH
drw_rect(drw, x + curpos, 2 + (bh-fh)/2, caret_width, fh - 4, 1, 0);
#elif CARET_WIDTH_PATCH
drw_rect(drw, x + curpos, 2, caret_width, bh - 4, 1, 0);
#elif LINE_HEIGHT_PATCH
drw_rect(drw, x + curpos, 2 + (bh-fh)/2, 2, fh - 4, 1, 0);
#else
drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
@ -1846,6 +1850,9 @@ usage(void)
"1"
#endif // RESTRICT_RETURN_PATCH
"] "
#if CARET_WIDTH_PATCH
"[-cw caret_width] "
#endif // CARET_WIDTH_PATCH
#if MANAGED_PATCH
"[-wm] "
#endif // MANAGED_PATCH
@ -2084,6 +2091,10 @@ main(int argc, char *argv[])
else if (!strcmp(argv[i], "-shf")) /* selected hi foreground color */
colors[SchemeSelHighlight][ColFg] = argv[++i];
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
#if CARET_WIDTH_PATCH
else if (!strcmp(argv[i], "-cw")) /* sets caret witdth */
caret_width = atoi(argv[++i]);
#endif // CARET_WIDTH_PATCH
else if (!strcmp(argv[i], "-w")) /* embedding window id */
embed = argv[++i];
#if SEPARATOR_PATCH

View File

@ -19,6 +19,12 @@
*/
#define BORDER_PATCH 0
/* By default the caret in dmenu has a width of 2 pixels. This patch makes that configurable
* as well as overridable via a command line option.
* https://github.com/DarkSamus669/dmenu-patches/blob/main/dmenu-caretwidth-5.2.diff
*/
#define CARET_WIDTH_PATCH 0
/* This patch makes dmenu case-insensitive by default, replacing the
* case-insensitive -i option with a case sensitive -s option.
* http://tools.suckless.org/dmenu/patches/case-insensitive/