@@ -104,7 +104,7 @@ function processTrace(traceData) {
104104 updateOutput ( ) ;
105105}
106106
107- function highlightCodeLine ( curLine , visitedLinesSet , hasError ) {
107+ function highlightCodeLine ( curLine , visitedLinesSet , hasError , isTerminated ) {
108108 var tbl = $ ( "table#pyCodeOutput" ) ;
109109
110110 // reset then set:
@@ -121,14 +121,17 @@ function highlightCodeLine(curLine, visitedLinesSet, hasError) {
121121 lineBgCol = errorColor ;
122122 }
123123
124+ // put a default white top border to keep space usage consistent
124125 tbl . find ( 'td.cod' ) . css ( 'border-top' , '1px solid #ffffff' ) ;
125126
126- if ( ! hasError ) {
127- tbl . find ( 'td.cod:eq(' + ( curLine - 1 ) + ')' ) . css ( 'border-top' , '1px solid #F87D76' )
127+ if ( ! hasError && ! isTerminated ) {
128+ tbl . find ( 'td.cod:eq(' + ( curLine - 1 ) + ')' ) . css ( 'border-top' , '1px solid #F87D76' ) ;
128129 }
129130
130131 tbl . find ( 'td.cod' ) . css ( 'background-color' , '' ) ;
131- tbl . find ( 'td.cod:eq(' + ( curLine - 1 ) + ')' ) . css ( 'background-color' , lineBgCol ) ;
132+ if ( ! isTerminated || hasError ) {
133+ tbl . find ( 'td.cod:eq(' + ( curLine - 1 ) + ')' ) . css ( 'background-color' , lineBgCol ) ;
134+ }
132135}
133136
134137// relies on curTrace and curInstr globals
@@ -138,8 +141,15 @@ function updateOutput() {
138141
139142 // render VCR controls:
140143 var totalInstrs = curTrace . length ;
141- $ ( "#vcrControls #curInstr" ) . html ( curInstr + 1 ) ;
142- $ ( "#vcrControls #totalInstrs" ) . html ( totalInstrs ) ;
144+
145+ // to be user-friendly, if we're on the LAST instruction, print "Program has terminated"
146+ // and DON'T highlight any lines of code in the code display
147+ if ( curInstr == ( totalInstrs - 1 ) ) {
148+ $ ( "#vcrControls #curInstr" ) . html ( "Program has terminated" ) ;
149+ }
150+ else {
151+ $ ( "#vcrControls #curInstr" ) . html ( "About to do step " + ( curInstr + 1 ) + " of " + ( totalInstrs - 1 ) ) ;
152+ }
143153
144154 $ ( "#vcrControls #jmpFirstInstr" ) . attr ( "disabled" , false ) ;
145155 $ ( "#vcrControls #jmpStepBack" ) . attr ( "disabled" , false ) ;
@@ -150,7 +160,7 @@ function updateOutput() {
150160 $ ( "#vcrControls #jmpFirstInstr" ) . attr ( "disabled" , true ) ;
151161 $ ( "#vcrControls #jmpStepBack" ) . attr ( "disabled" , true ) ;
152162 }
153- if ( curInstr == ( totalInstrs - 1 ) ) {
163+ if ( curInstr == ( totalInstrs - 1 ) ) {
154164 $ ( "#vcrControls #jmpLastInstr" ) . attr ( "disabled" , true ) ;
155165 $ ( "#vcrControls #jmpStepFwd" ) . attr ( "disabled" , true ) ;
156166 }
@@ -193,7 +203,7 @@ function updateOutput() {
193203 visitedLinesSet [ curTrace [ i ] . line ] = true ;
194204 }
195205 }
196- highlightCodeLine ( curEntry . line , visitedLinesSet , hasError ) ;
206+ highlightCodeLine ( curEntry . line , visitedLinesSet , hasError , ( curInstr == ( totalInstrs - 1 ) ) ) ;
197207 }
198208
199209
0 commit comments