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

Function highlightWorker

tools/pythonauto/static/codemirror/codemirror.js:913–946  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

911 }
912
913 function highlightWorker(cm) {
914 var doc = cm.doc;
915 if (doc.frontier < doc.first) doc.frontier = doc.first;
916 if (doc.frontier >= cm.display.showingTo) return;
917 var end = +new Date + cm.options.workTime;
918 var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
919 var changed = [], prevChange;
920 doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.showingTo + 500), function(line) {
921 if (doc.frontier >= cm.display.showingFrom) { // Visible
922 var oldStyles = line.styles;
923 line.styles = highlightLine(cm, line, state, true);
924 var ischange = !oldStyles || oldStyles.length != line.styles.length;
925 for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
926 if (ischange) {
927 if (prevChange && prevChange.end == doc.frontier) prevChange.end++;
928 else changed.push(prevChange = {start: doc.frontier, end: doc.frontier + 1});
929 }
930 line.stateAfter = copyState(doc.mode, state);
931 } else {
932 processLine(cm, line.text, state);
933 line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
934 }
935 ++doc.frontier;
936 if (+new Date > end) {
937 startWorker(cm, cm.options.workDelay);
938 return true;
939 }
940 });
941 if (changed.length)
942 operation(cm, function() {
943 for (var i = 0; i < changed.length; ++i)
944 regChange(this, changed[i].start, changed[i].end);
945 })();
946 }
947
948 // Finds the line to start with when starting a parse. Tries to
949 // find a line with a stateAfter, so that it can start with a

Callers

nothing calls this directly

Calls 7

copyStateFunction · 0.70
getStateBeforeFunction · 0.70
highlightLineFunction · 0.70
processLineFunction · 0.70
startWorkerFunction · 0.70
operationFunction · 0.70
regChangeFunction · 0.70

Tested by

no test coverage detected