@@ -396,6 +396,7 @@ ExecutionVisualizer.prototype.render = function() {
396396 <div id="pyCodeOutputDiv"/>\
397397 <div id="editCodeLinkDiv"><a id="editBtn">Edit code</a></div>\
398398 <div id="executionSlider"/>\
399+ <div id="executionSliderFooter"/>\
399400 <div id="vcrControls">\
400401 <button id="jmpFirstInstr", type="button"><< First</button>\
401402 <button id="jmpStepBack", type="button">< Back</button>\
@@ -640,6 +641,7 @@ ExecutionVisualizer.prototype.render = function() {
640641 myViz . domRoot . find ( "#pyStdout" ) . css ( "width" , $ ( this ) . width ( ) - 20 /* wee tweaks */ ) ;
641642
642643 myViz . domRoot . find ( "#codeDisplayDiv" ) . css ( "height" , "auto" ) ; // redetermine height if necessary
644+ myViz . renderSliderBreakpoints ( ) ; // update breakpoint display accordingly on resize
643645 if ( myViz . params . updateOutputCallback ) // report size change
644646 myViz . params . updateOutputCallback ( this ) ;
645647 } } ) ;
@@ -1103,6 +1105,42 @@ ExecutionVisualizer.prototype.stepBack = function() {
11031105}
11041106
11051107
1108+ ExecutionVisualizer . prototype . renderSliderBreakpoints = function ( ) {
1109+ var myViz = this ; // to prevent confusion of 'this' inside of nested functions
1110+
1111+ myViz . domRoot . find ( "#executionSliderFooter" ) . empty ( ) ;
1112+ var w = myViz . domRoot . find ( '#executionSlider' ) . width ( ) ;
1113+
1114+ // I originally didn't want to delete and re-create this overlay every time,
1115+ // but if I don't do so, there are weird flickering artifacts with clearing
1116+ // the SVG container; so it's best to just delete and re-create the container each time
1117+ var sliderOverlay = myViz . domRootD3 . select ( '#executionSliderFooter' )
1118+ . append ( 'svg' )
1119+ . attr ( 'id' , 'sliderOverlay' )
1120+ . attr ( 'width' , w )
1121+ . attr ( 'height' , 12 ) ;
1122+
1123+ var xrange = d3 . scale . linear ( )
1124+ . domain ( [ 0 , myViz . curTrace . length - 1 ] )
1125+ . range ( [ 0 , w ] ) ;
1126+
1127+ sliderOverlay . selectAll ( 'rect' )
1128+ . data ( myViz . sortedBreakpointsList )
1129+ . enter ( ) . append ( 'rect' )
1130+ . attr ( 'x' , function ( d , i ) {
1131+ // make edge case of 0 look decent:
1132+ return ( d === 0 ) ? 0 : xrange ( d ) - 2 ;
1133+ } )
1134+ . attr ( 'y' , 0 )
1135+ . attr ( 'width' , 2 )
1136+ . attr ( 'height' , 12 )
1137+ . style ( 'fill' , function ( d ) {
1138+ return breakpointColor ;
1139+ } ) ;
1140+ }
1141+
1142+
1143+
11061144ExecutionVisualizer . prototype . renderPyCodeOutput = function ( ) {
11071145 var myViz = this ; // to prevent confusion of 'this' inside of nested functions
11081146
@@ -1119,48 +1157,6 @@ ExecutionVisualizer.prototype.renderPyCodeOutput = function() {
11191157 // 'breakpointHere' - has a breakpoint been set here?
11201158 this . codeOutputLines = [ ] ;
11211159
1122-
1123- function renderSliderBreakpoints ( ) {
1124- myViz . domRoot . find ( "#executionSliderFooter" ) . empty ( ) ;
1125-
1126- // I originally didn't want to delete and re-create this overlay every time,
1127- // but if I don't do so, there are weird flickering artifacts with clearing
1128- // the SVG container; so it's best to just delete and re-create the container each time
1129- var sliderOverlay = myViz . domRootD3 . select ( '#executionSliderFooter' )
1130- . append ( 'svg' )
1131- . attr ( 'id' , 'sliderOverlay' )
1132- . attr ( 'width' , myViz . domRoot . find ( '#executionSlider' ) . width ( ) )
1133- . attr ( 'height' , 12 ) ;
1134-
1135- var xrange = d3 . scale . linear ( )
1136- . domain ( [ 0 , myViz . curTrace . length - 1 ] )
1137- . range ( [ 0 , myViz . domRoot . find ( '#executionSlider' ) . width ( ) ] ) ;
1138-
1139- sliderOverlay . selectAll ( 'rect' )
1140- . data ( myViz . sortedBreakpointsList )
1141- . enter ( ) . append ( 'rect' )
1142- . attr ( 'x' , function ( d , i ) {
1143- // make the edge cases look decent
1144- if ( d == 0 ) {
1145- return 0 ;
1146- }
1147- else {
1148- return xrange ( d ) - 3 ;
1149- }
1150- } )
1151- . attr ( 'y' , 0 )
1152- . attr ( 'width' , 2 )
1153- . attr ( 'height' , 12 )
1154- . style ( 'fill' , function ( d ) {
1155- if ( myViz . hoverBreakpoints . has ( d ) ) {
1156- return hoverBreakpointColor ;
1157- }
1158- else {
1159- return breakpointColor ;
1160- }
1161- } ) ;
1162- }
1163-
11641160 function _getSortedBreakpointsList ( ) {
11651161 var ret = [ ] ;
11661162 myViz . breakpoints . forEach ( function ( k , v ) {
@@ -1184,65 +1180,20 @@ ExecutionVisualizer.prototype.renderPyCodeOutput = function() {
11841180 myViz . sortedBreakpointsList = _getSortedBreakpointsList ( ) ;
11851181 }
11861182
1187-
1188- function setHoverBreakpoint ( t ) {
1189- var exePts = d3 . select ( t ) . datum ( ) . executionPoints ;
1190-
1191- // don't do anything if exePts is empty
1192- // (i.e., this line was never executed)
1193- if ( ! exePts || exePts . length == 0 ) {
1194- return ;
1195- }
1196-
1197- myViz . hoverBreakpoints = d3 . map ( ) ;
1198- $ . each ( exePts , function ( i , ep ) {
1199- // don't add redundant entries
1200- if ( ! myViz . breakpoints . has ( ep ) ) {
1201- myViz . hoverBreakpoints . set ( ep , 1 ) ;
1202- }
1203- } ) ;
1204-
1205- addToBreakpoints ( exePts ) ;
1206- renderSliderBreakpoints ( ) ;
1207- }
1208-
1209-
1210- function setBreakpoint ( t ) {
1211- var exePts = d3 . select ( t ) . datum ( ) . executionPoints ;
1212-
1213- // don't do anything if exePts is empty
1214- // (i.e., this line was never executed)
1215- if ( ! exePts || exePts . length == 0 ) {
1216- return ;
1217- }
1218-
1219- addToBreakpoints ( exePts ) ;
1220-
1221- // remove from hoverBreakpoints so that slider display immediately changes color
1222- $ . each ( exePts , function ( i , ep ) {
1223- myViz . hoverBreakpoints . remove ( ep ) ;
1224- } ) ;
1225-
1183+ function setBreakpoint ( t , d ) {
1184+ addToBreakpoints ( d . executionPoints ) ;
12261185 d3 . select ( t . parentNode ) . select ( 'td.lineNo' ) . style ( 'color' , breakpointColor ) ;
12271186 d3 . select ( t . parentNode ) . select ( 'td.lineNo' ) . style ( 'font-weight' , 'bold' ) ;
1228-
1229- renderSliderBreakpoints ( ) ;
1187+ d3 . select ( t . parentNode ) . select ( 'td.cod' ) . style ( 'color' , breakpointColor ) ;
1188+ myViz . renderSliderBreakpoints ( ) ;
12301189 }
12311190
1232- function unsetBreakpoint ( t ) {
1233- var exePts = d3 . select ( t ) . datum ( ) . executionPoints ;
1234-
1235- // don't do anything if exePts is empty
1236- // (i.e., this line was never executed)
1237- if ( ! exePts || exePts . length == 0 ) {
1238- return ;
1239- }
1240-
1241- removeFromBreakpoints ( exePts ) ;
1242-
1243- var lineNo = d3 . select ( t ) . datum ( ) . lineNumber ;
1244-
1245- renderSliderBreakpoints ( ) ;
1191+ function unsetBreakpoint ( t , d ) {
1192+ removeFromBreakpoints ( d . executionPoints ) ;
1193+ d3 . select ( t . parentNode ) . select ( 'td.lineNo' ) . style ( 'color' , '' ) ;
1194+ d3 . select ( t . parentNode ) . select ( 'td.lineNo' ) . style ( 'font-weight' , '' ) ;
1195+ d3 . select ( t . parentNode ) . select ( 'td.cod' ) . style ( 'color' , '' ) ;
1196+ myViz . renderSliderBreakpoints ( ) ;
12461197 }
12471198
12481199 var lines = this . curInputCode . split ( '\n' ) ;
@@ -1340,47 +1291,32 @@ ExecutionVisualizer.prototype.renderPyCodeOutput = function() {
13401291 }
13411292
13421293 // 2012-09-05: Disable breakpoints for now to simplify UX
1343- /*
1344- if (!this.params.embeddedMode) {
1345- codeOutputD3.style('cursor', function(d, i) {return 'pointer'})
1346- .on('mouseover', function() {
1347- setHoverBreakpoint(this);
1348- })
1349- .on('mouseout', function() {
1350- myViz.hoverBreakpoints = d3.map();
1351-
1352- var breakpointHere = d3.select(this).datum().breakpointHere;
1353-
1354- if (!breakpointHere) {
1355- unsetBreakpoint(this);
1294+ // 2016-05-01: Revive breakpoint functionality
1295+ codeOutputD3
1296+ . style ( 'cursor' , function ( d , i ) {
1297+ // don't do anything if exePts empty (i.e., this line was never executed)
1298+ var exePts = d . executionPoints ;
1299+ if ( ! exePts || exePts . length == 0 ) {
1300+ return ;
1301+ } else {
1302+ return 'pointer'
13561303 }
1357-
1358- renderSliderBreakpoints(); // get rid of hover breakpoint colors
13591304 } )
1360- .on('mousedown', function() {
1361- // don't do anything if exePts is empty
1362- // (i.e., this line was never executed)
1363- var exePts = d3.select(this).datum().executionPoints;
1305+ . on ( 'click' , function ( d , i ) {
1306+ // don't do anything if exePts empty (i.e., this line was never executed)
1307+ var exePts = d . executionPoints ;
13641308 if ( ! exePts || exePts . length == 0 ) {
13651309 return ;
13661310 }
13671311
1368- // toggle breakpoint
1369- d3.select(this).datum().breakpointHere = !d3.select(this).datum().breakpointHere;
1370-
1371- var breakpointHere = d3.select(this).datum().breakpointHere;
1372- if (breakpointHere) {
1373- setBreakpoint(this);
1312+ d . breakpointHere = ! d . breakpointHere ; // toggle
1313+ if ( d . breakpointHere ) {
1314+ setBreakpoint ( this , d ) ;
13741315 }
13751316 else {
1376- unsetBreakpoint(this);
1317+ unsetBreakpoint ( this , d ) ;
13771318 }
13781319 } ) ;
1379-
1380- renderSliderBreakpoints(); // renders breakpoints written in as code comments
1381- }
1382- */
1383-
13841320}
13851321
13861322
@@ -3656,7 +3592,6 @@ var connectorInactiveColor = '#cccccc';
36563592var errorColor = brightRed ;
36573593
36583594var breakpointColor = brightRed ;
3659- var hoverBreakpointColor = connectorBaseColor ;
36603595
36613596
36623597// Unicode arrow types: '\u21d2', '\u21f0', '\u2907'
0 commit comments