new patches and stuff
parent
d788f7ced9
commit
8b29fbc29e
@ -1,11 +1,11 @@
|
||||
--- config.def.h
|
||||
+++ config.def.h
|
||||
@@ -11,8 +11,6 @@ static const char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
- [SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||
- [SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
@@ -2,6 +2,8 @@
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
+static int centered = 0; /* -c option; centers dmenu on screen */
|
||||
+static int min_width = 500; /* minimum width when centered */
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
|
@ -0,0 +1,23 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=12"
|
||||
};
|
||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
[SchemeNorm] = { "#f8f8f2", "#282a36" },
|
||||
[SchemeSel] = { "#282a36", "#bd93f9" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
static unsigned int lines = 0;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
@ -0,0 +1,199 @@
|
||||
.TH DMENU 1 dmenu\-VERSION
|
||||
.SH NAME
|
||||
dmenu \- dynamic menu
|
||||
.SH SYNOPSIS
|
||||
.B dmenu
|
||||
.RB [ \-bfiv ]
|
||||
.RB [ \-g
|
||||
.IR columns ]
|
||||
.RB [ \-l
|
||||
.IR lines ]
|
||||
.RB [ \-m
|
||||
.IR monitor ]
|
||||
.RB [ \-p
|
||||
.IR prompt ]
|
||||
.RB [ \-fn
|
||||
.IR font ]
|
||||
.RB [ \-nb
|
||||
.IR color ]
|
||||
.RB [ \-nf
|
||||
.IR color ]
|
||||
.RB [ \-sb
|
||||
.IR color ]
|
||||
.RB [ \-sf
|
||||
.IR color ]
|
||||
.RB [ \-w
|
||||
.IR windowid ]
|
||||
.P
|
||||
.BR dmenu_run " ..."
|
||||
.SH DESCRIPTION
|
||||
.B dmenu
|
||||
is a dynamic menu for X, which reads a list of newline\-separated items from
|
||||
stdin. When the user selects an item and presses Return, their choice is printed
|
||||
to stdout and dmenu terminates. Entering text will narrow the items to those
|
||||
matching the tokens in the input.
|
||||
.P
|
||||
.B dmenu_run
|
||||
is a script used by
|
||||
.IR dwm (1)
|
||||
which lists programs in the user's $PATH and runs the result in their $SHELL.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-b
|
||||
dmenu appears at the bottom of the screen.
|
||||
.TP
|
||||
.B \-f
|
||||
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
|
||||
is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||
.TP
|
||||
.B \-i
|
||||
dmenu matches menu items case insensitively.
|
||||
.TP
|
||||
.BI \-g " columns"
|
||||
dmenu lists items in a grid with the given number of columns.
|
||||
.TP
|
||||
.BI \-l " lines"
|
||||
dmenu lists items in a grid with the given number of lines.
|
||||
.TP
|
||||
.BI \-m " monitor"
|
||||
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
||||
from 0.
|
||||
.TP
|
||||
.BI \-p " prompt"
|
||||
defines the prompt to be displayed to the left of the input field.
|
||||
.TP
|
||||
.BI \-fn " font"
|
||||
defines the font or font set used.
|
||||
.TP
|
||||
.BI \-nb " color"
|
||||
defines the normal background color.
|
||||
.IR #RGB ,
|
||||
.IR #RRGGBB ,
|
||||
and X color names are supported.
|
||||
.TP
|
||||
.BI \-nf " color"
|
||||
defines the normal foreground color.
|
||||
.TP
|
||||
.BI \-sb " color"
|
||||
defines the selected background color.
|
||||
.TP
|
||||
.BI \-sf " color"
|
||||
defines the selected foreground color.
|
||||
.TP
|
||||
.B \-v
|
||||
prints version information to stdout, then exits.
|
||||
.TP
|
||||
.BI \-w " windowid"
|
||||
embed into windowid.
|
||||
.SH USAGE
|
||||
dmenu is completely controlled by the keyboard. Items are selected using the
|
||||
arrow keys, page up, page down, home, and end.
|
||||
.TP
|
||||
.B Tab
|
||||
Copy the selected item to the input field.
|
||||
.TP
|
||||
.B Return
|
||||
Confirm selection. Prints the selected item to stdout and exits, returning
|
||||
success.
|
||||
.TP
|
||||
.B Ctrl-Return
|
||||
Confirm selection. Prints the selected item to stdout and continues.
|
||||
.TP
|
||||
.B Shift\-Return
|
||||
Confirm input. Prints the input text to stdout and exits, returning success.
|
||||
.TP
|
||||
.B Escape
|
||||
Exit without selecting an item, returning failure.
|
||||
.TP
|
||||
.B Ctrl-Left
|
||||
Move cursor to the start of the current word
|
||||
.TP
|
||||
.B Ctrl-Right
|
||||
Move cursor to the end of the current word
|
||||
.TP
|
||||
.B C\-a
|
||||
Home
|
||||
.TP
|
||||
.B C\-b
|
||||
Left
|
||||
.TP
|
||||
.B C\-c
|
||||
Escape
|
||||
.TP
|
||||
.B C\-d
|
||||
Delete
|
||||
.TP
|
||||
.B C\-e
|
||||
End
|
||||
.TP
|
||||
.B C\-f
|
||||
Right
|
||||
.TP
|
||||
.B C\-g
|
||||
Escape
|
||||
.TP
|
||||
.B C\-h
|
||||
Backspace
|
||||
.TP
|
||||
.B C\-i
|
||||
Tab
|
||||
.TP
|
||||
.B C\-j
|
||||
Return
|
||||
.TP
|
||||
.B C\-J
|
||||
Shift-Return
|
||||
.TP
|
||||
.B C\-k
|
||||
Delete line right
|
||||
.TP
|
||||
.B C\-m
|
||||
Return
|
||||
.TP
|
||||
.B C\-M
|
||||
Shift-Return
|
||||
.TP
|
||||
.B C\-n
|
||||
Down
|
||||
.TP
|
||||
.B C\-p
|
||||
Up
|
||||
.TP
|
||||
.B C\-u
|
||||
Delete line left
|
||||
.TP
|
||||
.B C\-w
|
||||
Delete word left
|
||||
.TP
|
||||
.B C\-y
|
||||
Paste from primary X selection
|
||||
.TP
|
||||
.B C\-Y
|
||||
Paste from X clipboard
|
||||
.TP
|
||||
.B M\-b
|
||||
Move cursor to the start of the current word
|
||||
.TP
|
||||
.B M\-f
|
||||
Move cursor to the end of the current word
|
||||
.TP
|
||||
.B M\-g
|
||||
Home
|
||||
.TP
|
||||
.B M\-G
|
||||
End
|
||||
.TP
|
||||
.B M\-h
|
||||
Up
|
||||
.TP
|
||||
.B M\-j
|
||||
Page down
|
||||
.TP
|
||||
.B M\-k
|
||||
Page up
|
||||
.TP
|
||||
.B M\-l
|
||||
Down
|
||||
.SH SEE ALSO
|
||||
.IR dwm (1),
|
||||
.IR stest (1)
|
@ -1,11 +1,11 @@
|
||||
--- dmenu.c
|
||||
+++ dmenu.c
|
||||
@@ -702,8 +615,6 @@ main(int argc, char *argv[])
|
||||
@@ -757,6 +781,8 @@ main(int argc, char *argv[])
|
||||
topbar = 0;
|
||||
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||
fast = 1;
|
||||
- else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */
|
||||
- fuzzy = 0;
|
||||
+ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
|
||||
+ centered = 1;
|
||||
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||
fstrncmp = strncasecmp;
|
||||
fstrstr = cistrstr;
|
||||
|
@ -0,0 +1,36 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..dd3eb31 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -21,3 +21,6 @@ static unsigned int lines = 0;
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
+
|
||||
+/* Size of the window border */
|
||||
+static unsigned int border_width = 0;
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 27b7a30..7c130fc 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -684,9 +684,11 @@ setup(void)
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
- win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
|
||||
+ win = XCreateWindow(dpy, root, x, y, mw, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
+ if (border_width)
|
||||
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
|
||||
@@ -757,6 +759,8 @@ main(int argc, char *argv[])
|
||||
colors[SchemeSel][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
+ else if (!strcmp(argv[i], "-bw"))
|
||||
+ border_width = atoi(argv[++i]); /* border width */
|
||||
else
|
||||
usage();
|
@ -0,0 +1,104 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..88ef264 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -2,6 +2,8 @@
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
+static int centered = 0; /* -c option; centers dmenu on screen */
|
||||
+static int min_width = 500; /* minimum width when centered */
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
diff --git a/dmenu.1 b/dmenu.1
|
||||
index 323f93c..c036baa 100644
|
||||
--- a/dmenu.1
|
||||
+++ b/dmenu.1
|
||||
@@ -40,6 +40,9 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
|
||||
.B \-b
|
||||
dmenu appears at the bottom of the screen.
|
||||
.TP
|
||||
+.B \-c
|
||||
+dmenu appears centered on the screen.
|
||||
+.TP
|
||||
.B \-f
|
||||
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
|
||||
is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 27b7a30..427fb04 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -96,6 +96,15 @@ calcoffsets(void)
|
||||
break;
|
||||
}
|
||||
|
||||
+static int
|
||||
+max_textw(void)
|
||||
+{
|
||||
+ int len = 0;
|
||||
+ for (struct item *item = items; item && item->text; item++)
|
||||
+ len = MAX(TEXTW(item->text), len);
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
@@ -636,6 +645,7 @@ setup(void)
|
||||
bh = drw->fonts->h + 2;
|
||||
lines = MAX(lines, 0);
|
||||
mh = (lines + 1) * bh;
|
||||
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||
#ifdef XINERAMA
|
||||
i = 0;
|
||||
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||
@@ -662,9 +672,16 @@ setup(void)
|
||||
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||
break;
|
||||
|
||||
- x = info[i].x_org;
|
||||
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||
- mw = info[i].width;
|
||||
+ if (centered) {
|
||||
+ mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
|
||||
+ x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||
+ y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||
+ } else {
|
||||
+ x = info[i].x_org;
|
||||
+ y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||
+ mw = info[i].width;
|
||||
+ }
|
||||
+
|
||||
XFree(info);
|
||||
} else
|
||||
#endif
|
||||
@@ -672,9 +689,16 @@ setup(void)
|
||||
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||
die("could not get embedding window attributes: 0x%lx",
|
||||
parentwin);
|
||||
- x = 0;
|
||||
- y = topbar ? 0 : wa.height - mh;
|
||||
- mw = wa.width;
|
||||
+
|
||||
+ if (centered) {
|
||||
+ mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
|
||||
+ x = (wa.width - mw) / 2;
|
||||
+ y = (wa.height - mh) / 2;
|
||||
+ } else {
|
||||
+ x = 0;
|
||||
+ y = topbar ? 0 : wa.height - mh;
|
||||
+ mw = wa.width;
|
||||
+ }
|
||||
}
|
||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||
inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||
@@ -733,6 +757,8 @@ main(int argc, char *argv[])
|
||||
topbar = 0;
|
||||
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||
fast = 1;
|
||||
+ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
|
||||
+ centered = 1;
|
||||
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||
fstrncmp = strncasecmp;
|
||||
fstrstr = cistrstr;
|
@ -1,28 +0,0 @@
|
||||
From f16313b64965d74e6cbb30fa41d53aaf09b9ad49 Mon Sep 17 00:00:00 2001
|
||||
From: David Lima <antdavidlima@gmail.com>
|
||||
Date: Sun, 28 Nov 2021 17:02:43 -0300
|
||||
Subject: [PATCH] apply dracula theme to dmenu
|
||||
|
||||
---
|
||||
config.def.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..e688388 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -9,8 +9,8 @@ static const char *fonts[] = {
|
||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
- [SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
- [SchemeSel] = { "#eeeeee", "#005577" },
|
||||
+ [SchemeNorm] = { "#f8f8f2", "#282a36" },
|
||||
+ [SchemeSel] = { "#f8f8f2", "#6272a4" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
--
|
||||
2.34.1
|
||||
|
||||
|
@ -0,0 +1,107 @@
|
||||
From 39ab9676914bd0d8105d0f96bbd7611a53077438 Mon Sep 17 00:00:00 2001
|
||||
From: Miles Alan <m@milesalan.com>
|
||||
Date: Sat, 4 Jul 2020 11:19:04 -0500
|
||||
Subject: [PATCH] Add -g option to display entries in the given number of grid
|
||||
columns
|
||||
|
||||
This option can be used in conjunction with -l to format dmenu's options in
|
||||
arbitrary size grids. For example, to create a 4 column by 6 line grid, you
|
||||
could use: dmenu -g 4 -l 6
|
||||
---
|
||||
config.def.h | 3 ++-
|
||||
dmenu.1 | 7 ++++++-
|
||||
dmenu.c | 22 ++++++++++++++++------
|
||||
3 files changed, 24 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..96cf3c9 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -13,8 +13,9 @@ static const char *colors[SchemeLast][2] = {
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
-/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
+/* -l and -g options; controls number of lines and columns in grid if > 0 */
|
||||
static unsigned int lines = 0;
|
||||
+static unsigned int columns = 0;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
diff --git a/dmenu.1 b/dmenu.1
|
||||
index 323f93c..d0a734a 100644
|
||||
--- a/dmenu.1
|
||||
+++ b/dmenu.1
|
||||
@@ -4,6 +4,8 @@ dmenu \- dynamic menu
|
||||
.SH SYNOPSIS
|
||||
.B dmenu
|
||||
.RB [ \-bfiv ]
|
||||
+.RB [ \-g
|
||||
+.IR columns ]
|
||||
.RB [ \-l
|
||||
.IR lines ]
|
||||
.RB [ \-m
|
||||
@@ -47,8 +49,11 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||
.B \-i
|
||||
dmenu matches menu items case insensitively.
|
||||
.TP
|
||||
+.BI \-g " columns"
|
||||
+dmenu lists items in a grid with the given number of columns.
|
||||
+.TP
|
||||
.BI \-l " lines"
|
||||
-dmenu lists items vertically, with the given number of lines.
|
||||
+dmenu lists items in a grid with the given number of lines.
|
||||
.TP
|
||||
.BI \-m " monitor"
|
||||
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 6b8f51b..d79b6bb 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -77,7 +77,7 @@ calcoffsets(void)
|
||||
int i, n;
|
||||
|
||||
if (lines > 0)
|
||||
- n = lines * bh;
|
||||
+ n = lines * columns * bh;
|
||||
else
|
||||
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
||||
/* calculate which items will begin the next page and previous page */
|
||||
@@ -152,9 +152,15 @@ drawmenu(void)
|
||||
}
|
||||
|
||||
if (lines > 0) {
|
||||
- /* draw vertical list */
|
||||
- for (item = curr; item != next; item = item->right)
|
||||
- drawitem(item, x, y += bh, mw - x);
|
||||
+ /* draw grid */
|
||||
+ int i = 0;
|
||||
+ for (item = curr; item != next; item = item->right, i++)
|
||||
+ drawitem(
|
||||
+ item,
|
||||
+ x + ((i / lines) * ((mw - x) / columns)),
|
||||
+ y + (((i % lines) + 1) * bh),
|
||||
+ (mw - x) / columns
|
||||
+ );
|
||||
} else if (matches) {
|
||||
/* draw horizontal list */
|
||||
x += inputw;
|
||||
@@ -708,9 +714,13 @@ main(int argc, char *argv[])
|
||||
} else if (i + 1 == argc)
|
||||
usage();
|
||||
/* these options take one argument */
|
||||
- else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
||||
+ else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
|
||||
+ columns = atoi(argv[++i]);
|
||||
+ if (lines == 0) lines = 1;
|
||||
+ } else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
|
||||
lines = atoi(argv[++i]);
|
||||
- else if (!strcmp(argv[i], "-m"))
|
||||
+ if (columns == 0) columns = 1;
|
||||
+ } else if (!strcmp(argv[i], "-m"))
|
||||
mon = atoi(argv[++i]);
|
||||
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||
prompt = argv[++i];
|
||||
--
|
||||
2.23.1
|
||||
|
@ -1,94 +0,0 @@
|
||||
From a06d0d3d7bbb3c0f5bad44934dbbf1e88e7d9558 Mon Sep 17 00:00:00 2001
|
||||
From: Miles Alan <m@milesalan.com>
|
||||
Date: Sat, 4 Jul 2020 11:49:04 -0500
|
||||
Subject: [PATCH] Highlight matched text in a different color scheme
|
||||
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dmenu.c | 43 +++++++++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 43 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..64eab2a 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -11,6 +11,8 @@ static const char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
+ [SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||
+ [SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
};
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 6b8f51b..d5e1991 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -26,7 +26,7 @@
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
/* enums */
|
||||
-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
||||
+enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeLast }; /* color schemes */
|
||||
|
||||
struct item {
|
||||
char *text;
|
||||
@@ -113,6 +113,43 @@ cistrstr(const char *s, const char *sub)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+static void
|
||||
+drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
+{
|
||||
+ char restorechar, tokens[sizeof text], *highlight, *token;
|
||||
+ int indentx, highlightlen;
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]);
|
||||
+ strcpy(tokens, text);
|
||||
+ for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) {
|
||||
+ highlight = fstrstr(item->text, token);
|
||||
+ while (highlight) {
|
||||
+ // Move item str end, calc width for highlight indent, & restore
|
||||
+ highlightlen = highlight - item->text;
|
||||
+ restorechar = *highlight;
|
||||
+ item->text[highlightlen] = '\0';
|
||||
+ indentx = TEXTW(item->text);
|
||||
+ item->text[highlightlen] = restorechar;
|
||||
+
|
||||
+ // Move highlight str end, draw highlight, & restore
|
||||
+ restorechar = highlight[strlen(token)];
|
||||
+ highlight[strlen(token)] = '\0';
|
||||
+ if (indentx - (lrpad / 2) - 1 < maxw)
|
||||
+ drw_text(
|
||||
+ drw,
|
||||
+ x + indentx - (lrpad / 2) - 1,
|
||||
+ y,
|
||||
+ MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
||||
+ bh, 0, highlight, 0
|
||||
+ );
|
||||
+ highlight[strlen(token)] = restorechar;
|
||||
+
|
||||
+ if (strlen(highlight) - strlen(token) < strlen(token)) break;
|
||||
+ highlight = fstrstr(highlight + strlen(token), token);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int
|
||||
drawitem(struct item *item, int x, int y, int w)
|
||||
{
|
||||
@@ -123,7 +160,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);
|
||||
+ int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||
+ drawhighlights(item, x, y, w);
|
||||
+ return r;
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
2.23.1
|
||||
|
Loading…
Reference in New Issue