Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../lib
File: codemirror.js
var span = stretchCur[j];
[6500] Fix | Delete
for (var k = 0; k < oldCur.length; ++k)
[6501] Fix | Delete
if (oldCur[k].marker == span.marker) continue spans;
[6502] Fix | Delete
oldCur.push(span);
[6503] Fix | Delete
}
[6504] Fix | Delete
} else if (stretchCur) {
[6505] Fix | Delete
old[i] = stretchCur;
[6506] Fix | Delete
}
[6507] Fix | Delete
}
[6508] Fix | Delete
return old;
[6509] Fix | Delete
}
[6510] Fix | Delete
[6511] Fix | Delete
// Used to 'clip' out readOnly ranges when making a change.
[6512] Fix | Delete
function removeReadOnlyRanges(doc, from, to) {
[6513] Fix | Delete
var markers = null;
[6514] Fix | Delete
doc.iter(from.line, to.line + 1, function(line) {
[6515] Fix | Delete
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
[6516] Fix | Delete
var mark = line.markedSpans[i].marker;
[6517] Fix | Delete
if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
[6518] Fix | Delete
(markers || (markers = [])).push(mark);
[6519] Fix | Delete
}
[6520] Fix | Delete
});
[6521] Fix | Delete
if (!markers) return null;
[6522] Fix | Delete
var parts = [{from: from, to: to}];
[6523] Fix | Delete
for (var i = 0; i < markers.length; ++i) {
[6524] Fix | Delete
var mk = markers[i], m = mk.find(0);
[6525] Fix | Delete
for (var j = 0; j < parts.length; ++j) {
[6526] Fix | Delete
var p = parts[j];
[6527] Fix | Delete
if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
[6528] Fix | Delete
var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
[6529] Fix | Delete
if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
[6530] Fix | Delete
newParts.push({from: p.from, to: m.from});
[6531] Fix | Delete
if (dto > 0 || !mk.inclusiveRight && !dto)
[6532] Fix | Delete
newParts.push({from: m.to, to: p.to});
[6533] Fix | Delete
parts.splice.apply(parts, newParts);
[6534] Fix | Delete
j += newParts.length - 1;
[6535] Fix | Delete
}
[6536] Fix | Delete
}
[6537] Fix | Delete
return parts;
[6538] Fix | Delete
}
[6539] Fix | Delete
[6540] Fix | Delete
// Connect or disconnect spans from a line.
[6541] Fix | Delete
function detachMarkedSpans(line) {
[6542] Fix | Delete
var spans = line.markedSpans;
[6543] Fix | Delete
if (!spans) return;
[6544] Fix | Delete
for (var i = 0; i < spans.length; ++i)
[6545] Fix | Delete
spans[i].marker.detachLine(line);
[6546] Fix | Delete
line.markedSpans = null;
[6547] Fix | Delete
}
[6548] Fix | Delete
function attachMarkedSpans(line, spans) {
[6549] Fix | Delete
if (!spans) return;
[6550] Fix | Delete
for (var i = 0; i < spans.length; ++i)
[6551] Fix | Delete
spans[i].marker.attachLine(line);
[6552] Fix | Delete
line.markedSpans = spans;
[6553] Fix | Delete
}
[6554] Fix | Delete
[6555] Fix | Delete
// Helpers used when computing which overlapping collapsed span
[6556] Fix | Delete
// counts as the larger one.
[6557] Fix | Delete
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
[6558] Fix | Delete
function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
[6559] Fix | Delete
[6560] Fix | Delete
// Returns a number indicating which of two overlapping collapsed
[6561] Fix | Delete
// spans is larger (and thus includes the other). Falls back to
[6562] Fix | Delete
// comparing ids when the spans cover exactly the same range.
[6563] Fix | Delete
function compareCollapsedMarkers(a, b) {
[6564] Fix | Delete
var lenDiff = a.lines.length - b.lines.length;
[6565] Fix | Delete
if (lenDiff != 0) return lenDiff;
[6566] Fix | Delete
var aPos = a.find(), bPos = b.find();
[6567] Fix | Delete
var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
[6568] Fix | Delete
if (fromCmp) return -fromCmp;
[6569] Fix | Delete
var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
[6570] Fix | Delete
if (toCmp) return toCmp;
[6571] Fix | Delete
return b.id - a.id;
[6572] Fix | Delete
}
[6573] Fix | Delete
[6574] Fix | Delete
// Find out whether a line ends or starts in a collapsed span. If
[6575] Fix | Delete
// so, return the marker for that span.
[6576] Fix | Delete
function collapsedSpanAtSide(line, start) {
[6577] Fix | Delete
var sps = sawCollapsedSpans && line.markedSpans, found;
[6578] Fix | Delete
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
[6579] Fix | Delete
sp = sps[i];
[6580] Fix | Delete
if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
[6581] Fix | Delete
(!found || compareCollapsedMarkers(found, sp.marker) < 0))
[6582] Fix | Delete
found = sp.marker;
[6583] Fix | Delete
}
[6584] Fix | Delete
return found;
[6585] Fix | Delete
}
[6586] Fix | Delete
function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
[6587] Fix | Delete
function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
[6588] Fix | Delete
[6589] Fix | Delete
// Test whether there exists a collapsed span that partially
[6590] Fix | Delete
// overlaps (covers the start or end, but not both) of a new span.
[6591] Fix | Delete
// Such overlap is not allowed.
[6592] Fix | Delete
function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
[6593] Fix | Delete
var line = getLine(doc, lineNo);
[6594] Fix | Delete
var sps = sawCollapsedSpans && line.markedSpans;
[6595] Fix | Delete
if (sps) for (var i = 0; i < sps.length; ++i) {
[6596] Fix | Delete
var sp = sps[i];
[6597] Fix | Delete
if (!sp.marker.collapsed) continue;
[6598] Fix | Delete
var found = sp.marker.find(0);
[6599] Fix | Delete
var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
[6600] Fix | Delete
var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
[6601] Fix | Delete
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
[6602] Fix | Delete
if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
[6603] Fix | Delete
fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
[6604] Fix | Delete
return true;
[6605] Fix | Delete
}
[6606] Fix | Delete
}
[6607] Fix | Delete
[6608] Fix | Delete
// A visual line is a line as drawn on the screen. Folding, for
[6609] Fix | Delete
// example, can cause multiple logical lines to appear on the same
[6610] Fix | Delete
// visual line. This finds the start of the visual line that the
[6611] Fix | Delete
// given line is part of (usually that is the line itself).
[6612] Fix | Delete
function visualLine(line) {
[6613] Fix | Delete
var merged;
[6614] Fix | Delete
while (merged = collapsedSpanAtStart(line))
[6615] Fix | Delete
line = merged.find(-1, true).line;
[6616] Fix | Delete
return line;
[6617] Fix | Delete
}
[6618] Fix | Delete
[6619] Fix | Delete
// Returns an array of logical lines that continue the visual line
[6620] Fix | Delete
// started by the argument, or undefined if there are no such lines.
[6621] Fix | Delete
function visualLineContinued(line) {
[6622] Fix | Delete
var merged, lines;
[6623] Fix | Delete
while (merged = collapsedSpanAtEnd(line)) {
[6624] Fix | Delete
line = merged.find(1, true).line;
[6625] Fix | Delete
(lines || (lines = [])).push(line);
[6626] Fix | Delete
}
[6627] Fix | Delete
return lines;
[6628] Fix | Delete
}
[6629] Fix | Delete
[6630] Fix | Delete
// Get the line number of the start of the visual line that the
[6631] Fix | Delete
// given line number is part of.
[6632] Fix | Delete
function visualLineNo(doc, lineN) {
[6633] Fix | Delete
var line = getLine(doc, lineN), vis = visualLine(line);
[6634] Fix | Delete
if (line == vis) return lineN;
[6635] Fix | Delete
return lineNo(vis);
[6636] Fix | Delete
}
[6637] Fix | Delete
// Get the line number of the start of the next visual line after
[6638] Fix | Delete
// the given line.
[6639] Fix | Delete
function visualLineEndNo(doc, lineN) {
[6640] Fix | Delete
if (lineN > doc.lastLine()) return lineN;
[6641] Fix | Delete
var line = getLine(doc, lineN), merged;
[6642] Fix | Delete
if (!lineIsHidden(doc, line)) return lineN;
[6643] Fix | Delete
while (merged = collapsedSpanAtEnd(line))
[6644] Fix | Delete
line = merged.find(1, true).line;
[6645] Fix | Delete
return lineNo(line) + 1;
[6646] Fix | Delete
}
[6647] Fix | Delete
[6648] Fix | Delete
// Compute whether a line is hidden. Lines count as hidden when they
[6649] Fix | Delete
// are part of a visual line that starts with another line, or when
[6650] Fix | Delete
// they are entirely covered by collapsed, non-widget span.
[6651] Fix | Delete
function lineIsHidden(doc, line) {
[6652] Fix | Delete
var sps = sawCollapsedSpans && line.markedSpans;
[6653] Fix | Delete
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
[6654] Fix | Delete
sp = sps[i];
[6655] Fix | Delete
if (!sp.marker.collapsed) continue;
[6656] Fix | Delete
if (sp.from == null) return true;
[6657] Fix | Delete
if (sp.marker.widgetNode) continue;
[6658] Fix | Delete
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
[6659] Fix | Delete
return true;
[6660] Fix | Delete
}
[6661] Fix | Delete
}
[6662] Fix | Delete
function lineIsHiddenInner(doc, line, span) {
[6663] Fix | Delete
if (span.to == null) {
[6664] Fix | Delete
var end = span.marker.find(1, true);
[6665] Fix | Delete
return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
[6666] Fix | Delete
}
[6667] Fix | Delete
if (span.marker.inclusiveRight && span.to == line.text.length)
[6668] Fix | Delete
return true;
[6669] Fix | Delete
for (var sp, i = 0; i < line.markedSpans.length; ++i) {
[6670] Fix | Delete
sp = line.markedSpans[i];
[6671] Fix | Delete
if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
[6672] Fix | Delete
(sp.to == null || sp.to != span.from) &&
[6673] Fix | Delete
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
[6674] Fix | Delete
lineIsHiddenInner(doc, line, sp)) return true;
[6675] Fix | Delete
}
[6676] Fix | Delete
}
[6677] Fix | Delete
[6678] Fix | Delete
// LINE WIDGETS
[6679] Fix | Delete
[6680] Fix | Delete
// Line widgets are block elements displayed above or below a line.
[6681] Fix | Delete
[6682] Fix | Delete
var LineWidget = CodeMirror.LineWidget = function(doc, node, options) {
[6683] Fix | Delete
if (options) for (var opt in options) if (options.hasOwnProperty(opt))
[6684] Fix | Delete
this[opt] = options[opt];
[6685] Fix | Delete
this.doc = doc;
[6686] Fix | Delete
this.node = node;
[6687] Fix | Delete
};
[6688] Fix | Delete
eventMixin(LineWidget);
[6689] Fix | Delete
[6690] Fix | Delete
function adjustScrollWhenAboveVisible(cm, line, diff) {
[6691] Fix | Delete
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
[6692] Fix | Delete
addToScrollPos(cm, null, diff);
[6693] Fix | Delete
}
[6694] Fix | Delete
[6695] Fix | Delete
LineWidget.prototype.clear = function() {
[6696] Fix | Delete
var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
[6697] Fix | Delete
if (no == null || !ws) return;
[6698] Fix | Delete
for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
[6699] Fix | Delete
if (!ws.length) line.widgets = null;
[6700] Fix | Delete
var height = widgetHeight(this);
[6701] Fix | Delete
updateLineHeight(line, Math.max(0, line.height - height));
[6702] Fix | Delete
if (cm) runInOp(cm, function() {
[6703] Fix | Delete
adjustScrollWhenAboveVisible(cm, line, -height);
[6704] Fix | Delete
regLineChange(cm, no, "widget");
[6705] Fix | Delete
});
[6706] Fix | Delete
};
[6707] Fix | Delete
LineWidget.prototype.changed = function() {
[6708] Fix | Delete
var oldH = this.height, cm = this.doc.cm, line = this.line;
[6709] Fix | Delete
this.height = null;
[6710] Fix | Delete
var diff = widgetHeight(this) - oldH;
[6711] Fix | Delete
if (!diff) return;
[6712] Fix | Delete
updateLineHeight(line, line.height + diff);
[6713] Fix | Delete
if (cm) runInOp(cm, function() {
[6714] Fix | Delete
cm.curOp.forceUpdate = true;
[6715] Fix | Delete
adjustScrollWhenAboveVisible(cm, line, diff);
[6716] Fix | Delete
});
[6717] Fix | Delete
};
[6718] Fix | Delete
[6719] Fix | Delete
function widgetHeight(widget) {
[6720] Fix | Delete
if (widget.height != null) return widget.height;
[6721] Fix | Delete
var cm = widget.doc.cm;
[6722] Fix | Delete
if (!cm) return 0;
[6723] Fix | Delete
if (!contains(document.body, widget.node)) {
[6724] Fix | Delete
var parentStyle = "position: relative;";
[6725] Fix | Delete
if (widget.coverGutter)
[6726] Fix | Delete
parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;";
[6727] Fix | Delete
if (widget.noHScroll)
[6728] Fix | Delete
parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
[6729] Fix | Delete
removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
[6730] Fix | Delete
}
[6731] Fix | Delete
return widget.height = widget.node.parentNode.offsetHeight;
[6732] Fix | Delete
}
[6733] Fix | Delete
[6734] Fix | Delete
function addLineWidget(doc, handle, node, options) {
[6735] Fix | Delete
var widget = new LineWidget(doc, node, options);
[6736] Fix | Delete
var cm = doc.cm;
[6737] Fix | Delete
if (cm && widget.noHScroll) cm.display.alignWidgets = true;
[6738] Fix | Delete
changeLine(doc, handle, "widget", function(line) {
[6739] Fix | Delete
var widgets = line.widgets || (line.widgets = []);
[6740] Fix | Delete
if (widget.insertAt == null) widgets.push(widget);
[6741] Fix | Delete
else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
[6742] Fix | Delete
widget.line = line;
[6743] Fix | Delete
if (cm && !lineIsHidden(doc, line)) {
[6744] Fix | Delete
var aboveVisible = heightAtLine(line) < doc.scrollTop;
[6745] Fix | Delete
updateLineHeight(line, line.height + widgetHeight(widget));
[6746] Fix | Delete
if (aboveVisible) addToScrollPos(cm, null, widget.height);
[6747] Fix | Delete
cm.curOp.forceUpdate = true;
[6748] Fix | Delete
}
[6749] Fix | Delete
return true;
[6750] Fix | Delete
});
[6751] Fix | Delete
return widget;
[6752] Fix | Delete
}
[6753] Fix | Delete
[6754] Fix | Delete
// LINE DATA STRUCTURE
[6755] Fix | Delete
[6756] Fix | Delete
// Line objects. These hold state related to a line, including
[6757] Fix | Delete
// highlighting info (the styles array).
[6758] Fix | Delete
var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
[6759] Fix | Delete
this.text = text;
[6760] Fix | Delete
attachMarkedSpans(this, markedSpans);
[6761] Fix | Delete
this.height = estimateHeight ? estimateHeight(this) : 1;
[6762] Fix | Delete
};
[6763] Fix | Delete
eventMixin(Line);
[6764] Fix | Delete
Line.prototype.lineNo = function() { return lineNo(this); };
[6765] Fix | Delete
[6766] Fix | Delete
// Change the content (text, markers) of a line. Automatically
[6767] Fix | Delete
// invalidates cached information and tries to re-estimate the
[6768] Fix | Delete
// line's height.
[6769] Fix | Delete
function updateLine(line, text, markedSpans, estimateHeight) {
[6770] Fix | Delete
line.text = text;
[6771] Fix | Delete
if (line.stateAfter) line.stateAfter = null;
[6772] Fix | Delete
if (line.styles) line.styles = null;
[6773] Fix | Delete
if (line.order != null) line.order = null;
[6774] Fix | Delete
detachMarkedSpans(line);
[6775] Fix | Delete
attachMarkedSpans(line, markedSpans);
[6776] Fix | Delete
var estHeight = estimateHeight ? estimateHeight(line) : 1;
[6777] Fix | Delete
if (estHeight != line.height) updateLineHeight(line, estHeight);
[6778] Fix | Delete
}
[6779] Fix | Delete
[6780] Fix | Delete
// Detach a line from the document tree and its markers.
[6781] Fix | Delete
function cleanUpLine(line) {
[6782] Fix | Delete
line.parent = null;
[6783] Fix | Delete
detachMarkedSpans(line);
[6784] Fix | Delete
}
[6785] Fix | Delete
[6786] Fix | Delete
function extractLineClasses(type, output) {
[6787] Fix | Delete
if (type) for (;;) {
[6788] Fix | Delete
var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
[6789] Fix | Delete
if (!lineClass) break;
[6790] Fix | Delete
type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
[6791] Fix | Delete
var prop = lineClass[1] ? "bgClass" : "textClass";
[6792] Fix | Delete
if (output[prop] == null)
[6793] Fix | Delete
output[prop] = lineClass[2];
[6794] Fix | Delete
else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
[6795] Fix | Delete
output[prop] += " " + lineClass[2];
[6796] Fix | Delete
}
[6797] Fix | Delete
return type;
[6798] Fix | Delete
}
[6799] Fix | Delete
[6800] Fix | Delete
function callBlankLine(mode, state) {
[6801] Fix | Delete
if (mode.blankLine) return mode.blankLine(state);
[6802] Fix | Delete
if (!mode.innerMode) return;
[6803] Fix | Delete
var inner = CodeMirror.innerMode(mode, state);
[6804] Fix | Delete
if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
[6805] Fix | Delete
}
[6806] Fix | Delete
[6807] Fix | Delete
function readToken(mode, stream, state, inner) {
[6808] Fix | Delete
for (var i = 0; i < 10; i++) {
[6809] Fix | Delete
if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
[6810] Fix | Delete
var style = mode.token(stream, state);
[6811] Fix | Delete
if (stream.pos > stream.start) return style;
[6812] Fix | Delete
}
[6813] Fix | Delete
throw new Error("Mode " + mode.name + " failed to advance stream.");
[6814] Fix | Delete
}
[6815] Fix | Delete
[6816] Fix | Delete
// Utility for getTokenAt and getLineTokens
[6817] Fix | Delete
function takeToken(cm, pos, precise, asArray) {
[6818] Fix | Delete
function getObj(copy) {
[6819] Fix | Delete
return {start: stream.start, end: stream.pos,
[6820] Fix | Delete
string: stream.current(),
[6821] Fix | Delete
type: style || null,
[6822] Fix | Delete
state: copy ? copyState(doc.mode, state) : state};
[6823] Fix | Delete
}
[6824] Fix | Delete
[6825] Fix | Delete
var doc = cm.doc, mode = doc.mode, style;
[6826] Fix | Delete
pos = clipPos(doc, pos);
[6827] Fix | Delete
var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
[6828] Fix | Delete
var stream = new StringStream(line.text, cm.options.tabSize), tokens;
[6829] Fix | Delete
if (asArray) tokens = [];
[6830] Fix | Delete
while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
[6831] Fix | Delete
stream.start = stream.pos;
[6832] Fix | Delete
style = readToken(mode, stream, state);
[6833] Fix | Delete
if (asArray) tokens.push(getObj(true));
[6834] Fix | Delete
}
[6835] Fix | Delete
return asArray ? tokens : getObj();
[6836] Fix | Delete
}
[6837] Fix | Delete
[6838] Fix | Delete
// Run the given mode's parser over a line, calling f for each token.
[6839] Fix | Delete
function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
[6840] Fix | Delete
var flattenSpans = mode.flattenSpans;
[6841] Fix | Delete
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
[6842] Fix | Delete
var curStart = 0, curStyle = null;
[6843] Fix | Delete
var stream = new StringStream(text, cm.options.tabSize), style;
[6844] Fix | Delete
var inner = cm.options.addModeClass && [null];
[6845] Fix | Delete
if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
[6846] Fix | Delete
while (!stream.eol()) {
[6847] Fix | Delete
if (stream.pos > cm.options.maxHighlightLength) {
[6848] Fix | Delete
flattenSpans = false;
[6849] Fix | Delete
if (forceToEnd) processLine(cm, text, state, stream.pos);
[6850] Fix | Delete
stream.pos = text.length;
[6851] Fix | Delete
style = null;
[6852] Fix | Delete
} else {
[6853] Fix | Delete
style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
[6854] Fix | Delete
}
[6855] Fix | Delete
if (inner) {
[6856] Fix | Delete
var mName = inner[0].name;
[6857] Fix | Delete
if (mName) style = "m-" + (style ? mName + " " + style : mName);
[6858] Fix | Delete
}
[6859] Fix | Delete
if (!flattenSpans || curStyle != style) {
[6860] Fix | Delete
while (curStart < stream.start) {
[6861] Fix | Delete
curStart = Math.min(stream.start, curStart + 50000);
[6862] Fix | Delete
f(curStart, curStyle);
[6863] Fix | Delete
}
[6864] Fix | Delete
curStyle = style;
[6865] Fix | Delete
}
[6866] Fix | Delete
stream.start = stream.pos;
[6867] Fix | Delete
}
[6868] Fix | Delete
while (curStart < stream.pos) {
[6869] Fix | Delete
// Webkit seems to refuse to render text nodes longer than 57444 characters
[6870] Fix | Delete
var pos = Math.min(stream.pos, curStart + 50000);
[6871] Fix | Delete
f(pos, curStyle);
[6872] Fix | Delete
curStart = pos;
[6873] Fix | Delete
}
[6874] Fix | Delete
}
[6875] Fix | Delete
[6876] Fix | Delete
// Compute a style array (an array starting with a mode generation
[6877] Fix | Delete
// -- for invalidation -- followed by pairs of end positions and
[6878] Fix | Delete
// style strings), which is used to highlight the tokens on the
[6879] Fix | Delete
// line.
[6880] Fix | Delete
function highlightLine(cm, line, state, forceToEnd) {
[6881] Fix | Delete
// A styles array always starts with a number identifying the
[6882] Fix | Delete
// mode/overlays that it is based on (for easy invalidation).
[6883] Fix | Delete
var st = [cm.state.modeGen], lineClasses = {};
[6884] Fix | Delete
// Compute the base array of styles
[6885] Fix | Delete
runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
[6886] Fix | Delete
st.push(end, style);
[6887] Fix | Delete
}, lineClasses, forceToEnd);
[6888] Fix | Delete
[6889] Fix | Delete
// Run overlays, adjust style array.
[6890] Fix | Delete
for (var o = 0; o < cm.state.overlays.length; ++o) {
[6891] Fix | Delete
var overlay = cm.state.overlays[o], i = 1, at = 0;
[6892] Fix | Delete
runMode(cm, line.text, overlay.mode, true, function(end, style) {
[6893] Fix | Delete
var start = i;
[6894] Fix | Delete
// Ensure there's a token end at the current position, and that i points at it
[6895] Fix | Delete
while (at < end) {
[6896] Fix | Delete
var i_end = st[i];
[6897] Fix | Delete
if (i_end > end)
[6898] Fix | Delete
st.splice(i, 1, end, st[i+1], i_end);
[6899] Fix | Delete
i += 2;
[6900] Fix | Delete
at = Math.min(end, i_end);
[6901] Fix | Delete
}
[6902] Fix | Delete
if (!style) return;
[6903] Fix | Delete
if (overlay.opaque) {
[6904] Fix | Delete
st.splice(start, i - start, end, "cm-overlay " + style);
[6905] Fix | Delete
i = start + 2;
[6906] Fix | Delete
} else {
[6907] Fix | Delete
for (; start < i; start += 2) {
[6908] Fix | Delete
var cur = st[start+1];
[6909] Fix | Delete
st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
[6910] Fix | Delete
}
[6911] Fix | Delete
}
[6912] Fix | Delete
}, lineClasses);
[6913] Fix | Delete
}
[6914] Fix | Delete
[6915] Fix | Delete
return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
[6916] Fix | Delete
}
[6917] Fix | Delete
[6918] Fix | Delete
function getLineStyles(cm, line, updateFrontier) {
[6919] Fix | Delete
if (!line.styles || line.styles[0] != cm.state.modeGen) {
[6920] Fix | Delete
var state = getStateBefore(cm, lineNo(line));
[6921] Fix | Delete
var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
[6922] Fix | Delete
line.stateAfter = state;
[6923] Fix | Delete
line.styles = result.styles;
[6924] Fix | Delete
if (result.classes) line.styleClasses = result.classes;
[6925] Fix | Delete
else if (line.styleClasses) line.styleClasses = null;
[6926] Fix | Delete
if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
[6927] Fix | Delete
}
[6928] Fix | Delete
return line.styles;
[6929] Fix | Delete
}
[6930] Fix | Delete
[6931] Fix | Delete
// Lightweight form of highlight -- proceed over this line and
[6932] Fix | Delete
// update state, but don't save a style array. Used for lines that
[6933] Fix | Delete
// aren't currently visible.
[6934] Fix | Delete
function processLine(cm, text, state, startAt) {
[6935] Fix | Delete
var mode = cm.doc.mode;
[6936] Fix | Delete
var stream = new StringStream(text, cm.options.tabSize);
[6937] Fix | Delete
stream.start = stream.pos = startAt || 0;
[6938] Fix | Delete
if (text == "") callBlankLine(mode, state);
[6939] Fix | Delete
while (!stream.eol()) {
[6940] Fix | Delete
readToken(mode, stream, state);
[6941] Fix | Delete
stream.start = stream.pos;
[6942] Fix | Delete
}
[6943] Fix | Delete
}
[6944] Fix | Delete
[6945] Fix | Delete
// Convert a style as returned by a mode (either null, or a string
[6946] Fix | Delete
// containing one or more styles) to a CSS style. This is cached,
[6947] Fix | Delete
// and also looks for line-wide styles.
[6948] Fix | Delete
var styleToClassCache = {}, styleToClassCacheWithMode = {};
[6949] Fix | Delete
function interpretTokenStyle(style, options) {
[6950] Fix | Delete
if (!style || /^\s*$/.test(style)) return null;
[6951] Fix | Delete
var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
[6952] Fix | Delete
return cache[style] ||
[6953] Fix | Delete
(cache[style] = style.replace(/\S+/g, "cm-$&"));
[6954] Fix | Delete
}
[6955] Fix | Delete
[6956] Fix | Delete
// Render the DOM representation of the text of a line. Also builds
[6957] Fix | Delete
// up a 'line map', which points at the DOM nodes that represent
[6958] Fix | Delete
// specific stretches of text, and is used by the measuring code.
[6959] Fix | Delete
// The returned object contains the DOM node, this map, and
[6960] Fix | Delete
// information about line-wide styles that were set by the mode.
[6961] Fix | Delete
function buildLineContent(cm, lineView) {
[6962] Fix | Delete
// The padding-right forces the element to have a 'border', which
[6963] Fix | Delete
// is needed on Webkit to be able to get line-level bounding
[6964] Fix | Delete
// rectangles for it (in measureChar).
[6965] Fix | Delete
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
[6966] Fix | Delete
var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
[6967] Fix | Delete
col: 0, pos: 0, cm: cm,
[6968] Fix | Delete
trailingSpace: false,
[6969] Fix | Delete
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
[6970] Fix | Delete
lineView.measure = {};
[6971] Fix | Delete
[6972] Fix | Delete
// Iterate over the logical lines that make up this visual line.
[6973] Fix | Delete
for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
[6974] Fix | Delete
var line = i ? lineView.rest[i - 1] : lineView.line, order;
[6975] Fix | Delete
builder.pos = 0;
[6976] Fix | Delete
builder.addToken = buildToken;
[6977] Fix | Delete
// Optionally wire in some hacks into the token-rendering
[6978] Fix | Delete
// algorithm, to deal with browser quirks.
[6979] Fix | Delete
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
[6980] Fix | Delete
builder.addToken = buildTokenBadBidi(builder.addToken, order);
[6981] Fix | Delete
builder.map = [];
[6982] Fix | Delete
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
[6983] Fix | Delete
insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
[6984] Fix | Delete
if (line.styleClasses) {
[6985] Fix | Delete
if (line.styleClasses.bgClass)
[6986] Fix | Delete
builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
[6987] Fix | Delete
if (line.styleClasses.textClass)
[6988] Fix | Delete
builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
[6989] Fix | Delete
}
[6990] Fix | Delete
[6991] Fix | Delete
// Ensure at least a single node is present, for measuring.
[6992] Fix | Delete
if (builder.map.length == 0)
[6993] Fix | Delete
builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
[6994] Fix | Delete
[6995] Fix | Delete
// Store the map and a cache object for the current logical line
[6996] Fix | Delete
if (i == 0) {
[6997] Fix | Delete
lineView.measure.map = builder.map;
[6998] Fix | Delete
lineView.measure.cache = {};
[6999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function