MCPcopy Index your code
hub / github.com/DHTMLX/gantt / highlightLine

Function highlightLine

samples/common/codehighlight/codemirror.js:1066–1109  ·  view source on GitHub ↗
(cm, line, context, forceToEnd)

Source from the content-addressed store, hash-verified

1064 // style strings), which is used to highlight the tokens on the
1065 // line.
1066 function highlightLine(cm, line, context, forceToEnd) {
1067 // A styles array always starts with a number identifying the
1068 // mode/overlays that it is based on (for easy invalidation).
1069 var st = [cm.state.modeGen], lineClasses = {};
1070 // Compute the base array of styles
1071 runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },
1072 lineClasses, forceToEnd);
1073 var state = context.state;
1074
1075 // Run overlays, adjust style array.
1076 var loop = function ( o ) {
1077 context.baseTokens = st;
1078 var overlay = cm.state.overlays[o], i = 1, at = 0;
1079 context.state = true;
1080 runMode(cm, line.text, overlay.mode, context, function (end, style) {
1081 var start = i;
1082 // Ensure there's a token end at the current position, and that i points at it
1083 while (at < end) {
1084 var i_end = st[i];
1085 if (i_end > end)
1086 { st.splice(i, 1, end, st[i+1], i_end); }
1087 i += 2;
1088 at = Math.min(end, i_end);
1089 }
1090 if (!style) { return }
1091 if (overlay.opaque) {
1092 st.splice(start, i - start, end, "overlay " + style);
1093 i = start + 2;
1094 } else {
1095 for (; start < i; start += 2) {
1096 var cur = st[start+1];
1097 st[start+1] = (cur ? cur + " " : "") + "overlay " + style;
1098 }
1099 }
1100 }, lineClasses);
1101 context.state = state;
1102 context.baseTokens = null;
1103 context.baseTokenPos = 1;
1104 };
1105
1106 for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
1107
1108 return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
1109 }
1110
1111 function getLineStyles(cm, line, updateFrontier) {
1112 if (!line.styles || line.styles[0] != cm.state.modeGen) {

Callers 2

getLineStylesFunction · 0.85
highlightWorkerFunction · 0.85

Calls 2

runModeFunction · 0.85
loopFunction · 0.85

Tested by

no test coverage detected