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
[7500] Fix | Delete
lineCount: function() {return this.size;},
[7501] Fix | Delete
firstLine: function() {return this.first;},
[7502] Fix | Delete
lastLine: function() {return this.first + this.size - 1;},
[7503] Fix | Delete
[7504] Fix | Delete
clipPos: function(pos) {return clipPos(this, pos);},
[7505] Fix | Delete
[7506] Fix | Delete
getCursor: function(start) {
[7507] Fix | Delete
var range = this.sel.primary(), pos;
[7508] Fix | Delete
if (start == null || start == "head") pos = range.head;
[7509] Fix | Delete
else if (start == "anchor") pos = range.anchor;
[7510] Fix | Delete
else if (start == "end" || start == "to" || start === false) pos = range.to();
[7511] Fix | Delete
else pos = range.from();
[7512] Fix | Delete
return pos;
[7513] Fix | Delete
},
[7514] Fix | Delete
listSelections: function() { return this.sel.ranges; },
[7515] Fix | Delete
somethingSelected: function() {return this.sel.somethingSelected();},
[7516] Fix | Delete
[7517] Fix | Delete
setCursor: docMethodOp(function(line, ch, options) {
[7518] Fix | Delete
setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
[7519] Fix | Delete
}),
[7520] Fix | Delete
setSelection: docMethodOp(function(anchor, head, options) {
[7521] Fix | Delete
setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
[7522] Fix | Delete
}),
[7523] Fix | Delete
extendSelection: docMethodOp(function(head, other, options) {
[7524] Fix | Delete
extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
[7525] Fix | Delete
}),
[7526] Fix | Delete
extendSelections: docMethodOp(function(heads, options) {
[7527] Fix | Delete
extendSelections(this, clipPosArray(this, heads), options);
[7528] Fix | Delete
}),
[7529] Fix | Delete
extendSelectionsBy: docMethodOp(function(f, options) {
[7530] Fix | Delete
var heads = map(this.sel.ranges, f);
[7531] Fix | Delete
extendSelections(this, clipPosArray(this, heads), options);
[7532] Fix | Delete
}),
[7533] Fix | Delete
setSelections: docMethodOp(function(ranges, primary, options) {
[7534] Fix | Delete
if (!ranges.length) return;
[7535] Fix | Delete
for (var i = 0, out = []; i < ranges.length; i++)
[7536] Fix | Delete
out[i] = new Range(clipPos(this, ranges[i].anchor),
[7537] Fix | Delete
clipPos(this, ranges[i].head));
[7538] Fix | Delete
if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
[7539] Fix | Delete
setSelection(this, normalizeSelection(out, primary), options);
[7540] Fix | Delete
}),
[7541] Fix | Delete
addSelection: docMethodOp(function(anchor, head, options) {
[7542] Fix | Delete
var ranges = this.sel.ranges.slice(0);
[7543] Fix | Delete
ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
[7544] Fix | Delete
setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
[7545] Fix | Delete
}),
[7546] Fix | Delete
[7547] Fix | Delete
getSelection: function(lineSep) {
[7548] Fix | Delete
var ranges = this.sel.ranges, lines;
[7549] Fix | Delete
for (var i = 0; i < ranges.length; i++) {
[7550] Fix | Delete
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
[7551] Fix | Delete
lines = lines ? lines.concat(sel) : sel;
[7552] Fix | Delete
}
[7553] Fix | Delete
if (lineSep === false) return lines;
[7554] Fix | Delete
else return lines.join(lineSep || this.lineSeparator());
[7555] Fix | Delete
},
[7556] Fix | Delete
getSelections: function(lineSep) {
[7557] Fix | Delete
var parts = [], ranges = this.sel.ranges;
[7558] Fix | Delete
for (var i = 0; i < ranges.length; i++) {
[7559] Fix | Delete
var sel = getBetween(this, ranges[i].from(), ranges[i].to());
[7560] Fix | Delete
if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator());
[7561] Fix | Delete
parts[i] = sel;
[7562] Fix | Delete
}
[7563] Fix | Delete
return parts;
[7564] Fix | Delete
},
[7565] Fix | Delete
replaceSelection: function(code, collapse, origin) {
[7566] Fix | Delete
var dup = [];
[7567] Fix | Delete
for (var i = 0; i < this.sel.ranges.length; i++)
[7568] Fix | Delete
dup[i] = code;
[7569] Fix | Delete
this.replaceSelections(dup, collapse, origin || "+input");
[7570] Fix | Delete
},
[7571] Fix | Delete
replaceSelections: docMethodOp(function(code, collapse, origin) {
[7572] Fix | Delete
var changes = [], sel = this.sel;
[7573] Fix | Delete
for (var i = 0; i < sel.ranges.length; i++) {
[7574] Fix | Delete
var range = sel.ranges[i];
[7575] Fix | Delete
changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin};
[7576] Fix | Delete
}
[7577] Fix | Delete
var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
[7578] Fix | Delete
for (var i = changes.length - 1; i >= 0; i--)
[7579] Fix | Delete
makeChange(this, changes[i]);
[7580] Fix | Delete
if (newSel) setSelectionReplaceHistory(this, newSel);
[7581] Fix | Delete
else if (this.cm) ensureCursorVisible(this.cm);
[7582] Fix | Delete
}),
[7583] Fix | Delete
undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
[7584] Fix | Delete
redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
[7585] Fix | Delete
undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
[7586] Fix | Delete
redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
[7587] Fix | Delete
[7588] Fix | Delete
setExtending: function(val) {this.extend = val;},
[7589] Fix | Delete
getExtending: function() {return this.extend;},
[7590] Fix | Delete
[7591] Fix | Delete
historySize: function() {
[7592] Fix | Delete
var hist = this.history, done = 0, undone = 0;
[7593] Fix | Delete
for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
[7594] Fix | Delete
for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
[7595] Fix | Delete
return {undo: done, redo: undone};
[7596] Fix | Delete
},
[7597] Fix | Delete
clearHistory: function() {this.history = new History(this.history.maxGeneration);},
[7598] Fix | Delete
[7599] Fix | Delete
markClean: function() {
[7600] Fix | Delete
this.cleanGeneration = this.changeGeneration(true);
[7601] Fix | Delete
},
[7602] Fix | Delete
changeGeneration: function(forceSplit) {
[7603] Fix | Delete
if (forceSplit)
[7604] Fix | Delete
this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
[7605] Fix | Delete
return this.history.generation;
[7606] Fix | Delete
},
[7607] Fix | Delete
isClean: function (gen) {
[7608] Fix | Delete
return this.history.generation == (gen || this.cleanGeneration);
[7609] Fix | Delete
},
[7610] Fix | Delete
[7611] Fix | Delete
getHistory: function() {
[7612] Fix | Delete
return {done: copyHistoryArray(this.history.done),
[7613] Fix | Delete
undone: copyHistoryArray(this.history.undone)};
[7614] Fix | Delete
},
[7615] Fix | Delete
setHistory: function(histData) {
[7616] Fix | Delete
var hist = this.history = new History(this.history.maxGeneration);
[7617] Fix | Delete
hist.done = copyHistoryArray(histData.done.slice(0), null, true);
[7618] Fix | Delete
hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
[7619] Fix | Delete
},
[7620] Fix | Delete
[7621] Fix | Delete
addLineClass: docMethodOp(function(handle, where, cls) {
[7622] Fix | Delete
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
[7623] Fix | Delete
var prop = where == "text" ? "textClass"
[7624] Fix | Delete
: where == "background" ? "bgClass"
[7625] Fix | Delete
: where == "gutter" ? "gutterClass" : "wrapClass";
[7626] Fix | Delete
if (!line[prop]) line[prop] = cls;
[7627] Fix | Delete
else if (classTest(cls).test(line[prop])) return false;
[7628] Fix | Delete
else line[prop] += " " + cls;
[7629] Fix | Delete
return true;
[7630] Fix | Delete
});
[7631] Fix | Delete
}),
[7632] Fix | Delete
removeLineClass: docMethodOp(function(handle, where, cls) {
[7633] Fix | Delete
return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
[7634] Fix | Delete
var prop = where == "text" ? "textClass"
[7635] Fix | Delete
: where == "background" ? "bgClass"
[7636] Fix | Delete
: where == "gutter" ? "gutterClass" : "wrapClass";
[7637] Fix | Delete
var cur = line[prop];
[7638] Fix | Delete
if (!cur) return false;
[7639] Fix | Delete
else if (cls == null) line[prop] = null;
[7640] Fix | Delete
else {
[7641] Fix | Delete
var found = cur.match(classTest(cls));
[7642] Fix | Delete
if (!found) return false;
[7643] Fix | Delete
var end = found.index + found[0].length;
[7644] Fix | Delete
line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
[7645] Fix | Delete
}
[7646] Fix | Delete
return true;
[7647] Fix | Delete
});
[7648] Fix | Delete
}),
[7649] Fix | Delete
[7650] Fix | Delete
addLineWidget: docMethodOp(function(handle, node, options) {
[7651] Fix | Delete
return addLineWidget(this, handle, node, options);
[7652] Fix | Delete
}),
[7653] Fix | Delete
removeLineWidget: function(widget) { widget.clear(); },
[7654] Fix | Delete
[7655] Fix | Delete
markText: function(from, to, options) {
[7656] Fix | Delete
return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range");
[7657] Fix | Delete
},
[7658] Fix | Delete
setBookmark: function(pos, options) {
[7659] Fix | Delete
var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
[7660] Fix | Delete
insertLeft: options && options.insertLeft,
[7661] Fix | Delete
clearWhenEmpty: false, shared: options && options.shared,
[7662] Fix | Delete
handleMouseEvents: options && options.handleMouseEvents};
[7663] Fix | Delete
pos = clipPos(this, pos);
[7664] Fix | Delete
return markText(this, pos, pos, realOpts, "bookmark");
[7665] Fix | Delete
},
[7666] Fix | Delete
findMarksAt: function(pos) {
[7667] Fix | Delete
pos = clipPos(this, pos);
[7668] Fix | Delete
var markers = [], spans = getLine(this, pos.line).markedSpans;
[7669] Fix | Delete
if (spans) for (var i = 0; i < spans.length; ++i) {
[7670] Fix | Delete
var span = spans[i];
[7671] Fix | Delete
if ((span.from == null || span.from <= pos.ch) &&
[7672] Fix | Delete
(span.to == null || span.to >= pos.ch))
[7673] Fix | Delete
markers.push(span.marker.parent || span.marker);
[7674] Fix | Delete
}
[7675] Fix | Delete
return markers;
[7676] Fix | Delete
},
[7677] Fix | Delete
findMarks: function(from, to, filter) {
[7678] Fix | Delete
from = clipPos(this, from); to = clipPos(this, to);
[7679] Fix | Delete
var found = [], lineNo = from.line;
[7680] Fix | Delete
this.iter(from.line, to.line + 1, function(line) {
[7681] Fix | Delete
var spans = line.markedSpans;
[7682] Fix | Delete
if (spans) for (var i = 0; i < spans.length; i++) {
[7683] Fix | Delete
var span = spans[i];
[7684] Fix | Delete
if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
[7685] Fix | Delete
span.from == null && lineNo != from.line ||
[7686] Fix | Delete
span.from != null && lineNo == to.line && span.from >= to.ch) &&
[7687] Fix | Delete
(!filter || filter(span.marker)))
[7688] Fix | Delete
found.push(span.marker.parent || span.marker);
[7689] Fix | Delete
}
[7690] Fix | Delete
++lineNo;
[7691] Fix | Delete
});
[7692] Fix | Delete
return found;
[7693] Fix | Delete
},
[7694] Fix | Delete
getAllMarks: function() {
[7695] Fix | Delete
var markers = [];
[7696] Fix | Delete
this.iter(function(line) {
[7697] Fix | Delete
var sps = line.markedSpans;
[7698] Fix | Delete
if (sps) for (var i = 0; i < sps.length; ++i)
[7699] Fix | Delete
if (sps[i].from != null) markers.push(sps[i].marker);
[7700] Fix | Delete
});
[7701] Fix | Delete
return markers;
[7702] Fix | Delete
},
[7703] Fix | Delete
[7704] Fix | Delete
posFromIndex: function(off) {
[7705] Fix | Delete
var ch, lineNo = this.first, sepSize = this.lineSeparator().length;
[7706] Fix | Delete
this.iter(function(line) {
[7707] Fix | Delete
var sz = line.text.length + sepSize;
[7708] Fix | Delete
if (sz > off) { ch = off; return true; }
[7709] Fix | Delete
off -= sz;
[7710] Fix | Delete
++lineNo;
[7711] Fix | Delete
});
[7712] Fix | Delete
return clipPos(this, Pos(lineNo, ch));
[7713] Fix | Delete
},
[7714] Fix | Delete
indexFromPos: function (coords) {
[7715] Fix | Delete
coords = clipPos(this, coords);
[7716] Fix | Delete
var index = coords.ch;
[7717] Fix | Delete
if (coords.line < this.first || coords.ch < 0) return 0;
[7718] Fix | Delete
var sepSize = this.lineSeparator().length;
[7719] Fix | Delete
this.iter(this.first, coords.line, function (line) {
[7720] Fix | Delete
index += line.text.length + sepSize;
[7721] Fix | Delete
});
[7722] Fix | Delete
return index;
[7723] Fix | Delete
},
[7724] Fix | Delete
[7725] Fix | Delete
copy: function(copyHistory) {
[7726] Fix | Delete
var doc = new Doc(getLines(this, this.first, this.first + this.size),
[7727] Fix | Delete
this.modeOption, this.first, this.lineSep);
[7728] Fix | Delete
doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
[7729] Fix | Delete
doc.sel = this.sel;
[7730] Fix | Delete
doc.extend = false;
[7731] Fix | Delete
if (copyHistory) {
[7732] Fix | Delete
doc.history.undoDepth = this.history.undoDepth;
[7733] Fix | Delete
doc.setHistory(this.getHistory());
[7734] Fix | Delete
}
[7735] Fix | Delete
return doc;
[7736] Fix | Delete
},
[7737] Fix | Delete
[7738] Fix | Delete
linkedDoc: function(options) {
[7739] Fix | Delete
if (!options) options = {};
[7740] Fix | Delete
var from = this.first, to = this.first + this.size;
[7741] Fix | Delete
if (options.from != null && options.from > from) from = options.from;
[7742] Fix | Delete
if (options.to != null && options.to < to) to = options.to;
[7743] Fix | Delete
var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep);
[7744] Fix | Delete
if (options.sharedHist) copy.history = this.history;
[7745] Fix | Delete
(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
[7746] Fix | Delete
copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
[7747] Fix | Delete
copySharedMarkers(copy, findSharedMarkers(this));
[7748] Fix | Delete
return copy;
[7749] Fix | Delete
},
[7750] Fix | Delete
unlinkDoc: function(other) {
[7751] Fix | Delete
if (other instanceof CodeMirror) other = other.doc;
[7752] Fix | Delete
if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
[7753] Fix | Delete
var link = this.linked[i];
[7754] Fix | Delete
if (link.doc != other) continue;
[7755] Fix | Delete
this.linked.splice(i, 1);
[7756] Fix | Delete
other.unlinkDoc(this);
[7757] Fix | Delete
detachSharedMarkers(findSharedMarkers(this));
[7758] Fix | Delete
break;
[7759] Fix | Delete
}
[7760] Fix | Delete
// If the histories were shared, split them again
[7761] Fix | Delete
if (other.history == this.history) {
[7762] Fix | Delete
var splitIds = [other.id];
[7763] Fix | Delete
linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
[7764] Fix | Delete
other.history = new History(null);
[7765] Fix | Delete
other.history.done = copyHistoryArray(this.history.done, splitIds);
[7766] Fix | Delete
other.history.undone = copyHistoryArray(this.history.undone, splitIds);
[7767] Fix | Delete
}
[7768] Fix | Delete
},
[7769] Fix | Delete
iterLinkedDocs: function(f) {linkedDocs(this, f);},
[7770] Fix | Delete
[7771] Fix | Delete
getMode: function() {return this.mode;},
[7772] Fix | Delete
getEditor: function() {return this.cm;},
[7773] Fix | Delete
[7774] Fix | Delete
splitLines: function(str) {
[7775] Fix | Delete
if (this.lineSep) return str.split(this.lineSep);
[7776] Fix | Delete
return splitLinesAuto(str);
[7777] Fix | Delete
},
[7778] Fix | Delete
lineSeparator: function() { return this.lineSep || "\n"; }
[7779] Fix | Delete
});
[7780] Fix | Delete
[7781] Fix | Delete
// Public alias.
[7782] Fix | Delete
Doc.prototype.eachLine = Doc.prototype.iter;
[7783] Fix | Delete
[7784] Fix | Delete
// Set up methods on CodeMirror's prototype to redirect to the editor's document.
[7785] Fix | Delete
var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
[7786] Fix | Delete
for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
[7787] Fix | Delete
CodeMirror.prototype[prop] = (function(method) {
[7788] Fix | Delete
return function() {return method.apply(this.doc, arguments);};
[7789] Fix | Delete
})(Doc.prototype[prop]);
[7790] Fix | Delete
[7791] Fix | Delete
eventMixin(Doc);
[7792] Fix | Delete
[7793] Fix | Delete
// Call f for all linked documents.
[7794] Fix | Delete
function linkedDocs(doc, f, sharedHistOnly) {
[7795] Fix | Delete
function propagate(doc, skip, sharedHist) {
[7796] Fix | Delete
if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
[7797] Fix | Delete
var rel = doc.linked[i];
[7798] Fix | Delete
if (rel.doc == skip) continue;
[7799] Fix | Delete
var shared = sharedHist && rel.sharedHist;
[7800] Fix | Delete
if (sharedHistOnly && !shared) continue;
[7801] Fix | Delete
f(rel.doc, shared);
[7802] Fix | Delete
propagate(rel.doc, doc, shared);
[7803] Fix | Delete
}
[7804] Fix | Delete
}
[7805] Fix | Delete
propagate(doc, null, true);
[7806] Fix | Delete
}
[7807] Fix | Delete
[7808] Fix | Delete
// Attach a document to an editor.
[7809] Fix | Delete
function attachDoc(cm, doc) {
[7810] Fix | Delete
if (doc.cm) throw new Error("This document is already in use.");
[7811] Fix | Delete
cm.doc = doc;
[7812] Fix | Delete
doc.cm = cm;
[7813] Fix | Delete
estimateLineHeights(cm);
[7814] Fix | Delete
loadMode(cm);
[7815] Fix | Delete
if (!cm.options.lineWrapping) findMaxLine(cm);
[7816] Fix | Delete
cm.options.mode = doc.modeOption;
[7817] Fix | Delete
regChange(cm);
[7818] Fix | Delete
}
[7819] Fix | Delete
[7820] Fix | Delete
// LINE UTILITIES
[7821] Fix | Delete
[7822] Fix | Delete
// Find the line object corresponding to the given line number.
[7823] Fix | Delete
function getLine(doc, n) {
[7824] Fix | Delete
n -= doc.first;
[7825] Fix | Delete
if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
[7826] Fix | Delete
for (var chunk = doc; !chunk.lines;) {
[7827] Fix | Delete
for (var i = 0;; ++i) {
[7828] Fix | Delete
var child = chunk.children[i], sz = child.chunkSize();
[7829] Fix | Delete
if (n < sz) { chunk = child; break; }
[7830] Fix | Delete
n -= sz;
[7831] Fix | Delete
}
[7832] Fix | Delete
}
[7833] Fix | Delete
return chunk.lines[n];
[7834] Fix | Delete
}
[7835] Fix | Delete
[7836] Fix | Delete
// Get the part of a document between two positions, as an array of
[7837] Fix | Delete
// strings.
[7838] Fix | Delete
function getBetween(doc, start, end) {
[7839] Fix | Delete
var out = [], n = start.line;
[7840] Fix | Delete
doc.iter(start.line, end.line + 1, function(line) {
[7841] Fix | Delete
var text = line.text;
[7842] Fix | Delete
if (n == end.line) text = text.slice(0, end.ch);
[7843] Fix | Delete
if (n == start.line) text = text.slice(start.ch);
[7844] Fix | Delete
out.push(text);
[7845] Fix | Delete
++n;
[7846] Fix | Delete
});
[7847] Fix | Delete
return out;
[7848] Fix | Delete
}
[7849] Fix | Delete
// Get the lines between from and to, as array of strings.
[7850] Fix | Delete
function getLines(doc, from, to) {
[7851] Fix | Delete
var out = [];
[7852] Fix | Delete
doc.iter(from, to, function(line) { out.push(line.text); });
[7853] Fix | Delete
return out;
[7854] Fix | Delete
}
[7855] Fix | Delete
[7856] Fix | Delete
// Update the height of a line, propagating the height change
[7857] Fix | Delete
// upwards to parent nodes.
[7858] Fix | Delete
function updateLineHeight(line, height) {
[7859] Fix | Delete
var diff = height - line.height;
[7860] Fix | Delete
if (diff) for (var n = line; n; n = n.parent) n.height += diff;
[7861] Fix | Delete
}
[7862] Fix | Delete
[7863] Fix | Delete
// Given a line object, find its line number by walking up through
[7864] Fix | Delete
// its parent links.
[7865] Fix | Delete
function lineNo(line) {
[7866] Fix | Delete
if (line.parent == null) return null;
[7867] Fix | Delete
var cur = line.parent, no = indexOf(cur.lines, line);
[7868] Fix | Delete
for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
[7869] Fix | Delete
for (var i = 0;; ++i) {
[7870] Fix | Delete
if (chunk.children[i] == cur) break;
[7871] Fix | Delete
no += chunk.children[i].chunkSize();
[7872] Fix | Delete
}
[7873] Fix | Delete
}
[7874] Fix | Delete
return no + cur.first;
[7875] Fix | Delete
}
[7876] Fix | Delete
[7877] Fix | Delete
// Find the line at the given vertical position, using the height
[7878] Fix | Delete
// information in the document tree.
[7879] Fix | Delete
function lineAtHeight(chunk, h) {
[7880] Fix | Delete
var n = chunk.first;
[7881] Fix | Delete
outer: do {
[7882] Fix | Delete
for (var i = 0; i < chunk.children.length; ++i) {
[7883] Fix | Delete
var child = chunk.children[i], ch = child.height;
[7884] Fix | Delete
if (h < ch) { chunk = child; continue outer; }
[7885] Fix | Delete
h -= ch;
[7886] Fix | Delete
n += child.chunkSize();
[7887] Fix | Delete
}
[7888] Fix | Delete
return n;
[7889] Fix | Delete
} while (!chunk.lines);
[7890] Fix | Delete
for (var i = 0; i < chunk.lines.length; ++i) {
[7891] Fix | Delete
var line = chunk.lines[i], lh = line.height;
[7892] Fix | Delete
if (h < lh) break;
[7893] Fix | Delete
h -= lh;
[7894] Fix | Delete
}
[7895] Fix | Delete
return n + i;
[7896] Fix | Delete
}
[7897] Fix | Delete
[7898] Fix | Delete
[7899] Fix | Delete
// Find the height above the given line.
[7900] Fix | Delete
function heightAtLine(lineObj) {
[7901] Fix | Delete
lineObj = visualLine(lineObj);
[7902] Fix | Delete
[7903] Fix | Delete
var h = 0, chunk = lineObj.parent;
[7904] Fix | Delete
for (var i = 0; i < chunk.lines.length; ++i) {
[7905] Fix | Delete
var line = chunk.lines[i];
[7906] Fix | Delete
if (line == lineObj) break;
[7907] Fix | Delete
else h += line.height;
[7908] Fix | Delete
}
[7909] Fix | Delete
for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
[7910] Fix | Delete
for (var i = 0; i < p.children.length; ++i) {
[7911] Fix | Delete
var cur = p.children[i];
[7912] Fix | Delete
if (cur == chunk) break;
[7913] Fix | Delete
else h += cur.height;
[7914] Fix | Delete
}
[7915] Fix | Delete
}
[7916] Fix | Delete
return h;
[7917] Fix | Delete
}
[7918] Fix | Delete
[7919] Fix | Delete
// Get the bidi ordering for the given line (and cache it). Returns
[7920] Fix | Delete
// false for lines that are fully left-to-right, and an array of
[7921] Fix | Delete
// BidiSpan objects otherwise.
[7922] Fix | Delete
function getOrder(line) {
[7923] Fix | Delete
var order = line.order;
[7924] Fix | Delete
if (order == null) order = line.order = bidiOrdering(line.text);
[7925] Fix | Delete
return order;
[7926] Fix | Delete
}
[7927] Fix | Delete
[7928] Fix | Delete
// HISTORY
[7929] Fix | Delete
[7930] Fix | Delete
function History(startGen) {
[7931] Fix | Delete
// Arrays of change events and selections. Doing something adds an
[7932] Fix | Delete
// event to done and clears undo. Undoing moves events from done
[7933] Fix | Delete
// to undone, redoing moves them in the other direction.
[7934] Fix | Delete
this.done = []; this.undone = [];
[7935] Fix | Delete
this.undoDepth = Infinity;
[7936] Fix | Delete
// Used to track when changes can be merged into a single undo
[7937] Fix | Delete
// event
[7938] Fix | Delete
this.lastModTime = this.lastSelTime = 0;
[7939] Fix | Delete
this.lastOp = this.lastSelOp = null;
[7940] Fix | Delete
this.lastOrigin = this.lastSelOrigin = null;
[7941] Fix | Delete
// Used by the isClean() method
[7942] Fix | Delete
this.generation = this.maxGeneration = startGen || 1;
[7943] Fix | Delete
}
[7944] Fix | Delete
[7945] Fix | Delete
// Create a history change event from an updateDoc-style change
[7946] Fix | Delete
// object.
[7947] Fix | Delete
function historyChangeFromChange(doc, change) {
[7948] Fix | Delete
var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
[7949] Fix | Delete
attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
[7950] Fix | Delete
linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
[7951] Fix | Delete
return histChange;
[7952] Fix | Delete
}
[7953] Fix | Delete
[7954] Fix | Delete
// Pop all selection events off the end of a history array. Stop at
[7955] Fix | Delete
// a change event.
[7956] Fix | Delete
function clearSelectionEvents(array) {
[7957] Fix | Delete
while (array.length) {
[7958] Fix | Delete
var last = lst(array);
[7959] Fix | Delete
if (last.ranges) array.pop();
[7960] Fix | Delete
else break;
[7961] Fix | Delete
}
[7962] Fix | Delete
}
[7963] Fix | Delete
[7964] Fix | Delete
// Find the top change event in the history. Pop off selection
[7965] Fix | Delete
// events that are in the way.
[7966] Fix | Delete
function lastChangeEvent(hist, force) {
[7967] Fix | Delete
if (force) {
[7968] Fix | Delete
clearSelectionEvents(hist.done);
[7969] Fix | Delete
return lst(hist.done);
[7970] Fix | Delete
} else if (hist.done.length && !lst(hist.done).ranges) {
[7971] Fix | Delete
return lst(hist.done);
[7972] Fix | Delete
} else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
[7973] Fix | Delete
hist.done.pop();
[7974] Fix | Delete
return lst(hist.done);
[7975] Fix | Delete
}
[7976] Fix | Delete
}
[7977] Fix | Delete
[7978] Fix | Delete
// Register a change in the history. Merges changes that are within
[7979] Fix | Delete
// a single operation, or are close together with an origin that
[7980] Fix | Delete
// allows merging (starting with "+") into a single event.
[7981] Fix | Delete
function addChangeToHistory(doc, change, selAfter, opId) {
[7982] Fix | Delete
var hist = doc.history;
[7983] Fix | Delete
hist.undone.length = 0;
[7984] Fix | Delete
var time = +new Date, cur;
[7985] Fix | Delete
[7986] Fix | Delete
if ((hist.lastOp == opId ||
[7987] Fix | Delete
hist.lastOrigin == change.origin && change.origin &&
[7988] Fix | Delete
((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
[7989] Fix | Delete
change.origin.charAt(0) == "*")) &&
[7990] Fix | Delete
(cur = lastChangeEvent(hist, hist.lastOp == opId))) {
[7991] Fix | Delete
// Merge this change into the last event
[7992] Fix | Delete
var last = lst(cur.changes);
[7993] Fix | Delete
if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
[7994] Fix | Delete
// Optimized case for simple insertion -- don't want to add
[7995] Fix | Delete
// new changesets for every character typed
[7996] Fix | Delete
last.to = changeEnd(change);
[7997] Fix | Delete
} else {
[7998] Fix | Delete
// Add new sub-event
[7999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function