shithub: zuke

Download patch

ref: 22a548c0ca2d9531706c7aa3c8b9fd980bc1d3e4
parent: 58d8c8fa11e2249d5fa145e182153da85ff44ed6
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Sun Feb 21 17:46:38 EST 2016

zuke: display artist/album/title as three columns

--- a/zuke.c
+++ b/zuke.c
@@ -45,20 +45,32 @@
 static void
 redraw(Image *screen, int new)
 {
-	char tmp[256];
+	Image *col;
 	Point p, sp;
 	Rectangle sel, r;
-	int i;
+	int i, colwidth;
 
 	if(new && getwindow(display, Refnone) < 0)
 		sysfatal("getwindow: %r");
 	else
 		draw(screen, screen->r, cola, nil, ZP);
-	sp.x = sp.y = 0;
 
+	scrollsz = Dy(screen->r) / f->height - 1;
+	colwidth = (Dx(screen->r) - 8) / 3; /* 3 = artist, album, title */
+
+	p.x = sp.x = screen->r.min.x + colwidth + 4;
+	p.y = 0;
+	sp.y = screen->r.max.y;
+	line(screen, p, sp, Endsquare, Endsquare, 0, colb, ZP);
+
+	p.x = sp.x = screen->r.min.x + colwidth + 8 + colwidth + 4;
+	p.y = 0;
+	sp.y = screen->r.max.y;
+	line(screen, p, sp, Endsquare, Endsquare, 0, colb, ZP);
+
+	sp.x = sp.y = 0;
 	p.x = screen->r.min.x + 2;
 	p.y = screen->r.min.y + 2;
-	scrollsz = Dy(screen->r) / f->height - 1;
 
 	for(i = scroll; i < plnum; i++){
 		if(p.y > screen->r.max.y)
@@ -73,16 +85,36 @@
 			line(screen, left, right, 0, 0, 0, colb, sp);
 		}
 
-		snprint(tmp, sizeof(tmp), "%s  -  %s  -  %s", pl[i].artist[0], pl[i].album, pl[i].title);
 		if(pcur == i){
+			col = cola;
 			sel = screen->r;
 			sel.min.y = p.y;
 			sel.max.y = p.y + f->height;
 			draw(screen, sel, colb, nil, ZP);
-			string(screen, p, cola, sp, f, tmp);
+		}else{
+			col = colb;
 		}
-		else
-			string(screen, p, colb, sp, f, tmp);
+
+		sel = screen->r;
+		r = screen->r;
+
+		p.x = screen->r.min.x + 2;
+		sel.max.x = p.x + colwidth;
+		replclipr(screen, 0, sel);
+		string(screen, p, col, sp, f, pl[i].artist[0]);
+		p.x += colwidth + 8;
+		sel.min.x = p.x;
+		sel.max.x = p.x + colwidth;
+		replclipr(screen, 0, sel);
+		string(screen, p, col, sp, f, pl[i].album);
+		p.x += colwidth + 8;
+		sel.min.x = p.x;
+		sel.max.x = p.x + colwidth;
+		replclipr(screen, 0, sel);
+		string(screen, p, col, sp, f, pl[i].title);
+
+		replclipr(screen, 0, r);
+
 		p.y += f->height;
 	}