mirror of
https://github.com/mintycube/dmenu.git
synced 2024-10-22 14:05:48 +02:00
Merge upstream changes
This commit is contained in:
commit
d73301dee5
@ -67,10 +67,10 @@ static const unsigned int alphas[][3] = {
|
||||
#if MORECOLOR_PATCH
|
||||
[SchemeMid] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // MORECOLOR_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
[SchemeSelHighlight] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeNormHighlight] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if HIGHPRIORITY_PATCH
|
||||
[SchemeHp] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // HIGHPRIORITY_PATCH
|
||||
@ -100,10 +100,10 @@ char *colors[][2] = {
|
||||
#if MORECOLOR_PATCH
|
||||
[SchemeMid] = { "#eeeeee", "#770000" },
|
||||
#endif // MORECOLOR_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
[SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||
[SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if HIGHPRIORITY_PATCH
|
||||
[SchemeHp] = { "#bbbbbb", "#333333" },
|
||||
#endif // HIGHPRIORITY_PATCH
|
||||
|
8
config.h
8
config.h
@ -67,10 +67,10 @@ static const unsigned int alphas[][3] = {
|
||||
#if MORECOLOR_PATCH
|
||||
[SchemeMid] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // MORECOLOR_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
[SchemeSelHighlight] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeNormHighlight] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if HIGHPRIORITY_PATCH
|
||||
[SchemeHp] = { OPAQUE, baralpha, borderalpha },
|
||||
#endif // HIGHPRIORITY_PATCH
|
||||
@ -100,10 +100,10 @@ char *colors[][2] = {
|
||||
#if MORECOLOR_PATCH
|
||||
[SchemeMid] = { "#eeeeee", "#770000" },
|
||||
#endif // MORECOLOR_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
[SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||
[SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if HIGHPRIORITY_PATCH
|
||||
[SchemeHp] = { "#bbbbbb", "#333333" },
|
||||
#endif // HIGHPRIORITY_PATCH
|
||||
|
66
dmenu.c
66
dmenu.c
@ -55,10 +55,10 @@ enum {
|
||||
#if MORECOLOR_PATCH
|
||||
SchemeMid,
|
||||
#endif // MORECOLOR_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
SchemeNormHighlight,
|
||||
SchemeSelHighlight,
|
||||
#endif // HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if HIGHPRIORITY_PATCH
|
||||
SchemeHp,
|
||||
#endif // HIGHPRIORITY_PATCH
|
||||
@ -330,11 +330,11 @@ drawitem(struct item *item, int x, int y, int w)
|
||||
case 'p':
|
||||
drw_setscheme(drw, scheme[SchemePurple]);
|
||||
break;
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
case 'h':
|
||||
drw_setscheme(drw, scheme[SchemeNormHighlight]);
|
||||
break;
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
case 's':
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
break;
|
||||
@ -366,11 +366,11 @@ drawitem(struct item *item, int x, int y, int w)
|
||||
case 'p':
|
||||
drw_setscheme(drw, scheme[SchemePurple]);
|
||||
break;
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
case 'h':
|
||||
drw_setscheme(drw, scheme[SchemeNormHighlight]);
|
||||
break;
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
case 's':
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
break;
|
||||
@ -471,13 +471,13 @@ drawitem(struct item *item, int x, int y, int w)
|
||||
, True
|
||||
#endif // PANGO_PATCH
|
||||
);
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
#if EMOJI_HIGHLIGHT_PATCH
|
||||
drawhighlights(item, output + iscomment, x + ((iscomment == 6) ? temppadding : 0), y, w);
|
||||
#else
|
||||
drawhighlights(item, x, y, w);
|
||||
#endif // EMOJI_HIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -1383,7 +1383,7 @@ paste(void)
|
||||
|
||||
#if ALPHA_PATCH
|
||||
static void
|
||||
xinitvisual()
|
||||
xinitvisual(void)
|
||||
{
|
||||
XVisualInfo *infos;
|
||||
XRenderPictFormat *fmt;
|
||||
@ -1527,6 +1527,11 @@ run(void)
|
||||
case ButtonPress:
|
||||
buttonpress(&ev);
|
||||
break;
|
||||
#if MOTION_SUPPORT_PATCH
|
||||
case MotionNotify:
|
||||
motionevent(&ev.xbutton);
|
||||
break;
|
||||
#endif // MOTION_SUPPORT_PATCH
|
||||
#endif // MOUSE_SUPPORT_PATCH
|
||||
case DestroyNotify:
|
||||
if (ev.xdestroywindow.window != win)
|
||||
@ -1749,6 +1754,9 @@ setup(void)
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask
|
||||
#if MOUSE_SUPPORT_PATCH
|
||||
| ButtonPressMask
|
||||
#if MOTION_SUPPORT_PATCH
|
||||
| PointerMotionMask
|
||||
#endif // MOTION_SUPPORT_PATCH
|
||||
#endif // MOUSE_SUPPORT_PATCH
|
||||
;
|
||||
win = XCreateWindow(
|
||||
@ -1904,9 +1912,9 @@ usage(void)
|
||||
#if XYW_PATCH
|
||||
" [-X xoffset] [-Y yoffset] [-W width]" // (arguments made upper case due to conflicts)
|
||||
#endif // XYW_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
"\n [-nhb color] [-nhf color] [-shb color] [-shf color]" // highlight colors
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if SEPARATOR_PATCH
|
||||
"\n [-d separator] [-D separator]"
|
||||
#endif // SEPARATOR_PATCH
|
||||
@ -1927,6 +1935,25 @@ main(int argc, char *argv[])
|
||||
fputs("warning: no locale support\n", stderr);
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("cannot open display");
|
||||
|
||||
/* These need to be checked before we init the visuals and read X resources. */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-v")) { /* prints version information */
|
||||
puts("dmenu-"VERSION);
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[i], "-w")) {
|
||||
argv[i][0] = '\0';
|
||||
embed = strdup(argv[++i]);
|
||||
#if ALPHA_PATCH
|
||||
} else if (!strcmp(argv[i], "-o")) { /* opacity, pass -o 0 to disable alpha */
|
||||
opacity = atoi(argv[++i]);
|
||||
#endif // ALPHA_PATCH
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
argv[i][0] = '\0'; // mark as used
|
||||
}
|
||||
|
||||
screen = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, screen);
|
||||
if (!embed || !(parentwin = strtol(embed, NULL, 0)))
|
||||
@ -1936,15 +1963,6 @@ main(int argc, char *argv[])
|
||||
parentwin);
|
||||
|
||||
#if ALPHA_PATCH
|
||||
/* These need to be checked before we init the visuals. */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-o")) { /* opacity, pass -o 0 to disable alpha */
|
||||
opacity = atoi(argv[++i]);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
argv[i][0] = '\0'; // mark as used
|
||||
}
|
||||
xinitvisual();
|
||||
drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap);
|
||||
#else
|
||||
@ -2054,7 +2072,7 @@ main(int argc, char *argv[])
|
||||
#endif // XYW_PATCH
|
||||
else if (!strcmp(argv[i], "-m"))
|
||||
mon = atoi(argv[++i]);
|
||||
#if ALPHA_PATCH
|
||||
#if ALPHA_PATCH && !XRESOURCES_PATCH
|
||||
else if (!strcmp(argv[i], "-o")) /* opacity, pass -o 0 to disable alpha */
|
||||
opacity = atoi(argv[++i]);
|
||||
#endif // ALPHA_PATCH
|
||||
@ -2088,7 +2106,7 @@ main(int argc, char *argv[])
|
||||
else if (!strcmp(argv[i], "-hp"))
|
||||
hpitems = tokenize(argv[++i], ",", &hplength);
|
||||
#endif // HIGHPRIORITY_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
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 */
|
||||
@ -2097,13 +2115,15 @@ main(int argc, char *argv[])
|
||||
colors[SchemeSelHighlight][ColBg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-shf")) /* selected hi foreground color */
|
||||
colors[SchemeSelHighlight][ColFg] = argv[++i];
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if CARET_WIDTH_PATCH
|
||||
else if (!strcmp(argv[i], "-cw")) /* sets caret witdth */
|
||||
caret_width = atoi(argv[++i]);
|
||||
#endif // CARET_WIDTH_PATCH
|
||||
#if !XRESOURCES_PATCH
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
#endif // XRESOURCES_PATCH
|
||||
#if SEPARATOR_PATCH
|
||||
else if (!strcmp(argv[i], "-d") || /* field separator */
|
||||
(separator_greedy = !strcmp(argv[i], "-D"))) {
|
||||
|
11
drw.c
11
drw.c
@ -9,7 +9,7 @@
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
#if !PANGO_PATCH
|
||||
#if !PANGO_PATCH || HIGHLIGHT_PATCH
|
||||
#define UTF_INVALID 0xFFFD
|
||||
#define UTF_SIZ 4
|
||||
|
||||
@ -61,6 +61,15 @@ utf8decode(const char *c, long *u, size_t clen)
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
#if HIGHLIGHT_PATCH
|
||||
size_t
|
||||
utf8len(const char *c)
|
||||
{
|
||||
long utf8codepoint = 0;
|
||||
return utf8decode(c, &utf8codepoint, UTF_SIZ);
|
||||
}
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#endif // PANGO_PATCH
|
||||
|
||||
Drw *
|
||||
|
6
drw.h
6
drw.h
@ -68,6 +68,10 @@ unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int
|
||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||
#endif // PANGO_PATCH
|
||||
|
||||
#if HIGHLIGHT_PATCH
|
||||
size_t utf8len(const char *c);
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
|
||||
/* Colorscheme abstraction */
|
||||
#if ALPHA_PATCH
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
|
||||
@ -100,4 +104,4 @@ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
|
||||
#if SCROLL_PATCH
|
||||
#include "patch/scroll.h"
|
||||
#endif
|
||||
#endif
|
||||
|
@ -5,4 +5,4 @@ max_textw(void)
|
||||
for (struct item *item = items; item && item->text; item++)
|
||||
len = MAX(TEXTW(item->text), len);
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
static void
|
||||
refreshoptions()
|
||||
refreshoptions(void)
|
||||
{
|
||||
int dynlen = strlen(dynamic);
|
||||
char* cmd= malloc(dynlen + strlen(text) + 2);
|
||||
@ -88,4 +88,4 @@ readstream(FILE* stream)
|
||||
text[0] = '\0';
|
||||
cursor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
static void refreshoptions();
|
||||
static void readstream(FILE* stream);
|
||||
static void refreshoptions(void);
|
||||
static void readstream(FILE* stream);
|
||||
|
@ -1,66 +0,0 @@
|
||||
static void
|
||||
#if EMOJI_HIGHLIGHT_PATCH
|
||||
drawhighlights(struct item *item, char *output, int x, int y, int maxw)
|
||||
#else
|
||||
drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
#endif // EMOJI_HIGHLIGHT_PATCH
|
||||
{
|
||||
int i, indent;
|
||||
char *highlight;
|
||||
char c;
|
||||
|
||||
#if EMOJI_HIGHLIGHT_PATCH
|
||||
char *itemtext = output;
|
||||
#elif TSV_PATCH && !SEPARATOR_PATCH
|
||||
char *itemtext = item->stext;
|
||||
#else
|
||||
char *itemtext = item->text;
|
||||
#endif // TSV_PATCH
|
||||
|
||||
if (!(strlen(itemtext) && strlen(text)))
|
||||
return;
|
||||
|
||||
/* Do not highlight items scheduled for output */
|
||||
#if MULTI_SELECTION_PATCH
|
||||
if (issel(item->id))
|
||||
return;
|
||||
#else
|
||||
if (item->out)
|
||||
return;
|
||||
#endif // MULTI_SELECTION_PATCH
|
||||
|
||||
drw_setscheme(drw, scheme[item == sel
|
||||
? SchemeSelHighlight
|
||||
: SchemeNormHighlight]);
|
||||
for (i = 0, highlight = itemtext; *highlight && text[i];) {
|
||||
#if FUZZYMATCH_PATCH
|
||||
if (!fstrncmp(&(*highlight), &text[i], 1))
|
||||
#else
|
||||
if (*highlight == text[i])
|
||||
#endif // FUZZYMATCH_PATCH
|
||||
{
|
||||
/* get indentation */
|
||||
c = *highlight;
|
||||
*highlight = '\0';
|
||||
indent = TEXTW(itemtext) - lrpad;
|
||||
*highlight = c;
|
||||
|
||||
/* highlight character */
|
||||
c = highlight[1];
|
||||
highlight[1] = '\0';
|
||||
drw_text(
|
||||
drw,
|
||||
x + indent + (lrpad / 2),
|
||||
y,
|
||||
MIN(maxw - indent - lrpad, TEXTW(highlight) - lrpad),
|
||||
bh, 0, highlight, 0
|
||||
#if PANGO_PATCH
|
||||
, True
|
||||
#endif // PANGO_PATCH
|
||||
);
|
||||
highlight[1] = c;
|
||||
i++;
|
||||
}
|
||||
highlight++;
|
||||
}
|
||||
}
|
@ -112,4 +112,4 @@ fuzzymatch(void)
|
||||
#endif // INSTANT_PATCH
|
||||
|
||||
calcoffsets();
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,4 @@ expect(char *expect, XKeyEvent *ignored)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif // MULTI_SELECTION_PATCH
|
||||
#endif // MULTI_SELECTION_PATCH
|
||||
|
@ -6,7 +6,12 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
#endif // EMOJI_HIGHLIGHT_PATCH
|
||||
{
|
||||
char restorechar, tokens[sizeof text], *highlight, *token;
|
||||
int indentx, highlightlen;
|
||||
int indent, highlightlen;
|
||||
|
||||
#if FUZZYMATCH_PATCH
|
||||
int i;
|
||||
#endif // FUZZYMATCH_PATCH
|
||||
|
||||
#if EMOJI_HIGHLIGHT_PATCH
|
||||
char *itemtext = output;
|
||||
#elif TSV_PATCH && !SEPARATOR_PATCH
|
||||
@ -15,6 +20,9 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
char *itemtext = item->text;
|
||||
#endif // EMOJI_HIGHLIGHT_PATCH | TSV_PATCH
|
||||
|
||||
if (!(strlen(itemtext) && strlen(text)))
|
||||
return;
|
||||
|
||||
/* Do not highlight items scheduled for output */
|
||||
#if MULTI_SELECTION_PATCH
|
||||
if (issel(item->id))
|
||||
@ -25,6 +33,45 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
#endif // MULTI_SELECTION_PATCH
|
||||
|
||||
drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]);
|
||||
|
||||
#if FUZZYMATCH_PATCH
|
||||
if (fuzzy) {
|
||||
for (i = 0, highlight = itemtext; *highlight && text[i];) {
|
||||
highlightlen = utf8len(highlight);
|
||||
#if FUZZYMATCH_PATCH
|
||||
if (!fstrncmp(&(*highlight), &text[i], highlightlen))
|
||||
#else
|
||||
if (*highlight == text[i])
|
||||
#endif // FUZZYMATCH_PATCH
|
||||
{
|
||||
/* get indentation */
|
||||
restorechar = *highlight;
|
||||
*highlight = '\0';
|
||||
indent = TEXTW(itemtext) - lrpad;
|
||||
*highlight = restorechar;
|
||||
|
||||
/* highlight character */
|
||||
restorechar = highlight[highlightlen];
|
||||
highlight[highlightlen] = '\0';
|
||||
drw_text(
|
||||
drw,
|
||||
x + indent + (lrpad / 2),
|
||||
y,
|
||||
MIN(maxw - indent - lrpad, TEXTW(highlight) - lrpad),
|
||||
bh, 0, highlight, 0
|
||||
#if PANGO_PATCH
|
||||
, True
|
||||
#endif // PANGO_PATCH
|
||||
);
|
||||
highlight[highlightlen] = restorechar;
|
||||
i += highlightlen;
|
||||
}
|
||||
highlight++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif // FUZZYMATCH_PATCH
|
||||
|
||||
strcpy(tokens, text);
|
||||
for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) {
|
||||
highlight = fstrstr(itemtext, token);
|
||||
@ -33,18 +80,18 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
highlightlen = highlight - itemtext;
|
||||
restorechar = *highlight;
|
||||
itemtext[highlightlen] = '\0';
|
||||
indentx = TEXTW(itemtext);
|
||||
indent = TEXTW(itemtext);
|
||||
itemtext[highlightlen] = restorechar;
|
||||
|
||||
// Move highlight str end, draw highlight, & restore
|
||||
restorechar = highlight[strlen(token)];
|
||||
highlight[strlen(token)] = '\0';
|
||||
if (indentx - (lrpad / 2) - 1 < maxw)
|
||||
if (indent - (lrpad / 2) - 1 < maxw)
|
||||
drw_text(
|
||||
drw,
|
||||
x + indentx - (lrpad / 2) - 1,
|
||||
x + indent - (lrpad / 2) - 1,
|
||||
y,
|
||||
MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
||||
MIN(maxw - indent, TEXTW(highlight) - lrpad),
|
||||
bh, 0, highlight, 0
|
||||
#if PANGO_PATCH
|
||||
, True
|
||||
@ -57,4 +104,4 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
||||
highlight = fstrstr(highlight + strlen(token), token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,4 +32,4 @@ arrayhas(char **list, int length, char *item) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1 @@
|
||||
static int arrayhas(char **list, int length, char *item);
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
#if CENTER_PATCH
|
||||
#include "center.c"
|
||||
#endif
|
||||
#if FUZZYHIGHLIGHT_PATCH
|
||||
#include "fuzzyhighlight.c"
|
||||
#elif HIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
#include "highlight.c"
|
||||
#endif
|
||||
#if FUZZYMATCH_PATCH
|
||||
@ -35,4 +33,4 @@
|
||||
#endif
|
||||
#if XRESOURCES_PATCH
|
||||
#include "xresources.c"
|
||||
#endif
|
||||
#endif
|
||||
|
@ -4,6 +4,9 @@ buttonpress(XEvent *e)
|
||||
struct item *item;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
int x = 0, y = 0, h = bh, w;
|
||||
#if GRID_PATCH
|
||||
int i, cols;
|
||||
#endif // GRID_PATCH
|
||||
|
||||
if (ev->window != win)
|
||||
return;
|
||||
@ -66,8 +69,40 @@ buttonpress(XEvent *e)
|
||||
if (ev->state & ~ControlMask)
|
||||
return;
|
||||
if (lines > 0) {
|
||||
#if GRID_PATCH
|
||||
cols = columns ? columns : 1;
|
||||
for (i = 0, item = curr; item != next; item = item->right, i++) {
|
||||
if (
|
||||
(ev->y >= y + ((i % lines) + 1) * bh) && // line y start
|
||||
(ev->y <= y + ((i % lines) + 2) * bh) && // line y end
|
||||
(ev->x >= x + ((i / lines) * (w / cols))) && // column x start
|
||||
(ev->x <= x + ((i / lines + 1) * (w / cols))) // column x end
|
||||
) {
|
||||
#if !MULTI_SELECTION_PATCH
|
||||
puts(item->text);
|
||||
#endif // MULTI_SELECTION_PATCH
|
||||
if (!(ev->state & ControlMask)) {
|
||||
#if MULTI_SELECTION_PATCH
|
||||
sel = item;
|
||||
selsel();
|
||||
printsel(ev->state);
|
||||
#endif // MULTI_SELECTION_PATCH
|
||||
exit(0);
|
||||
}
|
||||
sel = item;
|
||||
if (sel) {
|
||||
#if MULTI_SELECTION_PATCH
|
||||
selsel();
|
||||
#else
|
||||
sel->out = 1;
|
||||
#endif // MULTI_SELECTION_PATCH
|
||||
drawmenu();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* vertical list: (ctrl)left-click on item */
|
||||
w = mw - x;
|
||||
for (item = curr; item != next; item = item->right) {
|
||||
y += h;
|
||||
if (ev->y >= y && ev->y <= (y + h)) {
|
||||
@ -94,6 +129,7 @@ buttonpress(XEvent *e)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif // GRID_PATCH
|
||||
} else if (matches) {
|
||||
/* left-click on left arrow */
|
||||
x += inputw;
|
||||
@ -156,4 +192,80 @@ buttonpress(XEvent *e)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if MOTION_SUPPORT_PATCH
|
||||
static void
|
||||
motionevent(XButtonEvent *ev)
|
||||
{
|
||||
struct item *item;
|
||||
int x = 0, y = 0, w;
|
||||
#if GRID_PATCH
|
||||
int i, cols;
|
||||
#endif // GRID_PATCH
|
||||
|
||||
if (ev->window != win || matches == 0)
|
||||
return;
|
||||
|
||||
if (prompt && *prompt)
|
||||
x += promptw;
|
||||
|
||||
if (lines > 0) {
|
||||
/* input field */
|
||||
w = mw - x;
|
||||
#if GRID_PATCH
|
||||
cols = columns ? columns : 1;
|
||||
/* grid view or vertical list */
|
||||
for (i = 0, item = curr; item != next; item = item->right, i++) {
|
||||
if (
|
||||
(ev->y >= y + ((i % lines) + 1) * bh) && // line y start
|
||||
(ev->y <= y + ((i % lines) + 2) * bh) && // line y end
|
||||
(ev->x >= x + ((i / lines) * (w / cols))) && // column x start
|
||||
(ev->x <= x + ((i / lines + 1) * (w / cols))) // column x end
|
||||
) {
|
||||
sel = item;
|
||||
calcoffsets();
|
||||
drawmenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* vertical list */
|
||||
w = mw - x;
|
||||
for (item = curr; item != next; item = item->right) {
|
||||
y += bh;
|
||||
if (ev->y >= y && ev->y <= (y + bh)) {
|
||||
sel = item;
|
||||
calcoffsets();
|
||||
drawmenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // GRID_PATCH
|
||||
return;
|
||||
}
|
||||
|
||||
/* left-click on left arrow */
|
||||
x += inputw;
|
||||
#if SYMBOLS_PATCH
|
||||
w = TEXTW(symbol_1);
|
||||
#else
|
||||
w = TEXTW("<");
|
||||
#endif // SYMBOLS_PATCH
|
||||
/* horizontal list */
|
||||
for (item = curr; item != next; item = item->right) {
|
||||
x += w;
|
||||
#if SYMBOLS_PATCH
|
||||
w = MIN(TEXTW(item->text), mw - x - TEXTW(symbol_2));
|
||||
#else
|
||||
w = MIN(TEXTW(item->text), mw - x - TEXTW(">"));
|
||||
#endif // SYMBOLS_PATCH
|
||||
if (ev->x >= x && ev->x <= x + w) {
|
||||
sel = item;
|
||||
calcoffsets();
|
||||
drawmenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@ printsel(unsigned int state)
|
||||
}
|
||||
|
||||
static void
|
||||
selsel()
|
||||
selsel(void)
|
||||
{
|
||||
if (!sel)
|
||||
return;
|
||||
@ -50,4 +50,4 @@ selsel()
|
||||
selid = realloc(selid, (selidsize + 1) * sizeof(int));
|
||||
selid[selidsize - 1] = sel->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,4 +123,4 @@ out:
|
||||
free(history[i]);
|
||||
}
|
||||
free(history);
|
||||
}
|
||||
}
|
||||
|
@ -65,4 +65,4 @@ run(void)
|
||||
if (FD_ISSET(0, &fds))
|
||||
readstdin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
static void readevent();
|
||||
static void readevent();
|
||||
|
@ -1,7 +1,7 @@
|
||||
static char numbers[NUMBERSBUFSIZE] = "";
|
||||
|
||||
static void
|
||||
recalculatenumbers()
|
||||
recalculatenumbers(void)
|
||||
{
|
||||
unsigned int numer = 0, denom = 0;
|
||||
struct item *item;
|
||||
@ -13,4 +13,4 @@ recalculatenumbers()
|
||||
for (item = items; item && item->text; item++)
|
||||
denom++;
|
||||
snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#define NUMBERSMAXDIGITS 100
|
||||
#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1
|
||||
|
||||
static void recalculatenumbers();
|
||||
static void recalculatenumbers(void);
|
||||
|
@ -169,4 +169,4 @@ drw_text_align(Drw *drw, int x, int y, unsigned int w, unsigned int h, const cha
|
||||
XftDrawDestroy(d);
|
||||
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
enum { AlignL, AlignR };
|
||||
|
||||
int drw_text_align(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int textlen, int align);
|
||||
int drw_text_align(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int textlen, int align);
|
||||
|
@ -43,7 +43,7 @@ readxresources(void)
|
||||
if (XrmGetResource(xdb, "dmenu.bordercolor", "*", &type, &xval))
|
||||
colors[SchemeBorder][ColBg] = strdup(xval.addr);
|
||||
#endif // BORDER_PATCH
|
||||
#if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
|
||||
#if HIGHLIGHT_PATCH
|
||||
if (XrmGetResource(xdb, "dmenu.selhlbackground", "*", &type, &xval))
|
||||
colors[SchemeSelHighlight][ColBg] = strdup(xval.addr);
|
||||
if (XrmGetResource(xdb, "dmenu.selhlforeground", "*", &type, &xval))
|
||||
@ -52,7 +52,7 @@ readxresources(void)
|
||||
colors[SchemeNormHighlight][ColBg] = strdup(xval.addr);
|
||||
if (XrmGetResource(xdb, "dmenu.hlforeground", "*", &type, &xval))
|
||||
colors[SchemeNormHighlight][ColFg] = strdup(xval.addr);
|
||||
#endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
|
||||
#endif // HIGHLIGHT_PATCH
|
||||
#if HIGHPRIORITY_PATCH
|
||||
if (XrmGetResource(xdb, "dmenu.hpbackground", "*", &type, &xval))
|
||||
colors[SchemeHp][ColBg] = strdup(xval.addr);
|
||||
@ -87,4 +87,4 @@ readxresources(void)
|
||||
#endif // EMOJI_HIGHLIGHT_PATCH
|
||||
XrmDestroyDatabase(xdb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,12 +57,6 @@
|
||||
*/
|
||||
#define EMOJI_HIGHLIGHT_PATCH 0
|
||||
|
||||
/* This patch make it so that fuzzy matches gets highlighted and is therefore meant
|
||||
* to be used together with the fuzzymatch patch.
|
||||
* https://tools.suckless.org/dmenu/patches/fuzzyhighlight/
|
||||
*/
|
||||
#define FUZZYHIGHLIGHT_PATCH 0
|
||||
|
||||
/* This patch adds support for fuzzy-matching to dmenu, allowing users to type non-consecutive
|
||||
* portions of the string to be matched.
|
||||
* https://tools.suckless.org/dmenu/patches/fuzzymatch/
|
||||
@ -89,8 +83,13 @@
|
||||
#define GRIDNAV_PATCH 0
|
||||
|
||||
/* This patch highlights the individual characters of matched text for each dmenu list entry.
|
||||
* The fuzzy highlight patch takes precedence over this patch.
|
||||
* If combined with the fuzzymatch patch then fuzzy highlight will be used for highlighting
|
||||
* depending on whether fuzzy matching is enabled.
|
||||
*
|
||||
* Known issue: highlighting does not work properly when pango markup is used
|
||||
*
|
||||
* https://tools.suckless.org/dmenu/patches/highlight/
|
||||
* https://tools.suckless.org/dmenu/patches/fuzzyhighlight/
|
||||
*/
|
||||
#define HIGHLIGHT_PATCH 0
|
||||
|
||||
@ -141,6 +140,11 @@
|
||||
*/
|
||||
#define MOUSE_SUPPORT_PATCH 0
|
||||
|
||||
/* Expands the above to support mouse hovering.
|
||||
* https://tools.suckless.org/dmenu/patches/mouse-support/
|
||||
*/
|
||||
#define MOTION_SUPPORT_PATCH 0
|
||||
|
||||
/* Without this patch when you press Ctrl+Enter dmenu just outputs current item and it is not
|
||||
* possible to undo that.
|
||||
* With this patch dmenu will output all selected items only on exit. It is also possible to
|
||||
@ -211,6 +215,8 @@
|
||||
* A long term fix for the libXft library is pending approval of this pull request:
|
||||
* https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/1
|
||||
*
|
||||
* Known issue: not compatible with the scroll patch
|
||||
*
|
||||
* Also see:
|
||||
* https://developer.gnome.org/pygtk/stable/pango-markup-language.html
|
||||
* https://github.com/StillANixRookie/dmenu-pango
|
||||
@ -297,6 +303,9 @@
|
||||
|
||||
/* This patch adds support for text scrolling and no longer appends '...' for long input as
|
||||
* it can handle long text.
|
||||
*
|
||||
* Known issue: not compatible with the pango patch
|
||||
*
|
||||
* https://tools.suckless.org/dmenu/patches/scroll/
|
||||
*/
|
||||
#define SCROLL_PATCH 0
|
||||
|
23
patches.h
23
patches.h
@ -57,12 +57,6 @@
|
||||
*/
|
||||
#define EMOJI_HIGHLIGHT_PATCH 0
|
||||
|
||||
/* This patch make it so that fuzzy matches gets highlighted and is therefore meant
|
||||
* to be used together with the fuzzymatch patch.
|
||||
* https://tools.suckless.org/dmenu/patches/fuzzyhighlight/
|
||||
*/
|
||||
#define FUZZYHIGHLIGHT_PATCH 0
|
||||
|
||||
/* This patch adds support for fuzzy-matching to dmenu, allowing users to type non-consecutive
|
||||
* portions of the string to be matched.
|
||||
* https://tools.suckless.org/dmenu/patches/fuzzymatch/
|
||||
@ -89,8 +83,13 @@
|
||||
#define GRIDNAV_PATCH 1
|
||||
|
||||
/* This patch highlights the individual characters of matched text for each dmenu list entry.
|
||||
* The fuzzy highlight patch takes precedence over this patch.
|
||||
* If combined with the fuzzymatch patch then fuzzy highlight will be used for highlighting
|
||||
* depending on whether fuzzy matching is enabled.
|
||||
*
|
||||
* Known issue: highlighting does not work properly when pango markup is used
|
||||
*
|
||||
* https://tools.suckless.org/dmenu/patches/highlight/
|
||||
* https://tools.suckless.org/dmenu/patches/fuzzyhighlight/
|
||||
*/
|
||||
#define HIGHLIGHT_PATCH 0
|
||||
|
||||
@ -141,6 +140,11 @@
|
||||
*/
|
||||
#define MOUSE_SUPPORT_PATCH 1
|
||||
|
||||
/* Expands the above to support mouse hovering.
|
||||
* https://tools.suckless.org/dmenu/patches/mouse-support/
|
||||
*/
|
||||
#define MOTION_SUPPORT_PATCH 0
|
||||
|
||||
/* Without this patch when you press Ctrl+Enter dmenu just outputs current item and it is not
|
||||
* possible to undo that.
|
||||
* With this patch dmenu will output all selected items only on exit. It is also possible to
|
||||
@ -211,6 +215,8 @@
|
||||
* A long term fix for the libXft library is pending approval of this pull request:
|
||||
* https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/1
|
||||
*
|
||||
* Known issue: not compatible with the scroll patch
|
||||
*
|
||||
* Also see:
|
||||
* https://developer.gnome.org/pygtk/stable/pango-markup-language.html
|
||||
* https://github.com/StillANixRookie/dmenu-pango
|
||||
@ -297,6 +303,9 @@
|
||||
|
||||
/* This patch adds support for text scrolling and no longer appends '...' for long input as
|
||||
* it can handle long text.
|
||||
*
|
||||
* Known issue: not compatible with the pango patch
|
||||
*
|
||||
* https://tools.suckless.org/dmenu/patches/scroll/
|
||||
*/
|
||||
#define SCROLL_PATCH 1
|
||||
|
Loading…
Reference in New Issue
Block a user