code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function handleCharBinding(cm, e, ch) {
return dispatchKey(cm, "'" + ch + "'", e,
function(b) { return doHandleBinding(cm, b, true); });
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
handleCharBinding
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onKeyDown(e) {
var cm = this;
cm.curOp.focus = activeElt();
if (signalDOMEvent(cm, e)) return;
// IE does strange things with escape.
if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
var code = e.keyCode;
cm.display.shift = code == 16 || e.shiftKey;
var handled = handleKeyBinding(cm, e);
if (presto) {
lastStoppedKey = handled ? code : null;
// Opera has no cut event... we try to at least catch the key combo
if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
cm.replaceSelection("", null, "cut");
}
// Turn mouse into crosshair when Alt is held on Mac.
if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
showCrossHair(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onKeyDown
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function showCrossHair(cm) {
var lineDiv = cm.display.lineDiv;
addClass(lineDiv, "CodeMirror-crosshair");
function up(e) {
if (e.keyCode == 18 || !e.altKey) {
rmClass(lineDiv, "CodeMirror-crosshair");
off(document, "keyup", up);
off(document, "mouseover", up);
}
}
on(document, "keyup", up);
on(document, "mouseover", up);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
showCrossHair
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function up(e) {
if (e.keyCode == 18 || !e.altKey) {
rmClass(lineDiv, "CodeMirror-crosshair");
off(document, "keyup", up);
off(document, "mouseover", up);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
up
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onKeyUp(e) {
if (e.keyCode == 16) this.doc.sel.shift = false;
signalDOMEvent(this, e);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onKeyUp
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onKeyPress(e) {
var cm = this;
if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
var keyCode = e.keyCode, charCode = e.charCode;
if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return;
var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
if (handleCharBinding(cm, e, ch)) return;
cm.display.input.onKeyPress(e);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onKeyPress
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function delayBlurEvent(cm) {
cm.state.delayingBlurEvent = true;
setTimeout(function() {
if (cm.state.delayingBlurEvent) {
cm.state.delayingBlurEvent = false;
onBlur(cm);
}
}, 100);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
delayBlurEvent
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onFocus(cm) {
if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
if (cm.options.readOnly == "nocursor") return;
if (!cm.state.focused) {
signal(cm, "focus", cm);
cm.state.focused = true;
addClass(cm.display.wrapper, "CodeMirror-focused");
// This test prevents this from firing when a context
// menu is closed (since the input reset would kill the
// select-all detection hack)
if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
cm.display.input.reset();
if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730
}
cm.display.input.receivedFocus();
}
restartBlink(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onFocus
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onBlur(cm) {
if (cm.state.delayingBlurEvent) return;
if (cm.state.focused) {
signal(cm, "blur", cm);
cm.state.focused = false;
rmClass(cm.display.wrapper, "CodeMirror-focused");
}
clearInterval(cm.display.blinker);
setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onBlur
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onContextMenu(cm, e) {
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
if (signalDOMEvent(cm, e, "contextmenu")) return;
cm.display.input.onContextMenu(e);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onContextMenu
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function contextMenuInGutter(cm, e) {
if (!hasHandler(cm, "gutterContextMenu")) return false;
return gutterEvent(cm, e, "gutterContextMenu", false);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
contextMenuInGutter
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function adjustForChange(pos, change) {
if (cmp(pos, change.from) < 0) return pos;
if (cmp(pos, change.to) <= 0) return changeEnd(change);
var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
return Pos(line, ch);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
adjustForChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function computeSelAfterChange(doc, change) {
var out = [];
for (var i = 0; i < doc.sel.ranges.length; i++) {
var range = doc.sel.ranges[i];
out.push(new Range(adjustForChange(range.anchor, change),
adjustForChange(range.head, change)));
}
return normalizeSelection(out, doc.sel.primIndex);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
computeSelAfterChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function offsetPos(pos, old, nw) {
if (pos.line == old.line)
return Pos(nw.line, pos.ch - old.ch + nw.ch);
else
return Pos(nw.line + (pos.line - old.line), pos.ch);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
offsetPos
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function computeReplacedSel(doc, changes, hint) {
var out = [];
var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
for (var i = 0; i < changes.length; i++) {
var change = changes[i];
var from = offsetPos(change.from, oldPrev, newPrev);
var to = offsetPos(changeEnd(change), oldPrev, newPrev);
oldPrev = change.to;
newPrev = to;
if (hint == "around") {
var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
out[i] = new Range(inv ? to : from, inv ? from : to);
} else {
out[i] = new Range(from, from);
}
}
return new Selection(out, doc.sel.primIndex);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
computeReplacedSel
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function filterChange(doc, change, update) {
var obj = {
canceled: false,
from: change.from,
to: change.to,
text: change.text,
origin: change.origin,
cancel: function() { this.canceled = true; }
};
if (update) obj.update = function(from, to, text, origin) {
if (from) this.from = clipPos(doc, from);
if (to) this.to = clipPos(doc, to);
if (text) this.text = text;
if (origin !== undefined) this.origin = origin;
};
signal(doc, "beforeChange", doc, obj);
if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
if (obj.canceled) return null;
return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
filterChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function makeChange(doc, change, ignoreReadOnly) {
if (doc.cm) {
if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
if (doc.cm.state.suppressEdits) return;
}
if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
change = filterChange(doc, change, true);
if (!change) return;
}
// Possibly split or suppress the update based on the presence
// of read-only spans in its range.
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
if (split) {
for (var i = split.length - 1; i >= 0; --i)
makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
} else {
makeChangeInner(doc, change);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
makeChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function makeChangeInner(doc, change) {
if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
var selAfter = computeSelAfterChange(doc, change);
addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
var rebased = [];
linkedDocs(doc, function(doc, sharedHist) {
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
rebaseHist(doc.history, change);
rebased.push(doc.history);
}
makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
makeChangeInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function makeChangeFromHistory(doc, type, allowSelectionOnly) {
if (doc.cm && doc.cm.state.suppressEdits) return;
var hist = doc.history, event, selAfter = doc.sel;
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
// Verify that there is a useable event (so that ctrl-z won't
// needlessly clear selection events)
for (var i = 0; i < source.length; i++) {
event = source[i];
if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
break;
}
if (i == source.length) return;
hist.lastOrigin = hist.lastSelOrigin = null;
for (;;) {
event = source.pop();
if (event.ranges) {
pushSelectionToHistory(event, dest);
if (allowSelectionOnly && !event.equals(doc.sel)) {
setSelection(doc, event, {clearRedo: false});
return;
}
selAfter = event;
}
else break;
}
// Build up a reverse change object to add to the opposite history
// stack (redo when undoing, and vice versa).
var antiChanges = [];
pushSelectionToHistory(selAfter, dest);
dest.push({changes: antiChanges, generation: hist.generation});
hist.generation = event.generation || ++hist.maxGeneration;
var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
for (var i = event.changes.length - 1; i >= 0; --i) {
var change = event.changes[i];
change.origin = type;
if (filter && !filterChange(doc, change, false)) {
source.length = 0;
return;
}
antiChanges.push(historyChangeFromChange(doc, change));
var after = i ? computeSelAfterChange(doc, change) : lst(source);
makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)});
var rebased = [];
// Propagate to the linked documents
linkedDocs(doc, function(doc, sharedHist) {
if (!sharedHist && indexOf(rebased, doc.history) == -1) {
rebaseHist(doc.history, change);
rebased.push(doc.history);
}
makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
});
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
makeChangeFromHistory
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function shiftDoc(doc, distance) {
if (distance == 0) return;
doc.first += distance;
doc.sel = new Selection(map(doc.sel.ranges, function(range) {
return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
Pos(range.head.line + distance, range.head.ch));
}), doc.sel.primIndex);
if (doc.cm) {
regChange(doc.cm, doc.first, doc.first - distance, distance);
for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
regLineChange(doc.cm, l, "gutter");
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
shiftDoc
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function makeChangeSingleDoc(doc, change, selAfter, spans) {
if (doc.cm && !doc.cm.curOp)
return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
if (change.to.line < doc.first) {
shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
return;
}
if (change.from.line > doc.lastLine()) return;
// Clip the change to the size of this doc
if (change.from.line < doc.first) {
var shift = change.text.length - 1 - (doc.first - change.from.line);
shiftDoc(doc, shift);
change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
text: [lst(change.text)], origin: change.origin};
}
var last = doc.lastLine();
if (change.to.line > last) {
change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
text: [change.text[0]], origin: change.origin};
}
change.removed = getBetween(doc, change.from, change.to);
if (!selAfter) selAfter = computeSelAfterChange(doc, change);
if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
else updateDoc(doc, change, spans);
setSelectionNoUndo(doc, selAfter, sel_dontScroll);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
makeChangeSingleDoc
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function makeChangeSingleDocInEditor(cm, change, spans) {
var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
var recomputeMaxLength = false, checkWidthStart = from.line;
if (!cm.options.lineWrapping) {
checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
doc.iter(checkWidthStart, to.line + 1, function(line) {
if (line == display.maxLine) {
recomputeMaxLength = true;
return true;
}
});
}
if (doc.sel.contains(change.from, change.to) > -1)
signalCursorActivity(cm);
updateDoc(doc, change, spans, estimateHeight(cm));
if (!cm.options.lineWrapping) {
doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
var len = lineLength(line);
if (len > display.maxLineLength) {
display.maxLine = line;
display.maxLineLength = len;
display.maxLineChanged = true;
recomputeMaxLength = false;
}
});
if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
}
// Adjust frontier, schedule worker
doc.frontier = Math.min(doc.frontier, from.line);
startWorker(cm, 400);
var lendiff = change.text.length - (to.line - from.line) - 1;
// Remember that these lines changed, for updating the display
if (change.full)
regChange(cm);
else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
regLineChange(cm, from.line, "text");
else
regChange(cm, from.line, to.line + 1, lendiff);
var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
if (changeHandler || changesHandler) {
var obj = {
from: from, to: to,
text: change.text,
removed: change.removed,
origin: change.origin
};
if (changeHandler) signalLater(cm, "change", cm, obj);
if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
}
cm.display.selForContextMenu = null;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
makeChangeSingleDocInEditor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function replaceRange(doc, code, from, to, origin) {
if (!to) to = from;
if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
if (typeof code == "string") code = doc.splitLines(code);
makeChange(doc, {from: from, to: to, text: code, origin: origin});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
replaceRange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function maybeScrollWindow(cm, coords) {
if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
if (coords.top + box.top < 0) doScroll = true;
else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
if (doScroll != null && !phantom) {
var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
(coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
(coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
coords.left + "px; width: 2px;");
cm.display.lineSpace.appendChild(scrollNode);
scrollNode.scrollIntoView(doScroll);
cm.display.lineSpace.removeChild(scrollNode);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeScrollWindow
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function scrollPosIntoView(cm, pos, end, margin) {
if (margin == null) margin = 0;
for (var limit = 0; limit < 5; limit++) {
var changed = false, coords = cursorCoords(cm, pos);
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
Math.min(coords.top, endCoords.top) - margin,
Math.max(coords.left, endCoords.left),
Math.max(coords.bottom, endCoords.bottom) + margin);
var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
if (scrollPos.scrollTop != null) {
setScrollTop(cm, scrollPos.scrollTop);
if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
}
if (scrollPos.scrollLeft != null) {
setScrollLeft(cm, scrollPos.scrollLeft);
if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
}
if (!changed) break;
}
return coords;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
scrollPosIntoView
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function scrollIntoView(cm, x1, y1, x2, y2) {
var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
scrollIntoView
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function calculateScrollPos(cm, x1, y1, x2, y2) {
var display = cm.display, snapMargin = textHeight(cm.display);
if (y1 < 0) y1 = 0;
var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
var screen = displayHeight(cm), result = {};
if (y2 - y1 > screen) y2 = y1 + screen;
var docBottom = cm.doc.height + paddingVert(display);
var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
if (y1 < screentop) {
result.scrollTop = atTop ? 0 : y1;
} else if (y2 > screentop + screen) {
var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
if (newTop != screentop) result.scrollTop = newTop;
}
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
var tooWide = x2 - x1 > screenw;
if (tooWide) x2 = x1 + screenw;
if (x1 < 10)
result.scrollLeft = 0;
else if (x1 < screenleft)
result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10));
else if (x2 > screenw + screenleft - 3)
result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw;
return result;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
calculateScrollPos
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function addToScrollPos(cm, left, top) {
if (left != null || top != null) resolveScrollToPos(cm);
if (left != null)
cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
if (top != null)
cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
addToScrollPos
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function ensureCursorVisible(cm) {
resolveScrollToPos(cm);
var cur = cm.getCursor(), from = cur, to = cur;
if (!cm.options.lineWrapping) {
from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
to = Pos(cur.line, cur.ch + 1);
}
cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ensureCursorVisible
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function resolveScrollToPos(cm) {
var range = cm.curOp.scrollToPos;
if (range) {
cm.curOp.scrollToPos = null;
var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
Math.min(from.top, to.top) - range.margin,
Math.max(from.right, to.right),
Math.max(from.bottom, to.bottom) + range.margin);
cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
resolveScrollToPos
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function indentLine(cm, n, how, aggressive) {
var doc = cm.doc, state;
if (how == null) how = "add";
if (how == "smart") {
// Fall back to "prev" when the mode doesn't have an indentation
// method.
if (!doc.mode.indent) how = "prev";
else state = getStateBefore(cm, n);
}
var tabSize = cm.options.tabSize;
var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
if (line.stateAfter) line.stateAfter = null;
var curSpaceString = line.text.match(/^\s*/)[0], indentation;
if (!aggressive && !/\S/.test(line.text)) {
indentation = 0;
how = "not";
} else if (how == "smart") {
indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
if (indentation == Pass || indentation > 150) {
if (!aggressive) return;
how = "prev";
}
}
if (how == "prev") {
if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
else indentation = 0;
} else if (how == "add") {
indentation = curSpace + cm.options.indentUnit;
} else if (how == "subtract") {
indentation = curSpace - cm.options.indentUnit;
} else if (typeof how == "number") {
indentation = curSpace + how;
}
indentation = Math.max(0, indentation);
var indentString = "", pos = 0;
if (cm.options.indentWithTabs)
for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
if (pos < indentation) indentString += spaceStr(indentation - pos);
if (indentString != curSpaceString) {
replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
line.stateAfter = null;
return true;
} else {
// Ensure that, if the cursor was in the whitespace at the start
// of the line, it is moved to the end of that space.
for (var i = 0; i < doc.sel.ranges.length; i++) {
var range = doc.sel.ranges[i];
if (range.head.line == n && range.head.ch < curSpaceString.length) {
var pos = Pos(n, curSpaceString.length);
replaceOneSelection(doc, i, new Range(pos, pos));
break;
}
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
indentLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function changeLine(doc, handle, changeType, op) {
var no = handle, line = handle;
if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
else no = lineNo(handle);
if (no == null) return null;
if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
return line;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
changeLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function deleteNearSelection(cm, compute) {
var ranges = cm.doc.sel.ranges, kill = [];
// Build up a set of ranges to kill first, merging overlapping
// ranges.
for (var i = 0; i < ranges.length; i++) {
var toKill = compute(ranges[i]);
while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
var replaced = kill.pop();
if (cmp(replaced.from, toKill.from) < 0) {
toKill.from = replaced.from;
break;
}
}
kill.push(toKill);
}
// Next, remove those actual ranges.
runInOp(cm, function() {
for (var i = kill.length - 1; i >= 0; i--)
replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
ensureCursorVisible(cm);
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
deleteNearSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function findPosH(doc, pos, dir, unit, visually) {
var line = pos.line, ch = pos.ch, origDir = dir;
var lineObj = getLine(doc, line);
function findNextLine() {
var l = line + dir;
if (l < doc.first || l >= doc.first + doc.size) return false
line = l;
return lineObj = getLine(doc, l);
}
function moveOnce(boundToLine) {
var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
if (next == null) {
if (!boundToLine && findNextLine()) {
if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
else ch = dir < 0 ? lineObj.text.length : 0;
} else return false
} else ch = next;
return true;
}
if (unit == "char") {
moveOnce()
} else if (unit == "column") {
moveOnce(true)
} else if (unit == "word" || unit == "group") {
var sawType = null, group = unit == "group";
var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
for (var first = true;; first = false) {
if (dir < 0 && !moveOnce(!first)) break;
var cur = lineObj.text.charAt(ch) || "\n";
var type = isWordChar(cur, helper) ? "w"
: group && cur == "\n" ? "n"
: !group || /\s/.test(cur) ? null
: "p";
if (group && !first && !type) type = "s";
if (sawType && sawType != type) {
if (dir < 0) {dir = 1; moveOnce();}
break;
}
if (type) sawType = type;
if (dir > 0 && !moveOnce(!first)) break;
}
}
var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true);
if (!cmp(pos, result)) result.hitSide = true;
return result;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findPosH
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function findNextLine() {
var l = line + dir;
if (l < doc.first || l >= doc.first + doc.size) return false
line = l;
return lineObj = getLine(doc, l);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findNextLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function moveOnce(boundToLine) {
var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
if (next == null) {
if (!boundToLine && findNextLine()) {
if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
else ch = dir < 0 ? lineObj.text.length : 0;
} else return false
} else ch = next;
return true;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
moveOnce
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function findPosV(cm, pos, dir, unit) {
var doc = cm.doc, x = pos.left, y;
if (unit == "page") {
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
} else if (unit == "line") {
y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
}
for (;;) {
var target = coordsChar(cm, x, y);
if (!target.outside) break;
if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
y += dir * 5;
}
return target;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findPosV
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function interpret(val) {
return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
interpret
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function option(name, deflt, handle, notOnInit) {
CodeMirror.defaults[name] = deflt;
if (handle) optionHandlers[name] =
notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
option
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function normalizeKeyName(name) {
var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
var alt, ctrl, shift, cmd;
for (var i = 0; i < parts.length - 1; i++) {
var mod = parts[i];
if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
else if (/^a(lt)?$/i.test(mod)) alt = true;
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
else if (/^s(hift)$/i.test(mod)) shift = true;
else throw new Error("Unrecognized modifier name: " + mod);
}
if (alt) name = "Alt-" + name;
if (ctrl) name = "Ctrl-" + name;
if (cmd) name = "Cmd-" + name;
if (shift) name = "Shift-" + name;
return name;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
normalizeKeyName
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getKeyMap(val) {
return typeof val == "string" ? keyMap[val] : val;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getKeyMap
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function markText(doc, from, to, options, type) {
// Shared markers (across linked documents) are handled separately
// (markTextShared will call out to this again, once per
// document).
if (options && options.shared) return markTextShared(doc, from, to, options, type);
// Ensure we are in an operation.
if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
var marker = new TextMarker(doc, type), diff = cmp(from, to);
if (options) copyObj(options, marker, false);
// Don't connect empty markers unless clearWhenEmpty is false
if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
return marker;
if (marker.replacedWith) {
// Showing up as a widget implies collapsed (widget replaces text)
marker.collapsed = true;
marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
if (options.insertLeft) marker.widgetNode.insertLeft = true;
}
if (marker.collapsed) {
if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
throw new Error("Inserting collapsed marker partially overlapping an existing one");
sawCollapsedSpans = true;
}
if (marker.addToHistory)
addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
var curLine = from.line, cm = doc.cm, updateMaxLine;
doc.iter(curLine, to.line + 1, function(line) {
if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
updateMaxLine = true;
if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
addMarkedSpan(line, new MarkedSpan(marker,
curLine == from.line ? from.ch : null,
curLine == to.line ? to.ch : null));
++curLine;
});
// lineIsHidden depends on the presence of the spans, so needs a second pass
if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
});
if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
if (marker.readOnly) {
sawReadOnlySpans = true;
if (doc.history.done.length || doc.history.undone.length)
doc.clearHistory();
}
if (marker.collapsed) {
marker.id = ++nextMarkerId;
marker.atomic = true;
}
if (cm) {
// Sync editor state
if (updateMaxLine) cm.curOp.updateMaxLine = true;
if (marker.collapsed)
regChange(cm, from.line, to.line + 1);
else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
if (marker.atomic) reCheckSelection(cm.doc);
signalLater(cm, "markerAdded", cm, marker);
}
return marker;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
markText
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function markTextShared(doc, from, to, options, type) {
options = copyObj(options);
options.shared = false;
var markers = [markText(doc, from, to, options, type)], primary = markers[0];
var widget = options.widgetNode;
linkedDocs(doc, function(doc) {
if (widget) options.widgetNode = widget.cloneNode(true);
markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
for (var i = 0; i < doc.linked.length; ++i)
if (doc.linked[i].isParent) return;
primary = lst(markers);
});
return new SharedTextMarker(markers, primary);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
markTextShared
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function findSharedMarkers(doc) {
return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
function(m) { return m.parent; });
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findSharedMarkers
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function copySharedMarkers(doc, markers) {
for (var i = 0; i < markers.length; i++) {
var marker = markers[i], pos = marker.find();
var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
if (cmp(mFrom, mTo)) {
var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
marker.markers.push(subMark);
subMark.parent = marker;
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
copySharedMarkers
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function detachSharedMarkers(markers) {
for (var i = 0; i < markers.length; i++) {
var marker = markers[i], linked = [marker.primary.doc];;
linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
for (var j = 0; j < marker.markers.length; j++) {
var subMarker = marker.markers[j];
if (indexOf(linked, subMarker.doc) == -1) {
subMarker.parent = null;
marker.markers.splice(j--, 1);
}
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
detachSharedMarkers
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function MarkedSpan(marker, from, to) {
this.marker = marker;
this.from = from; this.to = to;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
MarkedSpan
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getMarkedSpanFor(spans, marker) {
if (spans) for (var i = 0; i < spans.length; ++i) {
var span = spans[i];
if (span.marker == marker) return span;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getMarkedSpanFor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function removeMarkedSpan(spans, span) {
for (var r, i = 0; i < spans.length; ++i)
if (spans[i] != span) (r || (r = [])).push(spans[i]);
return r;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
removeMarkedSpan
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function addMarkedSpan(line, span) {
line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
span.marker.attachLine(line);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
addMarkedSpan
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function markedSpansBefore(old, startCh, isInsert) {
if (old) for (var i = 0, nw; i < old.length; ++i) {
var span = old[i], marker = span.marker;
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
}
}
return nw;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
markedSpansBefore
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function markedSpansAfter(old, endCh, isInsert) {
if (old) for (var i = 0, nw; i < old.length; ++i) {
var span = old[i], marker = span.marker;
var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
span.to == null ? null : span.to - endCh));
}
}
return nw;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
markedSpansAfter
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function stretchSpansOverChange(doc, change) {
if (change.full) return null;
var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
if (!oldFirst && !oldLast) return null;
var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
// Get the spans that 'stick out' on both sides
var first = markedSpansBefore(oldFirst, startCh, isInsert);
var last = markedSpansAfter(oldLast, endCh, isInsert);
// Next, merge those two ends
var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
if (first) {
// Fix up .to properties of first
for (var i = 0; i < first.length; ++i) {
var span = first[i];
if (span.to == null) {
var found = getMarkedSpanFor(last, span.marker);
if (!found) span.to = startCh;
else if (sameLine) span.to = found.to == null ? null : found.to + offset;
}
}
}
if (last) {
// Fix up .from in last (or move them into first in case of sameLine)
for (var i = 0; i < last.length; ++i) {
var span = last[i];
if (span.to != null) span.to += offset;
if (span.from == null) {
var found = getMarkedSpanFor(first, span.marker);
if (!found) {
span.from = offset;
if (sameLine) (first || (first = [])).push(span);
}
} else {
span.from += offset;
if (sameLine) (first || (first = [])).push(span);
}
}
}
// Make sure we didn't create any zero-length spans
if (first) first = clearEmptySpans(first);
if (last && last != first) last = clearEmptySpans(last);
var newMarkers = [first];
if (!sameLine) {
// Fill gap with whole-line-spans
var gap = change.text.length - 2, gapMarkers;
if (gap > 0 && first)
for (var i = 0; i < first.length; ++i)
if (first[i].to == null)
(gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
for (var i = 0; i < gap; ++i)
newMarkers.push(gapMarkers);
newMarkers.push(last);
}
return newMarkers;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
stretchSpansOverChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function clearEmptySpans(spans) {
for (var i = 0; i < spans.length; ++i) {
var span = spans[i];
if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
spans.splice(i--, 1);
}
if (!spans.length) return null;
return spans;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clearEmptySpans
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function mergeOldSpans(doc, change) {
var old = getOldSpans(doc, change);
var stretched = stretchSpansOverChange(doc, change);
if (!old) return stretched;
if (!stretched) return old;
for (var i = 0; i < old.length; ++i) {
var oldCur = old[i], stretchCur = stretched[i];
if (oldCur && stretchCur) {
spans: for (var j = 0; j < stretchCur.length; ++j) {
var span = stretchCur[j];
for (var k = 0; k < oldCur.length; ++k)
if (oldCur[k].marker == span.marker) continue spans;
oldCur.push(span);
}
} else if (stretchCur) {
old[i] = stretchCur;
}
}
return old;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
mergeOldSpans
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function removeReadOnlyRanges(doc, from, to) {
var markers = null;
doc.iter(from.line, to.line + 1, function(line) {
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
var mark = line.markedSpans[i].marker;
if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
(markers || (markers = [])).push(mark);
}
});
if (!markers) return null;
var parts = [{from: from, to: to}];
for (var i = 0; i < markers.length; ++i) {
var mk = markers[i], m = mk.find(0);
for (var j = 0; j < parts.length; ++j) {
var p = parts[j];
if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
newParts.push({from: p.from, to: m.from});
if (dto > 0 || !mk.inclusiveRight && !dto)
newParts.push({from: m.to, to: p.to});
parts.splice.apply(parts, newParts);
j += newParts.length - 1;
}
}
return parts;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
removeReadOnlyRanges
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function detachMarkedSpans(line) {
var spans = line.markedSpans;
if (!spans) return;
for (var i = 0; i < spans.length; ++i)
spans[i].marker.detachLine(line);
line.markedSpans = null;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
detachMarkedSpans
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function attachMarkedSpans(line, spans) {
if (!spans) return;
for (var i = 0; i < spans.length; ++i)
spans[i].marker.attachLine(line);
line.markedSpans = spans;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
attachMarkedSpans
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function compareCollapsedMarkers(a, b) {
var lenDiff = a.lines.length - b.lines.length;
if (lenDiff != 0) return lenDiff;
var aPos = a.find(), bPos = b.find();
var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
if (fromCmp) return -fromCmp;
var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
if (toCmp) return toCmp;
return b.id - a.id;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
compareCollapsedMarkers
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function collapsedSpanAtSide(line, start) {
var sps = sawCollapsedSpans && line.markedSpans, found;
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
sp = sps[i];
if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
(!found || compareCollapsedMarkers(found, sp.marker) < 0))
found = sp.marker;
}
return found;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
collapsedSpanAtSide
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
var line = getLine(doc, lineNo);
var sps = sawCollapsedSpans && line.markedSpans;
if (sps) for (var i = 0; i < sps.length; ++i) {
var sp = sps[i];
if (!sp.marker.collapsed) continue;
var found = sp.marker.find(0);
var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
return true;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
conflictingCollapsedRange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function visualLine(line) {
var merged;
while (merged = collapsedSpanAtStart(line))
line = merged.find(-1, true).line;
return line;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
visualLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function visualLineContinued(line) {
var merged, lines;
while (merged = collapsedSpanAtEnd(line)) {
line = merged.find(1, true).line;
(lines || (lines = [])).push(line);
}
return lines;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
visualLineContinued
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function visualLineNo(doc, lineN) {
var line = getLine(doc, lineN), vis = visualLine(line);
if (line == vis) return lineN;
return lineNo(vis);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
visualLineNo
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function visualLineEndNo(doc, lineN) {
if (lineN > doc.lastLine()) return lineN;
var line = getLine(doc, lineN), merged;
if (!lineIsHidden(doc, line)) return lineN;
while (merged = collapsedSpanAtEnd(line))
line = merged.find(1, true).line;
return lineNo(line) + 1;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
visualLineEndNo
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function lineIsHidden(doc, line) {
var sps = sawCollapsedSpans && line.markedSpans;
if (sps) for (var sp, i = 0; i < sps.length; ++i) {
sp = sps[i];
if (!sp.marker.collapsed) continue;
if (sp.from == null) return true;
if (sp.marker.widgetNode) continue;
if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
return true;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
lineIsHidden
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function lineIsHiddenInner(doc, line, span) {
if (span.to == null) {
var end = span.marker.find(1, true);
return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
}
if (span.marker.inclusiveRight && span.to == line.text.length)
return true;
for (var sp, i = 0; i < line.markedSpans.length; ++i) {
sp = line.markedSpans[i];
if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
(sp.to == null || sp.to != span.from) &&
(sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
lineIsHiddenInner(doc, line, sp)) return true;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
lineIsHiddenInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function adjustScrollWhenAboveVisible(cm, line, diff) {
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
addToScrollPos(cm, null, diff);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
adjustScrollWhenAboveVisible
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function widgetHeight(widget) {
if (widget.height != null) return widget.height;
var cm = widget.doc.cm;
if (!cm) return 0;
if (!contains(document.body, widget.node)) {
var parentStyle = "position: relative;";
if (widget.coverGutter)
parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;";
if (widget.noHScroll)
parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
}
return widget.height = widget.node.parentNode.offsetHeight;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
widgetHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function addLineWidget(doc, handle, node, options) {
var widget = new LineWidget(doc, node, options);
var cm = doc.cm;
if (cm && widget.noHScroll) cm.display.alignWidgets = true;
changeLine(doc, handle, "widget", function(line) {
var widgets = line.widgets || (line.widgets = []);
if (widget.insertAt == null) widgets.push(widget);
else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
widget.line = line;
if (cm && !lineIsHidden(doc, line)) {
var aboveVisible = heightAtLine(line) < doc.scrollTop;
updateLineHeight(line, line.height + widgetHeight(widget));
if (aboveVisible) addToScrollPos(cm, null, widget.height);
cm.curOp.forceUpdate = true;
}
return true;
});
return widget;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
addLineWidget
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateLine(line, text, markedSpans, estimateHeight) {
line.text = text;
if (line.stateAfter) line.stateAfter = null;
if (line.styles) line.styles = null;
if (line.order != null) line.order = null;
detachMarkedSpans(line);
attachMarkedSpans(line, markedSpans);
var estHeight = estimateHeight ? estimateHeight(line) : 1;
if (estHeight != line.height) updateLineHeight(line, estHeight);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function cleanUpLine(line) {
line.parent = null;
detachMarkedSpans(line);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
cleanUpLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function extractLineClasses(type, output) {
if (type) for (;;) {
var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
if (!lineClass) break;
type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
var prop = lineClass[1] ? "bgClass" : "textClass";
if (output[prop] == null)
output[prop] = lineClass[2];
else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
output[prop] += " " + lineClass[2];
}
return type;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
extractLineClasses
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function callBlankLine(mode, state) {
if (mode.blankLine) return mode.blankLine(state);
if (!mode.innerMode) return;
var inner = CodeMirror.innerMode(mode, state);
if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
callBlankLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function readToken(mode, stream, state, inner) {
for (var i = 0; i < 10; i++) {
if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
var style = mode.token(stream, state);
if (stream.pos > stream.start) return style;
}
throw new Error("Mode " + mode.name + " failed to advance stream.");
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
readToken
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function takeToken(cm, pos, precise, asArray) {
function getObj(copy) {
return {start: stream.start, end: stream.pos,
string: stream.current(),
type: style || null,
state: copy ? copyState(doc.mode, state) : state};
}
var doc = cm.doc, mode = doc.mode, style;
pos = clipPos(doc, pos);
var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
var stream = new StringStream(line.text, cm.options.tabSize), tokens;
if (asArray) tokens = [];
while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
stream.start = stream.pos;
style = readToken(mode, stream, state);
if (asArray) tokens.push(getObj(true));
}
return asArray ? tokens : getObj();
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
takeToken
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getObj(copy) {
return {start: stream.start, end: stream.pos,
string: stream.current(),
type: style || null,
state: copy ? copyState(doc.mode, state) : state};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getObj
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
var flattenSpans = mode.flattenSpans;
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
var curStart = 0, curStyle = null;
var stream = new StringStream(text, cm.options.tabSize), style;
var inner = cm.options.addModeClass && [null];
if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
while (!stream.eol()) {
if (stream.pos > cm.options.maxHighlightLength) {
flattenSpans = false;
if (forceToEnd) processLine(cm, text, state, stream.pos);
stream.pos = text.length;
style = null;
} else {
style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
}
if (inner) {
var mName = inner[0].name;
if (mName) style = "m-" + (style ? mName + " " + style : mName);
}
if (!flattenSpans || curStyle != style) {
while (curStart < stream.start) {
curStart = Math.min(stream.start, curStart + 50000);
f(curStart, curStyle);
}
curStyle = style;
}
stream.start = stream.pos;
}
while (curStart < stream.pos) {
// Webkit seems to refuse to render text nodes longer than 57444 characters
var pos = Math.min(stream.pos, curStart + 50000);
f(pos, curStyle);
curStart = pos;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
runMode
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function highlightLine(cm, line, state, forceToEnd) {
// A styles array always starts with a number identifying the
// mode/overlays that it is based on (for easy invalidation).
var st = [cm.state.modeGen], lineClasses = {};
// Compute the base array of styles
runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
st.push(end, style);
}, lineClasses, forceToEnd);
// Run overlays, adjust style array.
for (var o = 0; o < cm.state.overlays.length; ++o) {
var overlay = cm.state.overlays[o], i = 1, at = 0;
runMode(cm, line.text, overlay.mode, true, function(end, style) {
var start = i;
// Ensure there's a token end at the current position, and that i points at it
while (at < end) {
var i_end = st[i];
if (i_end > end)
st.splice(i, 1, end, st[i+1], i_end);
i += 2;
at = Math.min(end, i_end);
}
if (!style) return;
if (overlay.opaque) {
st.splice(start, i - start, end, "cm-overlay " + style);
i = start + 2;
} else {
for (; start < i; start += 2) {
var cur = st[start+1];
st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
}
}
}, lineClasses);
}
return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
highlightLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getLineStyles(cm, line, updateFrontier) {
if (!line.styles || line.styles[0] != cm.state.modeGen) {
var state = getStateBefore(cm, lineNo(line));
var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
line.stateAfter = state;
line.styles = result.styles;
if (result.classes) line.styleClasses = result.classes;
else if (line.styleClasses) line.styleClasses = null;
if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
}
return line.styles;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getLineStyles
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function processLine(cm, text, state, startAt) {
var mode = cm.doc.mode;
var stream = new StringStream(text, cm.options.tabSize);
stream.start = stream.pos = startAt || 0;
if (text == "") callBlankLine(mode, state);
while (!stream.eol()) {
readToken(mode, stream, state);
stream.start = stream.pos;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
processLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function interpretTokenStyle(style, options) {
if (!style || /^\s*$/.test(style)) return null;
var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
return cache[style] ||
(cache[style] = style.replace(/\S+/g, "cm-$&"));
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
interpretTokenStyle
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function buildLineContent(cm, lineView) {
// The padding-right forces the element to have a 'border', which
// is needed on Webkit to be able to get line-level bounding
// rectangles for it (in measureChar).
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
col: 0, pos: 0, cm: cm,
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
lineView.measure = {};
// Iterate over the logical lines that make up this visual line.
for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
var line = i ? lineView.rest[i - 1] : lineView.line, order;
builder.pos = 0;
builder.addToken = buildToken;
// Optionally wire in some hacks into the token-rendering
// algorithm, to deal with browser quirks.
if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
builder.addToken = buildTokenBadBidi(builder.addToken, order);
builder.map = [];
var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
if (line.styleClasses) {
if (line.styleClasses.bgClass)
builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
if (line.styleClasses.textClass)
builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
}
// Ensure at least a single node is present, for measuring.
if (builder.map.length == 0)
builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
// Store the map and a cache object for the current logical line
if (i == 0) {
lineView.measure.map = builder.map;
lineView.measure.cache = {};
} else {
(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
(lineView.measure.caches || (lineView.measure.caches = [])).push({});
}
}
// See issue #2901
if (webkit) {
var last = builder.content.lastChild
if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
builder.content.className = "cm-tab-wrap-hack";
}
signal(cm, "renderLine", cm, lineView.line, builder.pre);
if (builder.pre.className)
builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
return builder;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
buildLineContent
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function defaultSpecialCharPlaceholder(ch) {
var token = elt("span", "\u2022", "cm-invalidchar");
token.title = "\\u" + ch.charCodeAt(0).toString(16);
token.setAttribute("aria-label", token.title);
return token;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
defaultSpecialCharPlaceholder
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function buildToken(builder, text, style, startStyle, endStyle, title, css) {
if (!text) return;
var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text;
var special = builder.cm.state.specialChars, mustWrap = false;
if (!special.test(text)) {
builder.col += text.length;
var content = document.createTextNode(displayText);
builder.map.push(builder.pos, builder.pos + text.length, content);
if (ie && ie_version < 9) mustWrap = true;
builder.pos += text.length;
} else {
var content = document.createDocumentFragment(), pos = 0;
while (true) {
special.lastIndex = pos;
var m = special.exec(text);
var skipped = m ? m.index - pos : text.length - pos;
if (skipped) {
var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
else content.appendChild(txt);
builder.map.push(builder.pos, builder.pos + skipped, txt);
builder.col += skipped;
builder.pos += skipped;
}
if (!m) break;
pos += skipped + 1;
if (m[0] == "\t") {
var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
txt.setAttribute("role", "presentation");
txt.setAttribute("cm-text", "\t");
builder.col += tabWidth;
} else if (m[0] == "\r" || m[0] == "\n") {
var txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
txt.setAttribute("cm-text", m[0]);
builder.col += 1;
} else {
var txt = builder.cm.options.specialCharPlaceholder(m[0]);
txt.setAttribute("cm-text", m[0]);
if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
else content.appendChild(txt);
builder.col += 1;
}
builder.map.push(builder.pos, builder.pos + 1, txt);
builder.pos++;
}
}
if (style || startStyle || endStyle || mustWrap || css) {
var fullStyle = style || "";
if (startStyle) fullStyle += startStyle;
if (endStyle) fullStyle += endStyle;
var token = elt("span", [content], fullStyle, css);
if (title) token.title = title;
return builder.content.appendChild(token);
}
builder.content.appendChild(content);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
buildToken
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function splitSpaces(old) {
var out = " ";
for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
out += " ";
return out;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
splitSpaces
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function buildTokenBadBidi(inner, order) {
return function(builder, text, style, startStyle, endStyle, title, css) {
style = style ? style + " cm-force-border" : "cm-force-border";
var start = builder.pos, end = start + text.length;
for (;;) {
// Find the part that overlaps with the start of this text
for (var i = 0; i < order.length; i++) {
var part = order[i];
if (part.to > start && part.from <= start) break;
}
if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css);
inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css);
startStyle = null;
text = text.slice(part.to - start);
start = part.to;
}
};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
buildTokenBadBidi
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
var widget = !ignoreWidget && marker.widgetNode;
if (widget) builder.map.push(builder.pos, builder.pos + size, widget);
if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
if (!widget)
widget = builder.content.appendChild(document.createElement("span"));
widget.setAttribute("cm-marker", marker.id);
}
if (widget) {
builder.cm.display.input.setUneditable(widget);
builder.content.appendChild(widget);
}
builder.pos += size;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
buildCollapsedSpan
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function insertLineContent(line, builder, styles) {
var spans = line.markedSpans, allText = line.text, at = 0;
if (!spans) {
for (var i = 1; i < styles.length; i+=2)
builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
return;
}
var len = allText.length, pos = 0, i = 1, text = "", style, css;
var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
for (;;) {
if (nextChange == pos) { // Update current marker set
spanStyle = spanEndStyle = spanStartStyle = title = css = "";
collapsed = null; nextChange = Infinity;
var foundBookmarks = [], endStyles
for (var j = 0; j < spans.length; ++j) {
var sp = spans[j], m = sp.marker;
if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
foundBookmarks.push(m);
} else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
if (sp.to != null && sp.to != pos && nextChange > sp.to) {
nextChange = sp.to;
spanEndStyle = "";
}
if (m.className) spanStyle += " " + m.className;
if (m.css) css = (css ? css + ";" : "") + m.css;
if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to)
if (m.title && !title) title = m.title;
if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
collapsed = sp;
} else if (sp.from > pos && nextChange > sp.from) {
nextChange = sp.from;
}
}
if (endStyles) for (var j = 0; j < endStyles.length; j += 2)
if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j]
if (!collapsed || collapsed.from == pos) for (var j = 0; j < foundBookmarks.length; ++j)
buildCollapsedSpan(builder, 0, foundBookmarks[j]);
if (collapsed && (collapsed.from || 0) == pos) {
buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
collapsed.marker, collapsed.from == null);
if (collapsed.to == null) return;
if (collapsed.to == pos) collapsed = false;
}
}
if (pos >= len) break;
var upto = Math.min(len, nextChange);
while (true) {
if (text) {
var end = pos + text.length;
if (!collapsed) {
var tokenText = end > upto ? text.slice(0, upto - pos) : text;
builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
}
if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
pos = end;
spanStartStyle = "";
}
text = allText.slice(at, at = styles[i++]);
style = interpretTokenStyle(styles[i++], builder.cm.options);
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
insertLineContent
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function isWholeLineUpdate(doc, change) {
return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
(!doc.cm || doc.cm.options.wholeLineUpdateBefore);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
isWholeLineUpdate
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateDoc(doc, change, markedSpans, estimateHeight) {
function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
function update(line, text, spans) {
updateLine(line, text, spans, estimateHeight);
signalLater(line, "change", line, change);
}
function linesFor(start, end) {
for (var i = start, result = []; i < end; ++i)
result.push(new Line(text[i], spansFor(i), estimateHeight));
return result;
}
var from = change.from, to = change.to, text = change.text;
var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
// Adjust the line structure
if (change.full) {
doc.insert(0, linesFor(0, text.length));
doc.remove(text.length, doc.size - text.length);
} else if (isWholeLineUpdate(doc, change)) {
// This is a whole-line replace. Treated specially to make
// sure line objects move the way they are supposed to.
var added = linesFor(0, text.length - 1);
update(lastLine, lastLine.text, lastSpans);
if (nlines) doc.remove(from.line, nlines);
if (added.length) doc.insert(from.line, added);
} else if (firstLine == lastLine) {
if (text.length == 1) {
update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
} else {
var added = linesFor(1, text.length - 1);
added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
doc.insert(from.line + 1, added);
}
} else if (text.length == 1) {
update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
doc.remove(from.line + 1, nlines);
} else {
update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
var added = linesFor(1, text.length - 1);
if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
doc.insert(from.line + 1, added);
}
signalLater(doc, "change", doc, change);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateDoc
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function update(line, text, spans) {
updateLine(line, text, spans, estimateHeight);
signalLater(line, "change", line, change);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
update
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function linesFor(start, end) {
for (var i = start, result = []; i < end; ++i)
result.push(new Line(text[i], spansFor(i), estimateHeight));
return result;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
linesFor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function LeafChunk(lines) {
this.lines = lines;
this.parent = null;
for (var i = 0, height = 0; i < lines.length; ++i) {
lines[i].parent = this;
height += lines[i].height;
}
this.height = height;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
LeafChunk
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function BranchChunk(children) {
this.children = children;
var size = 0, height = 0;
for (var i = 0; i < children.length; ++i) {
var ch = children[i];
size += ch.chunkSize(); height += ch.height;
ch.parent = this;
}
this.size = size;
this.height = height;
this.parent = null;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
BranchChunk
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function linkedDocs(doc, f, sharedHistOnly) {
function propagate(doc, skip, sharedHist) {
if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
var rel = doc.linked[i];
if (rel.doc == skip) continue;
var shared = sharedHist && rel.sharedHist;
if (sharedHistOnly && !shared) continue;
f(rel.doc, shared);
propagate(rel.doc, doc, shared);
}
}
propagate(doc, null, true);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
linkedDocs
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function propagate(doc, skip, sharedHist) {
if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
var rel = doc.linked[i];
if (rel.doc == skip) continue;
var shared = sharedHist && rel.sharedHist;
if (sharedHistOnly && !shared) continue;
f(rel.doc, shared);
propagate(rel.doc, doc, shared);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
propagate
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function attachDoc(cm, doc) {
if (doc.cm) throw new Error("This document is already in use.");
cm.doc = doc;
doc.cm = cm;
estimateLineHeights(cm);
loadMode(cm);
if (!cm.options.lineWrapping) findMaxLine(cm);
cm.options.mode = doc.modeOption;
regChange(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
attachDoc
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getLine(doc, n) {
n -= doc.first;
if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
for (var chunk = doc; !chunk.lines;) {
for (var i = 0;; ++i) {
var child = chunk.children[i], sz = child.chunkSize();
if (n < sz) { chunk = child; break; }
n -= sz;
}
}
return chunk.lines[n];
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getBetween(doc, start, end) {
var out = [], n = start.line;
doc.iter(start.line, end.line + 1, function(line) {
var text = line.text;
if (n == end.line) text = text.slice(0, end.ch);
if (n == start.line) text = text.slice(start.ch);
out.push(text);
++n;
});
return out;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getBetween
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.