Search is not available for this dataset
query
stringlengths
7
355k
document
stringlengths
9
341k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Set a new selection.
function setSelection(doc, sel, options) { setSelectionNoUndo(doc, sel, options); addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function setSelection(doc, sel, options) {\n\t\t setSelectionNoUndo(doc, sel, options);\n\t\t addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);\n\t\t }", "function setSelection(doc, sel, options) {\n\t\t setSelectionNoUndo(doc, sel, options);\n\t\t addSelectionToHistory(d...
[ "0.7453179", "0.7453179", "0.7395772", "0.7395772", "0.7395772", "0.7356902", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "0.7300484", "...
0.7272042
33
Verify that the selection does not partially select any atomic marked ranges.
function reCheckSelection(doc) { setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get hasSelection() {\n const start = this._model.finalSelectionStart;\n const end = this._model.finalSelectionEnd;\n if (!start || !end) {\n return false;\n }\n return start[0] !== end[0] || start[1] !== end[1];\n }", "function selectionIsSane() {\n\t\t\tvar minSi...
[ "0.6870172", "0.60677147", "0.6066715", "0.6055218", "0.60424894", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.5962891", "0.596198", "0.5916995", "0.5891306", "0.5881634", "0.5881634", "0.5879924", "0.5879924", "0.5879924", "0.5879924", ...
0.0
-1
Return a selection that does not partially select any atomic ranges.
function skipAtomicInSelection(doc, sel, bias, mayClear) { var out; for (var i = 0; i < sel.ranges.length; i++) { var range = sel.ranges[i]; var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear); var newHead = skipAtomic(doc, range.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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "selection_excluding(cells) {\n const selection = new Set(this.selection);\n for (const cell of cells) {\n selection.delete(cell);\n }\n return selection;\n }", "function skipAtomicInSelection(doc, sel, bias, mayClear) {\n var out;\n for (var i = 0; i < sel.ranges.l...
[ "0.6847842", "0.6637457", "0.6637457", "0.6637457", "0.6637457", "0.6637457", "0.6637457", "0.6637457", "0.6477013", "0.6475794", "0.6475794", "0.6439841", "0.6439841", "0.6439841", "0.6439841", "0.6439841", "0.6439841", "0.6439841", "0.6439841", "0.6439841", "0.6439841", "...
0.6596417
8
Ensure a given position is not inside an atomic range.
function skipAtomic(doc, pos, bias, mayClear) { var flipped = false, curPos = pos; var dir = bias || 1; doc.cantEdit = false; search: for (;;) { var line = getLine(doc, curPos.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 <= curPos.ch : sp.from < curPos.ch)) && (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) { if (mayClear) { signal(m, "beforeCursorEnter"); if (m.explicitlyCleared) { if (!line.markedSpans) break; else {--i; continue;} } } if (!m.atomic) continue; var newPos = m.find(dir < 0 ? -1 : 1); if (cmp(newPos, curPos) == 0) { newPos.ch += dir; if (newPos.ch < 0) { if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1)); else newPos = null; } else if (newPos.ch > line.text.length) { if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0); else newPos = null; } if (!newPos) { if (flipped) { // Driven in a corner -- no valid cursor position found at all // -- try again *with* clearing, if we didn't already if (!mayClear) return skipAtomic(doc, pos, bias, true); // Otherwise, turn off editing until further notice, and return the start of the doc doc.cantEdit = true; return Pos(doc.first, 0); } flipped = true; newPos = pos; dir = -dir; } } curPos = newPos; continue search; } } } return curPos; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static isInsideRange(position, range) {\n if (range.start.line === range.end.line) {\n return range.start.line === position.line\n && range.start.character <= position.character\n && position.character <= range.end.character;\n }\n else if (range.start....
[ "0.59889543", "0.59686285", "0.5916081", "0.56262064", "0.56172895", "0.5600432", "0.55854857", "0.55482024", "0.55333084", "0.55325186", "0.5510936", "0.54777867", "0.54776806", "0.541091", "0.54105973", "0.53991055", "0.53884256", "0.5388403", "0.5365578", "0.53471917", "0....
0.0
-1
SELECTION DRAWING Redraw the selection and/or cursor
function drawSelection(cm) { var display = cm.display, 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++) { var range = doc.sel.ranges[i]; var collapsed = range.empty(); if (collapsed || cm.options.showCursorWhenSelecting) drawSelectionCursor(cm, range, curFragment); if (!collapsed) drawSelectionRange(cm, range, selFragment); } // Move the hidden textarea near the cursor to prevent scrolling artifacts if (cm.options.moveInputWithCursor) { var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, headPos.top + lineOff.top - wrapOff.top)); result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, headPos.left + lineOff.left - wrapOff.left)); } return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawSelections() {\n\t\thideSelectionRect();\n\t}", "function updateSelection(){\n\t\t\tif(lastMousePos.pageX == null) return;\n\t\t\t\n\t\t\tsetSelectionPos(selection.second, lastMousePos);\n\t\t\tclearSelection();\n\t\t\t\n\t\t\tif(selectionIsSane()) drawSelection();\n\t\t}", "function drawSelection...
[ "0.78486377", "0.7741627", "0.7313765", "0.7160716", "0.69569415", "0.694826", "0.6926943", "0.68883574", "0.6829901", "0.6801858", "0.6770737", "0.6767673", "0.67041683", "0.67026585", "0.6661518", "0.6613574", "0.6611723", "0.66105074", "0.66044146", "0.65924394", "0.659029...
0.0
-1
Draws a cursor for the given range
function drawSelectionCursor(cm, range, output) { var pos = cursorCoords(cm, range.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"; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawSelectionCursor(cm, range, output) {\n var pos = cursorCoords(cm, range.head, \"div\", null, null, !cm.options.singleCursorHeightPerLine);\n\n var cursor = output.appendChild(elt(\"div\", \"\\u00a0\", \"CodeMirror-cursor\"));\n cursor.style.left = pos.left + \"px\";\n cursor.style.top = po...
[ "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.69801736", "0.68451244", "0.6837227", "0.6837227", "0.6837227", "0.6837227", "0.6835953", "0.6835953", "0.6835953", "0.6835953", "0.68251777", "0.68251777", "0.6819444", "0.68056154", "0.68...
0.6950206
7
Draws the given range as a highlighted selection
function drawSelectionRange(cm, range, output) { var display = cm.display, doc = cm.doc; var fragment = document.createDocumentFragment(); var padding = paddingH(cm.display), leftSide = padding.left, rightSide = display.lineSpace.offsetWidth - 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); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawSelectionRange(cm, range, output) {\n\t\t var display = cm.display, doc = cm.doc;\n\t\t var fragment = document.createDocumentFragment();\n\t\t var padding = paddingH(cm.display), leftSide = padding.left;\n\t\t var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.o...
[ "0.75189173", "0.75186044", "0.75186044", "0.75186044", "0.75186044", "0.7513986", "0.74924827", "0.74924827", "0.74924827", "0.74924827", "0.7467988", "0.7455654", "0.74446476", "0.74446476", "0.74435604", "0.74435604", "0.74435604", "0.74435604", "0.74435604", "0.74435604", ...
0.7454901
12
Finds the line to start with when starting a parse. Tries to find a line with a stateAfter, so that it can start with a valid state. If that fails, it returns the line with the smallest indentation, which tends to need the least context to parse correctly.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findStartLine(n) {\n var minindent, minline;\n for (var search = n, lim = n - 40; search > lim; --search) {\n if (search == 0) return 0;\n var line = lines[search-1];\n if (line.stateAfter) return search;\n var indented = line.indentation();\n if (minline == nu...
[ "0.6962411", "0.6955082", "0.6955082", "0.69002736", "0.6820576", "0.6820576", "0.6820576", "0.6815363", "0.6718006", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", "0.6714978", ...
0.6334255
57
Ensure the lineView.wrapping.heights array is populated. This is an array of bottom offsets for the lines that make up a drawn line. When lineWrapping is on, there might be more than one height.
function ensureLineHeights(cm, lineView, rect) { var wrapping = cm.options.lineWrapping; var curWidth = wrapping && cm.display.scroller.clientWidth; 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); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ensureLineHeights(cm, lineView, rect) {\n var wrapping = cm.options.lineWrapping;\n var curWidth = wrapping && cm.display.scroller.clientWidth;\n if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {\n var heights = lineView.measure.heights = [];\n if (wrapp...
[ "0.7544686", "0.7544686", "0.7544686", "0.7544686", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", "0.73758477", ...
0.7497
4
Find a line map (mapping character offsets to text nodes) and a measurement cache for the given line number. (A line view might contain multiple lines when collapsed ranges are present.)
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}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mapFromLineView(lineView, line, lineN) {\n if (lineView.line == line) {\n return {\n map: lineView.measure.map,\n cache: lineView.measure.cache\n };\n }\n\n for (var i = 0; i < lineView.rest.length; i++) {\n if (lineView.rest[i] == line) {\n return {\n ...
[ "0.75460523", "0.7488654", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.74369943", "0.7417173", "0.7417173", "0.74095714", ...
0.7348773
46
Render a line into the hidden node display.externalMeasured. Used when measurement is needed for a line that's not in the viewport.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateExternalMeasurement(cm, line) {\n line = visualLine(line);\n var lineN = lineNo(line);\n var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);\n view.lineN = lineN;\n var built = view.built = buildLineContent(cm, view);\n view.text = built.pre;\n removeChil...
[ "0.75342", "0.7484259", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.7475978", "0.74745804", "0.74694103", "...
0.7487335
1
Find a line view that corresponds to the given line number.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findViewForLine(cm, lineN) {\n if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)\n { return cm.display.view[findViewIndex(cm, lineN)] }\n var ext = cm.display.externalMeasured;\n if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)\n { return ext }\n }", "funct...
[ "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7498672", "0.7490927", "0.7490927", "0.7490927", "0.7490927", "...
0.7378883
45
Measurement can be split in two steps, the setup work that applies to the whole line, and the measurement of the actual character. Functions like coordsChar, that need to do a lot of measurements in a row, can thus ensure that the setup work is only done once.
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)); 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 }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function prepareMeasureForLine(cm, line) {\n var lineN = lineNo(line);\n var view = findViewForLine(cm, lineN);\n\n if (view && !view.text) {\n view = null;\n } else if (view && view.changes) {\n updateLineForChanges(cm, view, lineN, getDimensions(cm));\n cm.curOp.forceUpdate = true;\n ...
[ "0.61011076", "0.60801214", "0.6048344", "0.5924275", "0.59188163", "0.59188163", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", "0.590181", ...
0.5844106
38
Given a prepared measurement object, measures the position of an actual character (or fetches it from the cache).
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}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function measureCharPrepared(cm, prepared, ch, bias, varHeight) {\n if (prepared.before) ch = -1;\n var key = ch + (bias || \"\"), found;\n if (prepared.cache.hasOwnProperty(key)) {\n found = prepared.cache[key];\n } else {\n if (!prepared.rect)\n prepared.rect = prepared.view.text.get...
[ "0.6956743", "0.6956743", "0.6956743", "0.6956743", "0.6956743", "0.6956743", "0.6956743", "0.6956743", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "0.6948188", "...
0.69280237
27
Work around problem with bounding client rects on ranges being returned incorrectly when zoomed on IE10 and below.
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}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getRangeBoundingClientRect(range){// \"Return a DOMRect object describing the smallest rectangle that includes\r\n\t// the first rectangle in list and all of the remaining rectangles of which\r\n\t// the height or width is not zero.\"\r\n\t// http://www.w3.org/TR/cssom-view/#dom-range-getboundingclientrec...
[ "0.6960293", "0.68528867", "0.67470604", "0.6737133", "0.6737133", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6730641", "0.6724661", "0.6724661", "0.6669039", "0.6669039", "0.66471195", "0.6547397", "0.65430623",...
0.0
-1
Coverts a box from "div" coords to another coordinate system. Context may be "window", "page", "div", or "local"/null.
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}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fromCoordSystem(cm, coords, context) {\n if (context == \"div\") return coords;\n var left = coords.left, top = coords.top;\n // First move into \"page\" coordinate system\n if (context == \"page\") {\n left -= pageScrollX();\n top -= pageScrollY();\n } else if (context == \"local...
[ "0.65310293", "0.65310293", "0.65310293", "0.65310293", "0.6393128", "0.63907343", "0.6347056", "0.6333921", "0.6333921", "0.6333921", "0.6333921", "0.6333921", "0.6333921", "0.6333921", "0.6333921", "0.6323886", "0.6311887", "0.6311887", "0.63112855", "0.63112855", "0.630852...
0.633435
7
Returns a box for a given cursor position, which may have an 'other' property containing the position of the secondary cursor on a bidi boundary.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cursor_box_size() { return { x: 10, y: 10 }; }", "function getBox(o) {\n return {\n xMin: o.position.x,\n xMax: o.position.x + o.width,\n yMin: o.position.y,\n yMax: o.position.y + o.height\n };\n }", "function getBox(o) {\n return {\n xMin: o.position.x,\n ...
[ "0.61951715", "0.56517017", "0.5637188", "0.55549294", "0.5481452", "0.5451724", "0.51886904", "0.51287645", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", "0.51277184", ...
0.49929026
54
Used to cheaply estimate the coordinates for a position. Used for intermediate scroll updates.
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}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function calculate_coordinates () {\n\t }", "coordinates () {\n return this._position.coordinates()\n }", "function calcPos() {\n\t\t// Current coordinates\n\t\tvar coords = sphoords.getCoordinates();\n\t\tvar coords_deg = sphoords.getCoordinatesInDegrees();\n\n\t\t// Corresponding position on the sphere\n...
[ "0.6922836", "0.6853012", "0.6800622", "0.67038745", "0.67038745", "0.67038745", "0.6692944", "0.66866237", "0.6674445", "0.6644042", "0.66426384", "0.6631865", "0.6619488", "0.6619488", "0.6619488", "0.6619488", "0.6619488", "0.6619488", "0.6619488", "0.6619488", "0.66040397...
0.66073644
20
Positions returned by coordsChar contain some extra information. xRel is the relative x position of the input coordinates compared to the found position (so xRel > 0 means the coordinates are to the right of the character position, for example). When outside is true, that means the coordinates lie outside the line's vertical range.
function PosWithInfo(line, ch, outside, xRel) { var pos = Pos(line, ch); pos.xRel = xRel; if (outside) pos.outside = true; return pos; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function PosWithInfo(line, ch, sticky, outside, xRel) {\n var pos = Pos(line, ch, sticky);\n pos.xRel = xRel;\n\n if (outside) {\n pos.outside = outside;\n }\n\n return pos;\n } // Compute the character position closest to the given coordinates.", "function coordsChar(cm, x, y) {\n var do...
[ "0.6488047", "0.63717175", "0.63717175", "0.63717175", "0.63369083", "0.6326008", "0.6326008", "0.6326008", "0.6326008", "0.6326008", "0.6326008", "0.6326008", "0.6326008", "0.6310346", "0.6300315", "0.6300315", "0.6300315", "0.6300315", "0.62870514", "0.62870514", "0.6287051...
0.6315894
13
Compute the character position closest to the given coordinates. Input must be lineSpacelocal ("div" coordinate system).
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; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function PosWithInfo(line, ch, sticky, outside, xRel) {\n var pos = Pos(line, ch, sticky);\n pos.xRel = xRel;\n\n if (outside) {\n pos.outside = outside;\n }\n\n return pos;\n } // Compute the character position closest to the given coordinates.", "function coordsChar(cm, x, y) {\n var do...
[ "0.7138738", "0.626187", "0.626187", "0.626187", "0.626187", "0.6206231", "0.6206231", "0.6206231", "0.6206231", "0.6206231", "0.6206231", "0.6206231", "0.6206231", "0.6192183", "0.6177129", "0.6174354", "0.61715925", "0.61715925", "0.6164382", "0.6132255", "0.6120749", "0....
0.6153348
19
Compute the default text height.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function textHeight(display) {\n if (display.cachedTextHeight != null) {\n return display.cachedTextHeight;\n }\n\n if (measureText == null) {\n measureText = elt(\"pre\", null, \"CodeMirror-line-like\"); // Measure a bunch of lines, for browsers that compute\n // fractional heights.\n\n ...
[ "0.7177637", "0.69138646", "0.6897135", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.6894641", "0.68879944", "0.68811613", "0.6807327", "0.6807327", "0.6807327", "0.6807327", ...
0.67182964
32
Compute the default character width.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }", "function charWidth(display) {\n\t\t if (display.cachedCharWidth != null) return display.cachedCharWidth;\n\t\t var anchor = elt(\"span\", \"xxxxxxxxxx\");\n\t\t var pre = elt(\"pre\", [anchor]);\n\t\t removeChildrenAndAd...
[ "0.7920131", "0.7037969", "0.7021818", "0.7021073", "0.7021073", "0.7021073", "0.70129645", "0.70129645", "0.70129645", "0.70129645", "0.70129645", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.7000035", "0.6948909", "0.6948909"...
0.6951675
19
Start a new operation.
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 id: ++nextOpId // Unique ID }; if (operationGroup) { operationGroup.ops.push(cm.curOp); } else { cm.curOp.ownsGroup = operationGroup = { ops: [cm.curOp], delayedCallbacks: [] }; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startNew(options) {\n if (options === void 0) { options = {}; }\n return default_1.DefaultKernel.startNew(options);\n }", "function startNew(options) {\n return Private.startNew(options);\n }", "function startNew(options) {\n return Private.startNew(options);\n }",...
[ "0.61408204", "0.61112124", "0.61112124", "0.5981286", "0.58847827", "0.5828475", "0.57061714", "0.5692559", "0.5688068", "0.5688068", "0.5688068", "0.5681768", "0.5661453", "0.5646481", "0.5626896", "0.5626896", "0.5626896", "0.5626896", "0.5626896", "0.5621532", "0.5621532"...
0.57273746
6
Finish an operation, updating the display and signalling delayed events
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); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "finishProcessing() {\n this.busy = false;\n this.successful = true;\n }", "function handleFinish(values) {\n job.current = getJob(values, job.current, writeMessage);\n setBusy(job.current.pendingTime);\n }", "finish() {\n window.setTimeout(\n this.displayAbsorptionTexts.bind(thi...
[ "0.6298353", "0.6149194", "0.6141501", "0.61294717", "0.61197203", "0.6094414", "0.60886836", "0.6063711", "0.60263014", "0.602398", "0.60091406", "0.6005056", "0.59634334", "0.59634334", "0.59634334", "0.59634334", "0.5962261", "0.59593785", "0.5950094", "0.5950094", "0.5931...
0.0
-1
The DOM updates done when an operation finishes are batched so that the minimum number of relayouts are required.
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]); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function processQueue() {\n\t\t if (updateQueue.length) {\n\t\t ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);\n\t\t clearQueue();\n\t\t }\n\t\t}", "function processQueue() {\n\t if (updateQueue.length) {\n\t ReactComponentEnvironment.processChildrenUpdates(\n\t upda...
[ "0.65620655", "0.6510543", "0.6510543", "0.6510543", "0.6510543", "0.6510543", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "0.64983904", "...
0.5745588
87
Run the given function in an operation
function runInOp(cm, f) { if (cm.curOp) return f(); startOperation(cm); try { return f(); } finally { endOperation(cm); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function runInOp(cm, f) {\n\t\t if (cm.curOp) { return f() }\n\t\t startOperation(cm);\n\t\t try { return f() }\n\t\t finally { endOperation(cm); }\n\t\t }", "function runInOp(cm, f) {\n\t if (cm.curOp) return f();\n\t startOperation(cm);\n\t try { return f(); }\n\t finally { endOperatio...
[ "0.72196746", "0.72107506", "0.72107506", "0.72107506", "0.719325", "0.7188428", "0.7068937", "0.70685226", "0.70685226", "0.70685226", "0.70382166", "0.70382166", "0.70382166", "0.70382166", "0.70382166", "0.70382166", "0.70382166", "0.70382166", "0.70382166", "0.70382166", ...
0.7011758
35
Wraps a function in an operation. Returns the wrapped function.
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); } }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "function wrap(func, wrapper) {\n return partial(wrapper, func);\n }", "functio...
[ "0.6697844", "0.6697844", "0.6697844", "0.6697844", "0.6697844", "0.6697844", "0.6697844", "0.6697844", "0.6697844", "0.66415626", "0.6519331", "0.64675987", "0.64675987", "0.64675987", "0.64675987", "0.64675987", "0.64675987", "0.64675987", "0.64675987", "0.64675987", "0.646...
0.0
-1
Used to add methods to editor and doc instances, wrapping them in operations.
function methodOp(f) { return function() { if (this.curOp) return f.apply(this, arguments); startOperation(this); try { return f.apply(this, arguments); } finally { endOperation(this); } }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addEditorMethods(CodeMirror) {\n\t\t var optionHandlers = CodeMirror.optionHandlers;\n\n\t\t var helpers = CodeMirror.helpers = {};\n\n\t\t CodeMirror.prototype = {\n\t\t constructor: CodeMirror,\n\t\t focus: function(){win(this).focus(); this.display.input.focus();},\n\n\t\t setOp...
[ "0.6234695", "0.61433893", "0.61433893", "0.611974", "0.611974", "0.611974", "0.611974", "0.611974", "0.611974", "0.611974", "0.611974", "0.611974", "0.61185527", "0.61185527", "0.61185527", "0.61185527", "0.61185527", "0.61185527", "0.6086015", "0.6070089", "0.6070089", "0...
0.0
-1
VIEW TRACKING These objects are used to represent the visible (currently drawn) part of the document. A LineView may correspond to multiple logical lines, if those are connected by collapsed ranges.
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); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line; // Continuing lines, if any\n\n this.rest = visualLineContinued(line); // Number of logical lines in this visual line\n\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n...
[ "0.7227958", "0.6997179", "0.6997179", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.69601446", "0.6944605", "0.6944605", "0.6944605", "0.6944605", "0.6944605", "0.6944605", "0.69...
0.68997264
40
Create a range of LineView objects for the given lines.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line; // Continuing lines, if any\n\n this.rest = visualLineContinued(line); // Number of logical lines in this visual line\n\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n...
[ "0.7717119", "0.6600235", "0.6600235", "0.6600235", "0.6600235", "0.6600235", "0.6600235", "0.6600235", "0.6600235", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "0.6588617", "...
0.6575102
28
Updates the display.view data structure for a given change to the document. From and to are in prechange coordinates. Lendiff is the amount of lines added or subtracted by the change. This is used for changes that span multiple lines, or change the way lines are divided into visual lines. regLineChange (below) registers singleline changes.
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; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function regChange(cm, from, to, lendiff) {\n if (from == null) {\n from = cm.doc.first;\n }\n\n if (to == null) {\n to = cm.doc.first + cm.doc.size;\n }\n\n if (!lendiff) {\n lendiff = 0;\n }\n\n var display = cm.display;\n\n if (lendiff && to < display.viewTo && (display.up...
[ "0.7041117", "0.70191276", "0.7001752", "0.7001752", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", "0.6953793", ...
0.6969179
4
Register a change to a single line. Type must be one of "text", "gutter", "class", "widget"
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); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function LineChange (type, text) {\n this.type = type // ADDED, REMOVED, UNMODIFIED\n this.text = text\n}", "function regLineChange(cm, line, type) {\n cm.curOp.viewChanged = true\n var display = cm.display, ext = cm.display.externalMeasured\n if (ext && line >= ext.lineN && line < ext.lineN + ext.siz...
[ "0.75807256", "0.71199244", "0.71199244", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.7101364", "0.70958996", "0.70958996", "0.70958996", "0.70958996", "0.70958996", "0.70958996", "0.7095...
0.7067052
40
Find the view element corresponding to a given line. Return null when the line isn't visible.
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; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findViewForLine(cm, lineN) {\n if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)\n { return cm.display.view[findViewIndex(cm, lineN)] }\n var ext = cm.display.externalMeasured;\n if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)\n { return ext }\n }", "funct...
[ "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.7009115", "0.6991372", "0.6991372", "0.6991372", "0.6991372", "...
0.0
-1
Force the view to cover a given range, adding empty view element or clipping off existing ones as needed.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor(viewOf, qmin, qmax) {\n super(viewOf, (field, colLabel, colSchema, colData, df) =>\n _clipAnnoMatrix(field, colLabel, colSchema, colData, df, qmin, qmax)\n );\n this.isClipped = true;\n this.clipRange = [qmin, qmax];\n Object.seal(this);\n }", "setRenderedRange(range) {\n if (...
[ "0.5556946", "0.5472256", "0.5384595", "0.537245", "0.5349878", "0.53442", "0.53263646", "0.5308165", "0.52663255", "0.52513677", "0.52321917", "0.5231704", "0.52292764", "0.5206579", "0.5195497", "0.5195497", "0.5187255", "0.5187255", "0.5183682", "0.5183682", "0.51568943", ...
0.0
-1
Count the number of lines in the view whose DOM representation is out of date (or nonexistent).
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function countLines() {\n let page = document.getElementsByClassName(\"kix-zoomdocumentplugin-outer\")[0];\n if (page == null) {\n return (\"Element does not exist on the document.\")\n }\n let lineCount = 0;\n const pageText = page.innerText;\n\n for (let i = 0; i < pageText.length; i++) ...
[ "0.64771295", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6393244", "0.6392505", "0.6392505", "0.6392505", ...
0.6377945
26
INPUT HANDLING Poll for input changes, using the normal rate of polling. This runs as long as the editor is focused.
function slowPoll(cm) { if (cm.display.pollingFast) return; cm.display.poll.set(cm.options.pollInterval, function() { readInput(cm); if (cm.state.focused) slowPoll(cm); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "pollInput() {\n this.Mouse.poll();\n this.Keyboard.poll();\n }", "internalOnInput(event) {\n const me = this; // Keep the value synced with the inputValue at all times.\n\n me.inputting = true;\n me.value = me.input.value;\n me.inputting = false;\n me.trigger('input', {\n value: me.val...
[ "0.66223204", "0.66153526", "0.65691286", "0.65496546", "0.6438963", "0.64073694", "0.6386468", "0.630443", "0.62575155", "0.6193845", "0.6191011", "0.6055958", "0.6055958", "0.6055958", "0.6055958", "0.6055958", "0.6055958", "0.6052023", "0.6042059", "0.6042058", "0.6020005"...
0.60592455
11
When an event has just come in that is likely to add or change something in the input textarea, we poll faster, to ensure that the change appears on the screen quickly.
function fastPoll(cm) { var missed = false; cm.display.pollingFast = true; function p() { var changed = readInput(cm); if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);} else {cm.display.pollingFast = false; slowPoll(cm);} } cm.display.poll.set(20, p); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function slowPoll(cm) {\r\n if (cm.display.pollingFast) return;\r\n cm.display.poll.set(cm.options.pollInterval, function() {\r\n readInput(cm);\r\n if (cm.state.focused) slowPoll(cm);\r\n });\r\n }", "function fastPoll(cm) {\n var missed = false;\n cm.display.pollingFast = true;\n f...
[ "0.66384095", "0.66259307", "0.66259307", "0.66259307", "0.66259307", "0.66259307", "0.66259307", "0.661385", "0.661385", "0.661385", "0.661385", "0.661385", "0.661385", "0.65797645", "0.6477442", "0.6477442", "0.6477442", "0.63370305", "0.62778944", "0.62778944", "0.62778944...
0.6627468
1
Read input from the textarea, and update the document to match. When something is selected, it is present in the textarea, and selected (unless it is huge, in which case a placeholder is used). When nothing is selected, the cursor sits after previously seen text (can be empty), which is stored in prevInput (we must not reset the textarea when typing, because that breaks IME).
function readInput(cm) { var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc; // Since this is called a *lot*, try to bail out as cheaply as // possible when it is clear that nothing happened. hasSelection // will be the case when there is a lot of text in the textarea, // in which case reading its value would be expensive. if (!cm.state.focused || (hasSelection(input) && !prevInput) || isReadOnly(cm) || cm.options.disableInput) return false; // See paste handler for more on the fakedLastChar kludge if (cm.state.pasteIncoming && cm.state.fakedLastChar) { input.value = input.value.substring(0, input.value.length - 1); cm.state.fakedLastChar = false; } var text = input.value; // If nothing changed, bail. if (text == prevInput && !cm.somethingSelected()) return false; // Work around nonsensical selection resetting in IE9/10, and // inexplicable appearance of private area unicode characters on // some key combos in Mac (#2689). if (ie && ie_version >= 9 && cm.display.inputHasSelection === text || mac && /[\uf700-\uf7ff]/.test(text)) { resetInput(cm); return false; } var withOp = !cm.curOp; if (withOp) startOperation(cm); cm.display.shift = false; if (text.charCodeAt(0) == 0x200b && doc.sel == cm.display.selForContextMenu && !prevInput) prevInput = "\u200b"; // Find the part of the input that is actually new var same = 0, l = Math.min(prevInput.length, text.length); while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same; var inserted = text.slice(same), textLines = splitLines(inserted); // When pasing N lines into N selections, insert one line per selection var multiPaste = null; if (cm.state.pasteIncoming && doc.sel.ranges.length > 1) { if (lastCopied && lastCopied.join("\n") == inserted) multiPaste = doc.sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines); else if (textLines.length == doc.sel.ranges.length) multiPaste = map(textLines, function(l) { return [l]; }); } // Normal behavior is to insert the new text into every selection for (var i = doc.sel.ranges.length - 1; i >= 0; i--) { var range = doc.sel.ranges[i]; var from = range.from(), to = range.to(); // Handle deletion if (same < prevInput.length) from = Pos(from.line, from.ch - (prevInput.length - same)); // Handle overwrite else if (cm.state.overwrite && range.empty() && !cm.state.pasteIncoming) to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); var updateInput = cm.curOp.updateInput; var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines, origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"}; makeChange(cm.doc, changeEvent); signalLater(cm, "inputRead", cm, changeEvent); // When an 'electric' character is inserted, immediately trigger a reindent if (inserted && !cm.state.pasteIncoming && cm.options.electricChars && cm.options.smartIndent && range.head.ch < 100 && (!i || doc.sel.ranges[i - 1].head.line != range.head.line)) { var mode = cm.getModeAt(range.head); if (mode.electricChars) { for (var j = 0; j < mode.electricChars.length; j++) if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { indentLine(cm, range.head.line, "smart"); break; } } else if (mode.electricInput) { var end = changeEnd(changeEvent); if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch))) indentLine(cm, range.head.line, "smart"); } } } ensureCursorVisible(cm); cm.curOp.updateInput = updateInput; cm.curOp.typing = true; // Don't leave long text in the textarea, since it makes further polling slow if (text.length > 1000 || text.indexOf("\n") > -1) input.value = cm.display.prevInput = ""; else cm.display.prevInput = text; if (withOp) endOperation(cm); cm.state.pasteIncoming = cm.state.cutIncoming = false; return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function readInput() {\n if (leaveInputAlone || !focused) return;\n var changed = false, text = input.value, sr = selRange(input);\n if (!sr) return false;\n var changed = editing.text != text, rs = reducedSelection;\n var moved = changed || sr.start != editing.start || sr.end != (rs ? edi...
[ "0.6916783", "0.6916783", "0.6916783", "0.6318288", "0.6169842", "0.6169842", "0.6166273", "0.6166273", "0.6166273", "0.60491717", "0.60491717", "0.60491717", "0.60276484", "0.60057247", "0.60057247", "0.5980917", "0.5718081", "0.5718081", "0.5718081", "0.5718081", "0.5671565...
0.6072766
9
Reset the input to correspond to the selection (or to be empty, when not typing and nothing is selected)
function resetInput(cm, typing) { var minimal, selected, doc = cm.doc; if (cm.somethingSelected()) { cm.display.prevInput = ""; var range = doc.sel.primary(); minimal = hasCopyEvent && (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000); var content = minimal ? "-" : selected || cm.getSelection(); cm.display.input.value = content; if (cm.state.focused) selectInput(cm.display.input); if (ie && ie_version >= 9) cm.display.inputHasSelection = content; } else if (!typing) { cm.display.prevInput = cm.display.input.value = ""; if (ie && ie_version >= 9) cm.display.inputHasSelection = null; } cm.display.inaccurateSelection = minimal; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function resetInput(cm, typing) {\n var minimal, selected, doc = cm.doc;\n if (cm.somethingSelected()) {\n cm.display.prevInput = \"\";\n var range = doc.sel.primary();\n minimal = hasCopyEvent &&\n (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 10...
[ "0.8101943", "0.8101943", "0.8101943", "0.8101943", "0.7824159", "0.7824159", "0.74899524", "0.74849355", "0.7368271", "0.71624076", "0.71624076", "0.71624076", "0.71624076", "0.7149499", "0.7149499", "0.7133767", "0.7074472", "0.7054121", "0.7049481", "0.7049481", "0.7013619...
0.80305445
4
EVENT HANDLERS Attach the necessary event handlers when initializing the editor
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 = findWordAt(cm, pos); extendSelection(cm.doc, word.anchor, word.head); })); else on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); }); // Prevent normal selection in the editor (we handle our own) on(d.lineSpace, "selectstart", function(e) { if (!eventInWidget(d, 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);}); // 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); } }); on(d.scrollbarV, "scroll", function() { if (d.scroller.clientHeight) setScrollTop(cm, d.scrollbarV.scrollTop); }); on(d.scrollbarH, "scroll", function() { if (d.scroller.clientHeight) setScrollLeft(cm, d.scrollbarH.scrollLeft); }); // 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 clicks in the scrollbars from killing focus function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); } on(d.scrollbarH, "mousedown", reFocus); on(d.scrollbarV, "mousedown", reFocus); // Prevent wrapper from ever scrolling on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); on(d.input, "keyup", function(e) { onKeyUp.call(cm, e); }); on(d.input, "input", function() { if (ie && ie_version >= 9 && cm.display.inputHasSelection) cm.display.inputHasSelection = null; fastPoll(cm); }); on(d.input, "keydown", operation(cm, onKeyDown)); on(d.input, "keypress", operation(cm, onKeyPress)); on(d.input, "focus", bind(onFocus, cm)); on(d.input, "blur", bind(onBlur, cm)); function drag_(e) { if (!signalDOMEvent(cm, e)) e_stop(e); } if (cm.options.dragDrop) { on(d.scroller, "dragstart", function(e){onDragStart(cm, e);}); on(d.scroller, "dragenter", drag_); on(d.scroller, "dragover", drag_); on(d.scroller, "drop", operation(cm, onDrop)); } on(d.scroller, "paste", function(e) { if (eventInWidget(d, e)) return; cm.state.pasteIncoming = true; focusInput(cm); fastPoll(cm); }); on(d.input, "paste", function() { // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206 // Add a char to the end of textarea before paste occur so that // selection doesn't span to the end of textarea. if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) { var start = d.input.selectionStart, end = d.input.selectionEnd; d.input.value += "$"; // The selection end needs to be set before the start, otherwise there // can be an intermediate non-empty selection between the two, which // can override the middle-click paste buffer on linux and cause the // wrong thing to get pasted. d.input.selectionEnd = end; d.input.selectionStart = start; cm.state.fakedLastChar = true; } cm.state.pasteIncoming = true; fastPoll(cm); }); function prepareCopyCut(e) { if (cm.somethingSelected()) { lastCopied = cm.getSelections(); if (d.inaccurateSelection) { d.prevInput = ""; d.inaccurateSelection = false; d.input.value = lastCopied.join("\n"); selectInput(d.input); } } else { var text = [], ranges = []; for (var i = 0; i < cm.doc.sel.ranges.length; i++) { var line = cm.doc.sel.ranges[i].head.line; var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}; ranges.push(lineRange); text.push(cm.getRange(lineRange.anchor, lineRange.head)); } if (e.type == "cut") { cm.setSelections(ranges, null, sel_dontScroll); } else { d.prevInput = ""; d.input.value = text.join("\n"); selectInput(d.input); } lastCopied = text; } if (e.type == "cut") cm.state.cutIncoming = true; } on(d.input, "cut", prepareCopyCut); on(d.input, "copy", prepareCopyCut); // Needed to handle Tab key in KHTML if (khtml) on(d.sizer, "mouseup", function() { if (activeElt() == d.input) d.input.blur(); focusInput(cm); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function init() {\n\n\t\t// Bind the editor elements to variables\n\t\tbindElements();\n\n\t\t// Create event listeners for keyup, mouseup, etc.\n\t\tcreateEventBindings();\n\t}", "initEventListners() {\n this.engine.getSession().selection.on('changeCursor', () => this.updateCursorLabels());\n\n th...
[ "0.75899404", "0.7451777", "0.715617", "0.7042855", "0.7040459", "0.7005983", "0.6992898", "0.6976246", "0.69648314", "0.69638443", "0.6944345", "0.6893292", "0.68734", "0.6776197", "0.67756134", "0.67407024", "0.67152727", "0.6639332", "0.65564615", "0.6555081", "0.6547914",...
0.0
-1
Prevent clicks in the scrollbars from killing focus
function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function disableMiddleBtnScroll()\n{\n document.addEventListener(\"mousedown\", function(e){\n if(e.button==1)\n {\n e.preventDefault(); \n return false\n }\n });\n}", "_preventUserScrollForDefaultBehavior() {\n return;\n }", "function preventScrollEvents(e){\n e.stopPropagatio...
[ "0.72163326", "0.70704013", "0.7011935", "0.7011935", "0.69783056", "0.6931328", "0.6713907", "0.66733676", "0.6662504", "0.6662504", "0.6634197", "0.6634197", "0.6634197", "0.6634197", "0.66214454", "0.6586554", "0.65724975", "0.65635526", "0.65566754", "0.65494287", "0.6544...
0.0
-1
Called when the window resizes
function onResize(cm) { // Might be a text scaling operation, clear size caches. var d = cm.display; d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; cm.setSize(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onWindowResize() {\n updateSizes();\n }", "function windowResized() {\n resize();\n redraw();\n}", "onWindowResize() {\n\t\tthis.windowHeight = this.getWindowHeight();\n\t\tthis.updatePosition();\n\t}", "function onWindowResize() {\n\n\t\t\t}", "function windowResized() {\n resizeCanvas...
[ "0.87504816", "0.8489634", "0.84696436", "0.8312124", "0.7998738", "0.79904795", "0.7962713", "0.7941597", "0.79165184", "0.79024243", "0.7881844", "0.7881551", "0.78685206", "0.78685206", "0.7828244", "0.78222525", "0.78173137", "0.7804665", "0.7797177", "0.778925", "0.77879...
0.0
-1
MOUSE EVENTS Return true when the given mouse event happened in a widget
function eventInWidget(display, e) { for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) return true; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleMouseDown(xpos, ypos, state, evnt, widgets) {\n\tfor(var i = 0; i < widgets.length; i++) {\n\t\tvar widg = widgets[i];\n\t\tif(xpos > widg.x - widg.width/2 && xpos < widg.x + widg.width/2 && ypos > widg.y - widg.height/2 && ypos < widg.y + widg.height/2) {\n\t\t\tisWidgetLocked = true;\n\t\t\tlocked...
[ "0.69559646", "0.6932037", "0.6662541", "0.66276175", "0.65991014", "0.65874517", "0.65803057", "0.6566328", "0.65234137", "0.6465692", "0.6464835", "0.64126956", "0.6410146", "0.6397285", "0.6397285", "0.63822424", "0.6356875", "0.6343323", "0.6343323", "0.6343323", "0.63433...
0.6262401
42
Given a mouse event, find the corresponding position. If liberal is false, it checks whether a gutter or scrollbar was clicked, and returns null if it was. forRect is used by rectangular selections, and tries to estimate a character position even for coordinates beyond the right of the text.
function posFromMouse(cm, e, liberal, forRect) { var display = cm.display; if (!liberal) { var target = e_target(e); if (target == display.scrollbarH || target == display.scrollbarV || target == display.scrollbarFiller || target == display.gutterFiller) 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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function posFromMouse(cm, e, liberal, forRect) {\n var display = cm.display;\n if (!liberal) {\n var target = e_target(e);\n if (target == display.scrollbarH || target == display.scrollbarV ||\n target == display.scrollbarFiller || target == display.gutterFiller) return null;\n }\n v...
[ "0.7708518", "0.7708518", "0.7708518", "0.7708518", "0.7514741", "0.7514741", "0.74732226", "0.74732226", "0.74575555", "0.74575555", "0.7456957", "0.7456957", "0.7456957", "0.7456957", "0.7456957", "0.7456957", "0.7456957", "0.7456957", "0.74547905", "0.74547905", "0.7454790...
0.76387554
4
A mouse down can be a single click, double click, triple click, start of selection drag, start of text drag, new cursor (ctrlclick), rectangle drag (altdrag), or xwin middleclickpaste. Or it might be a click on something we should not interfere with, such as a scrollbar or widget.
function onMouseDown(e) { if (signalDOMEvent(this, e)) return; var cm = this, display = cm.display; 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: 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(bind(focusInput, cm), 20); e_preventDefault(e); break; case 3: if (captureRightClick) onContextMenu(cm, e); break; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onMouseDown(e) {\n var cm = this, display = cm.display;\n if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }\n display.input.ensurePolled();\n display.shift = e.shiftKey;\n\n if (eventInWidget(display, e)) {\n if (!webkit) {\n // Briefl...
[ "0.70923996", "0.70923996", "0.7091965", "0.7091965", "0.7091965", "0.7091965", "0.7091965", "0.7091965", "0.7091965", "0.7091965", "0.7091965", "0.70916486", "0.70872766", "0.7082329", "0.70563495", "0.7055906", "0.7055906", "0.7039263", "0.70240754", "0.70240754", "0.702407...
0.68553513
57
Start a text drag. When it ends, see if any dragging actually happen, and treat as a click if it didn't.
function leftButtonStartDrag(cm, e, start, modifier) { var display = cm.display; 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) extendSelection(cm.doc, start); focusInput(cm); // Work around unexplainable focus problem in IE9 (#2127) if (ie && ie_version == 9) setTimeout(function() {document.body.focus(); focusInput(cm);}, 20); } }); // 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); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startDragText(evt)\r\n{\r\n\r\n if(ActiveElem&&!DraggingObj) //---prevents dragging conflicts on other draggable elements---\r\n {\r\n if(evt.target.parentNode.getAttribute(\"id\")==\"activeText\")\r\n {\r\n if(evt.target.parentNode.parentNode.getAttribute(\"class\")==\"drag...
[ "0.66870064", "0.64880925", "0.64526504", "0.643963", "0.63796633", "0.6295826", "0.62258095", "0.6052833", "0.6033996", "0.6015346", "0.60106355", "0.60037816", "0.59898204", "0.5974962", "0.5962932", "0.5919407", "0.5909692", "0.58979154", "0.58868265", "0.5882919", "0.5857...
0.0
-1
Normal selection, as opposed to text dragging.
function leftButtonSelect(cm, e, start, type, addNew) { var display = cm.display, doc = cm.doc; e_preventDefault(e); var ourRange, ourIndex, startSel = doc.sel; if (addNew && !e.shiftKey) { ourIndex = doc.sel.contains(start); if (ourIndex > -1) ourRange = doc.sel.ranges[ourIndex]; else ourRange = new Range(start, start); } else { ourRange = doc.sel.primary(); } if (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 = findWordAt(cm, 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) { replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); } else { ourIndex = doc.sel.ranges.length; setSelection(doc, normalizeSelection(doc.sel.ranges.concat([ourRange]), ourIndex), {scroll: false, origin: "*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 = findWordAt(cm, 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) { ensureFocus(cm); 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) { counter = Infinity; e_preventDefault(e); focusInput(cm); 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); on(document, "mousemove", move); on(document, "mouseup", up); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "unselectText_() {\n try {\n this.win.getSelection().removeAllRanges();\n } catch (e) {\n // Selection API not supported.\n }\n }", "clearSelection() {\n this._clearSelection();\n }", "cut() {\n if (this.owner.isReadOnlyMode || this.selection.isEmpty) {\n return;\...
[ "0.74885833", "0.7268716", "0.7257491", "0.72482944", "0.72482944", "0.72482944", "0.7164153", "0.7164153", "0.71332663", "0.7116289", "0.7114912", "0.7097566", "0.7063641", "0.704988", "0.70417166", "0.70114183", "0.7003303", "0.69794875", "0.6955937", "0.6951775", "0.693761...
0.0
-1
Determines whether an event happened in the gutter, and fires the handlers for the corresponding event.
function gutterEvent(cm, e, type, prevent, signalfn) { 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]; signalfn(cm, type, cm, line, gutter, e); return e_defaultPrevented(e); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function gutterEvent(cm, e, type, prevent, signalfn) {\n try { var mX = e.clientX, mY = e.clientY; }\n catch(e) { return false; }\n if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;\n if (prevent) e_preventDefault(e);\n\n var display = cm.display;\n var lineBox...
[ "0.64240617", "0.64240617", "0.64240617", "0.64240617", "0.64240617", "0.64240617", "0.64240617", "0.63816375", "0.6362373", "0.6352625", "0.63408446", "0.63368946", "0.63368946", "0.63368946", "0.63368946", "0.63368946", "0.63368946", "0.63254106", "0.63254106", "0.63254106", ...
0.64164716
7
SCROLL EVENTS Sync the scrollable area and scrollbars, ensure the viewport covers the visible area.
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; if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val; if (gecko) updateDisplaySimple(cm); startWorker(cm, 100); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mkdOnWindowScroll() {\n \n }", "scrollChanged(indices) {\n this.internalControlEventOccurred('ArrayScrolledEvent', indices);\n }", "function Simulator_OnScroll()\n{\n\t//has simulator?\n\tif (__SIMULATOR)\n\t{\n\t\t//has controller?\n\t\tif (__CONTROLLER)\n\t\t{\n\t\t\t//no...
[ "0.6627659", "0.6600968", "0.6538907", "0.6503334", "0.64662033", "0.6455364", "0.6419602", "0.6419602", "0.6419602", "0.6419602", "0.6393245", "0.63877255", "0.638458", "0.63838536", "0.6375988", "0.6371613", "0.6371613", "0.6356219", "0.6298325", "0.6290961", "0.628675", ...
0.0
-1
Sync scroller and scrollbar, ensure the gutter elements are aligned.
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; if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = val; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateScrollbars(cm) {\n var d = cm.display, docHeight = cm.doc.height;\n var totalHeight = docHeight + paddingVert(d);\n d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + \"px\";\n d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + \"px...
[ "0.7326835", "0.7249031", "0.7249031", "0.7249031", "0.64672166", "0.64672166", "0.64672166", "0.64092076", "0.63350016", "0.63350016", "0.63350016", "0.63350016", "0.63306326", "0.63306326", "0.63306326", "0.63306326", "0.63306326", "0.63306326", "0.63306326", "0.63306326", ...
0.0
-1
KEY EVENTS Run a handler that was bound to a key.
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 if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false; var prevShift = cm.display.shift, done = false; try { if (isReadOnly(cm)) 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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function receive(key, handler) {\n pxsim.board().bus.listen(key, 0x1, handler);\n }", "function listen(key, callback) {\n handlers[key] = callback;\n}", "function keyPressed() {\n if (handler.active === handler.nameplate) {\n doorbell.keyPressed();\n }\n}", "static eventCallback(ful...
[ "0.6941176", "0.6512591", "0.6502818", "0.6433134", "0.6433134", "0.6433134", "0.6433134", "0.6433134", "0.6398334", "0.6292813", "0.62025106", "0.61664945", "0.6148886", "0.60888934", "0.6086359", "0.6081665", "0.607988", "0.6079462", "0.6077048", "0.6070363", "0.60488915", ...
0.0
-1
Collect the currently active keymaps.
function allKeyMaps(cm) { var maps = cm.state.keyMaps.slice(0); if (cm.options.extraKeys) maps.push(cm.options.extraKeys); maps.push(cm.options.keyMap); return maps; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function allKeyMaps(cm) {\n var maps = cm.state.keyMaps.slice(0);\n if (cm.options.extraKeys) maps.push(cm.options.extraKeys);\n maps.push(cm.options.keyMap);\n return maps;\n }", "function allKeyMaps(cm) {\n var maps = cm.state.keyMaps.slice(0);\n if (cm.options.extraKeys) maps.push(cm.option...
[ "0.6481273", "0.6481273", "0.6481273", "0.5782414", "0.5754308", "0.5750213", "0.5676832", "0.5676832", "0.5676832", "0.5676832", "0.5676832", "0.52943546", "0.52911264", "0.52725035", "0.5158715", "0.5131795", "0.51256", "0.512041", "0.5100498", "0.5100498", "0.5100498", "...
0.64718777
3
Handle a key from the keydown event.
function handleKeyBinding(cm, e) { // Handle automatic keymap transitions var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto; clearTimeout(maybeTransition); if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() { if (getKeyMap(cm.options.keyMap) == startMap) { cm.options.keyMap = (next.call ? next.call(null, cm) : next); keyMapChanged(cm); } }, 50); var name = keyName(e, true), handled = false; if (!name) return false; var keymaps = allKeyMaps(cm); if (e.shiftKey) { // 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-'. handled = lookupKey("Shift-" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);}) || lookupKey(name, keymaps, function(b) { if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) return doHandleBinding(cm, b); }); } else { handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); }); } if (handled) { e_preventDefault(e); restartBlink(cm); signalLater(cm, "keyHandled", cm, name, e); } return handled; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "HandleKeyDown(event) {}", "function keydown_handler(event)\n{\n\tif (event.defaultPrevented) return;\n\tif (game.handle_key(event.code, true)) return;\n\n\t// cancel the default action to avoid it being handled twice\n\tevent.preventDefault();\n}", "function keyDownHandler(event) {\n keyHandler(true, event)...
[ "0.7754498", "0.7530854", "0.725298", "0.71965206", "0.7193362", "0.71909934", "0.71838784", "0.7157211", "0.71227103", "0.7111613", "0.7088491", "0.705151", "0.70506364", "0.70471364", "0.70471364", "0.7042559", "0.70307916", "0.70020014", "0.69745636", "0.6955427", "0.69540...
0.0
-1
Handle a key from the keypress event
function handleCharBinding(cm, e, ch) { var handled = lookupKey("'" + ch + "'", allKeyMaps(cm), function(b) { return doHandleBinding(cm, b, true); }); if (handled) { e_preventDefault(e); restartBlink(cm); signalLater(cm, "keyHandled", cm, "'" + ch + "'", e); } return handled; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "HandleKeyDown(event) {}", "function handleKeyPress({ key }) {\n dispatch(playerTyped(key.toLowerCase()));\n }", "handleInput(keycode) {\n if (keycode !== undefined && player.moves === true) {\n key = keycode;\n }\n }", "handleKeyPress(kEvent) {\n switch (kEvent.keyCod...
[ "0.7767834", "0.765871", "0.758574", "0.74911857", "0.741585", "0.7402115", "0.7374124", "0.737354", "0.73173136", "0.72986954", "0.7289434", "0.7274268", "0.7264864", "0.72491187", "0.72488683", "0.7228675", "0.7217789", "0.7216279", "0.7157265", "0.71438694", "0.71438676", ...
0.0
-1
CONTEXT MENU HANDLING To make the context menu work, we need to briefly unhide the textarea (making it as unobtrusive as possible) to let the rightclick take effect on it.
function onContextMenu(cm, e) { if (signalDOMEvent(cm, e, "contextmenu")) return; var display = cm.display; if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return; var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; if (!pos || presto) return; // Opera is difficult. // Reset the current text selection only if the click is done outside of the selection // and 'resetSelectionOnContextMenu' option is true. var reset = cm.options.resetSelectionOnContextMenu; if (reset && cm.doc.sel.contains(pos) == -1) operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); var oldCSS = display.input.style.cssText; display.inputDiv.style.position = "absolute"; display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) + "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712) focusInput(cm); if (webkit) window.scrollTo(null, oldScrollY); resetInput(cm); // Adds "Select all" to context menu in FF if (!cm.somethingSelected()) display.input.value = display.prevInput = " "; display.selForContextMenu = cm.doc.sel; clearTimeout(display.detectingSelectAll); // Select-all will be greyed out if there's nothing to select, so // this adds a zero-width space so that we can later check whether // it got selected. function prepareSelectAllHack() { if (display.input.selectionStart != null) { var selected = cm.somethingSelected(); var extval = display.input.value = "\u200b" + (selected ? display.input.value : ""); display.prevInput = selected ? "" : "\u200b"; display.input.selectionStart = 1; display.input.selectionEnd = extval.length; // Re-set this, in case some other handler touched the // selection in the meantime. display.selForContextMenu = cm.doc.sel; } } function rehide() { display.inputDiv.style.position = "relative"; display.input.style.cssText = oldCSS; if (ie && ie_version < 9) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos; slowPoll(cm); // Try to detect the user choosing select-all if (display.input.selectionStart != null) { if (!ie || (ie && ie_version < 9)) prepareSelectAllHack(); var i = 0, poll = function() { if (display.selForContextMenu == cm.doc.sel && display.input.selectionStart == 0) operation(cm, commands.selectAll)(cm); else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500); else resetInput(cm); }; display.detectingSelectAll = setTimeout(poll, 200); } } if (ie && ie_version >= 9) prepareSelectAllHack(); if (captureRightClick) { e_stop(e); var mouseup = function() { off(window, "mouseup", mouseup); setTimeout(rehide, 20); }; on(window, "mouseup", mouseup); } else { setTimeout(rehide, 50); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function rightClickHandler(ev, textarea, screenElement, selectionService, shouldSelectWord) {\n moveTextAreaUnderMouseCursor(ev, textarea, screenElement);\n if (shouldSelectWord) {\n selectionService.rightClickSelect(ev);\n }\n // Get textarea ready to copy from the context menu\n textarea.va...
[ "0.68549496", "0.66134685", "0.66105276", "0.65586615", "0.65378284", "0.65269154", "0.6480186", "0.64347166", "0.635688", "0.6342562", "0.63181025", "0.63181025", "0.63043785", "0.6293949", "0.6293949", "0.62910026", "0.6225243", "0.6213995", "0.62080663", "0.6180426", "0.61...
0.5895472
41
Selectall will be greyed out if there's nothing to select, so this adds a zerowidth space so that we can later check whether it got selected.
function prepareSelectAllHack() { if (display.input.selectionStart != null) { var selected = cm.somethingSelected(); var extval = display.input.value = "\u200b" + (selected ? display.input.value : ""); display.prevInput = selected ? "" : "\u200b"; display.input.selectionStart = 1; display.input.selectionEnd = extval.length; // Re-set this, in case some other handler touched the // selection in the meantime. display.selForContextMenu = cm.doc.sel; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function selectAll()\r\n\t\t{\r\n\t\t\tthis.focus();\r\n\t\t\tthis.select();\r\n\t\t}", "function show_select_all(){\r\n var th = getPatternResult(PATTERN['select_all']).snapshotItem(0);\r\n if (th == null) \r\n return;\r\n th.innerHTML = '<input type=\"checkbox\"/>';\r\n th.setAttribute('titl...
[ "0.79616094", "0.68496317", "0.6849021", "0.6849021", "0.6849021", "0.6849021", "0.6849021", "0.67935604", "0.6774863", "0.6762403", "0.6762403", "0.6762403", "0.67509896", "0.67509896", "0.674237", "0.674237", "0.67349464", "0.67318714", "0.67183095", "0.67183095", "0.671830...
0.6836254
7
Adjust a position to refer to the postchange position of the same text, or the end of the change if the change covers it.
function adjustForChange(pos, change) { if (cmp(pos, change.from) < 0) return pos; if (cmp(pos, change.to) <= 0) return changeEnd(change); var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch; return Pos(line, ch); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function adjustForChange(pos, change) {\n\t\t if (cmp(pos, change.from) < 0) return pos;\n\t\t if (cmp(pos, change.to) <= 0) return changeEnd(change);\n\t\t\n\t\t var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;\n\t\t if (pos.line == change.to.line) ch +=...
[ "0.7519226", "0.7518439", "0.7451729", "0.7451729", "0.74473965", "0.7446557", "0.74229974", "0.74229974", "0.74229974", "0.74229974", "0.74229974", "0.74229974", "0.74229974", "0.7420914", "0.7420914", "0.7420914", "0.7420914", "0.7420914", "0.7420914", "0.7420914", "0.74209...
0.7477772
2
Used by replaceSelections to allow moving the selection to the start or around the replaced test. Hint may be "start" or "around".
function computeReplacedSel(doc, changes, hint) { var out = []; var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; for (var i = 0; i < changes.length; i++) { var change = changes[i]; var from = offsetPos(change.from, oldPrev, newPrev); var to = offsetPos(changeEnd(change), oldPrev, newPrev); oldPrev = change.to; newPrev = to; if (hint == "around") { var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; out[i] = new Range(inv ? to : from, inv ? from : to); } else { out[i] = new Range(from, from); } } return new Selection(out, doc.sel.primIndex); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "replaceBeforeCursor(start, text) {\n this.insertBetween(start, this.el.selectionStart, text);\n }", "function moveSelection(event) {\n event.preventDefault();\n event.stopPropagation();\n console.log('Calling moveSelection');\n \n optimalApp.selectionPosition[0] = event.pageX - optimalApp.selectionOffse...
[ "0.66459006", "0.6271295", "0.61861014", "0.61493886", "0.6106035", "0.6076117", "0.60731566", "0.60044765", "0.60039896", "0.59836966", "0.59836966", "0.59836966", "0.5970549", "0.5949476", "0.5948122", "0.5948122", "0.5948122", "0.59362864", "0.58872396", "0.58431464", "0.5...
0.5642735
70
Allow "beforeChange" event handlers to influence a change
function filterChange(doc, change, update) { var obj = { canceled: false, from: change.from, to: change.to, text: change.text, origin: change.origin, cancel: function() { this.canceled = true; } }; if (update) obj.update = function(from, to, text, origin) { if (from) this.from = clipPos(doc, from); if (to) this.to = clipPos(doc, to); if (text) this.text = text; if (origin !== undefined) this.origin = origin; }; signal(doc, "beforeChange", doc, obj); if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj); if (obj.canceled) return null; return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_beforeChange () {\n // nop\n }", "_beforeChange () {\n // nop\n }", "afterValidChange() { }", "change() { }", "internalOnChange(event) {\n const me = this,\n value = me.value,\n oldValue = me._lastValue;\n\n // Don't trigger change if we enter invalid value or if value has not chan...
[ "0.81645423", "0.81645423", "0.71159774", "0.70279074", "0.7022524", "0.68986124", "0.6856265", "0.6830239", "0.6816121", "0.6798605", "0.67954934", "0.67927516", "0.67825234", "0.67575413", "0.6720733", "0.6697086", "0.66936785", "0.6654987", "0.66254723", "0.6593608", "0.65...
0.0
-1
Apply a change to a document, and add it to the document's history, and propagating it to all linked documents.
function makeChange(doc, change, ignoreReadOnly) { if (doc.cm) { if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly); if (doc.cm.state.suppressEdits) return; } if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { change = filterChange(doc, change, true); if (!change) return; } // Possibly split or suppress the update based on the presence // of read-only spans in its range. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); if (split) { for (var i = split.length - 1; i >= 0; --i) makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}); } else { makeChangeInner(doc, change); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "apply(doc) {\n if (this.length != doc.length)\n throw new RangeError(\"Applying change set to a document with the wrong length\");\n iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);\n return doc;\n }", "function...
[ "0.6361561", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.62873036", "0.6285451", "0.6272269", "0.6272269", "0.6272269", "0.6272269", "0.6272269", "0.6272269", "0.6272269", "0.62...
0.0
-1
Revert a change stored in a document's history.
function makeChangeFromHistory(doc, type, allowSelectionOnly) { if (doc.cm && doc.cm.state.suppressEdits) return; var hist = doc.history, event, selAfter = doc.sel; var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; // Verify that there is a useable event (so that ctrl-z won't // needlessly clear selection events) for (var i = 0; i < source.length; i++) { event = source[i]; if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) break; } if (i == source.length) return; hist.lastOrigin = hist.lastSelOrigin = null; for (;;) { event = source.pop(); if (event.ranges) { pushSelectionToHistory(event, dest); if (allowSelectionOnly && !event.equals(doc.sel)) { setSelection(doc, event, {clearRedo: false}); return; } selAfter = event; } else break; } // Build up a reverse change object to add to the opposite history // stack (redo when undoing, and vice versa). var antiChanges = []; pushSelectionToHistory(selAfter, dest); dest.push({changes: antiChanges, generation: hist.generation}); hist.generation = event.generation || ++hist.maxGeneration; var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); for (var i = event.changes.length - 1; i >= 0; --i) { var change = event.changes[i]; change.origin = type; if (filter && !filterChange(doc, change, false)) { source.length = 0; return; } antiChanges.push(historyChangeFromChange(doc, change)); var after = i ? computeSelAfterChange(doc, change) : lst(source); makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); var rebased = []; // Propagate to the linked documents linkedDocs(doc, function(doc, sharedHist) { if (!sharedHist && indexOf(rebased, doc.history) == -1) { rebaseHist(doc.history, change); rebased.push(doc.history); } makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); }); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function undo() {\n var doc = app.activeDocument;\n var states = doc.historyStates;\n \n var curr = 0;\n for (var i=0; i<states.length; i++) {\n if (states[i] == doc.activeHistoryState) {\n curr = i;\n }\n }\n \n var prev ...
[ "0.66696423", "0.6660121", "0.6657044", "0.64068717", "0.6341633", "0.6332736", "0.6280933", "0.62805986", "0.62805986", "0.62659883", "0.620718", "0.61387384", "0.61312824", "0.61018074", "0.61000323", "0.6094208", "0.6079001", "0.5996461", "0.597296", "0.59380674", "0.59320...
0.0
-1
Subviews need their line numbers shifted when text is added above or below them in the parent document.
function shiftDoc(doc, distance) { if (distance == 0) return; doc.first += distance; doc.sel = new Selection(map(doc.sel.ranges, function(range) { return new Range(Pos(range.anchor.line + distance, range.anchor.ch), Pos(range.head.line + distance, range.head.ch)); }), doc.sel.primIndex); if (doc.cm) { regChange(doc.cm, doc.first, doc.first - distance, distance); for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) regLineChange(doc.cm, l, "gutter"); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function bn(e,t,a,n){null==t&&(t=e.doc.first),null==a&&(a=e.doc.first+e.doc.size),n||(n=0);var r=e.display;if(n&&a<r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>t)&&(r.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=r.viewTo)// Change after\n Jo&&pe(e.doc,t)<r.viewTo&&vn(e);else if(a<=r.viewFrom)// C...
[ "0.5986818", "0.5932057", "0.5650373", "0.56363535", "0.5577781", "0.55256647", "0.55159706", "0.5509551", "0.5506837", "0.54515785", "0.5449042", "0.5448814", "0.54456145", "0.54456145", "0.54456145", "0.54456145", "0.54456145", "0.54456145", "0.54456145", "0.54456145", "0.5...
0.0
-1
More lowerlevel change function, handling only a single document (not linked ones).
function makeChangeSingleDoc(doc, change, selAfter, spans) { if (doc.cm && !doc.cm.curOp) return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans); if (change.to.line < doc.first) { shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); return; } if (change.from.line > doc.lastLine()) return; // Clip the change to the size of this doc if (change.from.line < doc.first) { var shift = change.text.length - 1 - (doc.first - change.from.line); shiftDoc(doc, shift); change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), text: [lst(change.text)], origin: change.origin}; } var last = doc.lastLine(); if (change.to.line > last) { change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), text: [change.text[0]], origin: change.origin}; } change.removed = getBetween(doc, change.from, change.to); if (!selAfter) selAfter = computeSelAfterChange(doc, change); if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans); else updateDoc(doc, change, spans); setSelectionNoUndo(doc, selAfter, sel_dontScroll); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "change(docId, doc) {\n const cleanedDoc = this._getCleanedObject(doc);\n let storedDoc = this.store[docId];\n deepExtend(storedDoc, cleanedDoc);\n\n let changedData = {};\n _.each(cleanedDoc, (value, key) => {\n changedData[key] = storedDoc[key];\n });\n\n ...
[ "0.700297", "0.660607", "0.657349", "0.65440965", "0.64870083", "0.64870083", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.6453983", "0.64350307", "0.64350307", "0.64350307", ...
0.63992995
30
Handle the interaction of a change to a document with the editor that this document is part of.
function makeChangeSingleDocInEditor(cm, change, spans) { var doc = cm.doc, display = cm.display, from = change.from, to = change.to; var recomputeMaxLength = false, checkWidthStart = from.line; if (!cm.options.lineWrapping) { checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); doc.iter(checkWidthStart, to.line + 1, function(line) { if (line == display.maxLine) { recomputeMaxLength = true; return true; } }); } if (doc.sel.contains(change.from, change.to) > -1) signalCursorActivity(cm); updateDoc(doc, change, spans, estimateHeight(cm)); if (!cm.options.lineWrapping) { doc.iter(checkWidthStart, from.line + change.text.length, function(line) { var len = lineLength(line); if (len > display.maxLineLength) { display.maxLine = line; display.maxLineLength = len; display.maxLineChanged = true; recomputeMaxLength = false; } }); if (recomputeMaxLength) cm.curOp.updateMaxLine = true; } // Adjust frontier, schedule worker doc.frontier = Math.min(doc.frontier, from.line); startWorker(cm, 400); var lendiff = change.text.length - (to.line - from.line) - 1; // Remember that these lines changed, for updating the display if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) regLineChange(cm, from.line, "text"); else regChange(cm, from.line, to.line + 1, lendiff); var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); if (changeHandler || changesHandler) { var obj = { from: from, to: to, text: change.text, removed: change.removed, origin: change.origin }; if (changeHandler) signalLater(cm, "change", cm, obj); if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); } cm.display.selForContextMenu = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _onCurrentDocumentChange() {\n var doc = DocumentManager.getCurrentDocument(),\n container = _editorHolder.get(0);\n \n var perfTimerName = PerfUtils.markStart(\"EditorManager._onCurrentDocumentChange():\\t\" + (!doc || doc.file.fullPath));\n\n // Remove scroller-sha...
[ "0.6989578", "0.68647164", "0.6661219", "0.6592309", "0.65232587", "0.63881063", "0.63272256", "0.63092566", "0.6279335", "0.62503177", "0.61630493", "0.61265033", "0.61171705", "0.61171705", "0.6100543", "0.6096026", "0.60762805", "0.60762805", "0.6016115", "0.601135", "0.60...
0.6036763
18
SCROLLING THINGS INTO VIEW If an editor sits on the top or bottom of the window, partially scrolled out of view, this ensures that the cursor is visible.
function maybeScrollWindow(cm, coords) { var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; if (coords.top + box.top < 0) doScroll = true; else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false; if (doScroll != null && !phantom) { var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " + (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " + (coords.bottom - coords.top + scrollerCutOff) + "px; left: " + coords.left + "px; width: 2px;"); cm.display.lineSpace.appendChild(scrollNode); scrollNode.scrollIntoView(doScroll); cm.display.lineSpace.removeChild(scrollNode); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "updateView(selection, editor) {\n let path = editor.getPath();\n let i = 0;\n // We check that the selection is actually a point\n // We use selection because for the moment we think it's better not to update the view when the user selects a large part of text\n if (\n selection.newScreenRange....
[ "0.6380827", "0.62958086", "0.6136729", "0.6135841", "0.6080174", "0.6078307", "0.6056505", "0.6009804", "0.6009804", "0.6009804", "0.600625", "0.59079796", "0.59079796", "0.59079796", "0.59079796", "0.59079796", "0.59079796", "0.59079796", "0.5907465", "0.5891595", "0.589147...
0.0
-1
Scroll a given position into view (immediately), verifying that it actually became visible (as line heights are accurately measured, the position of something may 'drift' during drawing).
function scrollPosIntoView(cm, pos, end, margin) { if (margin == null) margin = 0; for (;;) { var changed = false, coords = cursorCoords(cm, pos); var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left), Math.min(coords.top, endCoords.top) - margin, Math.max(coords.left, endCoords.left), Math.max(coords.bottom, endCoords.bottom) + margin); var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; if (scrollPos.scrollTop != null) { setScrollTop(cm, scrollPos.scrollTop); if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true; } if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true; } if (!changed) return coords; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ifVisible(pos) {\n var bottomLine = html.clientHeight + html.scrollTop;\n\n if (pos < bottomLine) {\n return true;\n }\n }", "_checkScrollPosition() {\n\n var isVisible = this._isVisible;\n var isAtBottom = this._isAtBottom;\n var scrollTop = typeof window.scrollY !== 'undefined'...
[ "0.6941039", "0.65672356", "0.62917775", "0.61791223", "0.6119063", "0.601864", "0.5993806", "0.59667224", "0.59440273", "0.5869851", "0.58540875", "0.5849482", "0.5846473", "0.5828448", "0.58210266", "0.5809784", "0.5808769", "0.57965076", "0.5795773", "0.5781369", "0.577449...
0.0
-1
Scroll a given set of coordinates into view (immediately).
function scrollIntoView(cm, x1, y1, x2, y2) { var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2); if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop); if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function scrollIntoView(cm, x1, y1, x2, y2) {\n\t\t var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);\n\t\t if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);\n\t\t if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);\n\t\t }", "function scrollIntoView(c...
[ "0.66701293", "0.6622403", "0.6622403", "0.6622403", "0.65619946", "0.65619946", "0.65619946", "0.65619946", "0.65619946", "0.65619946", "0.65619946", "0.6482107", "0.61915034", "0.61915034", "0.61915034", "0.61915034", "0.61856335", "0.61743706", "0.61577165", "0.61577165", ...
0.65100485
11
Calculate a new scroll position needed to scroll the given rectangle into view. Returns an object with scrollTop and scrollLeft properties. When these are undefined, the vertical/horizontal position does not need to be adjusted.
function calculateScrollPos(cm, x1, y1, x2, y2) { var display = cm.display, snapMargin = textHeight(cm.display); if (y1 < 0) y1 = 0; var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; var screen = display.scroller.clientHeight - scrollerCutOff, result = {}; if (y2 - y1 > screen) y2 = y1 + screen; var docBottom = cm.doc.height + paddingVert(display); var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin; if (y1 < screentop) { result.scrollTop = atTop ? 0 : y1; } else if (y2 > screentop + screen) { var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen); if (newTop != screentop) result.scrollTop = newTop; } var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; var screenw = display.scroller.clientWidth - scrollerCutOff - display.gutters.offsetWidth; var tooWide = x2 - x1 > screenw; if (tooWide) x2 = y1 + screen; if (x1 < 10) result.scrollLeft = 0; else if (x1 < screenleft) result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)); else if (x2 > screenw + screenleft - 3) result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw; return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getPosition(rect) {\r\n return {\r\n \"top\" : window.scrollY + Math.round(rect.top),\r\n \"right\" : Math.round(rect.left + rect.width),\r\n \"bottom\" : window.scrollY + Math.round(rect.top + rect.height),\r\n \"left\" ...
[ "0.6595175", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6591926", "0.6491554", "0.6491554", "0.6491554", "0.6491554", "0.6491554", "0.6491554", "0.64889026", "0.6469144", "0.64613694", ...
0.62290764
41
Store a relative adjustment to the scroll position in the current operation (to be applied when the operation finishes).
function addToScrollPos(cm, left, top) { if (left != null || top != null) resolveScrollToPos(cm); if (left != null) cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left; if (top != null) cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "saveScrollPosition({ commit }, value) {\n commit('setScrollPosition', value)\n }", "function addToScrollPos(cm, left, top) {\n\t if (left != null || top != null) resolveScrollToPos(cm);\n\t if (left != null)\n\t cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scro...
[ "0.64328575", "0.63141257", "0.63141257", "0.63141257", "0.6269965", "0.62446713", "0.62446713", "0.62446713", "0.62446713", "0.62446713", "0.62446713", "0.62446713", "0.6215512", "0.6166497", "0.6105691", "0.6085317", "0.60724515", "0.60724515", "0.60724515", "0.6065848", "0...
0.6203502
13
Make sure that at the end of the operation the current cursor is shown.
function ensureCursorVisible(cm) { resolveScrollToPos(cm); var cur = cm.getCursor(), from = cur, to = cur; if (!cm.options.lineWrapping) { from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur; to = Pos(cur.line, cur.ch + 1); } cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function EmptyCursor () {}", "_showCursor() {\n if (!this._coreService.isCursorInitialized) {\n this._coreService.isCursorInitialized = true;\n this.refresh(this.buffer.y, this.buffer.y);\n }\n }", "checkForCursorVisibility() {\n this.showCaret();\n }", "endDr...
[ "0.71896726", "0.70795476", "0.70729387", "0.667339", "0.6522092", "0.6430521", "0.6329043", "0.62736994", "0.622839", "0.6224282", "0.6167339", "0.61538243", "0.61226624", "0.6042317", "0.6026656", "0.6026656", "0.6026656", "0.6026656", "0.60073024", "0.60073024", "0.6007302...
0.0
-1
When an operation has its scrollToPos property set, and another scroll action is applied before the end of the operation, this 'simulates' scrolling that position into view in a cheap way, so that the effect of intermediate scroll commands is not ignored.
function resolveScrollToPos(cm) { var range = cm.curOp.scrollToPos; if (range) { cm.curOp.scrollToPos = null; var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); var sPos = calculateScrollPos(cm, Math.min(from.left, to.left), Math.min(from.top, to.top) - range.margin, Math.max(from.right, to.right), Math.max(from.bottom, to.bottom) + range.margin); cm.scrollTo(sPos.scrollLeft, sPos.scrollTop); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "scrollBehavior (to, from, savedPosition) {\n if (savedPosition) {\n console.log(\"后退\")\n return savedPosition\n } else {\n console.log(\"前进\")\n return {x: 0, y: 0}\n }\n }", "scrollBehavior (to, from, savedPosition) {\n return new Promi...
[ "0.64442915", "0.6427002", "0.6380351", "0.6374905", "0.6312776", "0.6310328", "0.6300054", "0.6284562", "0.62773097", "0.6261587", "0.62396413", "0.6234451", "0.62333477", "0.6228509", "0.61966586", "0.6196645", "0.619365", "0.6175256", "0.6175256", "0.6175256", "0.6175256",...
0.6013901
59
API UTILITIES Indent the given line. The how parameter can be "smart", "add"/null, "subtract", or "prev". When aggressive is false (typically set to true for forced singleline indents), empty lines are not indented, and places where the mode returns Pass are left alone.
function indentLine(cm, n, how, aggressive) { var doc = cm.doc, state; if (how == null) how = "add"; if (how == "smart") { // Fall back to "prev" when the mode doesn't have an indentation // method. if (!doc.mode.indent) how = "prev"; else state = getStateBefore(cm, n); } var tabSize = cm.options.tabSize; var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); if (line.stateAfter) line.stateAfter = null; var curSpaceString = line.text.match(/^\s*/)[0], indentation; if (!aggressive && !/\S/.test(line.text)) { indentation = 0; how = "not"; } else if (how == "smart") { indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); if (indentation == Pass || indentation > 150) { if (!aggressive) return; how = "prev"; } } if (how == "prev") { if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize); else indentation = 0; } else if (how == "add") { indentation = curSpace + cm.options.indentUnit; } else if (how == "subtract") { indentation = curSpace - cm.options.indentUnit; } else if (typeof how == "number") { indentation = curSpace + how; } indentation = Math.max(0, indentation); var indentString = "", pos = 0; if (cm.options.indentWithTabs) for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} if (pos < indentation) indentString += spaceStr(indentation - pos); if (indentString != curSpaceString) { replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); } else { // Ensure that, if the cursor was in the whitespace at the start // of the line, it is moved to the end of that space. for (var i = 0; i < doc.sel.ranges.length; i++) { var range = doc.sel.ranges[i]; if (range.head.line == n && range.head.ch < curSpaceString.length) { var pos = Pos(n, curSpaceString.length); replaceOneSelection(doc, i, new Range(pos, pos)); break; } } } line.stateAfter = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function indentLine(cm, n, how, aggressive) {\n var doc = cm.doc,\n state;\n\n if (how == null) {\n how = \"add\";\n }\n\n if (how == \"smart\") {\n // Fall back to \"prev\" when the mode doesn't have an indentation\n // method.\n if (!doc.mode.indent) {\n how = \"prev...
[ "0.7768561", "0.7728095", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.7727709", "0.77135223", "0.770854", "...
0.76691395
26
Utility for applying a change to a line by handle or number, returning the number and optionally registering the line as changed.
function changeLine(doc, handle, changeType, op) { var no = handle, line = handle; if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle)); else no = lineNo(handle); if (no == null) return null; if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType); return line; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function changeLine(doc, handle, changeType, op) {\n\t var no = handle, line = handle;\n\t if (typeof handle == \"number\") line = getLine(doc, clipLine(doc, handle));\n\t else no = lineNo(handle);\n\t if (no == null) return null;\n\t if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType)...
[ "0.73564804", "0.73564804", "0.73564804", "0.73487985", "0.73487985", "0.73487985", "0.73487985", "0.73487985", "0.73487985", "0.73487985", "0.73463076", "0.73418856", "0.73418856", "0.73418856", "0.73418856", "0.73418856", "0.73418856", "0.73418856", "0.73418856", "0.73418856"...
0.73161405
28
Helper for deleting text near the selection(s), used to implement backspace, delete, and similar functionality.
function deleteNearSelection(cm, compute) { var ranges = cm.doc.sel.ranges, kill = []; // Build up a set of ranges to kill first, merging overlapping // ranges. for (var i = 0; i < ranges.length; i++) { var toKill = compute(ranges[i]); while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { var replaced = kill.pop(); if (cmp(replaced.from, toKill.from) < 0) { toKill.from = replaced.from; break; } } kill.push(toKill); } // Next, remove those actual ranges. runInOp(cm, function() { for (var i = kill.length - 1; i >= 0; i--) replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); ensureCursorVisible(cm); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function removeTextSelections() {\n if (document.selection) document.selection.empty();\n else if (window.getSelection) window.getSelection().removeAllRanges();\n}", "function removeTextSelection() {\n\n if (window.getSelection) {\n\n window.getSelection().removeAllRanges();\n\n } else if (document.se...
[ "0.7446558", "0.7391313", "0.709859", "0.7049477", "0.6970693", "0.69385004", "0.6919004", "0.68240345", "0.6810697", "0.68011355", "0.6721915", "0.6719395", "0.6719395", "0.6719395", "0.6719395", "0.6719395", "0.6719395", "0.6719395", "0.6719395", "0.6719395", "0.6687007", ...
0.5778332
75
Used for horizontal relative motion. Dir is 1 or 1 (left or right), unit can be "char", "column" (like char, but doesn't cross line boundaries), "word" (across next word), or "group" (to the start of next group of word or nonwordnonwhitespace chars). The visually param controls whether, in righttoleft text, direction 1 means to move towards the next index in the string, or towards the character to the right of the current position. The resulting position will have a hitSide=true property if it reached the end of the document.
function findPosH(doc, pos, dir, unit, visually) { var line = pos.line, ch = pos.ch, origDir = dir; var lineObj = getLine(doc, line); var possible = true; function findNextLine() { var l = line + dir; if (l < doc.first || l >= doc.first + doc.size) return (possible = false); line = l; return lineObj = getLine(doc, l); } function moveOnce(boundToLine) { var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true); if (next == null) { if (!boundToLine && findNextLine()) { if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj); else ch = dir < 0 ? lineObj.text.length : 0; } else return (possible = false); } else ch = next; return true; } if (unit == "char") moveOnce(); else if (unit == "column") moveOnce(true); else if (unit == "word" || unit == "group") { var sawType = null, group = unit == "group"; var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); for (var first = true;; first = false) { if (dir < 0 && !moveOnce(!first)) break; var cur = lineObj.text.charAt(ch) || "\n"; var type = isWordChar(cur, helper) ? "w" : group && cur == "\n" ? "n" : !group || /\s/.test(cur) ? null : "p"; if (group && !first && !type) type = "s"; if (sawType && sawType != type) { if (dir < 0) {dir = 1; moveOnce();} break; } if (type) sawType = type; if (dir > 0 && !moveOnce(!first)) break; } } var result = skipAtomic(doc, Pos(line, ch), origDir, true); if (!possible) result.hitSide = true; return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findPosH(doc, pos, dir, unit, visually) {\n var line = pos.line, ch = pos.ch, origDir = dir;\n var lineObj = getLine(doc, line);\n var possible = true;\n function findNextLine() {\n var l = line + dir;\n if (l < doc.first || l >= doc.first + doc.size) return (possible = false);\n ...
[ "0.6126276", "0.6126276", "0.6126276", "0.6126276", "0.6126276", "0.6126276", "0.61237055", "0.6094494", "0.60565525", "0.6052763", "0.60278237", "0.60217786", "0.60217786", "0.60217786", "0.59992564", "0.59992564", "0.59971863", "0.5986649", "0.5975884", "0.5975884", "0.5975...
0.6130347
0
For relative vertical movement. Dir may be 1 or 1. Unit can be "page" or "line". The resulting position will have a hitSide=true property if it reached the end of the document.
function findPosV(cm, pos, dir, unit) { var doc = cm.doc, x = pos.left, y; if (unit == "page") { var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display)); } else if (unit == "line") { y = dir > 0 ? pos.bottom + 3 : pos.top - 3; } for (;;) { var target = coordsChar(cm, x, y); if (!target.outside) break; if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; } y += dir * 5; } return target; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findPosV(cm, pos, dir, unit) {\n var doc = cm.doc, x = pos.left, y;\n if (unit == \"page\") {\n var pageSize = Math.min(cm.display.wrapper.clientHeight, win(cm).innerHeight || doc(cm).documentElement.clientHeight);\n var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);\n ...
[ "0.6914866", "0.6914866", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6870082", "0.6821437", "0.68100506", "0.68100506", "0.68100506", ...
0.67162454
39
Find the word at the given position (as returned by coordsChar).
function findWordAt(cm, pos) { var doc = cm.doc, line = getLine(doc, pos.line).text; var start = pos.ch, end = pos.ch; if (line) { var helper = cm.getHelper(pos, "wordChars"); if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; var startChar = line.charAt(start); var check = isWordChar(startChar, helper) ? function(ch) { return isWordChar(ch, helper); } : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; while (start > 0 && check(line.charAt(start - 1))) --start; while (end < line.length && check(line.charAt(end))) ++end; } return new Range(Pos(pos.line, start), Pos(pos.line, end)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "wordAt(pos) {\n let { text, from, length } = this.doc.lineAt(pos);\n let cat = this.charCategorizer(pos);\n let start = pos - from, end = pos - from;\n while (start > 0) {\n let prev = findClusterBreak(text, start, false);\n if (cat(text.slice(prev, start)) != expo...
[ "0.7163546", "0.7014515", "0.6941773", "0.6941773", "0.6912063", "0.6561325", "0.6549947", "0.65433896", "0.6538319", "0.6538319", "0.6503659", "0.6503659", "0.6503659", "0.6503659", "0.64854646", "0.64854646", "0.64854646", "0.64854646", "0.64854646", "0.64854646", "0.648546...
0.69475126
2
Create a marker, wire it up to the right lines, and
function markText(doc, from, to, options, type) { // Shared markers (across linked documents) are handled separately // (markTextShared will call out to this again, once per // document). if (options && options.shared) return markTextShared(doc, from, to, options, type); // Ensure we are in an operation. if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type); var marker = new TextMarker(doc, type), diff = cmp(from, to); if (options) copyObj(options, marker, false); // Don't connect empty markers unless clearWhenEmpty is false if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) return marker; if (marker.replacedWith) { // Showing up as a widget implies collapsed (widget replaces text) marker.collapsed = true; marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget"); if (!options.handleMouseEvents) marker.widgetNode.ignoreEvents = true; if (options.insertLeft) marker.widgetNode.insertLeft = true; } if (marker.collapsed) { if (conflictingCollapsedRange(doc, from.line, from, to, marker) || from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) throw new Error("Inserting collapsed marker partially overlapping an existing one"); sawCollapsedSpans = true; } if (marker.addToHistory) addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); var curLine = from.line, cm = doc.cm, updateMaxLine; doc.iter(curLine, to.line + 1, function(line) { if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) updateMaxLine = true; if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0); addMarkedSpan(line, new MarkedSpan(marker, curLine == from.line ? from.ch : null, curLine == to.line ? to.ch : null)); ++curLine; }); // lineIsHidden depends on the presence of the spans, so needs a second pass if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) { if (lineIsHidden(doc, line)) updateLineHeight(line, 0); }); if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); }); if (marker.readOnly) { sawReadOnlySpans = true; if (doc.history.done.length || doc.history.undone.length) doc.clearHistory(); } if (marker.collapsed) { marker.id = ++nextMarkerId; marker.atomic = true; } if (cm) { // Sync editor state if (updateMaxLine) cm.curOp.updateMaxLine = true; if (marker.collapsed) regChange(cm, from.line, to.line + 1); else if (marker.className || marker.title || marker.startStyle || marker.endStyle) for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text"); if (marker.atomic) reCheckSelection(cm.doc); signalLater(cm, "markerAdded", cm, marker); } return marker; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function drawMarker(lineWidth, lineHeightPerc, offset, markerLength, horiz) {\n var start, end;\n var height = em.height();\n if (horiz) {\n start = { x: offset, y: height};\n end = { x: offset, y: height - (markerLength*lineHeightPerc)};\n...
[ "0.706403", "0.6922555", "0.6829682", "0.67605793", "0.6707079", "0.66788775", "0.6592433", "0.6586964", "0.6577096", "0.6535049", "0.645897", "0.6454014", "0.6452927", "0.644539", "0.6428748", "0.64162165", "0.63716215", "0.6367775", "0.63661844", "0.6362076", "0.6345258", ...
0.0
-1
Search an array of spans for a span matching the given marker.
function getMarkedSpanFor(spans, marker) { if (spans) for (var i = 0; i < spans.length; ++i) { var span = spans[i]; if (span.marker == marker) return span; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getMarkedSpanFor(spans, marker) {\n if (spans) for (var i = 0; i < spans.length; ++i) {\n var span = spans[i];\n if (span.marker == marker) return span;\n }\n }", "function getMarkedSpanFor(spans, marker) {\n if (spans) for (var i = 0; i < spans.length; ++i) {\n var span = spans...
[ "0.7195285", "0.7195285", "0.7195285", "0.7195285", "0.7195285", "0.7195285", "0.7195285", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "0.7182503", "...
0.7141147
25
Remove a span from an array, returning undefined if no spans are left (we don't store arrays for lines without spans).
function removeMarkedSpan(spans, span) { for (var r, i = 0; i < spans.length; ++i) if (spans[i] != span) (r || (r = [])).push(spans[i]); return r; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function removeMarkedSpan(spans, span) {\n\t\t for (var r, i = 0; i < spans.length; ++i)\n\t\t if (spans[i] != span) (r || (r = [])).push(spans[i]);\n\t\t return r;\n\t\t }", "function removeMarkedSpan(spans, span) {\n for (var r, i = 0; i < spans.length; ++i)\n if (spans[i] != span) (r || (r...
[ "0.74040127", "0.7397826", "0.7397826", "0.7397826", "0.7397826", "0.7397826", "0.7397826", "0.7397826", "0.73853534", "0.73853534", "0.73853534", "0.73151606", "0.7314696", "0.729348", "0.729348", "0.729348", "0.729348", "0.729348", "0.729348", "0.729348", "0.729348", "0.7...
0.7361935
11
Add a span to a line.
function addMarkedSpan(line, span) { line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; span.marker.attachLine(line); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addMarkedSpan(line, span) {\n line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n span.marker.attachLine(line);\n }", "function addMarkedSpan(line, span) {\n line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n span.marker.attachLin...
[ "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "0.7689838", "...
0.7690222
0
Used for the algorithm that adjusts markers for a change in the document. These functions cut an array of spans at a given character position, returning an array of remaining chunks (or undefined if nothing remains).
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getOldSpans(doc, change) {\n\t\t var found = change[\"spans_\" + doc.id];\n\t\t if (!found) return null;\n\t\t for (var i = 0, nw = []; i < change.text.length; ++i)\n\t\t nw.push(removeClearedSpans(found[i]));\n\t\t return nw;\n\t\t }", "function removeClearedSpans(spans) {\n if (!s...
[ "0.54903406", "0.5486872", "0.5478584", "0.54643", "0.54643", "0.54643", "0.5456619", "0.5456619", "0.5456619", "0.5456619", "0.5456619", "0.5456619", "0.5456619", "0.54424185", "0.5440055", "0.54209167", "0.54209167", "0.54209167", "0.54209167", "0.54209167", "0.54209167", ...
0.0
-1
Given a change object, compute the new set of marker spans that cover the line in which the change took place. Removes spans entirely within the change, reconnects spans belonging to the same marker that appear on both sides of the change, and cuts off spans partially within the change. Returns an array of span arrays with one element for each line in (after) the change.
function stretchSpansOverChange(doc, change) { 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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getOldSpans(doc, change) {\n var found = change[\"spans_\" + doc.id];\n if (!found) return null;\n for (var i = 0, nw = []; i < change.text.length; ++i)\n nw.push(removeClearedSpans(found[i]));\n return nw;\n }", "function getOldSpans(doc, change) {\n var found = change[\"spans_\" +...
[ "0.6804883", "0.6804883", "0.6804883", "0.6804883", "0.6804883", "0.6804883", "0.6804883", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "0.6798043", "...
0.6699681
55
Remove spans that are empty and don't have a clearWhenEmpty option of false.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function clearEmptySpans(spans) {\n\t\t for (var i = 0; i < spans.length; ++i) {\n\t\t var span = spans[i];\n\t\t if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)\n\t\t spans.splice(i--, 1);\n\t\t }\n\t\t if (!spans.length) return null;\n\t\t retur...
[ "0.75844175", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.7581774", "0.75752497", "0.75752497", "0.75752497",...
0.7570095
26
Used for un/redoing changes from the history. Combines the result of computing the existing spans with the set of spans that existed in the history (so that deleting around a span and then undoing brings back the span).
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getOldSpans(doc, change) {\n\t\t var found = change[\"spans_\" + doc.id];\n\t\t if (!found) return null;\n\t\t for (var i = 0, nw = []; i < change.text.length; ++i)\n\t\t nw.push(removeClearedSpans(found[i]));\n\t\t return nw;\n\t\t }", "function getOldSpans(doc, change) {\n\t\t var...
[ "0.6204524", "0.6183464", "0.61482537", "0.61482537", "0.61482537", "0.6074324", "0.6074324", "0.6074324", "0.6074324", "0.6074324", "0.6074324", "0.6074324", "0.60686743", "0.6056806", "0.60326916", "0.60326916", "0.60326916", "0.60326916", "0.60326916", "0.60326916", "0.603...
0.0
-1
Used to 'clip' out readOnly ranges when making a change.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function clipRange(range, min, max) {\n return range\n .filter(segment => segment[1] >= min && segment[0] <= max)\n .map(segment => [Math.max(segment[0], min), Math.min(segment[1], max)]);\n}", "function removeReadOnlyRanges(doc, from, to) {\n\t\t var markers = null;\n\t\t doc.iter(from.line, to.lin...
[ "0.6547939", "0.6417559", "0.64017415", "0.6282898", "0.6282898", "0.6282898", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "0.61574495", "...
0.614353
30
Connect or disconnect spans from a line.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addMarkedSpan(line, span) {\n line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n span.marker.attachLine(line);\n }", "function addMarkedSpan(line, span) {\n line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];\n span.marker.attachLin...
[ "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "0.5948326", "...
0.0
-1
Helpers used when computing which overlapping collapsed span counts as the larger one.
function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compareCollapsedMarkers(a, b) {\n var lenDiff = a.lines.length - b.lines.length;\n\n if (lenDiff != 0) {\n return lenDiff;\n }\n\n var aPos = a.find(),\n bPos = b.find();\n var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);\n\n if (fromCmp) {\n retur...
[ "0.6158327", "0.5892967", "0.5875146", "0.5875146", "0.5875146", "0.58443254", "0.58443254", "0.58443254", "0.58443254", "0.58443254", "0.58443254", "0.58443254", "0.58198965", "0.58142793", "0.5766265", "0.5766265", "0.5766265", "0.5766265", "0.5766265", "0.5766265", "0.5766...
0.0
-1
Returns a number indicating which of two overlapping collapsed spans is larger (and thus includes the other). Falls back to comparing ids when the spans cover exactly the same range.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compareCollapsedMarkers(a, b) {\n var lenDiff = a.lines.length - b.lines.length;\n\n if (lenDiff != 0) {\n return lenDiff;\n }\n\n var aPos = a.find(),\n bPos = b.find();\n var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);\n\n if (fromCmp) {\n retur...
[ "0.7142431", "0.6935029", "0.6935029", "0.6935029", "0.6935029", "0.6935029", "0.6935029", "0.6935029", "0.69114345", "0.69114345", "0.69114345", "0.69104326", "0.6881797", "0.6881797", "0.6881797", "0.6881797", "0.6881797", "0.6881797", "0.6881797", "0.6881797", "0.6881797",...
0.68953055
12
Find out whether a line ends or starts in a collapsed span. If so, return the marker for that span.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function collapsedSpanAtSide(line, start) {\n\t\t var sps = sawCollapsedSpans && line.markedSpans, found;\n\t\t if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {\n\t\t sp = sps[i];\n\t\t if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&\n\t\t (!found || compare...
[ "0.7781851", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77472335", "0.77291834", "0.77291834",...
0.7656547
30
Test whether there exists a collapsed span that partially overlaps (covers the start or end, but not both) of a new span. Such overlap is not allowed.
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 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) || fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight))) return true; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function conflictingCollapsedRange(doc, lineNo, from, to, marker) {\n var line = getLine(doc, lineNo);\n var sps = sawCollapsedSpans && line.markedSpans;\n if (sps) for (var i = 0; i < sps.length; ++i) {\n var sp = sps[i];\n if (!sp.marker.collapsed) continue;\n var found = sp.marker.find(0...
[ "0.6864755", "0.6864755", "0.6864755", "0.6864755", "0.6864755", "0.6864755", "0.685666", "0.68406713", "0.68406713", "0.68406713", "0.68406713", "0.68406713", "0.68406713", "0.68406713", "0.68406713", "0.68317807", "0.68317807", "0.682337", "0.6810524", "0.6806325", "0.67974...
0.6841365
7
A visual line is a line as drawn on the screen. Folding, for example, can cause multiple logical lines to appear on the same visual line. This finds the start of the visual line that the given line is part of (usually that is the line itself).
function visualLine(line) { var merged; while (merged = collapsedSpanAtStart(line)) line = merged.find(-1, true).line; return line; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function visualLine(line) {\n\t\t var merged;\n\t\t while (merged = collapsedSpanAtStart(line))\n\t\t line = merged.find(-1, true).line;\n\t\t return line;\n\t\t }", "function visualLine(line) {\n\t\t var merged;\n\t\t while (merged = collapsedSpanAtStart(line))\n\t\t { line = merged.fi...
[ "0.8249701", "0.8240324", "0.82310987", "0.82310987", "0.82310987", "0.8211684", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", "0.81788206", ...
0.8173319
30
Returns an array of logical lines that continue the visual line started by the argument, or undefined if there are no such lines.
function visualLineContinued(line) { var merged, lines; while (merged = collapsedSpanAtEnd(line)) { line = merged.find(1, true).line; (lines || (lines = [])).push(line); } return lines; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function visualLineContinued(line) {\n var merged, lines;\n\n while (merged = collapsedSpanAtEnd(line)) {\n line = merged.find(1, true).line;\n (lines || (lines = [])).push(line);\n }\n\n return lines;\n } // Get the line number of the start of the visual line that the", "function visualLi...
[ "0.6935793", "0.66301644", "0.6583158", "0.6580819", "0.6580819", "0.6580819", "0.6580819", "0.6580819", "0.6580819", "0.6580819", "0.6579544", "0.6579544", "0.6579544", "0.65731263", "0.65731263", "0.65731263", "0.65731263", "0.65731263", "0.65731263", "0.65731263", "0.65731...
0.6561416
30
Get the line number of the start of the visual line that the given line number is part of.
function visualLineNo(doc, lineN) { var line = getLine(doc, lineN), vis = visualLine(line); if (line == vis) return lineN; return lineNo(vis); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function visualLineNo(doc, lineN) {\n var line = getLine(doc, lineN),\n vis = visualLine(line);\n\n if (line == vis) {\n return lineN;\n }\n\n return lineNo(vis);\n } // Get the line number of the start of the next visual line after", "function visualLineNo(doc, lineN) {\n\t\t var lin...
[ "0.79719335", "0.7488473", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74559027", "0.74231917",...
0.7371761
32
Get the line number of the start of the next visual line after the given line.
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; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function visualLineNo(doc, lineN) {\n var line = getLine(doc, lineN),\n vis = visualLine(line);\n\n if (line == vis) {\n return lineN;\n }\n\n return lineNo(vis);\n } // Get the line number of the start of the next visual line after", "function nextLine() {\n\t\t_this._compConst('LINE', ...
[ "0.79053533", "0.73212373", "0.70655745", "0.7048663", "0.70483404", "0.704656", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", "0.70358926", ...
0.69670045
88
Compute whether a line is hidden. Lines count as hidden when they are part of a visual line that starts with another line, or when they are entirely covered by collapsed, nonwidget span.
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; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lineIsHidden(doc, line) {\n var sps = sawCollapsedSpans && line.markedSpans;\n if (sps) for (var sp, i = 0; i < sps.length; ++i) {\n sp = sps[i];\n if (!sp.marker.collapsed) continue;\n if (sp.from == null) return true;\n if (sp.marker.widgetNode) continue;\n if (sp.from == ...
[ "0.850484", "0.850484", "0.850484", "0.850484", "0.850484", "0.850484", "0.850484", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.85011065", "0.8501106...
0.84692115
25
Change the content (text, markers) of a line. Automatically invalidates cached information and tries to reestimate the line's height.
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); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateLine(line, text, markedSpans, estimateHeight) {\n line.text = text;\n\n if (line.stateAfter) {\n line.stateAfter = null;\n }\n\n if (line.styles) {\n line.styles = null;\n }\n\n if (line.order != null) {\n line.order = null;\n }\n\n detachMarkedSpans(line);\n ...
[ "0.749166", "0.7394869", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.7390498", "0.73896736", "0.73896736", ...
0.7328578
32
Detach a line from the document tree and its markers.
function cleanUpLine(line) { line.parent = null; detachMarkedSpans(line); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function detachMarkedSpans(line) {\n var spans = line.markedSpans\n if (!spans) { return }\n for (var i = 0; i < spans.length; ++i)\n { spans[i].marker.detachLine(line) }\n line.markedSpans = null\n}", "function detachMarkedSpans(line) {\n var spans = line.markedSpans\n if (!spans) { return }\n for (va...
[ "0.74187696", "0.74187696", "0.7408218", "0.7399272", "0.7399272", "0.7396458", "0.73904276", "0.7388251", "0.7385665", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", "0.7383718", ...
0.72677463
58
Run the given mode's parser over a line, calling f for each token.
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; 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), lineClasses); } if (cm.options.addModeClass) { var mName = CodeMirror.innerMode(mode, state).mode.name; if (mName) style = "m-" + (style ? mName + " " + style : mName); } if (!flattenSpans || curStyle != style) { if (curStart < stream.start) f(stream.start, curStyle); curStart = stream.start; 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; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function runMode(cm, text, mode, state, f) {\n var flattenSpans = cm.options.flattenSpans;\n var curText = \"\", curStyle = null;\n var stream = new StringStream(text, cm.options.tabSize);\n if (text == \"\" && mode.blankLine) mode.blankLine(state);\n while (!stream.eol()) {\n var style = mode....
[ "0.6841281", "0.68301743", "0.68301743", "0.6777866", "0.6612709", "0.64859253", "0.64420784", "0.6336574", "0.6336574", "0.629284", "0.62294865", "0.62294865", "0.62294865", "0.62294865", "0.62294865", "0.62294865", "0.62294865", "0.62294865", "0.62294865", "0.62294865", "0....
0.6292484
10
Compute a style array (an array starting with a mode generation for invalidation followed by pairs of end positions and style strings), which is used to highlight the tokens on the line.
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}; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getStyleArrayForBlock(block) {\n var text = block.text,\n inlineStyleRanges = block.inlineStyleRanges;\n\n var inlineStyles = {\n BOLD: new Array(text.length),\n ITALIC: new Array(text.length),\n UNDERLINE: new Array(text.length),\n STRIKETHROUGH: new Array(text.length),\n CODE: new ...
[ "0.65245426", "0.64413244", "0.613997", "0.5957505", "0.5834924", "0.57767236", "0.5775472", "0.5775472", "0.5693552", "0.5693552", "0.5693552", "0.5693552", "0.5693552", "0.5693552", "0.5693552", "0.5663078", "0.5663078", "0.56104505", "0.56104505", "0.56104505", "0.56104505...
0.56565195
17