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 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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.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.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function fireCallbacksForOps(group) { // Calls delayed callbacks and cursorActivity handlers until no // new ones appear var callbacks = group.delayedCallbacks, i = 0; do { for (; i < callbacks.length; i++) callbacks[i].call(null); for (var j = 0; j < group.ops.length; j++) { var op = group.ops[j]; if (op.cursorActivityHandlers) while (op.cursorActivityCalled < op.cursorActivityHandlers.length) op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } } while (i < callbacks.length); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
fireCallbacksForOps
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function endOperation(cm) { var op = cm.curOp, group = op.ownsGroup; if (!group) return; try { fireCallbacksForOps(group); } finally { operationGroup = null; for (var i = 0; i < group.ops.length; i++) group.ops[i].cm.curOp = null; endOperations(group); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
endOperation
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function endOperations(group) { var ops = group.ops; for (var i = 0; i < ops.length; i++) // Read DOM endOperation_R1(ops[i]); for (var i = 0; i < ops.length; i++) // Write DOM (maybe) endOperation_W1(ops[i]); for (var i = 0; i < ops.length; i++) // Read DOM endOperation_R2(ops[i]); for (var i = 0; i < ops.length; i++) // Write DOM (maybe) endOperation_W2(ops[i]); for (var i = 0; i < ops.length; i++) // Read DOM endOperation_finish(ops[i]); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
endOperations
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function endOperation_R1(op) { var cm = op.cm, display = cm.display; maybeClipScrollbars(cm); if (op.updateMaxLine) findMaxLine(cm); op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || op.scrollToPos.to.line >= display.viewTo) || display.maxLineChanged && cm.options.lineWrapping; op.update = op.mustUpdate && new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
endOperation_R1
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function endOperation_W1(op) { op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
endOperation_W1
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function endOperation_R2(op) { var cm = op.cm, display = cm.display; if (op.updatedDisplay) updateHeightsInViewport(cm); op.barMeasure = measureForScrollbars(cm); // If the max line changed since it was last measured, measure it, // and ensure the document's width matches it. // updateDisplay_W2 will use these properties to do the actual resizing if (display.maxLineChanged && !cm.options.lineWrapping) { op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; cm.display.sizerWidth = op.adjustWidthTo; op.barMeasure.scrollWidth = Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth); op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm)); } if (op.updatedDisplay || op.selectionChanged) op.preparedSelection = display.input.prepareSelection(op.focus); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
endOperation_R2
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function endOperation_W2(op) { var cm = op.cm; if (op.adjustWidthTo != null) { cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; if (op.maxScrollLeft < cm.doc.scrollLeft) setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); cm.display.maxLineChanged = false; } var takeFocus = op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus()) if (op.preparedSelection) cm.display.input.showSelection(op.preparedSelection, takeFocus); if (op.updatedDisplay || op.startHeight != cm.doc.height) updateScrollbars(cm, op.barMeasure); if (op.updatedDisplay) setDocumentHeight(cm, op.barMeasure); if (op.selectionChanged) restartBlink(cm); if (cm.state.focused && op.updateInput) cm.display.input.reset(op.typing); if (takeFocus) ensureFocus(op.cm); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
endOperation_W2
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function endOperation_finish(op) { var cm = op.cm, display = cm.display, doc = cm.doc; if (op.updatedDisplay) postUpdateDisplay(cm, op.update); // Abort mouse wheel delta measurement, when scrolling explicitly if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) display.wheelStartX = display.wheelStartY = null; // Propagate the scroll position to the actual DOM scroller if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) { doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop)); display.scrollbars.setScrollTop(doc.scrollTop); display.scroller.scrollTop = doc.scrollTop; } if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) { doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft)); display.scrollbars.setScrollLeft(doc.scrollLeft); display.scroller.scrollLeft = doc.scrollLeft; alignHorizontally(cm); } // If we need to scroll a specific position into view, do so. if (op.scrollToPos) { var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from), clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords); } // Fire events for markers that are hidden/unidden by editing or // undoing var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; if (hidden) for (var i = 0; i < hidden.length; ++i) if (!hidden[i].lines.length) signal(hidden[i], "hide"); if (unhidden) for (var i = 0; i < unhidden.length; ++i) if (unhidden[i].lines.length) signal(unhidden[i], "unhide"); if (display.wrapper.offsetHeight) doc.scrollTop = cm.display.scroller.scrollTop; // Fire change events, and delayed event handlers if (op.changeObjs) signal(cm, "changes", cm, op.changeObjs); if (op.update) op.update.finish(); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
endOperation_finish
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function runInOp(cm, f) { if (cm.curOp) return f(); startOperation(cm); try { return f(); } finally { endOperation(cm); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
runInOp
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function operation(cm, f) { return function() { if (cm.curOp) return f.apply(cm, arguments); startOperation(cm); try { return f.apply(cm, arguments); } finally { endOperation(cm); } }; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
operation
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function methodOp(f) { return function() { if (this.curOp) return f.apply(this, arguments); startOperation(this); try { return f.apply(this, arguments); } finally { endOperation(this); } }; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
methodOp
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function docMethodOp(f) { return function() { var cm = this.cm; if (!cm || cm.curOp) return f.apply(this, arguments); startOperation(cm); try { return f.apply(this, arguments); } finally { endOperation(cm); } }; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
docMethodOp
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function LineView(doc, line, lineN) { // The starting line this.line = line; // Continuing lines, if any this.rest = visualLineContinued(line); // Number of logical lines in this visual line this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; this.node = this.text = null; this.hidden = lineIsHidden(doc, line); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
LineView
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function buildViewArray(cm, from, to) { var array = [], nextPos; for (var pos = from; pos < to; pos = nextPos) { var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); nextPos = pos + view.size; array.push(view); } return array; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
buildViewArray
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function regChange(cm, from, to, lendiff) { if (from == null) from = cm.doc.first; if (to == null) to = cm.doc.first + cm.doc.size; if (!lendiff) lendiff = 0; var display = cm.display; if (lendiff && to < display.viewTo && (display.updateLineNumbers == null || display.updateLineNumbers > from)) display.updateLineNumbers = from; cm.curOp.viewChanged = true; if (from >= display.viewTo) { // Change after if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) resetView(cm); } else if (to <= display.viewFrom) { // Change before if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { resetView(cm); } else { display.viewFrom += lendiff; display.viewTo += lendiff; } } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap resetView(cm); } else if (from <= display.viewFrom) { // Top overlap var cut = viewCuttingPoint(cm, to, to + lendiff, 1); if (cut) { display.view = display.view.slice(cut.index); display.viewFrom = cut.lineN; display.viewTo += lendiff; } else { resetView(cm); } } else if (to >= display.viewTo) { // Bottom overlap var cut = viewCuttingPoint(cm, from, from, -1); if (cut) { display.view = display.view.slice(0, cut.index); display.viewTo = cut.lineN; } else { resetView(cm); } } else { // Gap in the middle var cutTop = viewCuttingPoint(cm, from, from, -1); var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); if (cutTop && cutBot) { display.view = display.view.slice(0, cutTop.index) .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) .concat(display.view.slice(cutBot.index)); display.viewTo += lendiff; } else { resetView(cm); } } var ext = display.externalMeasured; if (ext) { if (to < ext.lineN) ext.lineN += lendiff; else if (from < ext.lineN + ext.size) display.externalMeasured = null; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
regChange
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function regLineChange(cm, line, type) { cm.curOp.viewChanged = true; var display = cm.display, ext = cm.display.externalMeasured; if (ext && line >= ext.lineN && line < ext.lineN + ext.size) display.externalMeasured = null; if (line < display.viewFrom || line >= display.viewTo) return; var lineView = display.view[findViewIndex(cm, line)]; if (lineView.node == null) return; var arr = lineView.changes || (lineView.changes = []); if (indexOf(arr, type) == -1) arr.push(type); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
regLineChange
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function resetView(cm) { cm.display.viewFrom = cm.display.viewTo = cm.doc.first; cm.display.view = []; cm.display.viewOffset = 0; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
resetView
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function findViewIndex(cm, n) { if (n >= cm.display.viewTo) return null; n -= cm.display.viewFrom; if (n < 0) return null; var view = cm.display.view; for (var i = 0; i < view.length; i++) { n -= view[i].size; if (n < 0) return i; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
findViewIndex
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function viewCuttingPoint(cm, oldN, newN, dir) { var index = findViewIndex(cm, oldN), diff, view = cm.display.view; if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) return {index: index, lineN: newN}; for (var i = 0, n = cm.display.viewFrom; i < index; i++) n += view[i].size; if (n != oldN) { if (dir > 0) { if (index == view.length - 1) return null; diff = (n + view[index].size) - oldN; index++; } else { diff = n - oldN; } oldN += diff; newN += diff; } while (visualLineNo(cm.doc, newN) != newN) { if (index == (dir < 0 ? 0 : view.length - 1)) return null; newN += dir * view[index - (dir < 0 ? 1 : 0)].size; index += dir; } return {index: index, lineN: newN}; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
viewCuttingPoint
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function adjustView(cm, from, to) { var display = cm.display, view = display.view; if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { display.view = buildViewArray(cm, from, to); display.viewFrom = from; } else { if (display.viewFrom > from) display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); else if (display.viewFrom < from) display.view = display.view.slice(findViewIndex(cm, from)); display.viewFrom = from; if (display.viewTo < to) display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); else if (display.viewTo > to) display.view = display.view.slice(0, findViewIndex(cm, to)); } display.viewTo = to; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
adjustView
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function countDirtyView(cm) { var view = cm.display.view, dirty = 0; for (var i = 0; i < view.length; i++) { var lineView = view[i]; if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty; } return dirty; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
countDirtyView
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function registerEventHandlers(cm) { var d = cm.display; on(d.scroller, "mousedown", operation(cm, onMouseDown)); // Older IE's will not fire a second mousedown for a double click if (ie && ie_version < 11) on(d.scroller, "dblclick", operation(cm, function(e) { if (signalDOMEvent(cm, e)) return; var pos = posFromMouse(cm, e); if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return; e_preventDefault(e); var word = cm.findWordAt(pos); extendSelection(cm.doc, word.anchor, word.head); })); else on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); }); // Some browsers fire contextmenu *after* opening the menu, at // which point we can't mess with it anymore. Context menu is // handled in onMouseDown for these browsers. if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);}); // Used to suppress mouse event handling when a touch happens var touchFinished, prevTouch = {end: 0}; function finishTouch() { if (d.activeTouch) { touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000); prevTouch = d.activeTouch; prevTouch.end = +new Date; } }; function isMouseLikeTouchEvent(e) { if (e.touches.length != 1) return false; var touch = e.touches[0]; return touch.radiusX <= 1 && touch.radiusY <= 1; } function farAway(touch, other) { if (other.left == null) return true; var dx = other.left - touch.left, dy = other.top - touch.top; return dx * dx + dy * dy > 20 * 20; } on(d.scroller, "touchstart", function(e) { if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) { clearTimeout(touchFinished); var now = +new Date; d.activeTouch = {start: now, moved: false, prev: now - prevTouch.end <= 300 ? prevTouch : null}; if (e.touches.length == 1) { d.activeTouch.left = e.touches[0].pageX; d.activeTouch.top = e.touches[0].pageY; } } }); on(d.scroller, "touchmove", function() { if (d.activeTouch) d.activeTouch.moved = true; }); on(d.scroller, "touchend", function(e) { var touch = d.activeTouch; if (touch && !eventInWidget(d, e) && touch.left != null && !touch.moved && new Date - touch.start < 300) { var pos = cm.coordsChar(d.activeTouch, "page"), range; if (!touch.prev || farAway(touch, touch.prev)) // Single tap range = new Range(pos, pos); else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap range = cm.findWordAt(pos); else // Triple tap range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); cm.setSelection(range.anchor, range.head); cm.focus(); e_preventDefault(e); } finishTouch(); }); on(d.scroller, "touchcancel", finishTouch); // Sync scrolling between fake scrollbars and real scrollable // area, ensure viewport is updated when scrolling. on(d.scroller, "scroll", function() { if (d.scroller.clientHeight) { setScrollTop(cm, d.scroller.scrollTop); setScrollLeft(cm, d.scroller.scrollLeft, true); signal(cm, "scroll", cm); } }); // Listen to wheel events in order to try and update the viewport on time. on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);}); on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);}); // Prevent wrapper from ever scrolling on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); d.dragFunctions = { enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);}, over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }}, start: function(e){onDragStart(cm, e);}, drop: operation(cm, onDrop), leave: function(e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }} }; var inp = d.input.getField(); on(inp, "keyup", function(e) { onKeyUp.call(cm, e); }); on(inp, "keydown", operation(cm, onKeyDown)); on(inp, "keypress", operation(cm, onKeyPress)); on(inp, "focus", bind(onFocus, cm)); on(inp, "blur", bind(onBlur, cm)); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
registerEventHandlers
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function finishTouch() { if (d.activeTouch) { touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000); prevTouch = d.activeTouch; prevTouch.end = +new Date; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
finishTouch
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function isMouseLikeTouchEvent(e) { if (e.touches.length != 1) return false; var touch = e.touches[0]; return touch.radiusX <= 1 && touch.radiusY <= 1; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
isMouseLikeTouchEvent
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function farAway(touch, other) { if (other.left == null) return true; var dx = other.left - touch.left, dy = other.top - touch.top; return dx * dx + dy * dy > 20 * 20; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
farAway
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function dragDropChanged(cm, value, old) { var wasOn = old && old != CodeMirror.Init; if (!value != !wasOn) { var funcs = cm.display.dragFunctions; var toggle = value ? on : off; toggle(cm.display.scroller, "dragstart", funcs.start); toggle(cm.display.scroller, "dragenter", funcs.enter); toggle(cm.display.scroller, "dragover", funcs.over); toggle(cm.display.scroller, "dragleave", funcs.leave); toggle(cm.display.scroller, "drop", funcs.drop); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
dragDropChanged
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function onResize(cm) { var d = cm.display; if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth) return; // Might be a text scaling operation, clear size caches. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; d.scrollbarsClipped = false; cm.setSize(); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
onResize
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function eventInWidget(display, e) { for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || (n.parentNode == display.sizer && n != display.mover)) return true; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
eventInWidget
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function posFromMouse(cm, e, liberal, forRect) { var display = cm.display; if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null; var x, y, space = display.lineSpace.getBoundingClientRect(); // Fails unpredictably on IE[67] when mouse is dragged around quickly. try { x = e.clientX - space.left; y = e.clientY - space.top; } catch (e) { return null; } var coords = coordsChar(cm, x, y), line; if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); } return coords; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
posFromMouse
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function onMouseDown(e) { var cm = this, display = cm.display; if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return; display.shift = e.shiftKey; if (eventInWidget(display, e)) { if (!webkit) { // Briefly turn off draggability, to allow widgets to do // normal dragging things. display.scroller.draggable = false; setTimeout(function(){display.scroller.draggable = true;}, 100); } return; } if (clickInGutter(cm, e)) return; var start = posFromMouse(cm, e); window.focus(); switch (e_button(e)) { case 1: // #3261: make sure, that we're not starting a second selection if (cm.state.selectingText) cm.state.selectingText(e); else if (start) leftButtonDown(cm, e, start); else if (e_target(e) == display.scroller) e_preventDefault(e); break; case 2: if (webkit) cm.state.lastMiddleDown = +new Date; if (start) extendSelection(cm.doc, start); setTimeout(function() {display.input.focus();}, 20); e_preventDefault(e); break; case 3: if (captureRightClick) onContextMenu(cm, e); else delayBlurEvent(cm); break; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
onMouseDown
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function leftButtonDown(cm, e, start) { if (ie) setTimeout(bind(ensureFocus, cm), 0); else cm.curOp.focus = activeElt(); var now = +new Date, type; if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) { type = "triple"; } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) { type = "double"; lastDoubleClick = {time: now, pos: start}; } else { type = "single"; lastClick = {time: now, pos: start}; } var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained; if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() && type == "single" && (contained = sel.contains(start)) > -1 && (cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) && (cmp(contained.to(), start) > 0 || start.xRel < 0)) leftButtonStartDrag(cm, e, start, modifier); else leftButtonSelect(cm, e, start, type, modifier); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
leftButtonDown
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function leftButtonStartDrag(cm, e, start, modifier) { var display = cm.display, startTime = +new Date; var dragEnd = operation(cm, function(e2) { if (webkit) display.scroller.draggable = false; cm.state.draggingText = false; off(document, "mouseup", dragEnd); off(display.scroller, "drop", dragEnd); if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { e_preventDefault(e2); if (!modifier && +new Date - 200 < startTime) extendSelection(cm.doc, start); // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) if (webkit || ie && ie_version == 9) setTimeout(function() {document.body.focus(); display.input.focus();}, 20); else display.input.focus(); } }); // Let the drag handler handle this. if (webkit) display.scroller.draggable = true; cm.state.draggingText = dragEnd; // IE's approach to draggable if (display.scroller.dragDrop) display.scroller.dragDrop(); on(document, "mouseup", dragEnd); on(display.scroller, "drop", dragEnd); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
leftButtonStartDrag
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function leftButtonSelect(cm, e, start, type, addNew) { var display = cm.display, doc = cm.doc; e_preventDefault(e); var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; if (addNew && !e.shiftKey) { ourIndex = doc.sel.contains(start); if (ourIndex > -1) ourRange = ranges[ourIndex]; else ourRange = new Range(start, start); } else { ourRange = doc.sel.primary(); ourIndex = doc.sel.primIndex; } if (chromeOS ? e.shiftKey && e.metaKey : e.altKey) { type = "rect"; if (!addNew) ourRange = new Range(start, start); start = posFromMouse(cm, e, true, true); ourIndex = -1; } else if (type == "double") { var word = cm.findWordAt(start); if (cm.display.shift || doc.extend) ourRange = extendRange(doc, ourRange, word.anchor, word.head); else ourRange = word; } else if (type == "triple") { var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0))); if (cm.display.shift || doc.extend) ourRange = extendRange(doc, ourRange, line.anchor, line.head); else ourRange = line; } else { ourRange = extendRange(doc, ourRange, start); } if (!addNew) { ourIndex = 0; setSelection(doc, new Selection([ourRange], 0), sel_mouse); startSel = doc.sel; } else if (ourIndex == -1) { ourIndex = ranges.length; setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex), {scroll: false, origin: "*mouse"}); } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) { setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), {scroll: false, origin: "*mouse"}); startSel = doc.sel; } else { replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); } var lastPos = start; function extendTo(pos) { if (cmp(lastPos, pos) == 0) return; lastPos = pos; if (type == "rect") { var ranges = [], tabSize = cm.options.tabSize; var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); line <= end; line++) { var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); if (left == right) ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); else if (text.length > leftPos) ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); } if (!ranges.length) ranges.push(new Range(start, start)); setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), {origin: "*mouse", scroll: false}); cm.scrollIntoView(pos); } else { var oldRange = ourRange; var anchor = oldRange.anchor, head = pos; if (type != "single") { if (type == "double") var range = cm.findWordAt(pos); else var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); if (cmp(range.anchor, anchor) > 0) { head = range.head; anchor = minPos(oldRange.from(), range.anchor); } else { head = range.anchor; anchor = maxPos(oldRange.to(), range.head); } } var ranges = startSel.ranges.slice(0); ranges[ourIndex] = new Range(clipPos(doc, anchor), head); setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); } } var editorSize = display.wrapper.getBoundingClientRect(); // Used to ensure timeout re-tries don't fire when another extend // happened in the meantime (clearTimeout isn't reliable -- at // least on Chrome, the timeouts still happen even when cleared, // if the clear happens after their scheduled firing time). var counter = 0; function extend(e) { var curCount = ++counter; var cur = posFromMouse(cm, e, true, type == "rect"); if (!cur) return; if (cmp(cur, lastPos) != 0) { cm.curOp.focus = activeElt(); extendTo(cur); var visible = visibleLines(display, doc); if (cur.line >= visible.to || cur.line < visible.from) setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150); } else { var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; if (outside) setTimeout(operation(cm, function() { if (counter != curCount) return; display.scroller.scrollTop += outside; extend(e); }), 50); } } function done(e) { cm.state.selectingText = false; counter = Infinity; e_preventDefault(e); display.input.focus(); off(document, "mousemove", move); off(document, "mouseup", up); doc.history.lastSelOrigin = null; } var move = operation(cm, function(e) { if (!e_button(e)) done(e); else extend(e); }); var up = operation(cm, done); cm.state.selectingText = up; on(document, "mousemove", move); on(document, "mouseup", up); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
leftButtonSelect
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function extendTo(pos) { if (cmp(lastPos, pos) == 0) return; lastPos = pos; if (type == "rect") { var ranges = [], tabSize = cm.options.tabSize; var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); line <= end; line++) { var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); if (left == right) ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); else if (text.length > leftPos) ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); } if (!ranges.length) ranges.push(new Range(start, start)); setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), {origin: "*mouse", scroll: false}); cm.scrollIntoView(pos); } else { var oldRange = ourRange; var anchor = oldRange.anchor, head = pos; if (type != "single") { if (type == "double") var range = cm.findWordAt(pos); else var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); if (cmp(range.anchor, anchor) > 0) { head = range.head; anchor = minPos(oldRange.from(), range.anchor); } else { head = range.anchor; anchor = maxPos(oldRange.to(), range.head); } } var ranges = startSel.ranges.slice(0); ranges[ourIndex] = new Range(clipPos(doc, anchor), head); setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
extendTo
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function extend(e) { var curCount = ++counter; var cur = posFromMouse(cm, e, true, type == "rect"); if (!cur) return; if (cmp(cur, lastPos) != 0) { cm.curOp.focus = activeElt(); extendTo(cur); var visible = visibleLines(display, doc); if (cur.line >= visible.to || cur.line < visible.from) setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150); } else { var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; if (outside) setTimeout(operation(cm, function() { if (counter != curCount) return; display.scroller.scrollTop += outside; extend(e); }), 50); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
extend
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function done(e) { cm.state.selectingText = false; counter = Infinity; e_preventDefault(e); display.input.focus(); off(document, "mousemove", move); off(document, "mouseup", up); doc.history.lastSelOrigin = null; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
done
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function gutterEvent(cm, e, type, prevent) { try { var mX = e.clientX, mY = e.clientY; } catch(e) { return false; } if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false; if (prevent) e_preventDefault(e); var display = cm.display; var lineBox = display.lineDiv.getBoundingClientRect(); if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e); mY -= lineBox.top - display.viewOffset; for (var i = 0; i < cm.options.gutters.length; ++i) { var g = display.gutters.childNodes[i]; if (g && g.getBoundingClientRect().right >= mX) { var line = lineAtHeight(cm.doc, mY); var gutter = cm.options.gutters[i]; signal(cm, type, cm, line, gutter, e); return e_defaultPrevented(e); } } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
gutterEvent
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function clickInGutter(cm, e) { return gutterEvent(cm, e, "gutterClick", true); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
clickInGutter
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function onDrop(e) { var cm = this; clearDragCursor(cm); if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return; e_preventDefault(e); if (ie) lastDrop = +new Date; var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; if (!pos || cm.isReadOnly()) return; // Might be a file drop, in which case we simply extract the text // and insert it. if (files && files.length && window.FileReader && window.File) { var n = files.length, text = Array(n), read = 0; var loadFile = function(file, i) { if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) return; var reader = new FileReader; reader.onload = operation(cm, function() { var content = reader.result; if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = ""; text[i] = content; if (++read == n) { pos = clipPos(cm.doc, pos); var change = {from: pos, to: pos, text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), origin: "paste"}; makeChange(cm.doc, change); setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); } }); reader.readAsText(file); }; for (var i = 0; i < n; ++i) loadFile(files[i], i); } else { // Normal drop // Don't do a replace if the drop happened inside of the selected text. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { cm.state.draggingText(e); // Ensure the editor is re-focused setTimeout(function() {cm.display.input.focus();}, 20); return; } try { var text = e.dataTransfer.getData("Text"); if (text) { if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey)) var selected = cm.listSelections(); setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); if (selected) for (var i = 0; i < selected.length; ++i) replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag"); cm.replaceSelection(text, "around", "paste"); cm.display.input.focus(); } } catch(e){} } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
onDrop
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
loadFile = function(file, i) { if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) return; var reader = new FileReader; reader.onload = operation(cm, function() { var content = reader.result; if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = ""; text[i] = content; if (++read == n) { pos = clipPos(cm.doc, pos); var change = {from: pos, to: pos, text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), origin: "paste"}; makeChange(cm.doc, change); setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); } }); reader.readAsText(file); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
loadFile
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function onDragStart(cm, e) { if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; } if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return; e.dataTransfer.setData("Text", cm.getSelection()); e.dataTransfer.effectAllowed = "copyMove" // Use dummy image instead of default browsers image. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. if (e.dataTransfer.setDragImage && !safari) { var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; if (presto) { img.width = img.height = 1; cm.display.wrapper.appendChild(img); // Force a relayout, or Opera won't use our image for some obscure reason img._top = img.offsetTop; } e.dataTransfer.setDragImage(img, 0, 0); if (presto) img.parentNode.removeChild(img); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
onDragStart
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function onDragOver(cm, e) { var pos = posFromMouse(cm, e); if (!pos) return; var frag = document.createDocumentFragment(); drawSelectionCursor(cm, pos, frag); if (!cm.display.dragCursor) { cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors"); cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv); } removeChildrenAndAdd(cm.display.dragCursor, frag); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
onDragOver
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function clearDragCursor(cm) { if (cm.display.dragCursor) { cm.display.lineSpace.removeChild(cm.display.dragCursor); cm.display.dragCursor = null; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
clearDragCursor
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function setScrollTop(cm, val) { if (Math.abs(cm.doc.scrollTop - val) < 2) return; cm.doc.scrollTop = val; if (!gecko) updateDisplaySimple(cm, {top: val}); if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val; cm.display.scrollbars.setScrollTop(val); if (gecko) updateDisplaySimple(cm); startWorker(cm, 100); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
setScrollTop
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function setScrollLeft(cm, val, isScroller) { if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return; val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth); cm.doc.scrollLeft = val; alignHorizontally(cm); if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val; cm.display.scrollbars.setScrollLeft(val); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
setScrollLeft
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
wheelEventDelta = function(e) { var dx = e.wheelDeltaX, dy = e.wheelDeltaY; if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail; if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail; else if (dy == null) dy = e.wheelDelta; return {x: dx, y: dy}; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
wheelEventDelta
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function onScrollWheel(cm, e) { var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; var display = cm.display, scroll = display.scroller; // Quit if there's nothing to scroll here var canScrollX = scroll.scrollWidth > scroll.clientWidth; var canScrollY = scroll.scrollHeight > scroll.clientHeight; if (!(dx && canScrollX || dy && canScrollY)) return; // Webkit browsers on OS X abort momentum scrolls when the target // of the scroll event is removed from the scrollable element. // This hack (see related code in patchDisplay) makes sure the // element is kept around. if (dy && mac && webkit) { outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { for (var i = 0; i < view.length; i++) { if (view[i].node == cur) { cm.display.currentWheelTarget = cur; break outer; } } } } // On some browsers, horizontal scrolling will cause redraws to // happen before the gutter has been realigned, causing it to // wriggle around in a most unseemly way. When we have an // estimated pixels/delta value, we just handle horizontal // scrolling entirely here. It'll be slightly off from native, but // better than glitching out. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { if (dy && canScrollY) setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))); setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth))); // Only prevent default scrolling if vertical scrolling is // actually possible. Otherwise, it causes vertical scroll // jitter on OSX trackpads when deltaX is small and deltaY // is large (issue #3579) if (!dy || (dy && canScrollY)) e_preventDefault(e); display.wheelStartX = null; // Abort measurement, if in progress return; } // 'Project' the visible viewport to cover the area that is being // scrolled into view (if we know enough to estimate it). if (dy && wheelPixelsPerUnit != null) { var pixels = dy * wheelPixelsPerUnit; var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; if (pixels < 0) top = Math.max(0, top + pixels - 50); else bot = Math.min(cm.doc.height, bot + pixels + 50); updateDisplaySimple(cm, {top: top, bottom: bot}); } if (wheelSamples < 20) { if (display.wheelStartX == null) { display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; display.wheelDX = dx; display.wheelDY = dy; setTimeout(function() { if (display.wheelStartX == null) return; var movedX = scroll.scrollLeft - display.wheelStartX; var movedY = scroll.scrollTop - display.wheelStartY; var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || (movedX && display.wheelDX && movedX / display.wheelDX); display.wheelStartX = display.wheelStartY = null; if (!sample) return; wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); ++wheelSamples; }, 200); } else { display.wheelDX += dx; display.wheelDY += dy; } } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
onScrollWheel
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function doHandleBinding(cm, bound, dropShift) { if (typeof bound == "string") { bound = commands[bound]; if (!bound) return false; } // Ensure previous input has been read, so that the handler sees a // consistent view of the document cm.display.input.ensurePolled(); var prevShift = cm.display.shift, done = false; try { if (cm.isReadOnly()) cm.state.suppressEdits = true; if (dropShift) cm.display.shift = false; done = bound(cm) != Pass; } finally { cm.display.shift = prevShift; cm.state.suppressEdits = false; } return done; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
doHandleBinding
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function lookupKeyForEditor(cm, name, handle) { for (var i = 0; i < cm.state.keyMaps.length; i++) { var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); if (result) return result; } return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) || lookupKey(name, cm.options.keyMap, handle, cm); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
lookupKeyForEditor
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function dispatchKey(cm, name, e, handle) { var seq = cm.state.keySeq; if (seq) { if (isModifierKey(name)) return "handled"; stopSeq.set(50, function() { if (cm.state.keySeq == seq) { cm.state.keySeq = null; cm.display.input.reset(); } }); name = seq + " " + name; } var result = lookupKeyForEditor(cm, name, handle); if (result == "multi") cm.state.keySeq = name; if (result == "handled") signalLater(cm, "keyHandled", cm, name, e); if (result == "handled" || result == "multi") { e_preventDefault(e); restartBlink(cm); } if (seq && !result && /\'$/.test(name)) { e_preventDefault(e); return true; } return !!result; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
dispatchKey
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function handleKeyBinding(cm, e) { var name = keyName(e, true); if (!name) return false; if (e.shiftKey && !cm.state.keySeq) { // First try to resolve full name (including 'Shift-'). Failing // that, see if there is a cursor-motion command (starting with // 'go') bound to the keyname without 'Shift-'. return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);}) || dispatchKey(cm, name, e, function(b) { if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) return doHandleBinding(cm, b); }); } else { return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); }); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
handleKeyBinding
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT