From 690436ef27ba260a407b0997eae0eb3bc6af6f71 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Thu, 15 Jun 2023 09:54:53 +0200 Subject: [PATCH] Adding caret patch ref. #23 --- README.md | 5 +++++ config.def.h | 3 +++ dmenu.c | 13 ++++++++++++- patches.def.h | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99de04a..be2c349 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.def.h b/config.def.h index 84e984c..90ba49d 100644 --- a/config.def.h +++ b/config.def.h @@ -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 diff --git a/dmenu.c b/dmenu.c index 2b3f6c6..5d20ed8 100644 --- a/dmenu.c +++ b/dmenu.c @@ -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 diff --git a/patches.def.h b/patches.def.h index e45c715..2190e87 100644 --- a/patches.def.h +++ b/patches.def.h @@ -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/