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 patchDisplay(cm, updateNumbersFrom, dims) {
var display = cm.display, lineNumbers = cm.options.lineNumbers;
var container = display.lineDiv, cur = container.firstChild;
function rm(node) {
var next = node.nextSibling;
// Works around a throw-scroll bug in OS X Webkit
if (webkit && mac && cm.display.currentWheelTarget == node)
node.style.display = "none";
else
node.parentNode.removeChild(node);
return next;
}
var view = display.view, lineN = display.viewFrom;
// Loop over the elements in the view, syncing cur (the DOM nodes
// in display.lineDiv) with the view as we go.
for (var i = 0; i < view.length; i++) {
var lineView = view[i];
if (lineView.hidden) {
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
var node = buildLineElement(cm, lineView, lineN, dims);
container.insertBefore(node, cur);
} else { // Already drawn
while (cur != lineView.node) cur = rm(cur);
var updateNumber = lineNumbers && updateNumbersFrom != null &&
updateNumbersFrom <= lineN && lineView.lineNumber;
if (lineView.changes) {
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
updateLineForChanges(cm, lineView, lineN, dims);
}
if (updateNumber) {
removeChildren(lineView.lineNumber);
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
}
cur = lineView.node.nextSibling;
}
lineN += lineView.size;
}
while (cur) cur = rm(cur);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
patchDisplay
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function rm(node) {
var next = node.nextSibling;
// Works around a throw-scroll bug in OS X Webkit
if (webkit && mac && cm.display.currentWheelTarget == node)
node.style.display = "none";
else
node.parentNode.removeChild(node);
return next;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
rm
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateLineForChanges(cm, lineView, lineN, dims) {
for (var j = 0; j < lineView.changes.length; j++) {
var type = lineView.changes[j];
if (type == "text") updateLineText(cm, lineView);
else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
else if (type == "class") updateLineClasses(lineView);
else if (type == "widget") updateLineWidgets(cm, lineView, dims);
}
lineView.changes = null;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateLineForChanges
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function ensureLineWrapped(lineView) {
if (lineView.node == lineView.text) {
lineView.node = elt("div", null, null, "position: relative");
if (lineView.text.parentNode)
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
lineView.node.appendChild(lineView.text);
if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
}
return lineView.node;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ensureLineWrapped
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateLineBackground(lineView) {
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
if (cls) cls += " CodeMirror-linebackground";
if (lineView.background) {
if (cls) lineView.background.className = cls;
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
} else if (cls) {
var wrap = ensureLineWrapped(lineView);
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateLineBackground
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function getLineContent(cm, lineView) {
var ext = cm.display.externalMeasured;
if (ext && ext.line == lineView.line) {
cm.display.externalMeasured = null;
lineView.measure = ext.measure;
return ext.built;
}
return buildLineContent(cm, lineView);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getLineContent
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateLineText(cm, lineView) {
var cls = lineView.text.className;
var built = getLineContent(cm, lineView);
if (lineView.text == lineView.node) lineView.node = built.pre;
lineView.text.parentNode.replaceChild(built.pre, lineView.text);
lineView.text = built.pre;
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
lineView.bgClass = built.bgClass;
lineView.textClass = built.textClass;
updateLineClasses(lineView);
} else if (cls) {
lineView.text.className = cls;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateLineText
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateLineClasses(lineView) {
updateLineBackground(lineView);
if (lineView.line.wrapClass)
ensureLineWrapped(lineView).className = lineView.line.wrapClass;
else if (lineView.node != lineView.text)
lineView.node.className = "";
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
lineView.text.className = textClass || "";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateLineClasses
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateLineGutter(cm, lineView, lineN, dims) {
if (lineView.gutter) {
lineView.node.removeChild(lineView.gutter);
lineView.gutter = null;
}
if (lineView.gutterBackground) {
lineView.node.removeChild(lineView.gutterBackground);
lineView.gutterBackground = null;
}
if (lineView.line.gutterClass) {
var wrap = ensureLineWrapped(lineView);
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
"left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
"px; width: " + dims.gutterTotalWidth + "px");
wrap.insertBefore(lineView.gutterBackground, lineView.text);
}
var markers = lineView.line.gutterMarkers;
if (cm.options.lineNumbers || markers) {
var wrap = ensureLineWrapped(lineView);
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
cm.display.input.setUneditable(gutterWrap);
wrap.insertBefore(gutterWrap, lineView.text);
if (lineView.line.gutterClass)
gutterWrap.className += " " + lineView.line.gutterClass;
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
lineView.lineNumber = gutterWrap.appendChild(
elt("div", lineNumberFor(cm.options, lineN),
"CodeMirror-linenumber CodeMirror-gutter-elt",
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
+ cm.display.lineNumInnerWidth + "px"));
if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
if (found)
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateLineGutter
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateLineWidgets(cm, lineView, dims) {
if (lineView.alignable) lineView.alignable = null;
for (var node = lineView.node.firstChild, next; node; node = next) {
var next = node.nextSibling;
if (node.className == "CodeMirror-linewidget")
lineView.node.removeChild(node);
}
insertLineWidgets(cm, lineView, dims);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateLineWidgets
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function buildLineElement(cm, lineView, lineN, dims) {
var built = getLineContent(cm, lineView);
lineView.text = lineView.node = built.pre;
if (built.bgClass) lineView.bgClass = built.bgClass;
if (built.textClass) lineView.textClass = built.textClass;
updateLineClasses(lineView);
updateLineGutter(cm, lineView, lineN, dims);
insertLineWidgets(cm, lineView, dims);
return lineView.node;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
buildLineElement
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function insertLineWidgets(cm, lineView, dims) {
insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
insertLineWidgets
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
if (!line.widgets) return;
var wrap = ensureLineWrapped(lineView);
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
positionLineWidget(widget, node, lineView, dims);
cm.display.input.setUneditable(node);
if (allowAbove && widget.above)
wrap.insertBefore(node, lineView.gutter || lineView.text);
else
wrap.appendChild(node);
signalLater(widget, "redraw");
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
insertLineWidgetsFor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function positionLineWidget(widget, node, lineView, dims) {
if (widget.noHScroll) {
(lineView.alignable || (lineView.alignable = [])).push(node);
var width = dims.wrapperWidth;
node.style.left = dims.fixedPos + "px";
if (!widget.coverGutter) {
width -= dims.gutterTotalWidth;
node.style.paddingLeft = dims.gutterTotalWidth + "px";
}
node.style.width = width + "px";
}
if (widget.coverGutter) {
node.style.zIndex = 5;
node.style.position = "relative";
if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
positionLineWidget
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function ensureFocus(cm) {
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ensureFocus
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function applyTextInput(cm, inserted, deleted, sel, origin) {
var doc = cm.doc;
cm.display.shift = false;
if (!sel) sel = doc.sel;
var paste = cm.state.pasteIncoming || origin == "paste";
var textLines = doc.splitLines(inserted), multiPaste = null
// When pasing N lines into N selections, insert one line per selection
if (paste && sel.ranges.length > 1) {
if (lastCopied && lastCopied.text.join("\n") == inserted) {
if (sel.ranges.length % lastCopied.text.length == 0) {
multiPaste = [];
for (var i = 0; i < lastCopied.text.length; i++)
multiPaste.push(doc.splitLines(lastCopied.text[i]));
}
} else if (textLines.length == sel.ranges.length) {
multiPaste = map(textLines, function(l) { return [l]; });
}
}
// Normal behavior is to insert the new text into every selection
for (var i = sel.ranges.length - 1; i >= 0; i--) {
var range = sel.ranges[i];
var from = range.from(), to = range.to();
if (range.empty()) {
if (deleted && deleted > 0) // Handle deletion
from = Pos(from.line, from.ch - deleted);
else if (cm.state.overwrite && !paste) // Handle overwrite
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
from = to = Pos(from.line, 0)
}
var updateInput = cm.curOp.updateInput;
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
makeChange(cm.doc, changeEvent);
signalLater(cm, "inputRead", cm, changeEvent);
}
if (inserted && !paste)
triggerElectric(cm, inserted);
ensureCursorVisible(cm);
cm.curOp.updateInput = updateInput;
cm.curOp.typing = true;
cm.state.pasteIncoming = cm.state.cutIncoming = false;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
applyTextInput
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function handlePaste(e, cm) {
var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
if (pasted) {
e.preventDefault();
if (!cm.isReadOnly() && !cm.options.disableInput)
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
return true;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
handlePaste
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function triggerElectric(cm, inserted) {
// When an 'electric' character is inserted, immediately trigger a reindent
if (!cm.options.electricChars || !cm.options.smartIndent) return;
var sel = cm.doc.sel;
for (var i = sel.ranges.length - 1; i >= 0; i--) {
var range = sel.ranges[i];
if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
var mode = cm.getModeAt(range.head);
var indented = false;
if (mode.electricChars) {
for (var j = 0; j < mode.electricChars.length; j++)
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
indented = indentLine(cm, range.head.line, "smart");
break;
}
} else if (mode.electricInput) {
if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
indented = indentLine(cm, range.head.line, "smart");
}
if (indented) signalLater(cm, "electricInput", cm, range.head.line);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
triggerElectric
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function copyableRanges(cm) {
var text = [], ranges = [];
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
var line = cm.doc.sel.ranges[i].head.line;
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
ranges.push(lineRange);
text.push(cm.getRange(lineRange.anchor, lineRange.head));
}
return {text: text, ranges: ranges};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
copyableRanges
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function disableBrowserMagic(field) {
field.setAttribute("autocorrect", "off");
field.setAttribute("autocapitalize", "off");
field.setAttribute("spellcheck", "false");
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
disableBrowserMagic
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function TextareaInput(cm) {
this.cm = cm;
// See input.poll and input.reset
this.prevInput = "";
// Flag that indicates whether we expect input to appear real soon
// now (after some event like 'keypress' or 'input') and are
// polling intensively.
this.pollingFast = false;
// Self-resetting timeout for the poller
this.polling = new Delayed();
// Tracks when input.reset has punted to just putting a short
// string into the textarea instead of the full selection.
this.inaccurateSelection = false;
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
this.hasSelection = false;
this.composing = null;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
TextareaInput
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function hiddenTextarea() {
var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
// The textarea is kept positioned near the cursor to prevent the
// fact that it'll be scrolled into view on input from scrolling
// our fake cursor out of view. On webkit, when wrap=off, paste is
// very slow. So make the area wide instead.
if (webkit) te.style.width = "1000px";
else te.setAttribute("wrap", "off");
// If border: 0; -- iOS fails to open keyboard (issue #1287)
if (ios) te.style.border = "1px solid black";
disableBrowserMagic(te);
return div;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
hiddenTextarea
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function prepareCopyCut(e) {
if (signalDOMEvent(cm, e)) return
if (cm.somethingSelected()) {
lastCopied = {lineWise: false, text: cm.getSelections()};
if (input.inaccurateSelection) {
input.prevInput = "";
input.inaccurateSelection = false;
te.value = lastCopied.text.join("\n");
selectInput(te);
}
} else if (!cm.options.lineWiseCopyCut) {
return;
} else {
var ranges = copyableRanges(cm);
lastCopied = {lineWise: true, text: ranges.text};
if (e.type == "cut") {
cm.setSelections(ranges.ranges, null, sel_dontScroll);
} else {
input.prevInput = "";
te.value = ranges.text.join("\n");
selectInput(te);
}
}
if (e.type == "cut") cm.state.cutIncoming = true;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
prepareCopyCut
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function p() {
var changed = input.poll();
if (!changed && !missed) {missed = true; input.polling.set(60, p);}
else {input.pollingFast = false; input.slowPoll();}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
p
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function prepareSelectAllHack() {
if (te.selectionStart != null) {
var selected = cm.somethingSelected();
var extval = "\u200b" + (selected ? te.value : "");
te.value = "\u21da"; // Used to catch context-menu undo
te.value = extval;
input.prevInput = selected ? "" : "\u200b";
te.selectionStart = 1; te.selectionEnd = extval.length;
// Re-set this, in case some other handler touched the
// selection in the meantime.
display.selForContextMenu = cm.doc.sel;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
prepareSelectAllHack
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function rehide() {
input.contextMenuPending = false;
input.wrapper.style.cssText = oldWrapperCSS
te.style.cssText = oldCSS;
if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
// Try to detect the user choosing select-all
if (te.selectionStart != null) {
if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
var i = 0, poll = function() {
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
te.selectionEnd > 0 && input.prevInput == "\u200b")
operation(cm, commands.selectAll)(cm);
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
else display.input.reset();
};
display.detectingSelectAll = setTimeout(poll, 200);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
rehide
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
poll = function() {
if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
te.selectionEnd > 0 && input.prevInput == "\u200b")
operation(cm, commands.selectAll)(cm);
else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
else display.input.reset();
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
poll
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
mouseup = function() {
off(window, "mouseup", mouseup);
setTimeout(rehide, 20);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
mouseup
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function ContentEditableInput(cm) {
this.cm = cm;
this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
this.polling = new Delayed();
this.gracePeriod = false;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ContentEditableInput
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function onCopyCut(e) {
if (signalDOMEvent(cm, e)) return
if (cm.somethingSelected()) {
lastCopied = {lineWise: false, text: cm.getSelections()};
if (e.type == "cut") cm.replaceSelection("", null, "cut");
} else if (!cm.options.lineWiseCopyCut) {
return;
} else {
var ranges = copyableRanges(cm);
lastCopied = {lineWise: true, text: ranges.text};
if (e.type == "cut") {
cm.operation(function() {
cm.setSelections(ranges.ranges, 0, sel_dontScroll);
cm.replaceSelection("", null, "cut");
});
}
}
// iOS exposes the clipboard API, but seems to discard content inserted into it
if (e.clipboardData && !ios) {
e.preventDefault();
e.clipboardData.clearData();
e.clipboardData.setData("text/plain", lastCopied.text.join("\n"));
} else {
// Old-fashioned briefly-focus-a-textarea hack
var kludge = hiddenTextarea(), te = kludge.firstChild;
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
te.value = lastCopied.text.join("\n");
var hadFocus = document.activeElement;
selectInput(te);
setTimeout(function() {
cm.display.lineSpace.removeChild(kludge);
hadFocus.focus();
}, 50);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onCopyCut
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function poll() {
if (input.cm.state.focused) {
input.pollSelection();
input.polling.set(input.cm.options.pollInterval, poll);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
poll
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function posToDOM(cm, pos) {
var view = findViewForLine(cm, pos.line);
if (!view || view.hidden) return null;
var line = getLine(cm.doc, pos.line);
var info = mapFromLineView(view, line, pos.line);
var order = getOrder(line), side = "left";
if (order) {
var partPos = getBidiPartAt(order, pos.ch);
side = partPos % 2 ? "right" : "left";
}
var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
result.offset = result.collapse == "right" ? result.end : result.start;
return result;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
posToDOM
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function domToPos(cm, node, offset) {
var lineNode;
if (node == cm.display.lineDiv) {
lineNode = cm.display.lineDiv.childNodes[offset];
if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
node = null; offset = 0;
} else {
for (lineNode = node;; lineNode = lineNode.parentNode) {
if (!lineNode || lineNode == cm.display.lineDiv) return null;
if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
}
}
for (var i = 0; i < cm.display.view.length; i++) {
var lineView = cm.display.view[i];
if (lineView.node == lineNode)
return locateNodeInLineView(lineView, node, offset);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
domToPos
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function locateNodeInLineView(lineView, node, offset) {
var wrapper = lineView.text.firstChild, bad = false;
if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
if (node == wrapper) {
bad = true;
node = wrapper.childNodes[offset];
offset = 0;
if (!node) {
var line = lineView.rest ? lst(lineView.rest) : lineView.line;
return badPos(Pos(lineNo(line), line.text.length), bad);
}
}
var textNode = node.nodeType == 3 ? node : null, topNode = node;
if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
textNode = node.firstChild;
if (offset) offset = textNode.nodeValue.length;
}
while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
var measure = lineView.measure, maps = measure.maps;
function find(textNode, topNode, offset) {
for (var i = -1; i < (maps ? maps.length : 0); i++) {
var map = i < 0 ? measure.map : maps[i];
for (var j = 0; j < map.length; j += 3) {
var curNode = map[j + 2];
if (curNode == textNode || curNode == topNode) {
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
var ch = map[j] + offset;
if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
return Pos(line, ch);
}
}
}
}
var found = find(textNode, topNode, offset);
if (found) return badPos(found, bad);
// FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
found = find(after, after.firstChild, 0);
if (found)
return badPos(Pos(found.line, found.ch - dist), bad);
else
dist += after.textContent.length;
}
for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
found = find(before, before.firstChild, -1);
if (found)
return badPos(Pos(found.line, found.ch + dist), bad);
else
dist += after.textContent.length;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
locateNodeInLineView
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function find(textNode, topNode, offset) {
for (var i = -1; i < (maps ? maps.length : 0); i++) {
var map = i < 0 ? measure.map : maps[i];
for (var j = 0; j < map.length; j += 3) {
var curNode = map[j + 2];
if (curNode == textNode || curNode == topNode) {
var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
var ch = map[j] + offset;
if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
return Pos(line, ch);
}
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
find
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function domTextBetween(cm, from, to, fromLine, toLine) {
var text = "", closing = false, lineSep = cm.doc.lineSeparator();
function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
function walk(node) {
if (node.nodeType == 1) {
var cmText = node.getAttribute("cm-text");
if (cmText != null) {
if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
text += cmText;
return;
}
var markerID = node.getAttribute("cm-marker"), range;
if (markerID) {
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
if (found.length && (range = found[0].find()))
text += getBetween(cm.doc, range.from, range.to).join(lineSep);
return;
}
if (node.getAttribute("contenteditable") == "false") return;
for (var i = 0; i < node.childNodes.length; i++)
walk(node.childNodes[i]);
if (/^(pre|div|p)$/i.test(node.nodeName))
closing = true;
} else if (node.nodeType == 3) {
var val = node.nodeValue;
if (!val) return;
if (closing) {
text += lineSep;
closing = false;
}
text += val;
}
}
for (;;) {
walk(from);
if (from == to) break;
from = from.nextSibling;
}
return text;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
domTextBetween
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function walk(node) {
if (node.nodeType == 1) {
var cmText = node.getAttribute("cm-text");
if (cmText != null) {
if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
text += cmText;
return;
}
var markerID = node.getAttribute("cm-marker"), range;
if (markerID) {
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
if (found.length && (range = found[0].find()))
text += getBetween(cm.doc, range.from, range.to).join(lineSep);
return;
}
if (node.getAttribute("contenteditable") == "false") return;
for (var i = 0; i < node.childNodes.length; i++)
walk(node.childNodes[i]);
if (/^(pre|div|p)$/i.test(node.nodeName))
closing = true;
} else if (node.nodeType == 3) {
var val = node.nodeValue;
if (!val) return;
if (closing) {
text += lineSep;
closing = false;
}
text += val;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
walk
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function Selection(ranges, primIndex) {
this.ranges = ranges;
this.primIndex = primIndex;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
Selection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function Range(anchor, head) {
this.anchor = anchor; this.head = head;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
Range
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function normalizeSelection(ranges, primIndex) {
var prim = ranges[primIndex];
ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
primIndex = indexOf(ranges, prim);
for (var i = 1; i < ranges.length; i++) {
var cur = ranges[i], prev = ranges[i - 1];
if (cmp(prev.to(), cur.from()) >= 0) {
var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
if (i <= primIndex) --primIndex;
ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
}
}
return new Selection(ranges, primIndex);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
normalizeSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function simpleSelection(anchor, head) {
return new Selection([new Range(anchor, head || anchor)], 0);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
simpleSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clipPos(doc, pos) {
if (pos.line < doc.first) return Pos(doc.first, 0);
var last = doc.first + doc.size - 1;
if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
return clipToLen(pos, getLine(doc, pos.line).text.length);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clipPos
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clipToLen(pos, linelen) {
var ch = pos.ch;
if (ch == null || ch > linelen) return Pos(pos.line, linelen);
else if (ch < 0) return Pos(pos.line, 0);
else return pos;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clipToLen
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clipPosArray(doc, array) {
for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
return out;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clipPosArray
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function extendRange(doc, range, head, other) {
if (doc.cm && doc.cm.display.shift || doc.extend) {
var anchor = range.anchor;
if (other) {
var posBefore = cmp(head, anchor) < 0;
if (posBefore != (cmp(other, anchor) < 0)) {
anchor = head;
head = other;
} else if (posBefore != (cmp(head, other) < 0)) {
head = other;
}
}
return new Range(anchor, head);
} else {
return new Range(other || head, head);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
extendRange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function extendSelection(doc, head, other, options) {
setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
extendSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function extendSelections(doc, heads, options) {
for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
var newSel = normalizeSelection(out, doc.sel.primIndex);
setSelection(doc, newSel, options);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
extendSelections
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function replaceOneSelection(doc, i, range, options) {
var ranges = doc.sel.ranges.slice(0);
ranges[i] = range;
setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
replaceOneSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setSimpleSelection(doc, anchor, head, options) {
setSelection(doc, simpleSelection(anchor, head), options);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setSimpleSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function filterSelectionChange(doc, sel, options) {
var obj = {
ranges: sel.ranges,
update: function(ranges) {
this.ranges = [];
for (var i = 0; i < ranges.length; i++)
this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
clipPos(doc, ranges[i].head));
},
origin: options && options.origin
};
signal(doc, "beforeSelectionChange", doc, obj);
if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
else return sel;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
filterSelectionChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setSelectionReplaceHistory(doc, sel, options) {
var done = doc.history.done, last = lst(done);
if (last && last.ranges) {
done[done.length - 1] = sel;
setSelectionNoUndo(doc, sel, options);
} else {
setSelection(doc, sel, options);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setSelectionReplaceHistory
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setSelection(doc, sel, options) {
setSelectionNoUndo(doc, sel, options);
addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setSelectionNoUndo(doc, sel, options) {
if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
sel = filterSelectionChange(doc, sel, options);
var bias = options && options.bias ||
(cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
if (!(options && options.scroll === false) && doc.cm)
ensureCursorVisible(doc.cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setSelectionNoUndo
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setSelectionInner(doc, sel) {
if (sel.equals(doc.sel)) return;
doc.sel = sel;
if (doc.cm) {
doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
signalCursorActivity(doc.cm);
}
signalLater(doc, "cursorActivity", doc);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setSelectionInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function reCheckSelection(doc) {
setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
reCheckSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function skipAtomicInSelection(doc, sel, bias, mayClear) {
var out;
for (var i = 0; i < sel.ranges.length; i++) {
var range = sel.ranges[i];
var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
if (out || newAnchor != range.anchor || newHead != range.head) {
if (!out) out = sel.ranges.slice(0, i);
out[i] = new Range(newAnchor, newHead);
}
}
return out ? normalizeSelection(out, sel.primIndex) : sel;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
skipAtomicInSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
var line = getLine(doc, pos.line);
if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
var sp = line.markedSpans[i], m = sp.marker;
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
(sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
if (mayClear) {
signal(m, "beforeCursorEnter");
if (m.explicitlyCleared) {
if (!line.markedSpans) break;
else {--i; continue;}
}
}
if (!m.atomic) continue;
if (oldPos) {
var near = m.find(dir < 0 ? 1 : -1), diff;
if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
return skipAtomicInner(doc, near, pos, dir, mayClear);
}
var far = m.find(dir < 0 ? -1 : 1);
if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
far = movePos(doc, far, dir, far.line == pos.line ? line : null);
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
}
}
return pos;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
skipAtomicInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function skipAtomic(doc, pos, oldPos, bias, mayClear) {
var dir = bias || 1;
var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
(!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
(!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
if (!found) {
doc.cantEdit = true;
return Pos(doc.first, 0);
}
return found;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
skipAtomic
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function movePos(doc, pos, dir, line) {
if (dir < 0 && pos.ch == 0) {
if (pos.line > doc.first) return clipPos(doc, Pos(pos.line - 1));
else return null;
} else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
if (pos.line < doc.first + doc.size - 1) return Pos(pos.line + 1, 0);
else return null;
} else {
return new Pos(pos.line, pos.ch + dir);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
movePos
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function prepareSelection(cm, primary) {
var doc = cm.doc, result = {};
var curFragment = result.cursors = document.createDocumentFragment();
var selFragment = result.selection = document.createDocumentFragment();
for (var i = 0; i < doc.sel.ranges.length; i++) {
if (primary === false && i == doc.sel.primIndex) continue;
var range = doc.sel.ranges[i];
if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue;
var collapsed = range.empty();
if (collapsed || cm.options.showCursorWhenSelecting)
drawSelectionCursor(cm, range.head, curFragment);
if (!collapsed)
drawSelectionRange(cm, range, selFragment);
}
return result;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
prepareSelection
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function drawSelectionCursor(cm, head, output) {
var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
cursor.style.left = pos.left + "px";
cursor.style.top = pos.top + "px";
cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
if (pos.other) {
// Secondary cursor, shown when on a 'jump' in bi-directional text
var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
otherCursor.style.display = "";
otherCursor.style.left = pos.other.left + "px";
otherCursor.style.top = pos.other.top + "px";
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
drawSelectionCursor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function drawSelectionRange(cm, range, output) {
var display = cm.display, doc = cm.doc;
var fragment = document.createDocumentFragment();
var padding = paddingH(cm.display), leftSide = padding.left;
var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
function add(left, top, width, bottom) {
if (top < 0) top = 0;
top = Math.round(top);
bottom = Math.round(bottom);
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
"px; height: " + (bottom - top) + "px"));
}
function drawForLine(line, fromArg, toArg) {
var lineObj = getLine(doc, line);
var lineLen = lineObj.text.length;
var start, end;
function coords(ch, bias) {
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
}
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
var leftPos = coords(from, "left"), rightPos, left, right;
if (from == to) {
rightPos = leftPos;
left = right = leftPos.left;
} else {
rightPos = coords(to - 1, "right");
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
left = leftPos.left;
right = rightPos.right;
}
if (fromArg == null && from == 0) left = leftSide;
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
add(left, leftPos.top, null, leftPos.bottom);
left = leftSide;
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
}
if (toArg == null && to == lineLen) right = rightSide;
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
start = leftPos;
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
end = rightPos;
if (left < leftSide + 1) left = leftSide;
add(left, rightPos.top, right - left, rightPos.bottom);
});
return {start: start, end: end};
}
var sFrom = range.from(), sTo = range.to();
if (sFrom.line == sTo.line) {
drawForLine(sFrom.line, sFrom.ch, sTo.ch);
} else {
var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
var singleVLine = visualLine(fromLine) == visualLine(toLine);
var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
if (singleVLine) {
if (leftEnd.top < rightStart.top - 2) {
add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
} else {
add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
}
}
if (leftEnd.bottom < rightStart.top)
add(leftSide, leftEnd.bottom, null, rightStart.top);
}
output.appendChild(fragment);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
drawSelectionRange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function add(left, top, width, bottom) {
if (top < 0) top = 0;
top = Math.round(top);
bottom = Math.round(bottom);
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
"px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
"px; height: " + (bottom - top) + "px"));
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
add
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function drawForLine(line, fromArg, toArg) {
var lineObj = getLine(doc, line);
var lineLen = lineObj.text.length;
var start, end;
function coords(ch, bias) {
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
}
iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
var leftPos = coords(from, "left"), rightPos, left, right;
if (from == to) {
rightPos = leftPos;
left = right = leftPos.left;
} else {
rightPos = coords(to - 1, "right");
if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
left = leftPos.left;
right = rightPos.right;
}
if (fromArg == null && from == 0) left = leftSide;
if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
add(left, leftPos.top, null, leftPos.bottom);
left = leftSide;
if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
}
if (toArg == null && to == lineLen) right = rightSide;
if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
start = leftPos;
if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
end = rightPos;
if (left < leftSide + 1) left = leftSide;
add(left, rightPos.top, right - left, rightPos.bottom);
});
return {start: start, end: end};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
drawForLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function coords(ch, bias) {
return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
coords
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function restartBlink(cm) {
if (!cm.state.focused) return;
var display = cm.display;
clearInterval(display.blinker);
var on = true;
display.cursorDiv.style.visibility = "";
if (cm.options.cursorBlinkRate > 0)
display.blinker = setInterval(function() {
display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
}, cm.options.cursorBlinkRate);
else if (cm.options.cursorBlinkRate < 0)
display.cursorDiv.style.visibility = "hidden";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
restartBlink
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function startWorker(cm, time) {
if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
cm.state.highlight.set(time, bind(highlightWorker, cm));
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
startWorker
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function highlightWorker(cm) {
var doc = cm.doc;
if (doc.frontier < doc.first) doc.frontier = doc.first;
if (doc.frontier >= cm.display.viewTo) return;
var end = +new Date + cm.options.workTime;
var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
var changedLines = [];
doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
if (doc.frontier >= cm.display.viewFrom) { // Visible
var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
line.styles = highlighted.styles;
var oldCls = line.styleClasses, newCls = highlighted.classes;
if (newCls) line.styleClasses = newCls;
else if (oldCls) line.styleClasses = null;
var ischange = !oldStyles || oldStyles.length != line.styles.length ||
oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
if (ischange) changedLines.push(doc.frontier);
line.stateAfter = tooLong ? state : copyState(doc.mode, state);
} else {
if (line.text.length <= cm.options.maxHighlightLength)
processLine(cm, line.text, state);
line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
}
++doc.frontier;
if (+new Date > end) {
startWorker(cm, cm.options.workDelay);
return true;
}
});
if (changedLines.length) runInOp(cm, function() {
for (var i = 0; i < changedLines.length; i++)
regLineChange(cm, changedLines[i], "text");
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
highlightWorker
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function findStartLine(cm, n, precise) {
var minindent, minline, doc = cm.doc;
var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
for (var search = n; search > lim; --search) {
if (search <= doc.first) return doc.first;
var line = getLine(doc, search - 1);
if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
var indented = countColumn(line.text, null, cm.options.tabSize);
if (minline == null || minindent > indented) {
minline = search - 1;
minindent = indented;
}
}
return minline;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findStartLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function getStateBefore(cm, n, precise) {
var doc = cm.doc, display = cm.display;
if (!doc.mode.startState) return true;
var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
if (!state) state = startState(doc.mode);
else state = copyState(doc.mode, state);
doc.iter(pos, n, function(line) {
processLine(cm, line.text, state);
var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
line.stateAfter = save ? copyState(doc.mode, state) : null;
++pos;
});
if (precise) doc.frontier = pos;
return state;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getStateBefore
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function paddingH(display) {
if (display.cachedPaddingH) return display.cachedPaddingH;
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
return data;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
paddingH
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function displayWidth(cm) {
return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
displayWidth
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function displayHeight(cm) {
return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
displayHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function ensureLineHeights(cm, lineView, rect) {
var wrapping = cm.options.lineWrapping;
var curWidth = wrapping && displayWidth(cm);
if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
var heights = lineView.measure.heights = [];
if (wrapping) {
lineView.measure.width = curWidth;
var rects = lineView.text.firstChild.getClientRects();
for (var i = 0; i < rects.length - 1; i++) {
var cur = rects[i], next = rects[i + 1];
if (Math.abs(cur.bottom - next.bottom) > 2)
heights.push((cur.bottom + next.top) / 2 - rect.top);
}
}
heights.push(rect.bottom - rect.top);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ensureLineHeights
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function mapFromLineView(lineView, line, lineN) {
if (lineView.line == line)
return {map: lineView.measure.map, cache: lineView.measure.cache};
for (var i = 0; i < lineView.rest.length; i++)
if (lineView.rest[i] == line)
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
for (var i = 0; i < lineView.rest.length; i++)
if (lineNo(lineView.rest[i]) > lineN)
return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
mapFromLineView
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateExternalMeasurement(cm, line) {
line = visualLine(line);
var lineN = lineNo(line);
var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
view.lineN = lineN;
var built = view.built = buildLineContent(cm, view);
view.text = built.pre;
removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
return view;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateExternalMeasurement
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function measureChar(cm, line, ch, bias) {
return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
measureChar
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function findViewForLine(cm, lineN) {
if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
return cm.display.view[findViewIndex(cm, lineN)];
var ext = cm.display.externalMeasured;
if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
return ext;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findViewForLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function prepareMeasureForLine(cm, line) {
var lineN = lineNo(line);
var view = findViewForLine(cm, lineN);
if (view && !view.text) {
view = null;
} else if (view && view.changes) {
updateLineForChanges(cm, view, lineN, getDimensions(cm));
cm.curOp.forceUpdate = true;
}
if (!view)
view = updateExternalMeasurement(cm, line);
var info = mapFromLineView(view, line, lineN);
return {
line: line, view: view, rect: null,
map: info.map, cache: info.cache, before: info.before,
hasHeights: false
};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
prepareMeasureForLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
if (prepared.before) ch = -1;
var key = ch + (bias || ""), found;
if (prepared.cache.hasOwnProperty(key)) {
found = prepared.cache[key];
} else {
if (!prepared.rect)
prepared.rect = prepared.view.text.getBoundingClientRect();
if (!prepared.hasHeights) {
ensureLineHeights(cm, prepared.view, prepared.rect);
prepared.hasHeights = true;
}
found = measureCharInner(cm, prepared, ch, bias);
if (!found.bogus) prepared.cache[key] = found;
}
return {left: found.left, right: found.right,
top: varHeight ? found.rtop : found.top,
bottom: varHeight ? found.rbottom : found.bottom};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
measureCharPrepared
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function nodeAndOffsetInLineMap(map, ch, bias) {
var node, start, end, collapse;
// First, search the line map for the text node corresponding to,
// or closest to, the target character.
for (var i = 0; i < map.length; i += 3) {
var mStart = map[i], mEnd = map[i + 1];
if (ch < mStart) {
start = 0; end = 1;
collapse = "left";
} else if (ch < mEnd) {
start = ch - mStart;
end = start + 1;
} else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
end = mEnd - mStart;
start = end - 1;
if (ch >= mEnd) collapse = "right";
}
if (start != null) {
node = map[i + 2];
if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
collapse = bias;
if (bias == "left" && start == 0)
while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
node = map[(i -= 3) + 2];
collapse = "left";
}
if (bias == "right" && start == mEnd - mStart)
while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
node = map[(i += 3) + 2];
collapse = "right";
}
break;
}
}
return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
nodeAndOffsetInLineMap
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function measureCharInner(cm, prepared, ch, bias) {
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
var rect;
if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
rect = node.parentNode.getBoundingClientRect();
} else if (ie && cm.options.lineWrapping) {
var rects = range(node, start, end).getClientRects();
if (rects.length)
rect = rects[bias == "right" ? rects.length - 1 : 0];
else
rect = nullRect;
} else {
rect = range(node, start, end).getBoundingClientRect() || nullRect;
}
if (rect.left || rect.right || start == 0) break;
end = start;
start = start - 1;
collapse = "right";
}
if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
} else { // If it is a widget, simply get the box for the whole widget.
if (start > 0) collapse = bias = "right";
var rects;
if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
rect = rects[bias == "right" ? rects.length - 1 : 0];
else
rect = node.getBoundingClientRect();
}
if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
var rSpan = node.parentNode.getClientRects()[0];
if (rSpan)
rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
else
rect = nullRect;
}
var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
var mid = (rtop + rbot) / 2;
var heights = prepared.view.measure.heights;
for (var i = 0; i < heights.length - 1; i++)
if (mid < heights[i]) break;
var top = i ? heights[i - 1] : 0, bot = heights[i];
var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
top: top, bottom: bot};
if (!rect.left && !rect.right) result.bogus = true;
if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
return result;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
measureCharInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function maybeUpdateRectForZooming(measure, rect) {
if (!window.screen || screen.logicalXDPI == null ||
screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
return rect;
var scaleX = screen.logicalXDPI / screen.deviceXDPI;
var scaleY = screen.logicalYDPI / screen.deviceYDPI;
return {left: rect.left * scaleX, right: rect.right * scaleX,
top: rect.top * scaleY, bottom: rect.bottom * scaleY};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeUpdateRectForZooming
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clearLineMeasurementCacheFor(lineView) {
if (lineView.measure) {
lineView.measure.cache = {};
lineView.measure.heights = null;
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
lineView.measure.caches[i] = {};
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clearLineMeasurementCacheFor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clearLineMeasurementCache(cm) {
cm.display.externalMeasure = null;
removeChildren(cm.display.lineMeasure);
for (var i = 0; i < cm.display.view.length; i++)
clearLineMeasurementCacheFor(cm.display.view[i]);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clearLineMeasurementCache
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clearCaches(cm) {
clearLineMeasurementCache(cm);
cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
cm.display.lineNumChars = null;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clearCaches
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function intoCoordSystem(cm, lineObj, rect, context) {
if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
var size = widgetHeight(lineObj.widgets[i]);
rect.top += size; rect.bottom += size;
}
if (context == "line") return rect;
if (!context) context = "local";
var yOff = heightAtLine(lineObj);
if (context == "local") yOff += paddingTop(cm.display);
else yOff -= cm.display.viewOffset;
if (context == "page" || context == "window") {
var lOff = cm.display.lineSpace.getBoundingClientRect();
yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
rect.left += xOff; rect.right += xOff;
}
rect.top += yOff; rect.bottom += yOff;
return rect;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
intoCoordSystem
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function fromCoordSystem(cm, coords, context) {
if (context == "div") return coords;
var left = coords.left, top = coords.top;
// First move into "page" coordinate system
if (context == "page") {
left -= pageScrollX();
top -= pageScrollY();
} else if (context == "local" || !context) {
var localBox = cm.display.sizer.getBoundingClientRect();
left += localBox.left;
top += localBox.top;
}
var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromCoordSystem
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function charCoords(cm, pos, context, lineObj, bias) {
if (!lineObj) lineObj = getLine(cm.doc, pos.line);
return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
charCoords
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
lineObj = lineObj || getLine(cm.doc, pos.line);
if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
function get(ch, right) {
var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
if (right) m.left = m.right; else m.right = m.left;
return intoCoordSystem(cm, lineObj, m, context);
}
function getBidi(ch, partPos) {
var part = order[partPos], right = part.level % 2;
if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
part = order[--partPos];
ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
right = true;
} else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
part = order[++partPos];
ch = bidiLeft(part) - part.level % 2;
right = false;
}
if (right && ch == part.to && ch > part.from) return get(ch - 1);
return get(ch, right);
}
var order = getOrder(lineObj), ch = pos.ch;
if (!order) return get(ch);
var partPos = getBidiPartAt(order, ch);
var val = getBidi(ch, partPos);
if (bidiOther != null) val.other = getBidi(ch, bidiOther);
return val;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
cursorCoords
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function get(ch, right) {
var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
if (right) m.left = m.right; else m.right = m.left;
return intoCoordSystem(cm, lineObj, m, context);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
get
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function getBidi(ch, partPos) {
var part = order[partPos], right = part.level % 2;
if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
part = order[--partPos];
ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
right = true;
} else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
part = order[++partPos];
ch = bidiLeft(part) - part.level % 2;
right = false;
}
if (right && ch == part.to && ch > part.from) return get(ch - 1);
return get(ch, right);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getBidi
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function estimateCoords(cm, pos) {
var left = 0, pos = clipPos(cm.doc, pos);
if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
var lineObj = getLine(cm.doc, pos.line);
var top = heightAtLine(lineObj) + paddingTop(cm.display);
return {left: left, right: left, top: top, bottom: top + lineObj.height};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
estimateCoords
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function PosWithInfo(line, ch, outside, xRel) {
var pos = Pos(line, ch);
pos.xRel = xRel;
if (outside) pos.outside = true;
return pos;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
PosWithInfo
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function coordsChar(cm, x, y) {
var doc = cm.doc;
y += cm.display.viewOffset;
if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
if (lineN > last)
return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
if (x < 0) x = 0;
var lineObj = getLine(doc, lineN);
for (;;) {
var found = coordsCharInner(cm, lineObj, lineN, x, y);
var merged = collapsedSpanAtEnd(lineObj);
var mergedPos = merged && merged.find(0, true);
if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
lineN = lineNo(lineObj = mergedPos.to.line);
else
return found;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
coordsChar
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function coordsCharInner(cm, lineObj, lineNo, x, y) {
var innerOff = y - heightAtLine(lineObj);
var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
var preparedMeasure = prepareMeasureForLine(cm, lineObj);
function getX(ch) {
var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
wrongLine = true;
if (innerOff > sp.bottom) return sp.left - adjust;
else if (innerOff < sp.top) return sp.left + adjust;
else wrongLine = false;
return sp.left;
}
var bidi = getOrder(lineObj), dist = lineObj.text.length;
var from = lineLeft(lineObj), to = lineRight(lineObj);
var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
// Do a binary search between these bounds.
for (;;) {
if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
var ch = x < fromX || x - fromX <= toX - x ? from : to;
var xDiff = x - (ch == from ? fromX : toX);
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
return pos;
}
var step = Math.ceil(dist / 2), middle = from + step;
if (bidi) {
middle = from;
for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
}
var middleX = getX(middle);
if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
coordsCharInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function getX(ch) {
var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
wrongLine = true;
if (innerOff > sp.bottom) return sp.left - adjust;
else if (innerOff < sp.top) return sp.left + adjust;
else wrongLine = false;
return sp.left;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getX
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function textHeight(display) {
if (display.cachedTextHeight != null) return display.cachedTextHeight;
if (measureText == null) {
measureText = elt("pre");
// Measure a bunch of lines, for browsers that compute
// fractional heights.
for (var i = 0; i < 49; ++i) {
measureText.appendChild(document.createTextNode("x"));
measureText.appendChild(elt("br"));
}
measureText.appendChild(document.createTextNode("x"));
}
removeChildrenAndAdd(display.measure, measureText);
var height = measureText.offsetHeight / 50;
if (height > 3) display.cachedTextHeight = height;
removeChildren(display.measure);
return height || 1;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
textHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function charWidth(display) {
if (display.cachedCharWidth != null) return display.cachedCharWidth;
var anchor = elt("span", "xxxxxxxxxx");
var pre = elt("pre", [anchor]);
removeChildrenAndAdd(display.measure, pre);
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
if (width > 2) display.cachedCharWidth = width;
return width || 10;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
charWidth
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function startOperation(cm) {
cm.curOp = {
cm: cm,
viewChanged: false, // Flag that indicates that lines might need to be redrawn
startHeight: cm.doc.height, // Used to detect need to update scrollbar
forceUpdate: false, // Used to force a redraw
updateInput: null, // Whether to reset the input textarea
typing: false, // Whether this reset should be careful to leave existing text (for compositing)
changeObjs: null, // Accumulated changes, for firing change events
cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
selectionChanged: false, // Whether the selection needs to be redrawn
updateMaxLine: false, // Set when the widest line needs to be determined anew
scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
scrollToPos: null, // Used to scroll to a specific position
focus: false,
id: ++nextOpId // Unique ID
};
if (operationGroup) {
operationGroup.ops.push(cm.curOp);
} else {
cm.curOp.ownsGroup = operationGroup = {
ops: [cm.curOp],
delayedCallbacks: []
};
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
startOperation
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.