MULTI_SELECT_PATCH --> MULTI_SELECTION_PATCH

This commit is contained in:
bakkeby 2020-08-08 13:49:00 +02:00
parent 240cce1c1a
commit 1f6c8c1e7c
5 changed files with 36 additions and 36 deletions

View File

@ -93,7 +93,7 @@ static int histnodup = 1; /* if 0, record repeated histories */
* Characters not considered part of a word while deleting words * Characters not considered part of a word while deleting words
* for example: " /?\"&[]" * for example: " /?\"&[]"
*/ */
#if PIPEOUT_PATCH && !MULTI_SELECT_PATCH #if PIPEOUT_PATCH && !MULTI_SELECTION_PATCH
static const char startpipe[] = "#"; static const char startpipe[] = "#";
#endif // PIPEOUT_PATCH #endif // PIPEOUT_PATCH
static const char worddelimiters[] = " "; static const char worddelimiters[] = " ";

42
dmenu.c
View File

@ -59,11 +59,11 @@ struct item {
#if NON_BLOCKING_STDIN_PATCH #if NON_BLOCKING_STDIN_PATCH
struct item *next; struct item *next;
#endif // NON_BLOCKING_STDIN_PATCH #endif // NON_BLOCKING_STDIN_PATCH
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
int id; /* for multiselect */ int id; /* for multiselect */
#else #else
int out; int out;
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
#if HIGHPRIORITY_PATCH #if HIGHPRIORITY_PATCH
int hp; int hp;
#endif // HIGHPRIORITY_PATCH #endif // HIGHPRIORITY_PATCH
@ -73,7 +73,7 @@ struct item {
}; };
static char text[BUFSIZ] = ""; static char text[BUFSIZ] = "";
#if PIPEOUT_PATCH && !MULTI_SELECT_PATCH #if PIPEOUT_PATCH && !MULTI_SELECTION_PATCH
static char pipeout[8] = " | dmenu"; static char pipeout[8] = " | dmenu";
#endif // PIPEOUT_PATCH #endif // PIPEOUT_PATCH
static char *embed; static char *embed;
@ -98,11 +98,11 @@ static int mon = -1, screen;
#if MANAGED_PATCH #if MANAGED_PATCH
static int managed = 0; static int managed = 0;
#endif // MANAGED_PATCH #endif // MANAGED_PATCH
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
static int *selid = NULL; static int *selid = NULL;
static unsigned int selidsize = 0; static unsigned int selidsize = 0;
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
#if PRINTINPUTTEXT_PATCH && !MULTI_SELECT_PATCH #if PRINTINPUTTEXT_PATCH && !MULTI_SELECTION_PATCH
static int use_text_input = 0; static int use_text_input = 0;
#endif // PRINTINPUTTEXT_PATCH #endif // PRINTINPUTTEXT_PATCH
#if PRESELECT_PATCH #if PRESELECT_PATCH
@ -225,9 +225,9 @@ cleanup(void)
drw_free(drw); drw_free(drw);
XSync(dpy, False); XSync(dpy, False);
XCloseDisplay(dpy); XCloseDisplay(dpy);
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
free(selid); free(selid);
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
} }
static char * static char *
@ -255,11 +255,11 @@ drawitem(struct item *item, int x, int y, int w)
else if (item->left == sel || item->right == sel) else if (item->left == sel || item->right == sel)
drw_setscheme(drw, scheme[SchemeMid]); drw_setscheme(drw, scheme[SchemeMid]);
#endif // MORECOLOR_PATCH #endif // MORECOLOR_PATCH
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
else if (issel(item->id)) else if (issel(item->id))
#else #else
else if (item->out) else if (item->out)
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
drw_setscheme(drw, scheme[SchemeOut]); drw_setscheme(drw, scheme[SchemeOut]);
else else
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
@ -770,9 +770,9 @@ keypress(XKeyEvent *ev)
goto draw; goto draw;
case XK_Return: case XK_Return:
case XK_KP_Enter: case XK_KP_Enter:
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
selsel(); selsel();
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
break; break;
case XK_bracketleft: case XK_bracketleft:
cleanup(); cleanup();
@ -874,7 +874,7 @@ insert:
break; break;
case XK_Return: case XK_Return:
case XK_KP_Enter: case XK_KP_Enter:
#if !MULTI_SELECT_PATCH #if !MULTI_SELECTION_PATCH
#if PIPEOUT_PATCH #if PIPEOUT_PATCH
#if PRINTINPUTTEXT_PATCH #if PRINTINPUTTEXT_PATCH
if (sel && ( if (sel && (
@ -905,22 +905,22 @@ insert:
#else #else
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
#endif // PIPEOUT_PATCH #endif // PIPEOUT_PATCH
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
if (!(ev->state & ControlMask)) { if (!(ev->state & ControlMask)) {
#if NAVHISTORY_PATCH #if NAVHISTORY_PATCH
savehistory((sel && !(ev->state & ShiftMask)) savehistory((sel && !(ev->state & ShiftMask))
? sel->text : text); ? sel->text : text);
#endif // NAVHISTORY_PATCH #endif // NAVHISTORY_PATCH
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
printsel(ev->state); printsel(ev->state);
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
cleanup(); cleanup();
exit(0); exit(0);
} }
#if !MULTI_SELECT_PATCH #if !MULTI_SELECTION_PATCH
if (sel) if (sel)
sel->out = 1; sel->out = 1;
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
break; break;
case XK_Right: case XK_Right:
if (text[cursor] != '\0') { if (text[cursor] != '\0') {
@ -1051,7 +1051,7 @@ readstdin(void)
*p = '\0'; *p = '\0';
if (!(items[i].text = strdup(buf))) if (!(items[i].text = strdup(buf)))
die("cannot strdup %u bytes:", strlen(buf) + 1); die("cannot strdup %u bytes:", strlen(buf) + 1);
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
items[i].id = i; /* for multiselect */ items[i].id = i; /* for multiselect */
#else #else
items[i].out = 0; items[i].out = 0;
@ -1388,7 +1388,7 @@ usage(void)
#if INSTANT_PATCH #if INSTANT_PATCH
"n" "n"
#endif // INSTANT_PATCH #endif // INSTANT_PATCH
#if PRINTINPUTTEXT_PATCH && !MULTI_SELECT_PATCH #if PRINTINPUTTEXT_PATCH && !MULTI_SELECTION_PATCH
"t" "t"
#endif // PRINTINPUTTEXT_PATCH #endif // PRINTINPUTTEXT_PATCH
#if PREFIXCOMPLETION_PATCH #if PREFIXCOMPLETION_PATCH
@ -1494,7 +1494,7 @@ main(int argc, char *argv[])
} else if (!strcmp(argv[i], "-n")) { /* instant select only match */ } else if (!strcmp(argv[i], "-n")) { /* instant select only match */
instant = !instant; instant = !instant;
#endif // INSTANT_PATCH #endif // INSTANT_PATCH
#if PRINTINPUTTEXT_PATCH && !MULTI_SELECT_PATCH #if PRINTINPUTTEXT_PATCH && !MULTI_SELECTION_PATCH
} else if (!strcmp(argv[i], "-t")) { /* favors text input over selection */ } else if (!strcmp(argv[i], "-t")) { /* favors text input over selection */
use_text_input = 1; use_text_input = 1;
#endif // PRINTINPUTTEXT_PATCH #endif // PRINTINPUTTEXT_PATCH

View File

@ -15,7 +15,7 @@
#if HIGHPRIORITY_PATCH #if HIGHPRIORITY_PATCH
#include "highpriority.c" #include "highpriority.c"
#endif #endif
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
#include "multiselect.c" #include "multiselect.c"
#endif #endif
#if MOUSE_SUPPORT_PATCH #if MOUSE_SUPPORT_PATCH

View File

@ -71,24 +71,24 @@ buttonpress(XEvent *e)
for (item = curr; item != next; item = item->right) { for (item = curr; item != next; item = item->right) {
y += h; y += h;
if (ev->y >= y && ev->y <= (y + h)) { if (ev->y >= y && ev->y <= (y + h)) {
#if !MULTI_SELECT_PATCH #if !MULTI_SELECTION_PATCH
puts(item->text); puts(item->text);
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
if (!(ev->state & ControlMask)) { if (!(ev->state & ControlMask)) {
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
sel = item; sel = item;
selsel(); selsel();
printsel(ev->state); printsel(ev->state);
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
exit(0); exit(0);
} }
sel = item; sel = item;
if (sel) { if (sel) {
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
selsel(); selsel();
#else #else
sel->out = 1; sel->out = 1;
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
drawmenu(); drawmenu();
} }
return; return;
@ -119,24 +119,24 @@ buttonpress(XEvent *e)
w = MIN(TEXTW(item->text), mw - x - TEXTW(">")); w = MIN(TEXTW(item->text), mw - x - TEXTW(">"));
#endif // SYMBOLS_PATCH #endif // SYMBOLS_PATCH
if (ev->x >= x && ev->x <= x + w) { if (ev->x >= x && ev->x <= x + w) {
#if !MULTI_SELECT_PATCH #if !MULTI_SELECTION_PATCH
puts(item->text); puts(item->text);
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
if (!(ev->state & ControlMask)) { if (!(ev->state & ControlMask)) {
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
sel = item; sel = item;
selsel(); selsel();
printsel(ev->state); printsel(ev->state);
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
exit(0); exit(0);
} }
sel = item; sel = item;
if (sel) { if (sel) {
#if MULTI_SELECT_PATCH #if MULTI_SELECTION_PATCH
selsel(); selsel();
#else #else
sel->out = 1; sel->out = 1;
#endif // MULTI_SELECT_PATCH #endif // MULTI_SELECTION_PATCH
drawmenu(); drawmenu();
} }
return; return;

View File

@ -120,7 +120,7 @@
* *
* https://tools.suckless.org/dmenu/patches/multi-selection/ * https://tools.suckless.org/dmenu/patches/multi-selection/
*/ */
#define MULTI_SELECT_PATCH 0 #define MULTI_SELECTION_PATCH 0
/* This patch provides dmenu the ability for history navigation similar to that of bash. /* This patch provides dmenu the ability for history navigation similar to that of bash.
* https://tools.suckless.org/dmenu/patches/navhistory/ * https://tools.suckless.org/dmenu/patches/navhistory/