Skip to content

Commit 0db14af

Browse files
author
Philip Guo
committed
bam
1 parent c2f23e0 commit 0db14af

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

PyTutorGAE/js/pytutor.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2828

2929

3030
// Massive refactoring notes:
31+
// - when you highlight breakpoints, the executed lines unhighlight :(
3132
// - test whether preseeded code and curInstr works
3233
// - test whether back button works properly
3334
// - does jsPlumb have a notion of "sets" of connectors so that we can reset a particular
@@ -652,7 +653,10 @@ ExecutionVisualizer.prototype.updateOutput = function() {
652653
}
653654

654655

655-
function highlightCodeLine(curLine, hasError, isTerminated) {
656+
function highlightCodeLine() {
657+
/* if instrLimitReached, then treat like a normal non-terminating line */
658+
var isTerminated = (!myViz.instrLimitReached && (myViz.curInstr == (totalInstrs-1)));
659+
656660
myViz.domRootD3.selectAll('#pyCodeOutputDiv td.lineNo')
657661
.attr('id', function(d) {return 'lineNo' + d.lineNumber;})
658662
.style('color', function(d)
@@ -662,7 +666,7 @@ ExecutionVisualizer.prototype.updateOutput = function() {
662666

663667
myViz.domRootD3.selectAll('#pyCodeOutputDiv td.cod')
664668
.style('background-color', function(d) {
665-
if (d.lineNumber == curLine) {
669+
if (d.lineNumber == curEntry.line) {
666670
if (hasError) {
667671
d.backgroundColor = errorColor;
668672
}
@@ -680,7 +684,7 @@ ExecutionVisualizer.prototype.updateOutput = function() {
680684
return d.backgroundColor;
681685
})
682686
.style('border-top', function(d) {
683-
if ((d.lineNumber == curLine) && !hasError && !isTerminated) {
687+
if ((d.lineNumber == curEntry.line) && !hasError && !isTerminated) {
684688
return '1px solid #F87D76';
685689
}
686690
else {
@@ -721,27 +725,25 @@ ExecutionVisualizer.prototype.updateOutput = function() {
721725

722726

723727
// smoothly scroll code display
724-
if (!isOutputLineVisible(curLine)) {
725-
scrollCodeOutputToLine(curLine);
728+
if (!isOutputLineVisible(curEntry.line)) {
729+
scrollCodeOutputToLine(curEntry.line);
726730
}
727731
}
728732

729733

734+
// calculate all lines that have been 'visited' (executed)
735+
// by execution up to (but NOT INCLUDING) this.curInstr:
736+
this.visitedLinesSet = d3.map();
737+
for (var i = 0; i < this.curInstr; i++) {
738+
if (this.curTrace[i].line) {
739+
this.visitedLinesSet.set(this.curTrace[i].line, 1);
740+
}
741+
}
742+
730743

731744
// render code output:
732745
if (curEntry.line) {
733-
// calculate all lines that have been 'visited' (executed)
734-
// by execution up to (but NOT INCLUDING) this.curInstr:
735-
this.visitedLinesSet = d3.map();
736-
for (var i = 0; i < this.curInstr; i++) {
737-
if (this.curTrace[i].line) {
738-
this.visitedLinesSet.set(this.curTrace[i].line, 1);
739-
}
740-
}
741-
742-
highlightCodeLine(curEntry.line, hasError,
743-
/* if instrLimitReached, then treat like a normal non-terminating line */
744-
(!this.instrLimitReached && (this.curInstr == (totalInstrs-1))));
746+
highlightCodeLine();
745747
}
746748

747749

0 commit comments

Comments
 (0)