add history
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Sun, 14 Jan 2024 11:24:37 +0000 (12:24 +0100)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Sun, 14 Jan 2024 11:24:37 +0000 (12:24 +0100)
library/template.scd
temp.scd

index 00b2ebe..cfa05f4 100644 (file)
@@ -1,3 +1,7 @@
+// history
+
+History.clear.end;
+History.start;
 
 // init
 
@@ -111,4 +115,10 @@ Pdef(\fagi, Pbind(*[
 )
 
 Pdef(\fagi).play;
-Pdef(\fagi).stop;
\ No newline at end of file
+Pdef(\fagi).stop;
+
+// finishing
+
+History.end;
+History.saveCS(PathName(thisProcess.nowExecutingPath).parentPath+/+"history-cs.scd");
+History.saveStory(PathName(thisProcess.nowExecutingPath).parentPath+/+"history-story.scd");
\ No newline at end of file
index b5af972..abef113 100644 (file)
--- a/temp.scd
+++ b/temp.scd
@@ -227,4 +227,94 @@ TempoClock.tempo = 1.5;
 Pdef(\fagi1).play;
 Pdef(\fagi2).play;
 Pdef(\fagi1).stop;
-Pdef(\fagi2).stop;
\ No newline at end of file
+Pdef(\fagi2).stop;
+
+// history
+
+(
+// create a short history
+h = History([
+    [0, \me, "1+2"],
+    [1, \me, "3+5"], [1.234, \you, "q = q ? ();"],
+    [3, \they, "\"The story\".speak"]
+]);
+// make a gui for it
+g = h.makeWin(0@20);
+// find or make a text window for code line display
+// (called 'doc' because that was a Document in pre-Qt times)
+g.findDoc;
+// post line at index 2 in h.lines in doc window
+g.postDoc(2);
+)
+
+h.document;
+
+// show how filtering works:
+
+g.filtering; // is filter on?
+g.filterOff; // shorthand for off
+g.filterOn;  // and on
+
+// filtering looks for lines by author key(s)
+// and strings in the code lines:
+g.filters.postcs;
+
+g.setKeyFilter(\all);
+g.setKeyFilter(\me);
+g.setStrFilter("");
+g.setStrFilter("3");
+
+g.filters.postcs;
+
+// internal state cached in the HistoryGui:
+g.filteredIndices;
+g.filteredShorts;
+
+//
+
+History.clear.end;     // if needed, clear History first
+History.start;         // starts recording, opens log file
+
+// execute these lines one by one, as a little performance history
+1 + 2;
+p = ProxySpace.push(s.boot);
+~a = {Dust.ar([1,1] * 30 ) * 0.3 };
+~a.play;
+~a.end(3);
+
+History.started; // is it on now?
+
+// stops recording history and ends logging.
+History.end;
+History.started;
+
+History.document;      // creates a document with current history
+History.showLogFolder; // opens the folder where logs are written.
+History.showLogFile;   // opens the current log file as it was written.
+
+
+// make a gui window, to access code history lines at will,
+// e.g. for code reuse in performance, adaptation, sharing, etc:
+g = History.makeWin;
+// specify left-bottom position, and number of lines in textview
+g = History.makeWin(0@20, 5);
+
+// play back the recorded history line by line
+History.play(0);
+
+
+// history can even record and play back stops with CmdPeriod.
+// run these lines one at a time:
+History.clear.start;
+1 + 2;
+2 + 3;
+s.boot;
+(dur: inf).play;
+
+CmdPeriod.run; // or hit the Stop key command, Cmd-., or ctrl-.
+3 + 4; // continue recording into history
+4 + 5;
+History.end;
+
+// Replays history, including a CmdPeriod, and keeps replaying history.
+History.play;
\ No newline at end of file