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 isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
isnan
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function CodeMirrorSpellChecker(options) {
// Initialize
options = options || {};
// Verify
if(typeof options.codeMirrorInstance !== "function" || typeof options.codeMirrorInstance.defineMode !== "function") {
console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`");
return;
}
// Because some browsers don't support this functionality yet
if(!String.prototype.includes) {
String.prototype.includes = function() {
"use strict";
return String.prototype.indexOf.apply(this, arguments) !== -1;
};
}
// Define the new mode
options.codeMirrorInstance.defineMode("spell-checker", function(config) {
// Load AFF/DIC data
if(!CodeMirrorSpellChecker.aff_loading) {
CodeMirrorSpellChecker.aff_loading = true;
var xhr_aff = new XMLHttpRequest();
xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true);
xhr_aff.onload = function() {
if(xhr_aff.readyState === 4 && xhr_aff.status === 200) {
CodeMirrorSpellChecker.aff_data = xhr_aff.responseText;
CodeMirrorSpellChecker.num_loaded++;
if(CodeMirrorSpellChecker.num_loaded == 2) {
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
platform: "any"
});
}
}
};
xhr_aff.send(null);
}
if(!CodeMirrorSpellChecker.dic_loading) {
CodeMirrorSpellChecker.dic_loading = true;
var xhr_dic = new XMLHttpRequest();
xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true);
xhr_dic.onload = function() {
if(xhr_dic.readyState === 4 && xhr_dic.status === 200) {
CodeMirrorSpellChecker.dic_data = xhr_dic.responseText;
CodeMirrorSpellChecker.num_loaded++;
if(CodeMirrorSpellChecker.num_loaded == 2) {
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
platform: "any"
});
}
}
};
xhr_dic.send(null);
}
// Define what separates a word
var rx_word = "!\"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ";
// Create the overlay and such
var overlay = {
token: function(stream) {
var ch = stream.peek();
var word = "";
if(rx_word.includes(ch)) {
stream.next();
return null;
}
while((ch = stream.peek()) != null && !rx_word.includes(ch)) {
word += ch;
stream.next();
}
if(CodeMirrorSpellChecker.typo && !CodeMirrorSpellChecker.typo.check(word))
return "spell-error"; // CSS class: cm-spell-error
return null;
}
};
var mode = options.codeMirrorInstance.getMode(
config, config.backdrop || "text/plain"
);
return options.codeMirrorInstance.overlayMode(mode, overlay, true);
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
CodeMirrorSpellChecker
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function setFullscreen(cm) {
var wrap = cm.getWrapperElement();
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
width: wrap.style.width, height: wrap.style.height};
wrap.style.width = "";
wrap.style.height = "auto";
wrap.className += " CodeMirror-fullscreen";
document.documentElement.style.overflow = "hidden";
cm.refresh();
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setFullscreen
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function setNormal(cm) {
var wrap = cm.getWrapperElement();
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
document.documentElement.style.overflow = "";
var info = cm.state.fullScreenRestore;
wrap.style.width = info.width; wrap.style.height = info.height;
window.scrollTo(info.scrollLeft, info.scrollTop);
cm.refresh();
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setNormal
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function clearPlaceholder(cm) {
if (cm.state.placeholder) {
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
cm.state.placeholder = null;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clearPlaceholder
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function setPlaceholder(cm) {
clearPlaceholder(cm);
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.className = "CodeMirror-placeholder";
var placeHolder = cm.getOption("placeholder")
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
elt.appendChild(placeHolder)
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setPlaceholder
|
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 (isEmpty(cm)) setPlaceholder(cm);
}
|
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 onChange(cm) {
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
if (empty) setPlaceholder(cm);
else clearPlaceholder(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
isEmpty
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onCursorActivity(cm) {
cm.operation(function() { update(cm); });
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onCursorActivity
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function onChange(cm) {
if (cm.state.markedSelection.length)
cm.operation(function() { clear(cm); });
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function coverRange(cm, from, to, addAt) {
if (cmp(from, to) == 0) return;
var array = cm.state.markedSelection;
var cls = cm.state.markedSelectionStyle;
for (var line = from.line;;) {
var start = line == from.line ? from : Pos(line, 0);
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
var end = atEnd ? to : Pos(endLine, 0);
var mark = cm.markText(start, end, {className: cls});
if (addAt == null) array.push(mark);
else array.splice(addAt++, 0, mark);
if (atEnd) break;
line = endLine;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
coverRange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function clear(cm) {
var array = cm.state.markedSelection;
for (var i = 0; i < array.length; ++i) array[i].clear();
array.length = 0;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clear
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function reset(cm) {
clear(cm);
var ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++)
coverRange(cm, ranges[i].from(), ranges[i].to());
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
reset
|
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(cm) {
if (!cm.somethingSelected()) return clear(cm);
if (cm.listSelections().length > 1) return reset(cm);
var from = cm.getCursor("start"), to = cm.getCursor("end");
var array = cm.state.markedSelection;
if (!array.length) return coverRange(cm, from, to);
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
return reset(cm);
while (cmp(from, coverStart.from) > 0) {
array.shift().clear();
coverStart = array[0].find();
}
if (cmp(from, coverStart.from) < 0) {
if (coverStart.to.line - from.line < CHUNK_SIZE) {
array.shift().clear();
coverRange(cm, from, coverStart.to, 0);
} else {
coverRange(cm, from, coverStart.from, 0);
}
}
while (cmp(to, coverEnd.to) < 0) {
array.pop().clear();
coverEnd = array[array.length - 1].find();
}
if (cmp(to, coverEnd.to) > 0) {
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
array.pop().clear();
coverRange(cm, coverEnd.from, to);
} else {
coverRange(cm, coverEnd.to, to);
}
}
}
|
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 CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
this.options = options = options ? copyObj(options) : {};
// Determine effective options based on given values and defaults.
copyObj(defaults, options, false);
setGuttersForLineNumbers(options);
var doc = options.value;
if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
this.doc = doc;
var input = new CodeMirror.inputStyles[options.inputStyle](this);
var display = this.display = new Display(place, doc, input);
display.wrapper.CodeMirror = this;
updateGutters(this);
themeChanged(this);
if (options.lineWrapping)
this.display.wrapper.className += " CodeMirror-wrap";
if (options.autofocus && !mobile) display.input.focus();
initScrollbars(this);
this.state = {
keyMaps: [], // stores maps added by addKeyMap
overlays: [], // highlighting overlays, as added by addOverlay
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
overwrite: false,
delayingBlurEvent: false,
focused: false,
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
selectingText: false,
draggingText: false,
highlight: new Delayed(), // stores highlight worker timeout
keySeq: null, // Unfinished key sequence
specialChars: null
};
var cm = this;
// Override magic textarea content restore that IE sometimes does
// on our hidden textarea on reload
if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
registerEventHandlers(this);
ensureGlobalHandlers();
startOperation(this);
this.curOp.forceUpdate = true;
attachDoc(this, doc);
if ((options.autofocus && !mobile) || cm.hasFocus())
setTimeout(bind(onFocus, this), 20);
else
onBlur(this);
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
optionHandlers[opt](this, options[opt], Init);
maybeUpdateLineNumberWidth(this);
if (options.finishInit) options.finishInit(this);
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
endOperation(this);
// Suppress optimizelegibility in Webkit, since it breaks text
// measuring on line wrapping boundaries.
if (webkit && options.lineWrapping &&
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
display.lineDiv.style.textRendering = "auto";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
CodeMirror
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function Display(place, doc, input) {
var d = this;
this.input = input;
// Covers bottom-right square when both scrollbars are present.
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
d.scrollbarFiller.setAttribute("cm-not-content", "true");
// Covers bottom of gutter when coverGutterNextToScrollbar is on
// and h scrollbar is present.
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
d.gutterFiller.setAttribute("cm-not-content", "true");
// Will contain the actual code, positioned to cover the viewport.
d.lineDiv = elt("div", null, "CodeMirror-code");
// Elements are added to these to represent selection and cursors.
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
d.cursorDiv = elt("div", null, "CodeMirror-cursors");
// A visibility: hidden element used to find the size of things.
d.measure = elt("div", null, "CodeMirror-measure");
// When lines outside of the viewport are measured, they are drawn in this.
d.lineMeasure = elt("div", null, "CodeMirror-measure");
// Wraps everything that needs to exist inside the vertically-padded coordinate system
d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
null, "position: relative; outline: none");
// Moved around its parent to cover visible view.
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
// Set to the height of the document, allowing scrolling.
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
d.sizerWidth = null;
// Behavior of elts with overflow: auto and padding is
// inconsistent across browsers. This is used to ensure the
// scrollable area is big enough.
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
// Will contain the gutters, if any.
d.gutters = elt("div", null, "CodeMirror-gutters");
d.lineGutter = null;
// Actual scrollable element.
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
d.scroller.setAttribute("tabIndex", "-1");
// The element in which the editor lives.
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
if (place) {
if (place.appendChild) place.appendChild(d.wrapper);
else place(d.wrapper);
}
// Current rendered range (may be bigger than the view window).
d.viewFrom = d.viewTo = doc.first;
d.reportedViewFrom = d.reportedViewTo = doc.first;
// Information about the rendered lines.
d.view = [];
d.renderedView = null;
// Holds info about a single rendered line when it was rendered
// for measurement, while not in view.
d.externalMeasured = null;
// Empty space (in pixels) above the view
d.viewOffset = 0;
d.lastWrapHeight = d.lastWrapWidth = 0;
d.updateLineNumbers = null;
d.nativeBarWidth = d.barHeight = d.barWidth = 0;
d.scrollbarsClipped = false;
// Used to only resize the line number gutter when necessary (when
// the amount of lines crosses a boundary that makes its width change)
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
// Set to true when a non-horizontal-scrolling line widget is
// added. As an optimization, line widget aligning is skipped when
// this is false.
d.alignWidgets = false;
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
// Tracks the maximum line length so that the horizontal scrollbar
// can be kept static when scrolling.
d.maxLine = null;
d.maxLineLength = 0;
d.maxLineChanged = false;
// Used for measuring wheel scrolling granularity
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
// True when shift is held down.
d.shift = false;
// Used to track whether anything happened since the context menu
// was opened.
d.selForContextMenu = null;
d.activeTouch = null;
input.init(d);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
Display
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function loadMode(cm) {
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
resetModeState(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
loadMode
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function resetModeState(cm) {
cm.doc.iter(function(line) {
if (line.stateAfter) line.stateAfter = null;
if (line.styles) line.styles = null;
});
cm.doc.frontier = cm.doc.first;
startWorker(cm, 100);
cm.state.modeGen++;
if (cm.curOp) regChange(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
resetModeState
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function wrappingChanged(cm) {
if (cm.options.lineWrapping) {
addClass(cm.display.wrapper, "CodeMirror-wrap");
cm.display.sizer.style.minWidth = "";
cm.display.sizerWidth = null;
} else {
rmClass(cm.display.wrapper, "CodeMirror-wrap");
findMaxLine(cm);
}
estimateLineHeights(cm);
regChange(cm);
clearCaches(cm);
setTimeout(function(){updateScrollbars(cm);}, 100);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
wrappingChanged
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function estimateHeight(cm) {
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
return function(line) {
if (lineIsHidden(cm.doc, line)) return 0;
var widgetsHeight = 0;
if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
}
if (wrapping)
return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
else
return widgetsHeight + th;
};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
estimateHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function estimateLineHeights(cm) {
var doc = cm.doc, est = estimateHeight(cm);
doc.iter(function(line) {
var estHeight = est(line);
if (estHeight != line.height) updateLineHeight(line, estHeight);
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
estimateLineHeights
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function themeChanged(cm) {
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
clearCaches(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
themeChanged
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function guttersChanged(cm) {
updateGutters(cm);
regChange(cm);
setTimeout(function(){alignHorizontally(cm);}, 20);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
guttersChanged
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateGutters(cm) {
var gutters = cm.display.gutters, specs = cm.options.gutters;
removeChildren(gutters);
for (var i = 0; i < specs.length; ++i) {
var gutterClass = specs[i];
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
if (gutterClass == "CodeMirror-linenumbers") {
cm.display.lineGutter = gElt;
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
}
}
gutters.style.display = i ? "" : "none";
updateGutterSpace(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateGutters
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateGutterSpace(cm) {
var width = cm.display.gutters.offsetWidth;
cm.display.sizer.style.marginLeft = width + "px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateGutterSpace
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function lineLength(line) {
if (line.height == 0) return 0;
var len = line.text.length, merged, cur = line;
while (merged = collapsedSpanAtStart(cur)) {
var found = merged.find(0, true);
cur = found.from.line;
len += found.from.ch - found.to.ch;
}
cur = line;
while (merged = collapsedSpanAtEnd(cur)) {
var found = merged.find(0, true);
len -= cur.text.length - found.from.ch;
cur = found.to.line;
len += cur.text.length - found.to.ch;
}
return len;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
lineLength
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function findMaxLine(cm) {
var d = cm.display, doc = cm.doc;
d.maxLine = getLine(doc, doc.first);
d.maxLineLength = lineLength(d.maxLine);
d.maxLineChanged = true;
doc.iter(function(line) {
var len = lineLength(line);
if (len > d.maxLineLength) {
d.maxLineLength = len;
d.maxLine = line;
}
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findMaxLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function setGuttersForLineNumbers(options) {
var found = indexOf(options.gutters, "CodeMirror-linenumbers");
if (found == -1 && options.lineNumbers) {
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
} else if (found > -1 && !options.lineNumbers) {
options.gutters = options.gutters.slice(0);
options.gutters.splice(found, 1);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setGuttersForLineNumbers
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function measureForScrollbars(cm) {
var d = cm.display, gutterW = d.gutters.offsetWidth;
var docH = Math.round(cm.doc.height + paddingVert(cm.display));
return {
clientHeight: d.scroller.clientHeight,
viewHeight: d.wrapper.clientHeight,
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
viewWidth: d.wrapper.clientWidth,
barLeft: cm.options.fixedGutter ? gutterW : 0,
docHeight: docH,
scrollHeight: docH + scrollGap(cm) + d.barHeight,
nativeBarWidth: d.nativeBarWidth,
gutterWidth: gutterW
};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
measureForScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function NativeScrollbars(place, scroll, cm) {
this.cm = cm;
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
place(vert); place(horiz);
on(vert, "scroll", function() {
if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
});
on(horiz, "scroll", function() {
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
});
this.checkedZeroWidth = false;
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
NativeScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function maybeDisable() {
// To find out whether the scrollbar is still visible, we
// check whether the element under the pixel in the bottom
// left corner of the scrollbar box is the scrollbar box
// itself (when the bar is still visible) or its filler child
// (when the bar is hidden). If it is still visible, we keep
// it enabled, if it's hidden, we disable pointer events.
var box = bar.getBoundingClientRect();
var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
if (elt != bar) bar.style.pointerEvents = "none";
else delay.set(1000, maybeDisable);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeDisable
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function initScrollbars(cm) {
if (cm.display.scrollbars) {
cm.display.scrollbars.clear();
if (cm.display.scrollbars.addClass)
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
}
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
// Prevent clicks in the scrollbars from killing focus
on(node, "mousedown", function() {
if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
});
node.setAttribute("cm-not-content", "true");
}, function(pos, axis) {
if (axis == "horizontal") setScrollLeft(cm, pos);
else setScrollTop(cm, pos);
}, cm);
if (cm.display.scrollbars.addClass)
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
initScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateScrollbars(cm, measure) {
if (!measure) measure = measureForScrollbars(cm);
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
updateScrollbarsInner(cm, measure);
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
updateHeightsInViewport(cm);
updateScrollbarsInner(cm, measureForScrollbars(cm));
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateScrollbarsInner(cm, measure) {
var d = cm.display;
var sizes = d.scrollbars.update(measure);
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
if (sizes.right && sizes.bottom) {
d.scrollbarFiller.style.display = "block";
d.scrollbarFiller.style.height = sizes.bottom + "px";
d.scrollbarFiller.style.width = sizes.right + "px";
} else d.scrollbarFiller.style.display = "";
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
d.gutterFiller.style.display = "block";
d.gutterFiller.style.height = sizes.bottom + "px";
d.gutterFiller.style.width = measure.gutterWidth + "px";
} else d.gutterFiller.style.display = "";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateScrollbarsInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function visibleLines(display, doc, viewport) {
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
top = Math.floor(top - paddingTop(display));
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
// forces those lines into the viewport (if possible).
if (viewport && viewport.ensure) {
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
if (ensureFrom < from) {
from = ensureFrom;
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
to = ensureTo;
}
}
return {from: from, to: Math.max(to, from + 1)};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
visibleLines
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function alignHorizontally(cm) {
var display = cm.display, view = display.view;
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
var gutterW = display.gutters.offsetWidth, left = comp + "px";
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
if (cm.options.fixedGutter && view[i].gutter)
view[i].gutter.style.left = left;
var align = view[i].alignable;
if (align) for (var j = 0; j < align.length; j++)
align[j].style.left = left;
}
if (cm.options.fixedGutter)
display.gutters.style.left = (comp + gutterW) + "px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
alignHorizontally
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function maybeUpdateLineNumberWidth(cm) {
if (!cm.options.lineNumbers) return false;
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
if (last.length != display.lineNumChars) {
var test = display.measure.appendChild(elt("div", [elt("div", last)],
"CodeMirror-linenumber CodeMirror-gutter-elt"));
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
display.lineGutter.style.width = "";
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
display.lineNumWidth = display.lineNumInnerWidth + padding;
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
display.lineGutter.style.width = display.lineNumWidth + "px";
updateGutterSpace(cm);
return true;
}
return false;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeUpdateLineNumberWidth
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function lineNumberFor(options, i) {
return String(options.lineNumberFormatter(i + options.firstLineNumber));
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
lineNumberFor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function compensateForHScroll(display) {
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
compensateForHScroll
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function DisplayUpdate(cm, viewport, force) {
var display = cm.display;
this.viewport = viewport;
// Store some values that we'll need later (but don't want to force a relayout for)
this.visible = visibleLines(display, cm.doc, viewport);
this.editorIsHidden = !display.wrapper.offsetWidth;
this.wrapperHeight = display.wrapper.clientHeight;
this.wrapperWidth = display.wrapper.clientWidth;
this.oldDisplayWidth = displayWidth(cm);
this.force = force;
this.dims = getDimensions(cm);
this.events = [];
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
DisplayUpdate
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function maybeClipScrollbars(cm) {
var display = cm.display;
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
display.heightForcer.style.height = scrollGap(cm) + "px";
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
display.scrollbarsClipped = true;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeClipScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateDisplayIfNeeded(cm, update) {
var display = cm.display, doc = cm.doc;
if (update.editorIsHidden) {
resetView(cm);
return false;
}
// Bail out if the visible area is already rendered and nothing changed.
if (!update.force &&
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
display.renderedView == display.view && countDirtyView(cm) == 0)
return false;
if (maybeUpdateLineNumberWidth(cm)) {
resetView(cm);
update.dims = getDimensions(cm);
}
// Compute a suitable new viewport (from & to)
var end = doc.first + doc.size;
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
if (sawCollapsedSpans) {
from = visualLineNo(cm.doc, from);
to = visualLineEndNo(cm.doc, to);
}
var different = from != display.viewFrom || to != display.viewTo ||
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
adjustView(cm, from, to);
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
// Position the mover div to align with the current scroll position
cm.display.mover.style.top = display.viewOffset + "px";
var toUpdate = countDirtyView(cm);
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
return false;
// For big changes, we hide the enclosing element during the
// update, since that speeds up the operations on most browsers.
var focused = activeElt();
if (toUpdate > 4) display.lineDiv.style.display = "none";
patchDisplay(cm, display.updateLineNumbers, update.dims);
if (toUpdate > 4) display.lineDiv.style.display = "";
display.renderedView = display.view;
// There might have been a widget with a focused element that got
// hidden or updated, if so re-focus it.
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
// Prevent selection and cursors from interfering with the scroll
// width and height.
removeChildren(display.cursorDiv);
removeChildren(display.selectionDiv);
display.gutters.style.height = display.sizer.style.minHeight = 0;
if (different) {
display.lastWrapHeight = update.wrapperHeight;
display.lastWrapWidth = update.wrapperWidth;
startWorker(cm, 400);
}
display.updateLineNumbers = null;
return true;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateDisplayIfNeeded
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function postUpdateDisplay(cm, update) {
var viewport = update.viewport;
for (var first = true;; first = false) {
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
// Clip forced viewport to actual scrollable area.
if (viewport && viewport.top != null)
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
// Updated line heights might result in the drawn area not
// actually covering the viewport. Keep looping until it does.
update.visible = visibleLines(cm.display, cm.doc, viewport);
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
break;
}
if (!updateDisplayIfNeeded(cm, update)) break;
updateHeightsInViewport(cm);
var barMeasure = measureForScrollbars(cm);
updateSelection(cm);
updateScrollbars(cm, barMeasure);
setDocumentHeight(cm, barMeasure);
}
update.signal(cm, "update", cm);
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
postUpdateDisplay
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateDisplaySimple(cm, viewport) {
var update = new DisplayUpdate(cm, viewport);
if (updateDisplayIfNeeded(cm, update)) {
updateHeightsInViewport(cm);
postUpdateDisplay(cm, update);
var barMeasure = measureForScrollbars(cm);
updateSelection(cm);
updateScrollbars(cm, barMeasure);
setDocumentHeight(cm, barMeasure);
update.finish();
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateDisplaySimple
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function setDocumentHeight(cm, measure) {
cm.display.sizer.style.minHeight = measure.docHeight + "px";
cm.display.heightForcer.style.top = measure.docHeight + "px";
cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setDocumentHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateHeightsInViewport(cm) {
var display = cm.display;
var prevBottom = display.lineDiv.offsetTop;
for (var i = 0; i < display.view.length; i++) {
var cur = display.view[i], height;
if (cur.hidden) continue;
if (ie && ie_version < 8) {
var bot = cur.node.offsetTop + cur.node.offsetHeight;
height = bot - prevBottom;
prevBottom = bot;
} else {
var box = cur.node.getBoundingClientRect();
height = box.bottom - box.top;
}
var diff = cur.line.height - height;
if (height < 2) height = textHeight(display);
if (diff > .001 || diff < -.001) {
updateLineHeight(cur.line, height);
updateWidgetHeight(cur.line);
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
updateWidgetHeight(cur.rest[j]);
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateHeightsInViewport
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function updateWidgetHeight(line) {
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateWidgetHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getDimensions(cm) {
var d = cm.display, left = {}, width = {};
var gutterLeft = d.gutters.clientLeft;
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
width[cm.options.gutters[i]] = n.clientWidth;
}
return {fixedPos: compensateForHScroll(d),
gutterTotalWidth: d.gutters.offsetWidth,
gutterLeft: left,
gutterWidth: width,
wrapperWidth: d.wrapper.clientWidth};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getDimensions
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.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.