sites

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

commit 8f07a40311451be6413b289a8a3fb50098cc29b7
parent 1a81284fe6bc0fe067b9890bc5336f216e906111
Author: Max Schillinger <maxschillinger@web.de>
Date:   Sat, 13 Jul 2024 21:18:45 +0200

[dmenu][patch][tsv-alt] Add patch for dmenu 5.3

Diffstat:
Atools.suckless.org/dmenu/patches/tsv-alt/dmenu-tsv-alt-5.3.diff | 135+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtools.suckless.org/dmenu/patches/tsv-alt/index.md | 6++++--
2 files changed, 139 insertions(+), 2 deletions(-)

diff --git a/tools.suckless.org/dmenu/patches/tsv-alt/dmenu-tsv-alt-5.3.diff b/tools.suckless.org/dmenu/patches/tsv-alt/dmenu-tsv-alt-5.3.diff @@ -0,0 +1,135 @@ +From 89ff978d15ff6b58e21bf871f09ceab2bf813138 Mon Sep 17 00:00:00 2001 +From: Max Schillinger <maxschillinger@web.de> +Date: Sat, 13 Jul 2024 21:06:57 +0200 +Subject: [PATCH] tsv-alt patch for dmenu 5.3 + +--- + config.def.h | 5 +++++ + dmenu.1 | 6 +++++- + dmenu.c | 26 ++++++++++++++++++-------- + 3 files changed, 28 insertions(+), 9 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1edb647..bd0fcef 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -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..e767276 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -3,7 +3,7 @@ + dmenu \- dynamic menu + .SH SYNOPSIS + .B dmenu +-.RB [ \-bfiv ] ++.RB [ \-bfirv ] + .RB [ \-l + .IR lines ] + .RB [ \-m +@@ -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 40f93e0..04bb085 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -29,6 +29,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ + + struct item { + char *text; ++ char *otext; + struct item *left, *right; + int out; + }; +@@ -104,7 +105,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); +@@ -489,7 +490,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); +@@ -548,7 +549,7 @@ paste(void) + static void + readstdin(void) + { +- char *line = NULL; ++ char *line = NULL, *tmp; + size_t i, itemsiz = 0, linesiz = 0; + ssize_t len; + +@@ -561,14 +562,21 @@ readstdin(void) + } + if (line[len - 1] == '\n') + line[len - 1] = '\0'; +- if (!(items[i].text = strdup(line))) ++ if (!(items[i].text = items[i].otext = strdup(line))) + die("strdup:"); +- ++ if ((items[i].otext = strchr(items[i].otext, '\t'))) { ++ *items[i].otext++ = '\0'; ++ if (revtab) { ++ tmp = items[i].text; ++ items[i].text = items[i].otext; ++ items[i].otext = tmp; ++ } ++ } + items[i].out = 0; + } + free(line); + if (items) +- items[i].text = NULL; ++ items[i].text = items[i].otext = NULL; + lines = MIN(lines, i); + } + +@@ -715,7 +723,7 @@ setup(void) + static void + usage(void) + { +- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ die("usage: dmenu [-bfirv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]"); + } + +@@ -737,7 +745,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 */ +-- +2.45.2 + diff --git a/tools.suckless.org/dmenu/patches/tsv-alt/index.md b/tools.suckless.org/dmenu/patches/tsv-alt/index.md @@ -24,7 +24,9 @@ due to said commit changing how stdin is read. Download -------- * [dmenu-tsv-alt-20220919-fce06f4.diff](dmenu-tsv-alt-20220919-fce06f4.diff) +* [dmenu-tsv-alt-5.3.diff](dmenu-tsv-alt-5.3.diff) -Author ------- +Authors +------- * yosh +* Max Schillinger - <maxschillinger@web.de> (5.3 version)