shithub: patch

ref: fdba1b8611216cb077271b465bf65a4e333ec413
dir: /zuke-repeatone/

View raw version
diff 1fca5f75797af9c8c78d4cd022c41b22040de29a uncommitted
--- a/sys/src/cmd/audio/zuke/zuke.c
+++ b/sys/src/cmd/audio/zuke/zuke.c
@@ -90,6 +90,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 */
@@ -395,28 +396,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);
 	}
 
 	r = back->r;
@@ -743,8 +748,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){
@@ -764,6 +775,7 @@
 					goto stop;
 			}
 			if(c == Cseekrel){
+again:
 				boffset = MAX(0, boffset + player->seek*Bps);
 				n = 0;
 				break;
@@ -1170,7 +1182,7 @@
 	f = display->defaultfont;
 	Scrollwidth = MAX(14, stringwidth(f, "#"));
 	Scrollheight = MAX(16, f->height);
-	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)
@@ -1372,6 +1384,9 @@
 			case 's':
 				toggleshuffle();
 				recenter();
+ 				break;
+ 			case 'r':
+ 				repeatone ^= 1;
 				break;
 			case 'c':
 			case 'p':