[wiki] [sites] dmenu patch that only displays lines up to first tab || prenev

From: <git_AT_suckless.org>
Date: Sun, 01 Nov 2020 14:10:47 +0100

commit 2aa855189ac70f60149ae13a3d0767f62ebdf239
Author: prenev <an2qzavok_AT_gmail.com>
Date: Sun Nov 1 16:06:57 2020 +0300

    dmenu patch that only displays lines up to first tab

diff --git a/tools.suckless.org/dmenu/patches/tsv/dmenu-tsv-20201101-1a13d04.diff b/tools.suckless.org/dmenu/patches/tsv/dmenu-tsv-20201101-1a13d04.diff
new file mode 100644
index 00000000..47828611
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/tsv/dmenu-tsv-20201101-1a13d04.diff
_AT_@ -0,0 +1,53 @@
+From 4d58bc01c9a31cdcaad540e67e5f60c87f488b55 Mon Sep 17 00:00:00 2001
+From: prenev <an2qzavok_AT_gmail.com>
+Date: Sun, 1 Nov 2020 15:50:10 +0300
+Subject: [PATCH] tab-separate input lines and only display first parts
+
+---
+ dmenu.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/dmenu.c b/dmenu.c
+index 65f25ce..d9e490a 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -30,6 +30,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+
+ struct item {
+ char *text;
++ char *stext;
+ struct item *left, *right;
+ int out;
+ };
+_AT_@ -123,7 +124,7 @@ drawitem(struct item *item, int x, int y, int w)
+ else
+ drw_setscheme(drw, scheme[SchemeNorm]);
+
+- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ return drw_text(drw, x, y, w, bh, lrpad / 2, item->stext, 0);
+ }
+
+ static void
+_AT_@ -165,7 +166,7 @@ drawmenu(void)
+ }
+ x += w;
+ for (item = curr; item != next; item = item->right)
+- x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">")));
++ x = drawitem(item, x, 0, MIN(TEXTW(item->stext), mw - x - TEXTW(">")));
+ if (next) {
+ w = TEXTW(">");
+ drw_setscheme(drw, scheme[SchemeNorm]);
+_AT_@ -534,6 +535,10 @@ readstdin(void)
+ *p = '+ if (!(items[i].text = strdup(buf)))
+ die("cannot strdup %u bytes:", strlen(buf) + 1);
++ if ((p = strchr(buf, ' ')))
++ *p = '++ if (!(items[i].stext = strdup(buf)))
++ die("cannot strdup %u bytes:", strlen(buf) + 1);
+ items[i].out = 0;
+ drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
+ if (tmpmax > inputw) {
+--
+2.28.0
+
diff --git a/tools.suckless.org/dmenu/patches/tsv/index.md b/tools.suckless.org/dmenu/patches/tsv/index.md
new file mode 100644
index 00000000..cde748fe
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/tsv/index.md
_AT_@ -0,0 +1,17 @@
+tsv
+====
+With this patch dmenu will split input lines at first tab character and
+only display first part, but it will perform matching on and output full
+lines as usual.
+
+This can be useful if you want to separate data and representation, for
+example, a music player wrapper can display only a track title to
+user, but still supply full filename to underlying script.
+
+Download
+--------
+* [dmenu-tsv-20201101-1a13d04.diff](dmenu-tsv-20201101-1a13d04.diff)
+
+Author
+------
+* Pavel Renev <an2qzavok_AT_gmail.com>
Received on Sun Nov 01 2020 - 14:10:47 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 01 2020 - 14:12:43 CET