Skip to content

Commit f08864a

Browse files
author
Philip Guo
committed
highlight function call site
1 parent 1c50dfd commit f08864a

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎v3/js/pytutor.js‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,15 @@ ExecutionVisualizer.prototype.updateOutput = function() {
824824
}
825825
}
826826

827+
var funcCallSiteLine = null;
828+
829+
// highlight the call site for a 'call' instruction
830+
if (curEntry.event == 'call' && myViz.curInstr > 0) {
831+
var prevEntry = myViz.curTrace[myViz.curInstr - 1];
832+
funcCallSiteLine = prevEntry.line;
833+
}
834+
835+
827836
myViz.domRootD3.selectAll('#pyCodeOutputDiv td.lineNo')
828837
.attr('id', function(d) {return 'lineNo' + d.lineNumber;})
829838
.style('color', function(d)
@@ -839,7 +848,12 @@ ExecutionVisualizer.prototype.updateOutput = function() {
839848
myViz.domRootD3.selectAll('#pyCodeOutputDiv td.cod')
840849
.style('background-color', function(d) {
841850
if (d.lineNumber == curEntry.line) {
842-
d.backgroundColor = hasError ? errorColor : highlightedLineColor;
851+
d.backgroundColor = hasError ? errorColor :
852+
(funcCallSiteLine ? funcCallLineColor :
853+
highlightedLineColor);
854+
}
855+
else if (d.lineNumber == funcCallSiteLine) {
856+
d.backgroundColor = highlightedLineColor;
843857
}
844858
else {
845859
d.backgroundColor = null;
@@ -1973,7 +1987,7 @@ var highlightedLineBorderColor = '#005583';
19731987

19741988
var visitedLineColor = highlightedLineBorderColor;
19751989

1976-
var terminatedLineColor = '#a2eebd';
1990+
var funcCallLineColor = '#a2eebd';
19771991

19781992
var darkRed = '#d03939';
19791993

0 commit comments

Comments
 (0)