MCPcopy
hub / github.com/witheve/Eve / highlightLine

Function highlightLine

src/codemirror.js:6859–6895  ·  view source on GitHub ↗
(cm, line, state, forceToEnd)

Source from the content-addressed store, hash-verified

6857 // style strings), which is used to highlight the tokens on the
6858 // line.
6859 function highlightLine(cm, line, state, forceToEnd) {
6860 // A styles array always starts with a number identifying the
6861 // mode/overlays that it is based on (for easy invalidation).
6862 var st = [cm.state.modeGen], lineClasses = {};
6863 // Compute the base array of styles
6864 runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
6865 st.push(end, style);
6866 }, lineClasses, forceToEnd);
6867
6868 // Run overlays, adjust style array.
6869 for (var o = 0; o < cm.state.overlays.length; ++o) {
6870 var overlay = cm.state.overlays[o], i = 1, at = 0;
6871 runMode(cm, line.text, overlay.mode, true, function(end, style) {
6872 var start = i;
6873 // Ensure there's a token end at the current position, and that i points at it
6874 while (at < end) {
6875 var i_end = st[i];
6876 if (i_end > end)
6877 st.splice(i, 1, end, st[i+1], i_end);
6878 i += 2;
6879 at = Math.min(end, i_end);
6880 }
6881 if (!style) return;
6882 if (overlay.opaque) {
6883 st.splice(start, i - start, end, "cm-overlay " + style);
6884 i = start + 2;
6885 } else {
6886 for (; start < i; start += 2) {
6887 var cur = st[start+1];
6888 st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
6889 }
6890 }
6891 }, lineClasses);
6892 }
6893
6894 return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
6895 }
6896
6897 function getLineStyles(cm, line, updateFrontier) {
6898 if (!line.styles || line.styles[0] != cm.state.modeGen) {

Callers 2

highlightWorkerFunction · 0.85
getLineStylesFunction · 0.85

Calls 1

runModeFunction · 0.85

Tested by

no test coverage detected