sites

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

dmenu-tsv-20201101-1a13d04.diff (1575B)


      1 From 4d58bc01c9a31cdcaad540e67e5f60c87f488b55 Mon Sep 17 00:00:00 2001
      2 From: prenev <an2qzavok@gmail.com>
      3 Date: Sun, 1 Nov 2020 15:50:10 +0300
      4 Subject: [PATCH] tab-separate input lines and only display first parts
      5 
      6 ---
      7  dmenu.c | 9 +++++++--
      8  1 file changed, 7 insertions(+), 2 deletions(-)
      9 
     10 diff --git a/dmenu.c b/dmenu.c
     11 index 65f25ce..d9e490a 100644
     12 --- a/dmenu.c
     13 +++ b/dmenu.c
     14 @@ -30,6 +30,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
     15  
     16  struct item {
     17  	char *text;
     18 +	char *stext;
     19  	struct item *left, *right;
     20  	int out;
     21  };
     22 @@ -123,7 +124,7 @@ drawitem(struct item *item, int x, int y, int w)
     23  	else
     24  		drw_setscheme(drw, scheme[SchemeNorm]);
     25  
     26 -	return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
     27 +	return drw_text(drw, x, y, w, bh, lrpad / 2, item->stext, 0);
     28  }
     29  
     30  static void
     31 @@ -165,7 +166,7 @@ drawmenu(void)
     32  		}
     33  		x += w;
     34  		for (item = curr; item != next; item = item->right)
     35 -			x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">")));
     36 +			x = drawitem(item, x, 0, MIN(TEXTW(item->stext), mw - x - TEXTW(">")));
     37  		if (next) {
     38  			w = TEXTW(">");
     39  			drw_setscheme(drw, scheme[SchemeNorm]);
     40 @@ -534,6 +535,10 @@ readstdin(void)
     41  			*p = '\0';
     42  		if (!(items[i].text = strdup(buf)))
     43  			die("cannot strdup %u bytes:", strlen(buf) + 1);
     44 +		if ((p = strchr(buf, '\t')))
     45 +			*p = '\0';
     46 +		if (!(items[i].stext = strdup(buf)))
     47 +			die("cannot strdup %u bytes:", strlen(buf) + 1);
     48  		items[i].out = 0;
     49  		drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
     50  		if (tmpmax > inputw) {
     51 -- 
     52 2.28.0
     53