@@ -73,7 +73,8 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
7373// dat is data returned by the Python Tutor backend consisting of two fields:
7474// code - string of executed code
7575// trace - a full execution trace
76- // params contains optional parameters, such as:
76+ //
77+ // params is an object containing optional parameters, such as:
7778// jumpToEnd - if non-null, jump to the very end of execution
7879// startingInstruction - the (zero-indexed) execution point to display upon rendering
7980// hideOutput - hide "Program output" display
@@ -99,6 +100,8 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
99100// (else place side-by-side)
100101// executeCodeWithRawInputFunc - function to call when you want to re-execute the given program
101102// with some new user input (somewhat hacky!)
103+ // highlightLines - highlight current and previously executed lines (default: false)
104+ // arrowLines - draw arrows pointing to current and previously executed lines (default: true)
102105function ExecutionVisualizer ( domRootID , dat , params ) {
103106 this . curInputCode = dat . code . rtrim ( ) ; // kill trailing spaces
104107 this . curTrace = dat . trace ;
@@ -135,6 +138,28 @@ function ExecutionVisualizer(domRootID, dat, params) {
135138 this . params = { } ; // make it an empty object by default
136139 }
137140
141+ var arrowLinesDef = ( this . params . arrowLines !== undefined ) ;
142+ var highlightLinesDef = ( this . params . highlightLines !== undefined ) ;
143+
144+ if ( ! arrowLinesDef && ! highlightLinesDef ) {
145+ // neither is set
146+ this . params . highlightLines = false ;
147+ this . params . arrowLines = true ;
148+ }
149+ else if ( arrowLinesDef && highlightLinesDef ) {
150+ // both are set, so just use their set values
151+ }
152+ else if ( arrowLinesDef ) {
153+ // only arrowLines set
154+ this . params . highlightLines = ! ( this . params . arrowLines ) ;
155+ }
156+ else {
157+ // only highlightLines set
158+ this . params . arrowLines = ! ( this . params . highlightLines ) ;
159+ }
160+
161+ // David's original logic ...
162+ /*
138163 if (!this.params.arrowLines && !this.params.highlightLines) {
139164 this.params.highlightLines = false;
140165 this.params.arrowLines = true;
@@ -151,6 +176,7 @@ function ExecutionVisualizer(domRootID, dat, params) {
151176 this.params.arrowLines = (this.params.arrowLines == true);
152177 this.params.highlightLines = (this.params.highlightLines == true);
153178 }
179+ */
154180
155181 // needs to be unique!
156182 this . visualizerID = curVisualizerID ;
0 commit comments