summaryrefslogtreecommitdiff
path: root/dmenu.c.orig
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-11 13:14:14 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-11 13:14:14 +0530
commitfb2a86f08b05823743381e9b9da743e4e82a3d7e (patch)
treef226720015a1a9f5cc3957ccd4e265250c4b6d8d /dmenu.c.orig
parentd4409876e1daa3e6f4c1f6a6007c4ecce971f436 (diff)
patched with morecolor patch
Diffstat (limited to 'dmenu.c.orig')
-rw-r--r--dmenu.c.orig59
1 files changed, 56 insertions, 3 deletions
diff --git a/dmenu.c.orig b/dmenu.c.orig
index 8b0930c..9497736 100644
--- a/dmenu.c.orig
+++ b/dmenu.c.orig
@@ -26,7 +26,9 @@
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
/* enums */
-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeNormHighlight, SchemeSelHighlight,
+ SchemeOut, SchemeLast }; /* color schemes */
+
struct item {
char *text;
@@ -114,9 +116,49 @@ cistrstr(const char *s, const char *sub)
return NULL;
}
+static void
+drawhighlights(struct item *item, int x, int y, int maxw)
+{
+ int i, indent;
+ char *highlight;
+ char c;
+
+ if (!(strlen(item->text) && strlen(text)))
+ return;
+
+ drw_setscheme(drw, scheme[item == sel
+ ? SchemeSelHighlight
+ : SchemeNormHighlight]);
+ for (i = 0, highlight = item->text; *highlight && text[i];) {
+ if (*highlight == text[i]) {
+ /* get indentation */
+ c = *highlight;
+ *highlight = '\0';
+ indent = TEXTW(item->text);
+ *highlight = c;
+
+ /* highlight character */
+ c = highlight[1];
+ highlight[1] = '\0';
+ drw_text(
+ drw,
+ x + indent - (lrpad / 2),
+ y,
+ MIN(maxw - indent, TEXTW(highlight) - lrpad),
+ bh, 0, highlight, 0
+ );
+ highlight[1] = c;
+ i++;
+ }
+ highlight++;
+ }
+}
+
+
static int
drawitem(struct item *item, int x, int y, int w)
{
+ int r;
if (item == sel)
drw_setscheme(drw, scheme[SchemeSel]);
else if (item->out)
@@ -124,7 +166,9 @@ drawitem(struct item *item, int x, int y, int w)
else
drw_setscheme(drw, scheme[SchemeNorm]);
- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
+ r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
+ drawhighlights(item, x, y, w);
+ return r;
}
static void
@@ -693,7 +737,8 @@ static void
usage(void)
{
fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
- " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
+ " [-nb color] [-nf color] [-sb color] [-sf color]\n"
+ " [-nhb color] [-nhf color] [-shb color] [-shf color] [-w windowid]\n", stderr);
exit(1);
}
@@ -734,6 +779,14 @@ main(int argc, char *argv[])
colors[SchemeSel][ColBg] = argv[++i];
else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
colors[SchemeSel][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-nhb")) /* normal hi background color */
+ colors[SchemeNormHighlight][ColBg] = argv[++i];
+ else if (!strcmp(argv[i], "-nhf")) /* normal hi foreground color */
+ colors[SchemeNormHighlight][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-shb")) /* selected hi background color */
+ colors[SchemeSelHighlight][ColBg] = argv[++i];
+ else if (!strcmp(argv[i], "-shf")) /* selected hi foreground color */
+ colors[SchemeSelHighlight][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-w")) /* embedding window id */
embed = argv[++i];
else if (!strcmp(argv[i], "-bw"))