apply fuzzy-highlightpatch
This commit also integrates the fuzzy matching colors into the XResources loading.master
parent
1b31202e91
commit
8331a88407
|
|
@ -17,12 +17,16 @@ static char *prompt = NULL; /* -p option; prompt to the left of input
|
|||
|
||||
static char normfgcolor[] = "#bbbbbb";
|
||||
static char normbgcolor[] = "#222222";
|
||||
static char normhlcolor[] = "#ffc978";
|
||||
static char selfgcolor[] = "#eeeeee";
|
||||
static char selbgcolor[] = "#005577";
|
||||
static char selhlcolor[] = "#ffc978";
|
||||
static char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
[SchemeNorm] = { normfgcolor, normbgcolor },
|
||||
[SchemeNormHighlight] = { normhlcolor, normbgcolor },
|
||||
[SchemeSel] = { selfgcolor, selbgcolor },
|
||||
[SchemeSelHighlight] = { normhlcolor, selbgcolor },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
|
|
@ -41,7 +45,9 @@ ResourcePref resources[] = {
|
|||
{ "font", STRING, &font },
|
||||
{ "normfgcolor", STRING, &normfgcolor },
|
||||
{ "normbgcolor", STRING, &normbgcolor },
|
||||
{ "normhlcolor", STRING, &normhlcolor },
|
||||
{ "selfgcolor", STRING, &selfgcolor },
|
||||
{ "selbgcolor", STRING, &selbgcolor },
|
||||
{ "selhlcolor", STRING, &selhlcolor },
|
||||
{ "prompt", STRING, &prompt },
|
||||
};
|
||||
|
|
|
|||
20
dmenu.1
20
dmenu.1
|
|
@ -20,6 +20,14 @@ dmenu \- dynamic menu
|
|||
.IR color ]
|
||||
.RB [ \-sf
|
||||
.IR color ]
|
||||
.RB [ \-nhb
|
||||
.IR color ]
|
||||
.RB [ \-nhf
|
||||
.IR color ]
|
||||
.RB [ \-shb
|
||||
.IR color ]
|
||||
.RB [ \-shf
|
||||
.IR color ]
|
||||
.RB [ \-w
|
||||
.IR windowid ]
|
||||
.P
|
||||
|
|
@ -78,6 +86,18 @@ defines the selected background color.
|
|||
.BI \-sf " color"
|
||||
defines the selected foreground color.
|
||||
.TP
|
||||
.BI \-nhb " color"
|
||||
defines the normal highlight background color.
|
||||
.TP
|
||||
.BI \-nhf " color"
|
||||
defines the normal highlight foreground color.
|
||||
.TP
|
||||
.BI \-shb " color"
|
||||
defines the selected highlight background color.
|
||||
.TP
|
||||
.BI \-shf " color"
|
||||
defines the selected highlight foreground color.
|
||||
.TP
|
||||
.B \-v
|
||||
prints version information to stdout, then exits.
|
||||
.TP
|
||||
|
|
|
|||
59
dmenu.c
59
dmenu.c
|
|
@ -27,7 +27,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;
|
||||
|
|
@ -156,9 +158,49 @@ cistrstr(const char *h, const char *n)
|
|||
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)
|
||||
|
|
@ -166,7 +208,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
|
||||
|
|
@ -891,7 +935,8 @@ static void
|
|||
usage(void)
|
||||
{
|
||||
die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
||||
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
||||
" [-nb color] [-nf color] [-sb color] [-sf color]\n"
|
||||
" [-nhb color] [-nhf color] [-shb color] [-shf color] [-w windowid]\n");
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -938,6 +983,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
|
||||
|
|
|
|||
Loading…
Reference in New Issue