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
if (/^(pre|div|p)$/i.test(node.nodeName))
[2000] Fix | Delete
closing = true;
[2001] Fix | Delete
} else if (node.nodeType == 3) {
[2002] Fix | Delete
var val = node.nodeValue;
[2003] Fix | Delete
if (!val) return;
[2004] Fix | Delete
if (closing) {
[2005] Fix | Delete
text += lineSep;
[2006] Fix | Delete
closing = false;
[2007] Fix | Delete
}
[2008] Fix | Delete
text += val;
[2009] Fix | Delete
}
[2010] Fix | Delete
}
[2011] Fix | Delete
for (;;) {
[2012] Fix | Delete
walk(from);
[2013] Fix | Delete
if (from == to) break;
[2014] Fix | Delete
from = from.nextSibling;
[2015] Fix | Delete
}
[2016] Fix | Delete
return text;
[2017] Fix | Delete
}
[2018] Fix | Delete
[2019] Fix | Delete
CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
[2020] Fix | Delete
[2021] Fix | Delete
// SELECTION / CURSOR
[2022] Fix | Delete
[2023] Fix | Delete
// Selection objects are immutable. A new one is created every time
[2024] Fix | Delete
// the selection changes. A selection is one or more non-overlapping
[2025] Fix | Delete
// (and non-touching) ranges, sorted, and an integer that indicates
[2026] Fix | Delete
// which one is the primary selection (the one that's scrolled into
[2027] Fix | Delete
// view, that getCursor returns, etc).
[2028] Fix | Delete
function Selection(ranges, primIndex) {
[2029] Fix | Delete
this.ranges = ranges;
[2030] Fix | Delete
this.primIndex = primIndex;
[2031] Fix | Delete
}
[2032] Fix | Delete
[2033] Fix | Delete
Selection.prototype = {
[2034] Fix | Delete
primary: function() { return this.ranges[this.primIndex]; },
[2035] Fix | Delete
equals: function(other) {
[2036] Fix | Delete
if (other == this) return true;
[2037] Fix | Delete
if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
[2038] Fix | Delete
for (var i = 0; i < this.ranges.length; i++) {
[2039] Fix | Delete
var here = this.ranges[i], there = other.ranges[i];
[2040] Fix | Delete
if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
[2041] Fix | Delete
}
[2042] Fix | Delete
return true;
[2043] Fix | Delete
},
[2044] Fix | Delete
deepCopy: function() {
[2045] Fix | Delete
for (var out = [], i = 0; i < this.ranges.length; i++)
[2046] Fix | Delete
out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
[2047] Fix | Delete
return new Selection(out, this.primIndex);
[2048] Fix | Delete
},
[2049] Fix | Delete
somethingSelected: function() {
[2050] Fix | Delete
for (var i = 0; i < this.ranges.length; i++)
[2051] Fix | Delete
if (!this.ranges[i].empty()) return true;
[2052] Fix | Delete
return false;
[2053] Fix | Delete
},
[2054] Fix | Delete
contains: function(pos, end) {
[2055] Fix | Delete
if (!end) end = pos;
[2056] Fix | Delete
for (var i = 0; i < this.ranges.length; i++) {
[2057] Fix | Delete
var range = this.ranges[i];
[2058] Fix | Delete
if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
[2059] Fix | Delete
return i;
[2060] Fix | Delete
}
[2061] Fix | Delete
return -1;
[2062] Fix | Delete
}
[2063] Fix | Delete
};
[2064] Fix | Delete
[2065] Fix | Delete
function Range(anchor, head) {
[2066] Fix | Delete
this.anchor = anchor; this.head = head;
[2067] Fix | Delete
}
[2068] Fix | Delete
[2069] Fix | Delete
Range.prototype = {
[2070] Fix | Delete
from: function() { return minPos(this.anchor, this.head); },
[2071] Fix | Delete
to: function() { return maxPos(this.anchor, this.head); },
[2072] Fix | Delete
empty: function() {
[2073] Fix | Delete
return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
[2074] Fix | Delete
}
[2075] Fix | Delete
};
[2076] Fix | Delete
[2077] Fix | Delete
// Take an unsorted, potentially overlapping set of ranges, and
[2078] Fix | Delete
// build a selection out of it. 'Consumes' ranges array (modifying
[2079] Fix | Delete
// it).
[2080] Fix | Delete
function normalizeSelection(ranges, primIndex) {
[2081] Fix | Delete
var prim = ranges[primIndex];
[2082] Fix | Delete
ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
[2083] Fix | Delete
primIndex = indexOf(ranges, prim);
[2084] Fix | Delete
for (var i = 1; i < ranges.length; i++) {
[2085] Fix | Delete
var cur = ranges[i], prev = ranges[i - 1];
[2086] Fix | Delete
if (cmp(prev.to(), cur.from()) >= 0) {
[2087] Fix | Delete
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
[2088] Fix | Delete
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
[2089] Fix | Delete
if (i <= primIndex) --primIndex;
[2090] Fix | Delete
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
[2091] Fix | Delete
}
[2092] Fix | Delete
}
[2093] Fix | Delete
return new Selection(ranges, primIndex);
[2094] Fix | Delete
}
[2095] Fix | Delete
[2096] Fix | Delete
function simpleSelection(anchor, head) {
[2097] Fix | Delete
return new Selection([new Range(anchor, head || anchor)], 0);
[2098] Fix | Delete
}
[2099] Fix | Delete
[2100] Fix | Delete
// Most of the external API clips given positions to make sure they
[2101] Fix | Delete
// actually exist within the document.
[2102] Fix | Delete
function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
[2103] Fix | Delete
function clipPos(doc, pos) {
[2104] Fix | Delete
if (pos.line < doc.first) return Pos(doc.first, 0);
[2105] Fix | Delete
var last = doc.first + doc.size - 1;
[2106] Fix | Delete
if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
[2107] Fix | Delete
return clipToLen(pos, getLine(doc, pos.line).text.length);
[2108] Fix | Delete
}
[2109] Fix | Delete
function clipToLen(pos, linelen) {
[2110] Fix | Delete
var ch = pos.ch;
[2111] Fix | Delete
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
[2112] Fix | Delete
else if (ch < 0) return Pos(pos.line, 0);
[2113] Fix | Delete
else return pos;
[2114] Fix | Delete
}
[2115] Fix | Delete
function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
[2116] Fix | Delete
function clipPosArray(doc, array) {
[2117] Fix | Delete
for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
[2118] Fix | Delete
return out;
[2119] Fix | Delete
}
[2120] Fix | Delete
[2121] Fix | Delete
// SELECTION UPDATES
[2122] Fix | Delete
[2123] Fix | Delete
// The 'scroll' parameter given to many of these indicated whether
[2124] Fix | Delete
// the new cursor position should be scrolled into view after
[2125] Fix | Delete
// modifying the selection.
[2126] Fix | Delete
[2127] Fix | Delete
// If shift is held or the extend flag is set, extends a range to
[2128] Fix | Delete
// include a given position (and optionally a second position).
[2129] Fix | Delete
// Otherwise, simply returns the range between the given positions.
[2130] Fix | Delete
// Used for cursor motion and such.
[2131] Fix | Delete
function extendRange(doc, range, head, other) {
[2132] Fix | Delete
if (doc.cm && doc.cm.display.shift || doc.extend) {
[2133] Fix | Delete
var anchor = range.anchor;
[2134] Fix | Delete
if (other) {
[2135] Fix | Delete
var posBefore = cmp(head, anchor) < 0;
[2136] Fix | Delete
if (posBefore != (cmp(other, anchor) < 0)) {
[2137] Fix | Delete
anchor = head;
[2138] Fix | Delete
head = other;
[2139] Fix | Delete
} else if (posBefore != (cmp(head, other) < 0)) {
[2140] Fix | Delete
head = other;
[2141] Fix | Delete
}
[2142] Fix | Delete
}
[2143] Fix | Delete
return new Range(anchor, head);
[2144] Fix | Delete
} else {
[2145] Fix | Delete
return new Range(other || head, head);
[2146] Fix | Delete
}
[2147] Fix | Delete
}
[2148] Fix | Delete
[2149] Fix | Delete
// Extend the primary selection range, discard the rest.
[2150] Fix | Delete
function extendSelection(doc, head, other, options) {
[2151] Fix | Delete
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
[2152] Fix | Delete
}
[2153] Fix | Delete
[2154] Fix | Delete
// Extend all selections (pos is an array of selections with length
[2155] Fix | Delete
// equal the number of selections)
[2156] Fix | Delete
function extendSelections(doc, heads, options) {
[2157] Fix | Delete
for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
[2158] Fix | Delete
out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
[2159] Fix | Delete
var newSel = normalizeSelection(out, doc.sel.primIndex);
[2160] Fix | Delete
setSelection(doc, newSel, options);
[2161] Fix | Delete
}
[2162] Fix | Delete
[2163] Fix | Delete
// Updates a single range in the selection.
[2164] Fix | Delete
function replaceOneSelection(doc, i, range, options) {
[2165] Fix | Delete
var ranges = doc.sel.ranges.slice(0);
[2166] Fix | Delete
ranges[i] = range;
[2167] Fix | Delete
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
[2168] Fix | Delete
}
[2169] Fix | Delete
[2170] Fix | Delete
// Reset the selection to a single range.
[2171] Fix | Delete
function setSimpleSelection(doc, anchor, head, options) {
[2172] Fix | Delete
setSelection(doc, simpleSelection(anchor, head), options);
[2173] Fix | Delete
}
[2174] Fix | Delete
[2175] Fix | Delete
// Give beforeSelectionChange handlers a change to influence a
[2176] Fix | Delete
// selection update.
[2177] Fix | Delete
function filterSelectionChange(doc, sel, options) {
[2178] Fix | Delete
var obj = {
[2179] Fix | Delete
ranges: sel.ranges,
[2180] Fix | Delete
update: function(ranges) {
[2181] Fix | Delete
this.ranges = [];
[2182] Fix | Delete
for (var i = 0; i < ranges.length; i++)
[2183] Fix | Delete
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
[2184] Fix | Delete
clipPos(doc, ranges[i].head));
[2185] Fix | Delete
},
[2186] Fix | Delete
origin: options && options.origin
[2187] Fix | Delete
};
[2188] Fix | Delete
signal(doc, "beforeSelectionChange", doc, obj);
[2189] Fix | Delete
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
[2190] Fix | Delete
if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
[2191] Fix | Delete
else return sel;
[2192] Fix | Delete
}
[2193] Fix | Delete
[2194] Fix | Delete
function setSelectionReplaceHistory(doc, sel, options) {
[2195] Fix | Delete
var done = doc.history.done, last = lst(done);
[2196] Fix | Delete
if (last && last.ranges) {
[2197] Fix | Delete
done[done.length - 1] = sel;
[2198] Fix | Delete
setSelectionNoUndo(doc, sel, options);
[2199] Fix | Delete
} else {
[2200] Fix | Delete
setSelection(doc, sel, options);
[2201] Fix | Delete
}
[2202] Fix | Delete
}
[2203] Fix | Delete
[2204] Fix | Delete
// Set a new selection.
[2205] Fix | Delete
function setSelection(doc, sel, options) {
[2206] Fix | Delete
setSelectionNoUndo(doc, sel, options);
[2207] Fix | Delete
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
[2208] Fix | Delete
}
[2209] Fix | Delete
[2210] Fix | Delete
function setSelectionNoUndo(doc, sel, options) {
[2211] Fix | Delete
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
[2212] Fix | Delete
sel = filterSelectionChange(doc, sel, options);
[2213] Fix | Delete
[2214] Fix | Delete
var bias = options && options.bias ||
[2215] Fix | Delete
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
[2216] Fix | Delete
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
[2217] Fix | Delete
[2218] Fix | Delete
if (!(options && options.scroll === false) && doc.cm)
[2219] Fix | Delete
ensureCursorVisible(doc.cm);
[2220] Fix | Delete
}
[2221] Fix | Delete
[2222] Fix | Delete
function setSelectionInner(doc, sel) {
[2223] Fix | Delete
if (sel.equals(doc.sel)) return;
[2224] Fix | Delete
[2225] Fix | Delete
doc.sel = sel;
[2226] Fix | Delete
[2227] Fix | Delete
if (doc.cm) {
[2228] Fix | Delete
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
[2229] Fix | Delete
signalCursorActivity(doc.cm);
[2230] Fix | Delete
}
[2231] Fix | Delete
signalLater(doc, "cursorActivity", doc);
[2232] Fix | Delete
}
[2233] Fix | Delete
[2234] Fix | Delete
// Verify that the selection does not partially select any atomic
[2235] Fix | Delete
// marked ranges.
[2236] Fix | Delete
function reCheckSelection(doc) {
[2237] Fix | Delete
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
[2238] Fix | Delete
}
[2239] Fix | Delete
[2240] Fix | Delete
// Return a selection that does not partially select any atomic
[2241] Fix | Delete
// ranges.
[2242] Fix | Delete
function skipAtomicInSelection(doc, sel, bias, mayClear) {
[2243] Fix | Delete
var out;
[2244] Fix | Delete
for (var i = 0; i < sel.ranges.length; i++) {
[2245] Fix | Delete
var range = sel.ranges[i];
[2246] Fix | Delete
var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
[2247] Fix | Delete
var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
[2248] Fix | Delete
var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
[2249] Fix | Delete
if (out || newAnchor != range.anchor || newHead != range.head) {
[2250] Fix | Delete
if (!out) out = sel.ranges.slice(0, i);
[2251] Fix | Delete
out[i] = new Range(newAnchor, newHead);
[2252] Fix | Delete
}
[2253] Fix | Delete
}
[2254] Fix | Delete
return out ? normalizeSelection(out, sel.primIndex) : sel;
[2255] Fix | Delete
}
[2256] Fix | Delete
[2257] Fix | Delete
function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
[2258] Fix | Delete
var line = getLine(doc, pos.line);
[2259] Fix | Delete
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
[2260] Fix | Delete
var sp = line.markedSpans[i], m = sp.marker;
[2261] Fix | Delete
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
[2262] Fix | Delete
(sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
[2263] Fix | Delete
if (mayClear) {
[2264] Fix | Delete
signal(m, "beforeCursorEnter");
[2265] Fix | Delete
if (m.explicitlyCleared) {
[2266] Fix | Delete
if (!line.markedSpans) break;
[2267] Fix | Delete
else {--i; continue;}
[2268] Fix | Delete
}
[2269] Fix | Delete
}
[2270] Fix | Delete
if (!m.atomic) continue;
[2271] Fix | Delete
[2272] Fix | Delete
if (oldPos) {
[2273] Fix | Delete
var near = m.find(dir < 0 ? 1 : -1), diff;
[2274] Fix | Delete
if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
[2275] Fix | Delete
near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
[2276] Fix | Delete
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
[2277] Fix | Delete
return skipAtomicInner(doc, near, pos, dir, mayClear);
[2278] Fix | Delete
}
[2279] Fix | Delete
[2280] Fix | Delete
var far = m.find(dir < 0 ? -1 : 1);
[2281] Fix | Delete
if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
[2282] Fix | Delete
far = movePos(doc, far, dir, far.line == pos.line ? line : null);
[2283] Fix | Delete
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
[2284] Fix | Delete
}
[2285] Fix | Delete
}
[2286] Fix | Delete
return pos;
[2287] Fix | Delete
}
[2288] Fix | Delete
[2289] Fix | Delete
// Ensure a given position is not inside an atomic range.
[2290] Fix | Delete
function skipAtomic(doc, pos, oldPos, bias, mayClear) {
[2291] Fix | Delete
var dir = bias || 1;
[2292] Fix | Delete
var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
[2293] Fix | Delete
(!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
[2294] Fix | Delete
skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
[2295] Fix | Delete
(!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
[2296] Fix | Delete
if (!found) {
[2297] Fix | Delete
doc.cantEdit = true;
[2298] Fix | Delete
return Pos(doc.first, 0);
[2299] Fix | Delete
}
[2300] Fix | Delete
return found;
[2301] Fix | Delete
}
[2302] Fix | Delete
[2303] Fix | Delete
function movePos(doc, pos, dir, line) {
[2304] Fix | Delete
if (dir < 0 && pos.ch == 0) {
[2305] Fix | Delete
if (pos.line > doc.first) return clipPos(doc, Pos(pos.line - 1));
[2306] Fix | Delete
else return null;
[2307] Fix | Delete
} else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
[2308] Fix | Delete
if (pos.line < doc.first + doc.size - 1) return Pos(pos.line + 1, 0);
[2309] Fix | Delete
else return null;
[2310] Fix | Delete
} else {
[2311] Fix | Delete
return new Pos(pos.line, pos.ch + dir);
[2312] Fix | Delete
}
[2313] Fix | Delete
}
[2314] Fix | Delete
[2315] Fix | Delete
// SELECTION DRAWING
[2316] Fix | Delete
[2317] Fix | Delete
function updateSelection(cm) {
[2318] Fix | Delete
cm.display.input.showSelection(cm.display.input.prepareSelection());
[2319] Fix | Delete
}
[2320] Fix | Delete
[2321] Fix | Delete
function prepareSelection(cm, primary) {
[2322] Fix | Delete
var doc = cm.doc, result = {};
[2323] Fix | Delete
var curFragment = result.cursors = document.createDocumentFragment();
[2324] Fix | Delete
var selFragment = result.selection = document.createDocumentFragment();
[2325] Fix | Delete
[2326] Fix | Delete
for (var i = 0; i < doc.sel.ranges.length; i++) {
[2327] Fix | Delete
if (primary === false && i == doc.sel.primIndex) continue;
[2328] Fix | Delete
var range = doc.sel.ranges[i];
[2329] Fix | Delete
if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue;
[2330] Fix | Delete
var collapsed = range.empty();
[2331] Fix | Delete
if (collapsed || cm.options.showCursorWhenSelecting)
[2332] Fix | Delete
drawSelectionCursor(cm, range.head, curFragment);
[2333] Fix | Delete
if (!collapsed)
[2334] Fix | Delete
drawSelectionRange(cm, range, selFragment);
[2335] Fix | Delete
}
[2336] Fix | Delete
return result;
[2337] Fix | Delete
}
[2338] Fix | Delete
[2339] Fix | Delete
// Draws a cursor for the given range
[2340] Fix | Delete
function drawSelectionCursor(cm, head, output) {
[2341] Fix | Delete
var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
[2342] Fix | Delete
[2343] Fix | Delete
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
[2344] Fix | Delete
cursor.style.left = pos.left + "px";
[2345] Fix | Delete
cursor.style.top = pos.top + "px";
[2346] Fix | Delete
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
[2347] Fix | Delete
[2348] Fix | Delete
if (pos.other) {
[2349] Fix | Delete
// Secondary cursor, shown when on a 'jump' in bi-directional text
[2350] Fix | Delete
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
[2351] Fix | Delete
otherCursor.style.display = "";
[2352] Fix | Delete
otherCursor.style.left = pos.other.left + "px";
[2353] Fix | Delete
otherCursor.style.top = pos.other.top + "px";
[2354] Fix | Delete
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
[2355] Fix | Delete
}
[2356] Fix | Delete
}
[2357] Fix | Delete
[2358] Fix | Delete
// Draws the given range as a highlighted selection
[2359] Fix | Delete
function drawSelectionRange(cm, range, output) {
[2360] Fix | Delete
var display = cm.display, doc = cm.doc;
[2361] Fix | Delete
var fragment = document.createDocumentFragment();
[2362] Fix | Delete
var padding = paddingH(cm.display), leftSide = padding.left;
[2363] Fix | Delete
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
[2364] Fix | Delete
[2365] Fix | Delete
function add(left, top, width, bottom) {
[2366] Fix | Delete
if (top < 0) top = 0;
[2367] Fix | Delete
top = Math.round(top);
[2368] Fix | Delete
bottom = Math.round(bottom);
[2369] Fix | Delete
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
[2370] Fix | Delete
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
[2371] Fix | Delete
"px; height: " + (bottom - top) + "px"));
[2372] Fix | Delete
}
[2373] Fix | Delete
[2374] Fix | Delete
function drawForLine(line, fromArg, toArg) {
[2375] Fix | Delete
var lineObj = getLine(doc, line);
[2376] Fix | Delete
var lineLen = lineObj.text.length;
[2377] Fix | Delete
var start, end;
[2378] Fix | Delete
function coords(ch, bias) {
[2379] Fix | Delete
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
[2380] Fix | Delete
}
[2381] Fix | Delete
[2382] Fix | Delete
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
[2383] Fix | Delete
var leftPos = coords(from, "left"), rightPos, left, right;
[2384] Fix | Delete
if (from == to) {
[2385] Fix | Delete
rightPos = leftPos;
[2386] Fix | Delete
left = right = leftPos.left;
[2387] Fix | Delete
} else {
[2388] Fix | Delete
rightPos = coords(to - 1, "right");
[2389] Fix | Delete
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
[2390] Fix | Delete
left = leftPos.left;
[2391] Fix | Delete
right = rightPos.right;
[2392] Fix | Delete
}
[2393] Fix | Delete
if (fromArg == null && from == 0) left = leftSide;
[2394] Fix | Delete
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
[2395] Fix | Delete
add(left, leftPos.top, null, leftPos.bottom);
[2396] Fix | Delete
left = leftSide;
[2397] Fix | Delete
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
[2398] Fix | Delete
}
[2399] Fix | Delete
if (toArg == null && to == lineLen) right = rightSide;
[2400] Fix | Delete
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
[2401] Fix | Delete
start = leftPos;
[2402] Fix | Delete
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
[2403] Fix | Delete
end = rightPos;
[2404] Fix | Delete
if (left < leftSide + 1) left = leftSide;
[2405] Fix | Delete
add(left, rightPos.top, right - left, rightPos.bottom);
[2406] Fix | Delete
});
[2407] Fix | Delete
return {start: start, end: end};
[2408] Fix | Delete
}
[2409] Fix | Delete
[2410] Fix | Delete
var sFrom = range.from(), sTo = range.to();
[2411] Fix | Delete
if (sFrom.line == sTo.line) {
[2412] Fix | Delete
drawForLine(sFrom.line, sFrom.ch, sTo.ch);
[2413] Fix | Delete
} else {
[2414] Fix | Delete
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
[2415] Fix | Delete
var singleVLine = visualLine(fromLine) == visualLine(toLine);
[2416] Fix | Delete
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
[2417] Fix | Delete
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
[2418] Fix | Delete
if (singleVLine) {
[2419] Fix | Delete
if (leftEnd.top < rightStart.top - 2) {
[2420] Fix | Delete
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
[2421] Fix | Delete
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
[2422] Fix | Delete
} else {
[2423] Fix | Delete
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
[2424] Fix | Delete
}
[2425] Fix | Delete
}
[2426] Fix | Delete
if (leftEnd.bottom < rightStart.top)
[2427] Fix | Delete
add(leftSide, leftEnd.bottom, null, rightStart.top);
[2428] Fix | Delete
}
[2429] Fix | Delete
[2430] Fix | Delete
output.appendChild(fragment);
[2431] Fix | Delete
}
[2432] Fix | Delete
[2433] Fix | Delete
// Cursor-blinking
[2434] Fix | Delete
function restartBlink(cm) {
[2435] Fix | Delete
if (!cm.state.focused) return;
[2436] Fix | Delete
var display = cm.display;
[2437] Fix | Delete
clearInterval(display.blinker);
[2438] Fix | Delete
var on = true;
[2439] Fix | Delete
display.cursorDiv.style.visibility = "";
[2440] Fix | Delete
if (cm.options.cursorBlinkRate > 0)
[2441] Fix | Delete
display.blinker = setInterval(function() {
[2442] Fix | Delete
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
[2443] Fix | Delete
}, cm.options.cursorBlinkRate);
[2444] Fix | Delete
else if (cm.options.cursorBlinkRate < 0)
[2445] Fix | Delete
display.cursorDiv.style.visibility = "hidden";
[2446] Fix | Delete
}
[2447] Fix | Delete
[2448] Fix | Delete
// HIGHLIGHT WORKER
[2449] Fix | Delete
[2450] Fix | Delete
function startWorker(cm, time) {
[2451] Fix | Delete
if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
[2452] Fix | Delete
cm.state.highlight.set(time, bind(highlightWorker, cm));
[2453] Fix | Delete
}
[2454] Fix | Delete
[2455] Fix | Delete
function highlightWorker(cm) {
[2456] Fix | Delete
var doc = cm.doc;
[2457] Fix | Delete
if (doc.frontier < doc.first) doc.frontier = doc.first;
[2458] Fix | Delete
if (doc.frontier >= cm.display.viewTo) return;
[2459] Fix | Delete
var end = +new Date + cm.options.workTime;
[2460] Fix | Delete
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
[2461] Fix | Delete
var changedLines = [];
[2462] Fix | Delete
[2463] Fix | Delete
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
[2464] Fix | Delete
if (doc.frontier >= cm.display.viewFrom) { // Visible
[2465] Fix | Delete
var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
[2466] Fix | Delete
var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
[2467] Fix | Delete
line.styles = highlighted.styles;
[2468] Fix | Delete
var oldCls = line.styleClasses, newCls = highlighted.classes;
[2469] Fix | Delete
if (newCls) line.styleClasses = newCls;
[2470] Fix | Delete
else if (oldCls) line.styleClasses = null;
[2471] Fix | Delete
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
[2472] Fix | Delete
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
[2473] Fix | Delete
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
[2474] Fix | Delete
if (ischange) changedLines.push(doc.frontier);
[2475] Fix | Delete
line.stateAfter = tooLong ? state : copyState(doc.mode, state);
[2476] Fix | Delete
} else {
[2477] Fix | Delete
if (line.text.length <= cm.options.maxHighlightLength)
[2478] Fix | Delete
processLine(cm, line.text, state);
[2479] Fix | Delete
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
[2480] Fix | Delete
}
[2481] Fix | Delete
++doc.frontier;
[2482] Fix | Delete
if (+new Date > end) {
[2483] Fix | Delete
startWorker(cm, cm.options.workDelay);
[2484] Fix | Delete
return true;
[2485] Fix | Delete
}
[2486] Fix | Delete
});
[2487] Fix | Delete
if (changedLines.length) runInOp(cm, function() {
[2488] Fix | Delete
for (var i = 0; i < changedLines.length; i++)
[2489] Fix | Delete
regLineChange(cm, changedLines[i], "text");
[2490] Fix | Delete
});
[2491] Fix | Delete
}
[2492] Fix | Delete
[2493] Fix | Delete
// Finds the line to start with when starting a parse. Tries to
[2494] Fix | Delete
// find a line with a stateAfter, so that it can start with a
[2495] Fix | Delete
// valid state. If that fails, it returns the line with the
[2496] Fix | Delete
// smallest indentation, which tends to need the least context to
[2497] Fix | Delete
// parse correctly.
[2498] Fix | Delete
function findStartLine(cm, n, precise) {
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function