Skip to content

Commit 04fee87

Browse files
author
Philip Guo
committed
highlight function return site too
1 parent f08864a commit 04fee87

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎v3/js/pytutor.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,12 @@ ExecutionVisualizer.prototype.updateOutput = function() {
832832
funcCallSiteLine = prevEntry.line;
833833
}
834834

835+
var funcReturnSiteLine = null;
836+
// highlight the return site for a 'return' instruction
837+
if (curEntry.event == 'return' && myViz.curInstr < myViz.curTrace.length - 1) {
838+
var nextEntry = myViz.curTrace[myViz.curInstr + 1];
839+
funcReturnSiteLine = nextEntry.line;
840+
}
835841

836842
myViz.domRootD3.selectAll('#pyCodeOutputDiv td.lineNo')
837843
.attr('id', function(d) {return 'lineNo' + d.lineNumber;})
@@ -855,6 +861,9 @@ ExecutionVisualizer.prototype.updateOutput = function() {
855861
else if (d.lineNumber == funcCallSiteLine) {
856862
d.backgroundColor = highlightedLineColor;
857863
}
864+
else if (d.lineNumber == funcReturnSiteLine) {
865+
d.backgroundColor = highlightedLineLighterColor;
866+
}
858867
else {
859868
d.backgroundColor = null;
860869
}
@@ -1985,6 +1994,8 @@ ExecutionVisualizer.prototype.redrawConnectors = function() {
19851994
var highlightedLineColor = '#e4faeb';
19861995
var highlightedLineBorderColor = '#005583';
19871996

1997+
var highlightedLineLighterColor = '#effff4';
1998+
19881999
var visitedLineColor = highlightedLineBorderColor;
19892000

19902001
var funcCallLineColor = '#a2eebd';

0 commit comments

Comments
 (0)