From c8b3826fe0be52b70339345e98a017093b96fd06 Mon Sep 17 00:00:00 2001
From: slevy <slevy>
Date: Mon, 12 Apr 2004 17:00:46 +0000
Subject: [PATCH] Add usage message to parti_play(). Add "wait" option -- wait
 until end of "play".

---
 src/partiviewc.cc | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/partiviewc.cc b/src/partiviewc.cc
index fd6f481..98e975b 100644
--- a/src/partiviewc.cc
+++ b/src/partiviewc.cc
@@ -1077,6 +1077,7 @@ void parti_play( const char *rate ) {
 
   struct wfpath *path = &ppui.path;
   int playnow = 1;
+  int awaitdone = 0;
 
   if(rate != NULL) {
     char *ep;
@@ -1086,7 +1087,17 @@ void parti_play( const char *rate ) {
     else if(strchr(ep, 'k')) ppui.playloop = -1; /* rock */
     else if(strchr(ep, 'f') || strchr(ep, 'e')) ppui.playevery = 1;
     else if(strchr(ep, 'r') || strchr(ep, 't')) ppui.playevery = 0;
-    if(ep != rate) {
+    if(strstr(rate, "wait"))
+	awaitdone = 1;
+
+    if(ep == rate) {
+	/* No leading number -- did we get just "-" or "-?" or "-help"? */
+	if(0==strcmp(rate, "-") || strchr(rate, '?') || strchr(rate, 'h')) {
+	    msg("Usage: play [rate][s][l|k][f|r][wait]  e.g.  \"play\" or \"play 30\" or \"play 10kf wait\"");
+	    msg("   rate  frames/sec; [s]et speed, don't play now; [l]oop/roc[k]");
+	    msg("         play every [f]rame/skip to maintain [r]ate;  [wait] until done");
+	    return;
+	}
 	if(sp == 0) playnow = 0;
 	else ppui.playspeed = sp;
     }
@@ -1117,6 +1128,14 @@ void parti_play( const char *rate ) {
     ppui.play->value( ppui.playing );
     ppui.play->redraw();
   }
+
+  if(awaitdone) {
+      /* Don't let this command return until the "play" is finished, or at least stopped.
+       * But allow user input along the way.
+       */
+      while(ppui.playing)
+	  Fl::wait(0.1);
+  }
 }
 
 
-- 
GitLab