Skip to content

Commit

Permalink
Adding caret patch ref. #23
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkeby committed Jun 15, 2023
1 parent 9e72101 commit 690436e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion dmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions patches.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit 690436e

Please sign in to comment.