[wiki] [sites] [dmenu][patch] Add patch for dmenu-fce06f4: tsv-alt || yosh

From: <git_AT_suckless.org>
Date: Tue, 20 Sep 2022 01:50:48 +0200

commit bd07f20f6a98964b38cc6adfc92b3be2e61943a0
Author: yosh <yosh-git_AT_riseup.net>
Date: Mon Sep 19 19:25:12 2022 -0400

    [dmenu][patch] Add patch for dmenu-fce06f4: tsv-alt
    
    This commit adds a patch for dmenu to separate the displayed text and
    output text based on the presence of a tab character. While being
    similar to tsv, it is different enough to be considered a separate
    patch.

diff --git a/tools.suckless.org/dmenu/patches/tsv-alt/dmenu-tsv-alt-20220919-fce06f4.diff b/tools.suckless.org/dmenu/patches/tsv-alt/dmenu-tsv-alt-20220919-fce06f4.diff
new file mode 100644
index 00000000..511c408a
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/tsv-alt/dmenu-tsv-alt-20220919-fce06f4.diff
_AT_@ -0,0 +1,105 @@
+diff --git a/config.def.h b/config.def.h
+index 1edb647..bd0fcef 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -21,3 +21,8 @@ static unsigned int lines = 0;
+ * for example: " /?\"&[]"
+ */
+ static const char worddelimiters[] = " ";
++
++/* tsv-alt: reverse the order of tab separation.
++ * 0 = display<TAB>output. 1 = output<TAB>display
++ * can be reversed with -r as well */
++static int revtab = 0;
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..39c3492 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -3,7 +3,7 @@
+ dmenu \- dynamic menu
+ .SH SYNOPSIS
+ .B dmenu
+-.RB [ \-bfiv ]
++.RB [ \-bfivr ]
+ .RB [ \-l
+ .IR lines ]
+ .RB [ \-m
+_AT_@ -80,6 +80,10 @@ prints version information to stdout, then exits.
+ .TP
+ .BI \-w " windowid"
+ embed into windowid.
++.TP
++.B \-r
++tsv-alt: reverse the behavior of tab separation.
++.TP
+ .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 818313a..9783fc4 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -30,6 +30,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+
+ struct item {
+ char *text;
++ char *otext;
+ struct item *left, *right;
+ int out;
+ };
+_AT_@ -105,7 +106,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(revtab ? items[i].otext : items[i].text);
+ free(items);
+ drw_free(drw);
+ XSync(dpy, False);
+_AT_@ -490,7 +491,7 @@ insert:
+ break;
+ case XK_Return:
+ case XK_KP_Enter:
+- puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
++ puts((sel && !(ev->state & ShiftMask)) ? sel->otext : text);
+ if (!(ev->state & ControlMask)) {
+ cleanup();
+ exit(0);
+_AT_@ -560,11 +561,15 @@ readstdin(void)
+ die("cannot realloc %zu bytes:", size);
+ if (line[len - 1] == '
')
+ line[len - 1] = '+- items[i].text = line;
++ items[i].text = items[i].otext = line;
++ if ((line = strchr(line, ' '))) {
++ *line++ = '++ revtab ? (items[i].text = line) : (items[i].otext = line);
++ }
+ items[i].out = 0;
+ }
+ if (items)
+- items[i].text = NULL;
++ items[i].text = items[i].otext = NULL;
+ lines = MIN(lines, i);
+ }
+
+_AT_@ -710,7 +715,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ fputs("usage: dmenu [-bfivr] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]
", stderr);
+ exit(1);
+ }
+_AT_@ -733,7 +738,9 @@ main(int argc, char *argv[])
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+- } else if (i + 1 == argc)
++ } else if (!strcmp(argv[i], "-r")) /* reverse the tab separation */
++ revtab = (!revtab);
++ else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
diff --git a/tools.suckless.org/dmenu/patches/tsv-alt/index.md b/tools.suckless.org/dmenu/patches/tsv-alt/index.md
new file mode 100644
index 00000000..54fead60
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/tsv-alt/index.md
_AT_@ -0,0 +1,30 @@
+tsv alt
+=======
+
+Description
+-----------
+This patch is similar to [tsv](https://tools.suckless.org/dmenu/patches/tsv/), but differs in the following way:
+
+All text before the first tab character will be the text displayed by
+dmenu and the text that matching is performed on, while all text after
+it will be the text outputted by dmenu. Subsequent tab characters do
+not affect anything.
+
+Configuration
+-------------
+Both a config.def.h value and runtime flag (`-r`) are available to
+reverse the behavior of tab separation. Be sure to check with any other
+patches for conflicts.
+
+Notes
+-----
+This patch is incompatible with any commit before `32db2b1` (2022-09-02)
+due to said commit changing how stdin is read.
+
+Download
+--------
+* [dmenu-tsv-alt-20220919-fce06f4.diff](dmenu-tsv-alt-20220919-fce06f4.diff)
+
+Author
+------
+* yosh
Received on Tue Sep 20 2022 - 01:50:48 CEST

This archive was generated by hypermail 2.3.0 : Tue Sep 20 2022 - 02:00:51 CEST