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

Function runMode

samples/common/codehighlight/codemirror.js:1211–1248  ·  view source on GitHub ↗
(cm, text, mode, context, f, lineClasses, forceToEnd)

Source from the content-addressed store, hash-verified

1209
1210 // Run the given mode's parser over a line, calling f for each token.
1211 function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
1212 var flattenSpans = mode.flattenSpans;
1213 if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; }
1214 var curStart = 0, curStyle = null;
1215 var stream = new StringStream(text, cm.options.tabSize, context), style;
1216 var inner = cm.options.addModeClass && [null];
1217 if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); }
1218 while (!stream.eol()) {
1219 if (stream.pos > cm.options.maxHighlightLength) {
1220 flattenSpans = false;
1221 if (forceToEnd) { processLine(cm, text, context, stream.pos); }
1222 stream.pos = text.length;
1223 style = null;
1224 } else {
1225 style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
1226 }
1227 if (inner) {
1228 var mName = inner[0].name;
1229 if (mName) { style = "m-" + (style ? mName + " " + style : mName); }
1230 }
1231 if (!flattenSpans || curStyle != style) {
1232 while (curStart < stream.start) {
1233 curStart = Math.min(stream.start, curStart + 5000);
1234 f(curStart, curStyle);
1235 }
1236 curStyle = style;
1237 }
1238 stream.start = stream.pos;
1239 }
1240 while (curStart < stream.pos) {
1241 // Webkit seems to refuse to render text nodes longer than 57444
1242 // characters, and returns inaccurate measurements in nodes
1243 // starting around 5000 chars.
1244 var pos = Math.min(stream.pos, curStart + 5000);
1245 f(pos, curStyle);
1246 curStart = pos;
1247 }
1248 }
1249
1250 // Finds the line to start with when starting a parse. Tries to
1251 // find a line with a stateAfter, so that it can start with a

Callers 2

highlightLineFunction · 0.85
loopFunction · 0.85

Calls 5

extractLineClassesFunction · 0.85
callBlankLineFunction · 0.85
processLineFunction · 0.85
readTokenFunction · 0.85
fFunction · 0.85

Tested by

no test coverage detected