Skip to content

Commit 52de77e

Browse files
authored
Merge pull request #502 from asolove/asolove/block-errors
Blocks error highlighting
2 parents 0bbdcef + 6106c24 commit 52de77e

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Then you can run
2525
```
2626
$ npm run local-install
2727
$ ln -s node_modules/pyret-lang pyret
28+
$ git submodule init
29+
$ git submodule update
2830
$ npm run build
2931
```
3032

src/web/js/output-ui.js

+30-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
return converter([74, a, b]);
4242
}
4343

44+
// Snap wants colors specified as "r,g,b(,a)" where each is [0-255]
45+
var snapConverter = $.colorspaces.converter('CIELAB', 'sRGB')
46+
function hueToSnapColor(hue) {
47+
var a = 40*Math.cos(hue);
48+
var b = 40*Math.sin(hue)
49+
return snapConverter([74, a, b]).map(x => Math.floor(x * 255)).join(",")
50+
}
51+
4452
var goldenAngle = 2.39996322972865332;
4553
var lastHue = 0;
4654

@@ -1075,16 +1083,35 @@
10751083
window.requestAnimationFrame(function() {
10761084
logger.log("highlight_anchor_hover",
10771085
{ error_id: context, anchor_id: id });
1078-
if (positions[0] !== undefined)
1079-
positions[0].hint();
1086+
1087+
if (positions[0] !== undefined) {
1088+
if(CPO.blocksIDE) {
1089+
// Blocks editor case
1090+
var snapColor = hueToSnapColor(color);
1091+
CPO.blocksIDE.flashSpriteScriptAt(
1092+
locsArray[0].dict['start-char'] + 1,
1093+
undefined,
1094+
snapColor);
1095+
} else {
1096+
// Non-Blocks editor
1097+
positions[0].hint();
1098+
}
1099+
}
10801100
emphasize(color);
10811101
});
10821102
});
10831103
anchor.on("mouseleave", function () {
10841104
logger.log("highlight_anchor_mouseleave",
10851105
{ error_id: context, anchor_id: id });
10861106
window.requestAnimationFrame(function() {
1087-
unhintLoc();
1107+
// Blocks editor case
1108+
if(CPO.blocksIDE) {
1109+
if(positions.length > 0) {
1110+
CPO.blocksIDE.unflashSpriteScripts();
1111+
}
1112+
} else {
1113+
unhintLoc();
1114+
}
10881115
demphasize(color);
10891116
});
10901117
});

0 commit comments

Comments
 (0)