shithub: patch

ref: b263a6de7c1759137085ba1052e51f3b5157d7de
dir: /zuke-repeatone/

View raw version
diff a786a79acfc5079761f8b3efe72142640c1e9d2c uncommitted
--- a//sys/src/cmd/audio/zuke/zuke.c
+++ b//sys/src/cmd/audio/zuke/zuke.c
@@ -89,6 +89,7 @@
 static char *cols = "AatD";
 static int colspath;
 static int *shuffle;
+static int repeatone;
 static Rectangle seekbar;
 static int seekmx, newseekmx = -1;
 static double seekoff; /* ms */
@@ -277,28 +278,32 @@
 	if(pcurplaying >= 0){
 		msec = byteswritten*1000/Bps;
 		if(dur > 0){
-			snprint(tmp, sizeof(tmp), "%s%P/%P 100%%",
+			snprint(tmp, sizeof(tmp), "%s%s%P/%P 100%%",
+				repeatone != 0 ? "¹" : "",
 				shuffle != nil ? "∫ " : "",
 				dur/1000, dur/1000);
 			w = stringwidth(f, tmp);
 			msec = MIN(msec, dur);
-			snprint(tmp, sizeof(tmp), "%s%P/%P %d%%",
+			snprint(tmp, sizeof(tmp), "%s%s%P/%P %d%%",
+				repeatone != 0 ? "¹" : "",
 				shuffle != nil ? "∫ " : "",
 				(uvlong)(newseekmx >= 0 ? seekoff : msec)/1000,
 				dur/1000, volume);
 		}else{
-			snprint(tmp, sizeof(tmp), "%s%P %d%%",
+			snprint(tmp, sizeof(tmp), "%s%s%P %d%%",
+				repeatone != 0 ? "¹" : "",
 				shuffle != nil ? "∫ " : "",
 				msec/1000, 100);
 			w = stringwidth(f, tmp);
-			snprint(tmp, sizeof(tmp), "%s%P %d%%",
+			snprint(tmp, sizeof(tmp), "%s%s%P %d%%",
+				repeatone != 0 ? "¹" : "",
 				shuffle != nil ? "∫ " : "",
 				msec/1000, volume);
 		}
 	}else{
-		snprint(tmp, sizeof(tmp), "%s%d%%", shuffle != nil ? "∫ " : "", 100);
+		snprint(tmp, sizeof(tmp), "%s%s%d%%", repeatone != 0 ? "¹" : "",shuffle != nil ? "∫ " : "", 100);
 		w = stringwidth(f, tmp);
-		snprint(tmp, sizeof(tmp), "%s%d%%", shuffle != nil ? "∫ " : "", volume);
+		snprint(tmp, sizeof(tmp), "%s%s%d%%", repeatone != 0 ? "¹" : "",shuffle != nil ? "∫ " : "", volume);
 	}
 
 	lockdisplay(display);
@@ -726,8 +731,14 @@
 
 	while(1){
 		n = ioread(io, p[1], buf, Relbufsz);
-		if(n <= 0)
+		if(n <= 0){
+			if(repeatone){
+				c = Cseekrel;
+				player->seek = -(Bps + boffset/Bps);	/* make sure */
+				goto again;
+			}
 			break;
+		}
 
 		thiscover = nil;
 		if(player->img != nil && nbrecv(player->img, &thiscover) != 0){
@@ -747,6 +758,7 @@
 					goto stop;
 			}
 			if(c == Cseekrel){
+again:
 				boffset = MAX(0, boffset + player->seek*Bps);
 				n = 0;
 				break;
@@ -1185,7 +1197,7 @@
 	Scrollwidth = MAX(14, stringwidth(f, "#"));
 	Scrollheight = MAX(16, f->height);
 	Seekthicc = Scrollheight + 2;
-	Coversz = MAX(64, stringwidth(f, "∫ 00:00:00/00:00:00 100%"));
+	Coversz = MAX(64, stringwidth(f, "¹∫ 00:00:00/00:00:00 100%"));
 	if((mctl = initmouse(nil, screen)) == nil)
 		sysfatal("initmouse: %r");
 	if((kctl = initkeyboard(nil)) == nil)
@@ -1400,6 +1412,10 @@
 				recenter();
 				full = 1;
 				break;
+			case 'r':
+				repeatone ^= 1;
+				redraw(0);
+				continue;
 			case 'c':
 			case 'p':
 			case ' ':