MCPcopy Index your code
hub / github.com/csev/py4e / highlightLine

Function highlightLine

tools/pythonauto/static/codemirror/codemirror.js:4444–4480  ·  view source on GitHub ↗
(cm, line, state, forceToEnd)

Source from the content-addressed store, hash-verified

4442 }
4443
4444 function highlightLine(cm, line, state, forceToEnd) {
4445 // A styles array always starts with a number identifying the
4446 // mode/overlays that it is based on (for easy invalidation).
4447 var st = [cm.state.modeGen];
4448 // Compute the base array of styles
4449 runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
4450 st.push(end, style);
4451 }, forceToEnd);
4452
4453 // Run overlays, adjust style array.
4454 for (var o = 0; o < cm.state.overlays.length; ++o) {
4455 var overlay = cm.state.overlays[o], i = 1, at = 0;
4456 runMode(cm, line.text, overlay.mode, true, function(end, style) {
4457 var start = i;
4458 // Ensure there's a token end at the current position, and that i points at it
4459 while (at < end) {
4460 var i_end = st[i];
4461 if (i_end > end)
4462 st.splice(i, 1, end, st[i+1], i_end);
4463 i += 2;
4464 at = Math.min(end, i_end);
4465 }
4466 if (!style) return;
4467 if (overlay.opaque) {
4468 st.splice(start, i - start, end, style);
4469 i = start + 2;
4470 } else {
4471 for (; start < i; start += 2) {
4472 var cur = st[start+1];
4473 st[start+1] = cur ? cur + " " + style : style;
4474 }
4475 }
4476 });
4477 }
4478
4479 return st;
4480 }
4481
4482 function getLineStyles(cm, line) {
4483 if (!line.styles || line.styles[0] != cm.state.modeGen)

Callers 2

highlightWorkerFunction · 0.70
getLineStylesFunction · 0.70

Calls 1

runModeFunction · 0.70

Tested by

no test coverage detected