sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 9528aed9c21367e9261659cdb26276c42496529d
parent 45e7e411b2c6f3f66c432974225453b50b56a504
Author: NRK <nrk@disroot.org>
Date:   Thu,  6 Oct 2022 07:58:55 +0600

[dmenu][spearator]: 5.2 rebase

Diffstat:
Atools.suckless.org/dmenu/patches/separator/dmenu-separator-5.2.patch | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dtools.suckless.org/dmenu/patches/separator/dmenu-separator-e35976f.diff | 109-------------------------------------------------------------------------------
Mtools.suckless.org/dmenu/patches/separator/index.md | 2+-
3 files changed, 134 insertions(+), 110 deletions(-)

diff --git a/tools.suckless.org/dmenu/patches/separator/dmenu-separator-5.2.patch b/tools.suckless.org/dmenu/patches/separator/dmenu-separator-5.2.patch @@ -0,0 +1,133 @@ +From db596234b244382e984228791e840190d82967ea Mon Sep 17 00:00:00 2001 +From: NRK <nrk@disroot.org> +Date: Fri, 3 Sep 2021 11:11:14 +0600 +Subject: [PATCH] patch: seperator + +--- + dmenu.1 | 12 ++++++++++++ + dmenu.c | 31 +++++++++++++++++++++++++++---- + 2 files changed, 39 insertions(+), 4 deletions(-) + +diff --git a/dmenu.1 b/dmenu.1 +index 323f93c..d511148 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -22,6 +22,10 @@ dmenu \- dynamic menu + .IR color ] + .RB [ \-w + .IR windowid ] ++.RB [ \-d ++.IR separator ] ++.RB [ \-D ++.IR separator ] + .P + .BR dmenu_run " ..." + .SH DESCRIPTION +@@ -80,6 +84,14 @@ prints version information to stdout, then exits. + .TP + .BI \-w " windowid" + embed into windowid. ++.TP ++.BI \-d " separator" ++separate the input into two halves on the first occurrence of the given charcter. ++Display only the first half in dmenu and print the second half to stdout upon selection. ++Appending '|' to the separator reverses the display/printing order. ++.TP ++.BI \-D " separator" ++same as \-d but separate based on the last occurrence. + .SH USAGE + dmenu is completely controlled by the keyboard. Items are selected using the + arrow keys, page up, page down, home, and end. +diff --git a/dmenu.c b/dmenu.c +index 7cf253b..a8eb321 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -30,12 +30,15 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ + + struct item { + char *text; ++ char *text_output; + struct item *left, *right; + int out; + }; + + static char text[BUFSIZ] = ""; + static char *embed; ++static char separator, separator_reverse; ++static char * (*sepchr)(const char *, int); + static int bh, mw, mh; + static int inputw = 0, promptw; + static int lrpad; /* sum of left and right padding */ +@@ -105,7 +108,7 @@ cleanup(void) + for (i = 0; i < SchemeLast; i++) + free(scheme[i]); + for (i = 0; items && items[i].text; ++i) +- free(items[i].text); ++ free(separator_reverse ? items[i].text_output : items[i].text); + free(items); + drw_free(drw); + XSync(dpy, False); +@@ -490,7 +493,7 @@ insert: + break; + case XK_Return: + case XK_KP_Enter: +- puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); ++ puts((sel && !(ev->state & ShiftMask)) ? sel->text_output : text); + if (!(ev->state & ControlMask)) { + cleanup(); + exit(0); +@@ -549,7 +552,7 @@ paste(void) + static void + readstdin(void) + { +- char *line = NULL; ++ char *p, *line = NULL; + size_t i, junk, size = 0; + ssize_t len; + +@@ -561,6 +564,19 @@ readstdin(void) + if (line[len - 1] == '\n') + line[len - 1] = '\0'; + items[i].text = line; ++ ++ if (separator && (p = sepchr(items[i].text, separator)) != NULL) { ++ *p = '\0'; ++ items[i].text_output = ++p; ++ } else { ++ items[i].text_output = items[i].text; ++ } ++ if (separator_reverse) { ++ p = items[i].text; ++ items[i].text = items[i].text_output; ++ items[i].text_output = p; ++ } ++ + items[i].out = 0; + } + if (items) +@@ -711,7 +727,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] [-w windowid]\n" ++ " [-d separator] [-D separator]"); + } + + int +@@ -753,6 +770,12 @@ 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], "-d") || /* field separator */ ++ !strcmp(argv[i], "-D")) { ++ sepchr = argv[i][1] == 'D' ? strrchr : strchr; ++ separator = argv[++i][0]; ++ separator_reverse = argv[i][1] == '|'; ++ } + else + usage(); + +-- +2.35.1 + diff --git a/tools.suckless.org/dmenu/patches/separator/dmenu-separator-e35976f.diff b/tools.suckless.org/dmenu/patches/separator/dmenu-separator-e35976f.diff @@ -1,109 +0,0 @@ -diff --git a/dmenu.1 b/dmenu.1 -index 323f93c..d511148 100644 ---- a/dmenu.1 -+++ b/dmenu.1 -@@ -22,6 +22,10 @@ dmenu \- dynamic menu - .IR color ] - .RB [ \-w - .IR windowid ] -+.RB [ \-d -+.IR separator ] -+.RB [ \-D -+.IR separator ] - .P - .BR dmenu_run " ..." - .SH DESCRIPTION -@@ -80,6 +84,14 @@ prints version information to stdout, then exits. - .TP - .BI \-w " windowid" - embed into windowid. -+.TP -+.BI \-d " separator" -+separate the input into two halves on the first occurrence of the given charcter. -+Display only the first half in dmenu and print the second half to stdout upon selection. -+Appending '|' to the separator reverses the display/printing order. -+.TP -+.BI \-D " separator" -+same as \-d but separate based on the last occurrence. - .SH USAGE - dmenu is completely controlled by the keyboard. Items are selected using the - arrow keys, page up, page down, home, and end. -diff --git a/dmenu.c b/dmenu.c -index 571bc35..f2add3b 100644 ---- a/dmenu.c -+++ b/dmenu.c -@@ -30,12 +30,15 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ - - struct item { - char *text; -+ char *text_output; - struct item *left, *right; - int out; - }; - - static char text[BUFSIZ] = ""; - static char *embed; -+static char separator, separator_reverse; -+static char * (*sepchr)(const char *, int); - static int bh, mw, mh; - static int inputw = 0, promptw; - static int lrpad; /* sum of left and right padding */ -@@ -105,7 +108,7 @@ cleanup(void) - for (i = 0; i < SchemeLast; i++) - free(scheme[i]); - for (i = 0; items && items[i].text; ++i) -- free(items[i].text); -+ free(separator_reverse ? items[i].text_output : items[i].text); - free(items); - drw_free(drw); - XSync(dpy, False); -@@ -490,7 +493,7 @@ insert: - break; - case XK_Return: - case XK_KP_Enter: -- puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); -+ puts((sel && !(ev->state & ShiftMask)) ? sel->text_output : text); - if (!(ev->state & ControlMask)) { - cleanup(); - exit(0); -@@ -561,6 +564,17 @@ readstdin(void) - *p = '\0'; - if (!(items[i].text = strdup(buf))) - die("cannot strdup %zu bytes:", strlen(buf) + 1); -+ if (separator && (p = sepchr(items[i].text, separator)) != NULL) { -+ *p = '\0'; -+ items[i].text_output = ++p; -+ } else { -+ items[i].text_output = items[i].text; -+ } -+ if (separator_reverse) { -+ p = items[i].text; -+ items[i].text = items[i].text_output; -+ items[i].text_output = p; -+ } - items[i].out = 0; - } - if (items) -@@ -711,7 +725,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] [-w windowid]\n" -+ " [-d separator] [-D separator]\n", stderr); - exit(1); - } - -@@ -754,6 +769,12 @@ 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], "-d") || /* field separator */ -+ !strcmp(argv[i], "-D")) { -+ sepchr = argv[i][1] == 'D' ? strrchr : strchr; -+ separator = argv[++i][0]; -+ separator_reverse = argv[i][1] == '|'; -+ } - else - usage(); - diff --git a/tools.suckless.org/dmenu/patches/separator/index.md b/tools.suckless.org/dmenu/patches/separator/index.md @@ -19,7 +19,7 @@ and display the latter half on dmenu while printing the first half upon selectio Download -------- -* [dmenu-separator-e35976f.diff](dmenu-separator-e35976f.diff) +* [dmenu-separator-5.2.patch](dmenu-separator-5.2.patch) Author ------