Skip to content

Commit fd97121

Browse files
committed
added buttons to live mode
1 parent 3822a25 commit fd97121

4 files changed

Lines changed: 46 additions & 7 deletions

File tree

‎v3/css/opt-live.css‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,24 @@
2222
padding-top: 3px;
2323
}
2424

25-
#curInstr {
26-
padding: 6px;
27-
margin: 6px auto;
25+
/* copied from pytutor.css */
26+
/* VCR control buttons for stepping through execution */
27+
#vcrControls {
28+
margin: 15px auto;
29+
/*width: 100%;*/
2830
text-align: center;
2931
}
3032

33+
#vcrControls button {
34+
margin-left: 2px;
35+
margin-right: 2px;
36+
}
37+
38+
#curInstr {
39+
margin-left: 4px;
40+
margin-right: 4px;
41+
}
42+
3143
/* keep it a fixed min height so that footer below it doesn't jiggle up
3244
and down */
3345
#frontendErrorOutput {

‎v3/js/opt-live.js‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ function updateStepLabels() {
140140
var isLastInstr = myVisualizer.curInstr === (totalInstrs-1);
141141
if (isLastInstr) {
142142
if (myVisualizer.promptForUserInput || myVisualizer.promptForMouseInput) {
143-
$("#curInstr").html('<font color="' + brightRed + '">input/raw_input not supported in live editor</font>');
143+
$("#curInstr").html('<font color="' + brightRed + '">input()/raw_input() not supported in live mode; use the <a href="visualize.html" target="_blank">regular visualizer</a></font>');
144144
} else if (myVisualizer.instrLimitReached) {
145145
$("#curInstr").html("Instruction limit reached (" + String(totalInstrs-1) + " steps)");
146146
} else {
147-
$("#curInstr").html("Program terminated (" + String(totalInstrs-1) + " steps)");
147+
$("#curInstr").html("Program terminated");
148148
}
149149
} else {
150150
$("#curInstr").html("Step " + String(myVisualizer.curInstr + 1) + " of " + String(totalInstrs-1));
@@ -284,6 +284,8 @@ function optliveFinishSuccessfulExecution() {
284284
uh.push([args.myViz.curInstr, curTs]);
285285
}
286286

287+
$('#executionSlider').slider('value', myVisualizer.curInstr); // update slider
288+
287289
return [false];
288290
}
289291
);
@@ -553,4 +555,21 @@ $(document).ready(function() {
553555

554556
setAceMode(); // set syntax highlighting at the end
555557
$("#pyOutputPane").show();
558+
559+
560+
$("#jmpFirstInstr").click(function() {
561+
if (myVisualizer) {myVisualizer.renderStep(0);}
562+
});
563+
564+
$("#jmpLastInstr").click(function() {
565+
if (myVisualizer) {myVisualizer.renderStep(myVisualizer.curTrace.length - 1);}
566+
});
567+
568+
$("#jmpStepBack").click(function() {
569+
if (myVisualizer) {myVisualizer.stepBack();}
570+
});
571+
572+
$("#jmpStepFwd").click(function() {
573+
if (myVisualizer) {myVisualizer.stepForward();}
574+
});
556575
});

‎v3/js/pytutor.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function ExecutionVisualizer(domRootID, dat, params) {
242242
// initialize in renderPyCodeOutput()
243243
this.codeOutputLines = null;
244244
this.breakpoints = null; // set of execution points to set as breakpoints
245-
this.sortedBreakpointsList = null; // sorted and synced with breakpointLines
245+
this.sortedBreakpointsList = []; // sorted and synced with breakpointLines
246246

247247
this.classAttrsHidden = {}; // kludgy hack for 'show/hide attributes' for class objects
248248

‎v3/live.html‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@
8989
<div id="codeInputPane"></div>
9090
<div id="legendDiv"></div>
9191
<div id="executionSlider" style="margin-top: 10px;"></div>
92-
<div id="curInstr"></div>
92+
93+
<div id="vcrControls">
94+
<button id="jmpFirstInstr", type="button">&lt;&lt; First</button>
95+
<button id="jmpStepBack", type="button">&lt; Back</button>
96+
<span id="curInstr"></span>
97+
<button id="jmpStepFwd", type="button">Forward &gt;</button>
98+
<button id="jmpLastInstr", type="button">Last &gt;&gt;</button>
99+
</div>
100+
93101
<div id="frontendErrorOutput"></div>
94102
</div>
95103
</td>

0 commit comments

Comments
 (0)