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 addMarkedSpan(line, span) { line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; span.marker.attachLine(line); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
addMarkedSpan
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function markedSpansBefore(old, startCh, isInsert) { if (old) for (var i = 0, nw; i < old.length; ++i) { var span = old[i], marker = span.marker; var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); } } return nw; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
markedSpansBefore
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function markedSpansAfter(old, endCh, isInsert) { if (old) for (var i = 0, nw; i < old.length; ++i) { var span = old[i], marker = span.marker; var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, span.to == null ? null : span.to - endCh)); } } return nw; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
markedSpansAfter
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function stretchSpansOverChange(doc, change) { if (change.full) return null; var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; if (!oldFirst && !oldLast) return null; var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; // Get the spans that 'stick out' on both sides var first = markedSpansBefore(oldFirst, startCh, isInsert); var last = markedSpansAfter(oldLast, endCh, isInsert); // Next, merge those two ends var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); if (first) { // Fix up .to properties of first for (var i = 0; i < first.length; ++i) { var span = first[i]; if (span.to == null) { var found = getMarkedSpanFor(last, span.marker); if (!found) span.to = startCh; else if (sameLine) span.to = found.to == null ? null : found.to + offset; } } } if (last) { // Fix up .from in last (or move them into first in case of sameLine) for (var i = 0; i < last.length; ++i) { var span = last[i]; if (span.to != null) span.to += offset; if (span.from == null) { var found = getMarkedSpanFor(first, span.marker); if (!found) { span.from = offset; if (sameLine) (first || (first = [])).push(span); } } else { span.from += offset; if (sameLine) (first || (first = [])).push(span); } } } // Make sure we didn't create any zero-length spans if (first) first = clearEmptySpans(first); if (last && last != first) last = clearEmptySpans(last); var newMarkers = [first]; if (!sameLine) { // Fill gap with whole-line-spans var gap = change.text.length - 2, gapMarkers; if (gap > 0 && first) for (var i = 0; i < first.length; ++i) if (first[i].to == null) (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null)); for (var i = 0; i < gap; ++i) newMarkers.push(gapMarkers); newMarkers.push(last); } return newMarkers; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
stretchSpansOverChange
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function clearEmptySpans(spans) { for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) spans.splice(i--, 1); } if (!spans.length) return null; return spans; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
clearEmptySpans
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function mergeOldSpans(doc, change) { var old = getOldSpans(doc, change); var stretched = stretchSpansOverChange(doc, change); if (!old) return stretched; if (!stretched) return old; for (var i = 0; i < old.length; ++i) { var oldCur = old[i], stretchCur = stretched[i]; if (oldCur && stretchCur) { spans: for (var j = 0; j < stretchCur.length; ++j) { var span = stretchCur[j]; for (var k = 0; k < oldCur.length; ++k) if (oldCur[k].marker == span.marker) continue spans; oldCur.push(span); } } else if (stretchCur) { old[i] = stretchCur; } } return old; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
mergeOldSpans
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function removeReadOnlyRanges(doc, from, to) { var markers = null; doc.iter(from.line, to.line + 1, function(line) { if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) { var mark = line.markedSpans[i].marker; if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) (markers || (markers = [])).push(mark); } }); if (!markers) return null; var parts = [{from: from, to: to}]; for (var i = 0; i < markers.length; ++i) { var mk = markers[i], m = mk.find(0); for (var j = 0; j < parts.length; ++j) { var p = parts[j]; if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue; var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) newParts.push({from: p.from, to: m.from}); if (dto > 0 || !mk.inclusiveRight && !dto) newParts.push({from: m.to, to: p.to}); parts.splice.apply(parts, newParts); j += newParts.length - 1; } } return parts; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
removeReadOnlyRanges
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function detachMarkedSpans(line) { var spans = line.markedSpans; if (!spans) return; for (var i = 0; i < spans.length; ++i) spans[i].marker.detachLine(line); line.markedSpans = null; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
detachMarkedSpans
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function attachMarkedSpans(line, spans) { if (!spans) return; for (var i = 0; i < spans.length; ++i) spans[i].marker.attachLine(line); line.markedSpans = spans; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
attachMarkedSpans
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function compareCollapsedMarkers(a, b) { var lenDiff = a.lines.length - b.lines.length; if (lenDiff != 0) return lenDiff; var aPos = a.find(), bPos = b.find(); var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); if (fromCmp) return -fromCmp; var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); if (toCmp) return toCmp; return b.id - a.id; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
compareCollapsedMarkers
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function collapsedSpanAtSide(line, start) { var sps = sawCollapsedSpans && line.markedSpans, found; if (sps) for (var sp, i = 0; i < sps.length; ++i) { sp = sps[i]; if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && (!found || compareCollapsedMarkers(found, sp.marker) < 0)) found = sp.marker; } return found; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
collapsedSpanAtSide
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function conflictingCollapsedRange(doc, lineNo, from, to, marker) { var line = getLine(doc, lineNo); var sps = sawCollapsedSpans && line.markedSpans; if (sps) for (var i = 0; i < sps.length; ++i) { var sp = sps[i]; if (!sp.marker.collapsed) continue; var found = sp.marker.find(0); var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue; if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) || fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0)) return true; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
conflictingCollapsedRange
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function visualLine(line) { var merged; while (merged = collapsedSpanAtStart(line)) line = merged.find(-1, true).line; return line; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
visualLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function visualLineContinued(line) { var merged, lines; while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line; (lines || (lines = [])).push(line); } return lines; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
visualLineContinued
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function visualLineNo(doc, lineN) { var line = getLine(doc, lineN), vis = visualLine(line); if (line == vis) return lineN; return lineNo(vis); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
visualLineNo
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function visualLineEndNo(doc, lineN) { if (lineN > doc.lastLine()) return lineN; var line = getLine(doc, lineN), merged; if (!lineIsHidden(doc, line)) return lineN; while (merged = collapsedSpanAtEnd(line)) line = merged.find(1, true).line; return lineNo(line) + 1; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
visualLineEndNo
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function lineIsHidden(doc, line) { var sps = sawCollapsedSpans && line.markedSpans; if (sps) for (var sp, i = 0; i < sps.length; ++i) { sp = sps[i]; if (!sp.marker.collapsed) continue; if (sp.from == null) return true; if (sp.marker.widgetNode) continue; if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) return true; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
lineIsHidden
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function lineIsHiddenInner(doc, line, span) { if (span.to == null) { var end = span.marker.find(1, true); return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)); } if (span.marker.inclusiveRight && span.to == line.text.length) return true; for (var sp, i = 0; i < line.markedSpans.length; ++i) { sp = line.markedSpans[i]; if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && (sp.to == null || sp.to != span.from) && (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && lineIsHiddenInner(doc, line, sp)) return true; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
lineIsHiddenInner
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function adjustScrollWhenAboveVisible(cm, line, diff) { if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) addToScrollPos(cm, null, diff); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
adjustScrollWhenAboveVisible
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function widgetHeight(widget) { if (widget.height != null) return widget.height; var cm = widget.doc.cm; if (!cm) return 0; if (!contains(document.body, widget.node)) { var parentStyle = "position: relative;"; if (widget.coverGutter) parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; if (widget.noHScroll) parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle)); } return widget.height = widget.node.parentNode.offsetHeight; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
widgetHeight
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function addLineWidget(doc, handle, node, options) { var widget = new LineWidget(doc, node, options); var cm = doc.cm; if (cm && widget.noHScroll) cm.display.alignWidgets = true; changeLine(doc, handle, "widget", function(line) { var widgets = line.widgets || (line.widgets = []); if (widget.insertAt == null) widgets.push(widget); else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); widget.line = line; if (cm && !lineIsHidden(doc, line)) { var aboveVisible = heightAtLine(line) < doc.scrollTop; updateLineHeight(line, line.height + widgetHeight(widget)); if (aboveVisible) addToScrollPos(cm, null, widget.height); cm.curOp.forceUpdate = true; } return true; }); return widget; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
addLineWidget
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function updateLine(line, text, markedSpans, estimateHeight) { line.text = text; if (line.stateAfter) line.stateAfter = null; if (line.styles) line.styles = null; if (line.order != null) line.order = null; detachMarkedSpans(line); attachMarkedSpans(line, markedSpans); var estHeight = estimateHeight ? estimateHeight(line) : 1; if (estHeight != line.height) updateLineHeight(line, estHeight); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
updateLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function cleanUpLine(line) { line.parent = null; detachMarkedSpans(line); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
cleanUpLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function extractLineClasses(type, output) { if (type) for (;;) { var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); if (!lineClass) break; type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); var prop = lineClass[1] ? "bgClass" : "textClass"; if (output[prop] == null) output[prop] = lineClass[2]; else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop])) output[prop] += " " + lineClass[2]; } return type; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
extractLineClasses
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function callBlankLine(mode, state) { if (mode.blankLine) return mode.blankLine(state); if (!mode.innerMode) return; var inner = CodeMirror.innerMode(mode, state); if (inner.mode.blankLine) return inner.mode.blankLine(inner.state); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
callBlankLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function readToken(mode, stream, state, inner) { for (var i = 0; i < 10; i++) { if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode; var style = mode.token(stream, state); if (stream.pos > stream.start) return style; } throw new Error("Mode " + mode.name + " failed to advance stream."); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
readToken
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function takeToken(cm, pos, precise, asArray) { function getObj(copy) { return {start: stream.start, end: stream.pos, string: stream.current(), type: style || null, state: copy ? copyState(doc.mode, state) : state}; } var doc = cm.doc, mode = doc.mode, style; pos = clipPos(doc, pos); var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise); var stream = new StringStream(line.text, cm.options.tabSize), tokens; if (asArray) tokens = []; while ((asArray || stream.pos < pos.ch) && !stream.eol()) { stream.start = stream.pos; style = readToken(mode, stream, state); if (asArray) tokens.push(getObj(true)); } return asArray ? tokens : getObj(); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
takeToken
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getObj(copy) { return {start: stream.start, end: stream.pos, string: stream.current(), type: style || null, state: copy ? copyState(doc.mode, state) : state}; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getObj
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) { var flattenSpans = mode.flattenSpans; if (flattenSpans == null) flattenSpans = cm.options.flattenSpans; var curStart = 0, curStyle = null; var stream = new StringStream(text, cm.options.tabSize), style; var inner = cm.options.addModeClass && [null]; if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses); while (!stream.eol()) { if (stream.pos > cm.options.maxHighlightLength) { flattenSpans = false; if (forceToEnd) processLine(cm, text, state, stream.pos); stream.pos = text.length; style = null; } else { style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses); } if (inner) { var mName = inner[0].name; if (mName) style = "m-" + (style ? mName + " " + style : mName); } if (!flattenSpans || curStyle != style) { while (curStart < stream.start) { curStart = Math.min(stream.start, curStart + 50000); f(curStart, curStyle); } curStyle = style; } stream.start = stream.pos; } while (curStart < stream.pos) { // Webkit seems to refuse to render text nodes longer than 57444 characters var pos = Math.min(stream.pos, curStart + 50000); f(pos, curStyle); curStart = pos; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
runMode
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function highlightLine(cm, line, state, forceToEnd) { // A styles array always starts with a number identifying the // mode/overlays that it is based on (for easy invalidation). var st = [cm.state.modeGen], lineClasses = {}; // Compute the base array of styles runMode(cm, line.text, cm.doc.mode, state, function(end, style) { st.push(end, style); }, lineClasses, forceToEnd); // Run overlays, adjust style array. for (var o = 0; o < cm.state.overlays.length; ++o) { var overlay = cm.state.overlays[o], i = 1, at = 0; runMode(cm, line.text, overlay.mode, true, function(end, style) { var start = i; // Ensure there's a token end at the current position, and that i points at it while (at < end) { var i_end = st[i]; if (i_end > end) st.splice(i, 1, end, st[i+1], i_end); i += 2; at = Math.min(end, i_end); } if (!style) return; if (overlay.opaque) { st.splice(start, i - start, end, "cm-overlay " + style); i = start + 2; } else { for (; start < i; start += 2) { var cur = st[start+1]; st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style; } } }, lineClasses); } return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
highlightLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getLineStyles(cm, line, updateFrontier) { if (!line.styles || line.styles[0] != cm.state.modeGen) { var state = getStateBefore(cm, lineNo(line)); var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state); line.stateAfter = state; line.styles = result.styles; if (result.classes) line.styleClasses = result.classes; else if (line.styleClasses) line.styleClasses = null; if (updateFrontier === cm.doc.frontier) cm.doc.frontier++; } return line.styles; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getLineStyles
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function processLine(cm, text, state, startAt) { var mode = cm.doc.mode; var stream = new StringStream(text, cm.options.tabSize); stream.start = stream.pos = startAt || 0; if (text == "") callBlankLine(mode, state); while (!stream.eol()) { readToken(mode, stream, state); stream.start = stream.pos; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
processLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function interpretTokenStyle(style, options) { if (!style || /^\s*$/.test(style)) return null; var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; return cache[style] || (cache[style] = style.replace(/\S+/g, "cm-$&")); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
interpretTokenStyle
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function buildLineContent(cm, lineView) { // The padding-right forces the element to have a 'border', which // is needed on Webkit to be able to get line-level bounding // rectangles for it (in measureChar). var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content, col: 0, pos: 0, cm: cm, splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; lineView.measure = {}; // Iterate over the logical lines that make up this visual line. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { var line = i ? lineView.rest[i - 1] : lineView.line, order; builder.pos = 0; builder.addToken = buildToken; // Optionally wire in some hacks into the token-rendering // algorithm, to deal with browser quirks. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line))) builder.addToken = buildTokenBadBidi(builder.addToken, order); builder.map = []; var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); if (line.styleClasses) { if (line.styleClasses.bgClass) builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); if (line.styleClasses.textClass) builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); } // Ensure at least a single node is present, for measuring. if (builder.map.length == 0) builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); // Store the map and a cache object for the current logical line if (i == 0) { lineView.measure.map = builder.map; lineView.measure.cache = {}; } else { (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map); (lineView.measure.caches || (lineView.measure.caches = [])).push({}); } } // See issue #2901 if (webkit) { var last = builder.content.lastChild if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab"))) builder.content.className = "cm-tab-wrap-hack"; } signal(cm, "renderLine", cm, lineView.line, builder.pre); if (builder.pre.className) builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); return builder; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
buildLineContent
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function defaultSpecialCharPlaceholder(ch) { var token = elt("span", "\u2022", "cm-invalidchar"); token.title = "\\u" + ch.charCodeAt(0).toString(16); token.setAttribute("aria-label", token.title); return token; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
defaultSpecialCharPlaceholder
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function buildToken(builder, text, style, startStyle, endStyle, title, css) { if (!text) return; var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text; var special = builder.cm.state.specialChars, mustWrap = false; if (!special.test(text)) { builder.col += text.length; var content = document.createTextNode(displayText); builder.map.push(builder.pos, builder.pos + text.length, content); if (ie && ie_version < 9) mustWrap = true; builder.pos += text.length; } else { var content = document.createDocumentFragment(), pos = 0; while (true) { special.lastIndex = pos; var m = special.exec(text); var skipped = m ? m.index - pos : text.length - pos; if (skipped) { var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); else content.appendChild(txt); builder.map.push(builder.pos, builder.pos + skipped, txt); builder.col += skipped; builder.pos += skipped; } if (!m) break; pos += skipped + 1; if (m[0] == "\t") { var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); txt.setAttribute("role", "presentation"); txt.setAttribute("cm-text", "\t"); builder.col += tabWidth; } else if (m[0] == "\r" || m[0] == "\n") { var txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar")); txt.setAttribute("cm-text", m[0]); builder.col += 1; } else { var txt = builder.cm.options.specialCharPlaceholder(m[0]); txt.setAttribute("cm-text", m[0]); if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); else content.appendChild(txt); builder.col += 1; } builder.map.push(builder.pos, builder.pos + 1, txt); builder.pos++; } } if (style || startStyle || endStyle || mustWrap || css) { var fullStyle = style || ""; if (startStyle) fullStyle += startStyle; if (endStyle) fullStyle += endStyle; var token = elt("span", [content], fullStyle, css); if (title) token.title = title; return builder.content.appendChild(token); } builder.content.appendChild(content); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
buildToken
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function splitSpaces(old) { var out = " "; for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0"; out += " "; return out; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
splitSpaces
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function buildTokenBadBidi(inner, order) { return function(builder, text, style, startStyle, endStyle, title, css) { style = style ? style + " cm-force-border" : "cm-force-border"; var start = builder.pos, end = start + text.length; for (;;) { // Find the part that overlaps with the start of this text for (var i = 0; i < order.length; i++) { var part = order[i]; if (part.to > start && part.from <= start) break; } if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css); inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css); startStyle = null; text = text.slice(part.to - start); start = part.to; } }; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
buildTokenBadBidi
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function buildCollapsedSpan(builder, size, marker, ignoreWidget) { var widget = !ignoreWidget && marker.widgetNode; if (widget) builder.map.push(builder.pos, builder.pos + size, widget); if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { if (!widget) widget = builder.content.appendChild(document.createElement("span")); widget.setAttribute("cm-marker", marker.id); } if (widget) { builder.cm.display.input.setUneditable(widget); builder.content.appendChild(widget); } builder.pos += size; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
buildCollapsedSpan
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function insertLineContent(line, builder, styles) { var spans = line.markedSpans, allText = line.text, at = 0; if (!spans) { for (var i = 1; i < styles.length; i+=2) builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options)); return; } var len = allText.length, pos = 0, i = 1, text = "", style, css; var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed; for (;;) { if (nextChange == pos) { // Update current marker set spanStyle = spanEndStyle = spanStartStyle = title = css = ""; collapsed = null; nextChange = Infinity; var foundBookmarks = [], endStyles for (var j = 0; j < spans.length; ++j) { var sp = spans[j], m = sp.marker; if (m.type == "bookmark" && sp.from == pos && m.widgetNode) { foundBookmarks.push(m); } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) { if (sp.to != null && sp.to != pos && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } if (m.className) spanStyle += " " + m.className; if (m.css) css = (css ? css + ";" : "") + m.css; if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle; if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to) if (m.title && !title) title = m.title; if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) collapsed = sp; } else if (sp.from > pos && nextChange > sp.from) { nextChange = sp.from; } } if (endStyles) for (var j = 0; j < endStyles.length; j += 2) if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j] if (!collapsed || collapsed.from == pos) for (var j = 0; j < foundBookmarks.length; ++j) buildCollapsedSpan(builder, 0, foundBookmarks[j]); if (collapsed && (collapsed.from || 0) == pos) { buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, collapsed.marker, collapsed.from == null); if (collapsed.to == null) return; if (collapsed.to == pos) collapsed = false; } } if (pos >= len) break; var upto = Math.min(len, nextChange); while (true) { if (text) { var end = pos + text.length; if (!collapsed) { var tokenText = end > upto ? text.slice(0, upto - pos) : text; builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css); } if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;} pos = end; spanStartStyle = ""; } text = allText.slice(at, at = styles[i++]); style = interpretTokenStyle(styles[i++], builder.cm.options); } } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
insertLineContent
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function isWholeLineUpdate(doc, change) { return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && (!doc.cm || doc.cm.options.wholeLineUpdateBefore); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
isWholeLineUpdate
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function updateDoc(doc, change, markedSpans, estimateHeight) { function spansFor(n) {return markedSpans ? markedSpans[n] : null;} function update(line, text, spans) { updateLine(line, text, spans, estimateHeight); signalLater(line, "change", line, change); } function linesFor(start, end) { for (var i = start, result = []; i < end; ++i) result.push(new Line(text[i], spansFor(i), estimateHeight)); return result; } var from = change.from, to = change.to, text = change.text; var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; // Adjust the line structure if (change.full) { doc.insert(0, linesFor(0, text.length)); doc.remove(text.length, doc.size - text.length); } else if (isWholeLineUpdate(doc, change)) { // This is a whole-line replace. Treated specially to make // sure line objects move the way they are supposed to. var added = linesFor(0, text.length - 1); update(lastLine, lastLine.text, lastSpans); if (nlines) doc.remove(from.line, nlines); if (added.length) doc.insert(from.line, added); } else if (firstLine == lastLine) { if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); } else { var added = linesFor(1, text.length - 1); added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); doc.insert(from.line + 1, added); } } else if (text.length == 1) { update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); doc.remove(from.line + 1, nlines); } else { update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); var added = linesFor(1, text.length - 1); if (nlines > 1) doc.remove(from.line + 1, nlines - 1); doc.insert(from.line + 1, added); } signalLater(doc, "change", doc, change); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
updateDoc
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function update(line, text, spans) { updateLine(line, text, spans, estimateHeight); signalLater(line, "change", line, change); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
update
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function linesFor(start, end) { for (var i = start, result = []; i < end; ++i) result.push(new Line(text[i], spansFor(i), estimateHeight)); return result; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
linesFor
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function LeafChunk(lines) { this.lines = lines; this.parent = null; for (var i = 0, height = 0; i < lines.length; ++i) { lines[i].parent = this; height += lines[i].height; } this.height = height; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
LeafChunk
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function BranchChunk(children) { this.children = children; var size = 0, height = 0; for (var i = 0; i < children.length; ++i) { var ch = children[i]; size += ch.chunkSize(); height += ch.height; ch.parent = this; } this.size = size; this.height = height; this.parent = null; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
BranchChunk
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function linkedDocs(doc, f, sharedHistOnly) { function propagate(doc, skip, sharedHist) { if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) { var rel = doc.linked[i]; if (rel.doc == skip) continue; var shared = sharedHist && rel.sharedHist; if (sharedHistOnly && !shared) continue; f(rel.doc, shared); propagate(rel.doc, doc, shared); } } propagate(doc, null, true); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
linkedDocs
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function propagate(doc, skip, sharedHist) { if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) { var rel = doc.linked[i]; if (rel.doc == skip) continue; var shared = sharedHist && rel.sharedHist; if (sharedHistOnly && !shared) continue; f(rel.doc, shared); propagate(rel.doc, doc, shared); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
propagate
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function attachDoc(cm, doc) { if (doc.cm) throw new Error("This document is already in use."); cm.doc = doc; doc.cm = cm; estimateLineHeights(cm); loadMode(cm); if (!cm.options.lineWrapping) findMaxLine(cm); cm.options.mode = doc.modeOption; regChange(cm); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
attachDoc
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getLine(doc, n) { n -= doc.first; if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document."); for (var chunk = doc; !chunk.lines;) { for (var i = 0;; ++i) { var child = chunk.children[i], sz = child.chunkSize(); if (n < sz) { chunk = child; break; } n -= sz; } } return chunk.lines[n]; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getBetween(doc, start, end) { var out = [], n = start.line; doc.iter(start.line, end.line + 1, function(line) { var text = line.text; if (n == end.line) text = text.slice(0, end.ch); if (n == start.line) text = text.slice(start.ch); out.push(text); ++n; }); return out; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getBetween
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getLines(doc, from, to) { var out = []; doc.iter(from, to, function(line) { out.push(line.text); }); return out; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getLines
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function updateLineHeight(line, height) { var diff = height - line.height; if (diff) for (var n = line; n; n = n.parent) n.height += diff; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
updateLineHeight
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function lineNo(line) { if (line.parent == null) return null; var cur = line.parent, no = indexOf(cur.lines, line); for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { for (var i = 0;; ++i) { if (chunk.children[i] == cur) break; no += chunk.children[i].chunkSize(); } } return no + cur.first; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
lineNo
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function lineAtHeight(chunk, h) { var n = chunk.first; outer: do { for (var i = 0; i < chunk.children.length; ++i) { var child = chunk.children[i], ch = child.height; if (h < ch) { chunk = child; continue outer; } h -= ch; n += child.chunkSize(); } return n; } while (!chunk.lines); for (var i = 0; i < chunk.lines.length; ++i) { var line = chunk.lines[i], lh = line.height; if (h < lh) break; h -= lh; } return n + i; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
lineAtHeight
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function heightAtLine(lineObj) { lineObj = visualLine(lineObj); var h = 0, chunk = lineObj.parent; for (var i = 0; i < chunk.lines.length; ++i) { var line = chunk.lines[i]; if (line == lineObj) break; else h += line.height; } for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { for (var i = 0; i < p.children.length; ++i) { var cur = p.children[i]; if (cur == chunk) break; else h += cur.height; } } return h; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
heightAtLine
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getOrder(line) { var order = line.order; if (order == null) order = line.order = bidiOrdering(line.text); return order; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getOrder
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function History(startGen) { // Arrays of change events and selections. Doing something adds an // event to done and clears undo. Undoing moves events from done // to undone, redoing moves them in the other direction. this.done = []; this.undone = []; this.undoDepth = Infinity; // Used to track when changes can be merged into a single undo // event this.lastModTime = this.lastSelTime = 0; this.lastOp = this.lastSelOp = null; this.lastOrigin = this.lastSelOrigin = null; // Used by the isClean() method this.generation = this.maxGeneration = startGen || 1; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
History
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function historyChangeFromChange(doc, change) { var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true); return histChange; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
historyChangeFromChange
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function clearSelectionEvents(array) { while (array.length) { var last = lst(array); if (last.ranges) array.pop(); else break; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
clearSelectionEvents
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function lastChangeEvent(hist, force) { if (force) { clearSelectionEvents(hist.done); return lst(hist.done); } else if (hist.done.length && !lst(hist.done).ranges) { return lst(hist.done); } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { hist.done.pop(); return lst(hist.done); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
lastChangeEvent
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function addChangeToHistory(doc, change, selAfter, opId) { var hist = doc.history; hist.undone.length = 0; var time = +new Date, cur; if ((hist.lastOp == opId || hist.lastOrigin == change.origin && change.origin && ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) || change.origin.charAt(0) == "*")) && (cur = lastChangeEvent(hist, hist.lastOp == opId))) { // Merge this change into the last event var last = lst(cur.changes); if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { // Optimized case for simple insertion -- don't want to add // new changesets for every character typed last.to = changeEnd(change); } else { // Add new sub-event cur.changes.push(historyChangeFromChange(doc, change)); } } else { // Can not be merged, start a new event. var before = lst(hist.done); if (!before || !before.ranges) pushSelectionToHistory(doc.sel, hist.done); cur = {changes: [historyChangeFromChange(doc, change)], generation: hist.generation}; hist.done.push(cur); while (hist.done.length > hist.undoDepth) { hist.done.shift(); if (!hist.done[0].ranges) hist.done.shift(); } } hist.done.push(selAfter); hist.generation = ++hist.maxGeneration; hist.lastModTime = hist.lastSelTime = time; hist.lastOp = hist.lastSelOp = opId; hist.lastOrigin = hist.lastSelOrigin = change.origin; if (!last) signal(doc, "historyAdded"); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
addChangeToHistory
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function selectionEventCanBeMerged(doc, origin, prev, sel) { var ch = origin.charAt(0); return ch == "*" || ch == "+" && prev.ranges.length == sel.ranges.length && prev.somethingSelected() == sel.somethingSelected() && new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
selectionEventCanBeMerged
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function addSelectionToHistory(doc, sel, opId, options) { var hist = doc.history, origin = options && options.origin; // A new event is started when the previous origin does not match // the current, or the origins don't allow matching. Origins // starting with * are always merged, those starting with + are // merged when similar and close together in time. if (opId == hist.lastSelOp || (origin && hist.lastSelOrigin == origin && (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) hist.done[hist.done.length - 1] = sel; else pushSelectionToHistory(sel, hist.done); hist.lastSelTime = +new Date; hist.lastSelOrigin = origin; hist.lastSelOp = opId; if (options && options.clearRedo !== false) clearSelectionEvents(hist.undone); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
addSelectionToHistory
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function pushSelectionToHistory(sel, dest) { var top = lst(dest); if (!(top && top.ranges && top.equals(sel))) dest.push(sel); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
pushSelectionToHistory
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function attachLocalSpans(doc, change, from, to) { var existing = change["spans_" + doc.id], n = 0; doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) { if (line.markedSpans) (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; ++n; }); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
attachLocalSpans
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function removeClearedSpans(spans) { if (!spans) return null; for (var i = 0, out; i < spans.length; ++i) { if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); } else if (out) out.push(spans[i]); } return !out ? spans : out.length ? out : null; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
removeClearedSpans
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getOldSpans(doc, change) { var found = change["spans_" + doc.id]; if (!found) return null; for (var i = 0, nw = []; i < change.text.length; ++i) nw.push(removeClearedSpans(found[i])); return nw; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getOldSpans
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function copyHistoryArray(events, newGroup, instantiateSel) { for (var i = 0, copy = []; i < events.length; ++i) { var event = events[i]; if (event.ranges) { copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); continue; } var changes = event.changes, newChanges = []; copy.push({changes: newChanges}); for (var j = 0; j < changes.length; ++j) { var change = changes[j], m; newChanges.push({from: change.from, to: change.to, text: change.text}); if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) { if (indexOf(newGroup, Number(m[1])) > -1) { lst(newChanges)[prop] = change[prop]; delete change[prop]; } } } } return copy; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
copyHistoryArray
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function rebaseHistSelSingle(pos, from, to, diff) { if (to < pos.line) { pos.line += diff; } else if (from < pos.line) { pos.line = from; pos.ch = 0; } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
rebaseHistSelSingle
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function rebaseHistArray(array, from, to, diff) { for (var i = 0; i < array.length; ++i) { var sub = array[i], ok = true; if (sub.ranges) { if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } for (var j = 0; j < sub.ranges.length; j++) { rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); } continue; } for (var j = 0; j < sub.changes.length; ++j) { var cur = sub.changes[j]; if (to < cur.from.line) { cur.from = Pos(cur.from.line + diff, cur.from.ch); cur.to = Pos(cur.to.line + diff, cur.to.ch); } else if (from <= cur.to.line) { ok = false; break; } } if (!ok) { array.splice(0, i + 1); i = 0; } } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
rebaseHistArray
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function rebaseHist(hist, change) { var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; rebaseHistArray(hist.done, from, to, diff); rebaseHistArray(hist.undone, from, to, diff); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
rebaseHist
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function e_defaultPrevented(e) { return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
e_defaultPrevented
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function e_button(e) { var b = e.which; if (b == null) { if (e.button & 1) b = 1; else if (e.button & 2) b = 3; else if (e.button & 4) b = 2; } if (mac && e.ctrlKey && b == 1) b = 3; return b; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
e_button
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function getHandlers(emitter, type, copy) { var arr = emitter._handlers && emitter._handlers[type] if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers else return arr || noHandlers }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
getHandlers
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function signalLater(emitter, type /*, values...*/) { var arr = getHandlers(emitter, type, false) if (!arr.length) return; var args = Array.prototype.slice.call(arguments, 2), list; if (operationGroup) { list = operationGroup.delayedCallbacks; } else if (orphanDelayedCallbacks) { list = orphanDelayedCallbacks; } else { list = orphanDelayedCallbacks = []; setTimeout(fireOrphanDelayed, 0); } function bnd(f) {return function(){f.apply(null, args);};}; for (var i = 0; i < arr.length; ++i) list.push(bnd(arr[i])); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
signalLater
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function fireOrphanDelayed() { var delayed = orphanDelayedCallbacks; orphanDelayedCallbacks = null; for (var i = 0; i < delayed.length; ++i) delayed[i](); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
fireOrphanDelayed
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function signalDOMEvent(cm, e, override) { if (typeof e == "string") e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; signal(cm, override || e.type, cm, e); return e_defaultPrevented(e) || e.codemirrorIgnore; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
signalDOMEvent
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function signalCursorActivity(cm) { var arr = cm._handlers && cm._handlers.cursorActivity; if (!arr) return; var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1) set.push(arr[i]); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
signalCursorActivity
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function hasHandler(emitter, type) { return getHandlers(emitter, type).length > 0 }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
hasHandler
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function eventMixin(ctor) { ctor.prototype.on = function(type, f) {on(this, type, f);}; ctor.prototype.off = function(type, f) {off(this, type, f);}; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
eventMixin
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function spaceStr(n) { while (spaceStrs.length <= n) spaceStrs.push(lst(spaceStrs) + " "); return spaceStrs[n]; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
spaceStr
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function indexOf(array, elt) { for (var i = 0; i < array.length; ++i) if (array[i] == elt) return i; return -1; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
indexOf
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function map(array, f) { var out = []; for (var i = 0; i < array.length; i++) out[i] = f(array[i], i); return out; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
map
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function createObj(base, props) { var inst; if (Object.create) { inst = Object.create(base); } else { nothing.prototype = base; inst = new nothing(); } if (props) copyObj(props, inst); return inst; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
createObj
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function copyObj(obj, target, overwrite) { if (!target) target = {}; for (var prop in obj) if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) target[prop] = obj[prop]; return target; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
copyObj
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function bind(f) { var args = Array.prototype.slice.call(arguments, 1); return function(){return f.apply(null, args);}; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
bind
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function isWordChar(ch, helper) { if (!helper) return isWordCharBasic(ch); if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true; return helper.test(ch); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
isWordChar
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function isEmpty(obj) { for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false; return true; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
isEmpty
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function elt(tag, content, className, style) { var e = document.createElement(tag); if (className) e.className = className; if (style) e.style.cssText = style; if (typeof content == "string") e.appendChild(document.createTextNode(content)); else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]); return e; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
elt
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function removeChildren(e) { for (var count = e.childNodes.length; count > 0; --count) e.removeChild(e.firstChild); return e; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
removeChildren
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function removeChildrenAndAdd(parent, e) { return removeChildren(parent).appendChild(e); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
removeChildrenAndAdd
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function activeElt() { var activeElement = document.activeElement; while (activeElement && activeElement.root && activeElement.root.activeElement) activeElement = activeElement.root.activeElement; return activeElement; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
activeElt
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function joinClasses(a, b) { var as = a.split(" "); for (var i = 0; i < as.length; i++) if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i]; return b; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
joinClasses
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function forEachCodeMirror(f) { if (!document.body.getElementsByClassName) return; var byClass = document.body.getElementsByClassName("CodeMirror"); for (var i = 0; i < byClass.length; i++) { var cm = byClass[i].CodeMirror; if (cm) f(cm); } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
forEachCodeMirror
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function ensureGlobalHandlers() { if (globalsRegistered) return; registerGlobalHandlers(); globalsRegistered = true; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
ensureGlobalHandlers
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function registerGlobalHandlers() { // When the window resizes, we need to refresh active editors. var resizeTimer; on(window, "resize", function() { if (resizeTimer == null) resizeTimer = setTimeout(function() { resizeTimer = null; forEachCodeMirror(onResize); }, 100); }); // When the window loses focus, we want to show the editor as blurred on(window, "blur", function() { forEachCodeMirror(onBlur); }); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
registerGlobalHandlers
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function zeroWidthElement(measure) { if (zwspSupported == null) { var test = elt("span", "\u200b"); removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); if (measure.firstChild.offsetHeight != 0) zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); } var node = zwspSupported ? elt("span", "\u200b") : elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); node.setAttribute("cm-text", ""); return node; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
zeroWidthElement
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function hasBadBidiRects(measure) { if (badBidiRects != null) return badBidiRects; var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); var r0 = range(txt, 0, 1).getBoundingClientRect(); if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780) var r1 = range(txt, 1, 2).getBoundingClientRect(); return badBidiRects = (r1.right - r0.right < 3); }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
hasBadBidiRects
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT
function hasBadZoomedRects(measure) { if (badZoomedRects != null) return badZoomedRects; var node = removeChildrenAndAdd(measure, elt("span", "x")); var normal = node.getBoundingClientRect(); var fromRange = range(node, 0, 1).getBoundingClientRect(); return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1; }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
hasBadZoomedRects
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
MIT