code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function fixShortcut(name) {
if(isMac) {
name = name.replace("Ctrl", "Cmd");
} else {
name = name.replace("Cmd", "Ctrl");
}
return name;
}
|
Fix shortcut. Mac use Command, others use Ctrl.
|
fixShortcut
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function getState(cm, pos) {
pos = pos || cm.getCursor("start");
var stat = cm.getTokenAt(pos);
if(!stat.type) return {};
var types = stat.type.split(" ");
var ret = {},
data, text;
for(var i = 0; i < types.length; i++) {
data = types[i];
if(data === "strong") {
ret.bold = true;
} else if(data === "variable-2") {
text = cm.getLine(pos.line);
if(/^\s*\d+\.\s/.test(text)) {
ret["ordered-list"] = true;
} else {
ret["unordered-list"] = true;
}
} else if(data === "atom") {
ret.quote = true;
} else if(data === "em") {
ret.italic = true;
} else if(data === "quote") {
ret.quote = true;
} else if(data === "strikethrough") {
ret.strikethrough = true;
} else if(data === "comment") {
ret.code = true;
} else if(data === "link") {
ret.link = true;
} else if(data === "tag") {
ret.image = true;
} else if(data.match(/^header(\-[1-6])?$/)) {
ret[data.replace("header", "heading")] = true;
}
}
return ret;
}
|
The state of CodeMirror at the given position.
|
getState
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function toggleFullScreen(editor) {
// Set fullscreen
var cm = editor.codemirror;
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
// Prevent scrolling on body during fullscreen active
if(cm.getOption("fullScreen")) {
saved_overflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
} else {
document.body.style.overflow = saved_overflow;
}
// Update toolbar class
var wrap = cm.getWrapperElement();
if(!/fullscreen/.test(wrap.previousSibling.className)) {
wrap.previousSibling.className += " fullscreen";
} else {
wrap.previousSibling.className = wrap.previousSibling.className.replace(/\s*fullscreen\b/, "");
}
// Update toolbar button
var toolbarButton = editor.toolbarElements.fullscreen;
if(!/active/.test(toolbarButton.className)) {
toolbarButton.className += " active";
} else {
toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, "");
}
// Hide side by side if needed
var sidebyside = cm.getWrapperElement().nextSibling;
if(/editor-preview-active-side/.test(sidebyside.className))
toggleSideBySide(editor);
}
|
Toggle full screen of the editor.
|
toggleFullScreen
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function toggleHeadingSmaller(editor) {
var cm = editor.codemirror;
_toggleHeading(cm, "smaller");
}
|
Action for toggling heading size: normal -> h1 -> h2 -> h3 -> h4 -> h5 -> h6 -> normal
|
toggleHeadingSmaller
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function toggleHeadingBigger(editor) {
var cm = editor.codemirror;
_toggleHeading(cm, "bigger");
}
|
Action for toggling heading size: normal -> h6 -> h5 -> h4 -> h3 -> h2 -> h1 -> normal
|
toggleHeadingBigger
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function cleanBlock(editor) {
var cm = editor.codemirror;
_cleanBlock(cm);
}
|
Action for clean block (remove headline, list, blockquote code, markers)
|
cleanBlock
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function isLocalStorageAvailable() {
if(typeof localStorage === "object") {
try {
localStorage.setItem("smde_localStorage", 1);
localStorage.removeItem("smde_localStorage");
} catch(e) {
return false;
}
} else {
return false;
}
return true;
}
|
Render editor to the given element.
|
isLocalStorageAvailable
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.debug.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
|
MIT
|
function Buffer (arg, encodingOrOffset, length) {
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
return new Buffer(arg, encodingOrOffset, length)
}
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new Error(
'If encoding is specified then the first argument must be a string'
)
}
return allocUnsafe(this, arg)
}
return from(this, arg, encodingOrOffset, length)
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
Buffer
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function from (that, value, encodingOrOffset, length) {
if (typeof value === 'number') {
throw new TypeError('"value" argument must not be a number')
}
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
return fromArrayBuffer(that, value, encodingOrOffset, length)
}
if (typeof value === 'string') {
return fromString(that, value, encodingOrOffset)
}
return fromObject(that, value)
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
from
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function assertSize (size) {
if (typeof size !== 'number') {
throw new TypeError('"size" argument must be a number')
}
}
|
Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
if value is a number.
Buffer.from(str[, encoding])
Buffer.from(array)
Buffer.from(buffer)
Buffer.from(arrayBuffer[, byteOffset[, length]])
|
assertSize
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function alloc (that, size, fill, encoding) {
assertSize(size)
if (size <= 0) {
return createBuffer(that, size)
}
if (fill !== undefined) {
// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpretted as a start offset.
return typeof encoding === 'string'
? createBuffer(that, size).fill(fill, encoding)
: createBuffer(that, size).fill(fill)
}
return createBuffer(that, size)
}
|
Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
if value is a number.
Buffer.from(str[, encoding])
Buffer.from(array)
Buffer.from(buffer)
Buffer.from(arrayBuffer[, byteOffset[, length]])
|
alloc
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function allocUnsafe (that, size) {
assertSize(size)
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
if (!Buffer.TYPED_ARRAY_SUPPORT) {
for (var i = 0; i < size; i++) {
that[i] = 0
}
}
return that
}
|
Creates a new filled Buffer instance.
alloc(size[, fill[, encoding]])
|
allocUnsafe
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function fromString (that, string, encoding) {
if (typeof encoding !== 'string' || encoding === '') {
encoding = 'utf8'
}
if (!Buffer.isEncoding(encoding)) {
throw new TypeError('"encoding" must be a valid string encoding')
}
var length = byteLength(string, encoding) | 0
that = createBuffer(that, length)
that.write(string, encoding)
return that
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromString
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function fromArrayLike (that, array) {
var length = checked(array.length) | 0
that = createBuffer(that, length)
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromArrayLike
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function fromArrayBuffer (that, array, byteOffset, length) {
array.byteLength // this throws if `array` is not a valid ArrayBuffer
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('\'offset\' is out of bounds')
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('\'length\' is out of bounds')
}
if (length === undefined) {
array = new Uint8Array(array, byteOffset)
} else {
array = new Uint8Array(array, byteOffset, length)
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
that = array
that.__proto__ = Buffer.prototype
} else {
// Fallback: Return an object instance of the Buffer class
that = fromArrayLike(that, array)
}
return that
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromArrayBuffer
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function fromObject (that, obj) {
if (Buffer.isBuffer(obj)) {
var len = checked(obj.length) | 0
that = createBuffer(that, len)
if (that.length === 0) {
return that
}
obj.copy(that, 0, 0, len)
return that
}
if (obj) {
if ((typeof ArrayBuffer !== 'undefined' &&
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {
return createBuffer(that, 0)
}
return fromArrayLike(that, obj)
}
if (obj.type === 'Buffer' && isArray(obj.data)) {
return fromArrayLike(that, obj.data)
}
}
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromObject
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function checked (length) {
// Note: cannot use `length < kMaxLength` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= kMaxLength()) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + kMaxLength().toString(16) + ' bytes')
}
return length | 0
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checked
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function SlowBuffer (length) {
if (+length != length) { // eslint-disable-line eqeqeq
length = 0
}
return Buffer.alloc(+length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
SlowBuffer
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function byteLength (string, encoding) {
if (Buffer.isBuffer(string)) {
return string.length
}
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
return string.byteLength
}
if (typeof string !== 'string') {
string = '' + string
}
var len = string.length
if (len === 0) return 0
// Use a for loop to avoid recursion
var loweredCase = false
for (;;) {
switch (encoding) {
case 'ascii':
case 'binary':
// Deprecated
case 'raw':
case 'raws':
return len
case 'utf8':
case 'utf-8':
case undefined:
return utf8ToBytes(string).length
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return len * 2
case 'hex':
return len >>> 1
case 'base64':
return base64ToBytes(string).length
default:
if (loweredCase) return utf8ToBytes(string).length // assume utf8
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
byteLength
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function slowToString (encoding, start, end) {
var loweredCase = false
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if (start === undefined || start < 0) {
start = 0
}
// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if (start > this.length) {
return ''
}
if (end === undefined || end > this.length) {
end = this.length
}
if (end <= 0) {
return ''
}
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
end >>>= 0
start >>>= 0
if (end <= start) {
return ''
}
if (!encoding) encoding = 'utf8'
while (true) {
switch (encoding) {
case 'hex':
return hexSlice(this, start, end)
case 'utf8':
case 'utf-8':
return utf8Slice(this, start, end)
case 'ascii':
return asciiSlice(this, start, end)
case 'binary':
return binarySlice(this, start, end)
case 'base64':
return base64Slice(this, start, end)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return utf16leSlice(this, start, end)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = (encoding + '').toLowerCase()
loweredCase = true
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
slowToString
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function swap (b, n, m) {
var i = b[n]
b[n] = b[m]
b[m] = i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
swap
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function arrayIndexOf (arr, val, byteOffset, encoding) {
var indexSize = 1
var arrLength = arr.length
var valLength = val.length
if (encoding !== undefined) {
encoding = String(encoding).toLowerCase()
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
encoding === 'utf16le' || encoding === 'utf-16le') {
if (arr.length < 2 || val.length < 2) {
return -1
}
indexSize = 2
arrLength /= 2
valLength /= 2
byteOffset /= 2
}
}
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
var foundIndex = -1
for (var i = 0; byteOffset + i < arrLength; i++) {
if (read(arr, byteOffset + i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i
if (i - foundIndex + 1 === valLength) return (byteOffset + foundIndex) * indexSize
} else {
if (foundIndex !== -1) i -= i - foundIndex
foundIndex = -1
}
}
return -1
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
arrayIndexOf
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
read
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function hexWrite (buf, string, offset, length) {
offset = Number(offset) || 0
var remaining = buf.length - offset
if (!length) {
length = remaining
} else {
length = Number(length)
if (length > remaining) {
length = remaining
}
}
// must be an even number of digits
var strLen = string.length
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
if (length > strLen / 2) {
length = strLen / 2
}
for (var i = 0; i < length; i++) {
var parsed = parseInt(string.substr(i * 2, 2), 16)
if (isNaN(parsed)) return i
buf[offset + i] = parsed
}
return i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
hexWrite
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8Write
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function asciiWrite (buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiWrite
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function binaryWrite (buf, string, offset, length) {
return asciiWrite(buf, string, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
binaryWrite
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function base64Write (buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64Write
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function ucs2Write (buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ucs2Write
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function base64Slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf)
} else {
return base64.fromByteArray(buf.slice(start, end))
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64Slice
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function utf8Slice (buf, start, end) {
end = Math.min(buf.length, end)
var res = []
var i = start
while (i < end) {
var firstByte = buf[i]
var codePoint = null
var bytesPerSequence = (firstByte > 0xEF) ? 4
: (firstByte > 0xDF) ? 3
: (firstByte > 0xBF) ? 2
: 1
if (i + bytesPerSequence <= end) {
var secondByte, thirdByte, fourthByte, tempCodePoint
switch (bytesPerSequence) {
case 1:
if (firstByte < 0x80) {
codePoint = firstByte
}
break
case 2:
secondByte = buf[i + 1]
if ((secondByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
if (tempCodePoint > 0x7F) {
codePoint = tempCodePoint
}
}
break
case 3:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
codePoint = tempCodePoint
}
}
break
case 4:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
fourthByte = buf[i + 3]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
codePoint = tempCodePoint
}
}
}
}
if (codePoint === null) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if (codePoint > 0xFFFF) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
codePoint = 0xDC00 | codePoint & 0x3FF
}
res.push(codePoint)
i += bytesPerSequence
}
return decodeCodePointsArray(res)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8Slice
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function decodeCodePointsArray (codePoints) {
var len = codePoints.length
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
}
// Decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while (i < len) {
res += String.fromCharCode.apply(
String,
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
)
}
return res
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
decodeCodePointsArray
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function asciiSlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; i++) {
ret += String.fromCharCode(buf[i] & 0x7F)
}
return ret
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiSlice
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function binarySlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; i++) {
ret += String.fromCharCode(buf[i])
}
return ret
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
binarySlice
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function hexSlice (buf, start, end) {
var len = buf.length
if (!start || start < 0) start = 0
if (!end || end < 0 || end > len) end = len
var out = ''
for (var i = start; i < end; i++) {
out += toHex(buf[i])
}
return out
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
hexSlice
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function utf16leSlice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
}
return res
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf16leSlice
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function checkOffset (offset, ext, length) {
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkOffset
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function checkInt (buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
if (offset + ext > buf.length) throw new RangeError('Index out of range')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkInt
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function objectWriteUInt16 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
(littleEndian ? i : 1 - i) * 8
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
objectWriteUInt16
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function objectWriteUInt32 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffffffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
objectWriteUInt32
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new RangeError('Index out of range')
if (offset < 0) throw new RangeError('Index out of range')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkIEEE754
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
}
ieee754.write(buf, value, offset, littleEndian, 23, 4)
return offset + 4
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
writeFloat
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
}
ieee754.write(buf, value, offset, littleEndian, 52, 8)
return offset + 8
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
writeDouble
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
// Node converts strings with length < 2 to ''
if (str.length < 2) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while (str.length % 4 !== 0) {
str = str + '='
}
return str
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64clean
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function stringtrim (str) {
if (str.trim) return str.trim()
return str.replace(/^\s+|\s+$/g, '')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
stringtrim
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function toHex (n) {
if (n < 16) return '0' + n.toString(16)
return n.toString(16)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
toHex
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
var length = string.length
var leadSurrogate = null
var bytes = []
for (var i = 0; i < length; i++) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8ToBytes
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function asciiToBytes (str) {
var byteArray = []
for (var i = 0; i < str.length; i++) {
// Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i) & 0xFF)
}
return byteArray
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiToBytes
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function utf16leToBytes (str, units) {
var c, hi, lo
var byteArray = []
for (var i = 0; i < str.length; i++) {
if ((units -= 2) < 0) break
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf16leToBytes
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function base64ToBytes (str) {
return base64.toByteArray(base64clean(str))
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64ToBytes
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function blitBuffer (src, dst, offset, length) {
for (var i = 0; i < length; i++) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
blitBuffer
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
isnan
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function CodeMirrorSpellChecker(options) {
// Initialize
options = options || {};
// Verify
if(typeof options.codeMirrorInstance !== "function" || typeof options.codeMirrorInstance.defineMode !== "function") {
console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`");
return;
}
// Because some browsers don't support this functionality yet
if(!String.prototype.includes) {
String.prototype.includes = function() {
"use strict";
return String.prototype.indexOf.apply(this, arguments) !== -1;
};
}
// Define the new mode
options.codeMirrorInstance.defineMode("spell-checker", function(config) {
// Load AFF/DIC data
if(!CodeMirrorSpellChecker.aff_loading) {
CodeMirrorSpellChecker.aff_loading = true;
var xhr_aff = new XMLHttpRequest();
xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true);
xhr_aff.onload = function() {
if(xhr_aff.readyState === 4 && xhr_aff.status === 200) {
CodeMirrorSpellChecker.aff_data = xhr_aff.responseText;
CodeMirrorSpellChecker.num_loaded++;
if(CodeMirrorSpellChecker.num_loaded == 2) {
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
platform: "any"
});
}
}
};
xhr_aff.send(null);
}
if(!CodeMirrorSpellChecker.dic_loading) {
CodeMirrorSpellChecker.dic_loading = true;
var xhr_dic = new XMLHttpRequest();
xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true);
xhr_dic.onload = function() {
if(xhr_dic.readyState === 4 && xhr_dic.status === 200) {
CodeMirrorSpellChecker.dic_data = xhr_dic.responseText;
CodeMirrorSpellChecker.num_loaded++;
if(CodeMirrorSpellChecker.num_loaded == 2) {
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
platform: "any"
});
}
}
};
xhr_dic.send(null);
}
// Define what separates a word
var rx_word = "!\"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ";
// Create the overlay and such
var overlay = {
token: function(stream) {
var ch = stream.peek();
var word = "";
if(rx_word.includes(ch)) {
stream.next();
return null;
}
while((ch = stream.peek()) != null && !rx_word.includes(ch)) {
word += ch;
stream.next();
}
if(CodeMirrorSpellChecker.typo && !CodeMirrorSpellChecker.typo.check(word))
return "spell-error"; // CSS class: cm-spell-error
return null;
}
};
var mode = options.codeMirrorInstance.getMode(
config, config.backdrop || "text/plain"
);
return options.codeMirrorInstance.overlayMode(mode, overlay, true);
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
CodeMirrorSpellChecker
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setFullscreen(cm) {
var wrap = cm.getWrapperElement();
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
width: wrap.style.width, height: wrap.style.height};
wrap.style.width = "";
wrap.style.height = "auto";
wrap.className += " CodeMirror-fullscreen";
document.documentElement.style.overflow = "hidden";
cm.refresh();
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setFullscreen
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setNormal(cm) {
var wrap = cm.getWrapperElement();
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
document.documentElement.style.overflow = "";
var info = cm.state.fullScreenRestore;
wrap.style.width = info.width; wrap.style.height = info.height;
window.scrollTo(info.scrollLeft, info.scrollTop);
cm.refresh();
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setNormal
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clearPlaceholder(cm) {
if (cm.state.placeholder) {
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
cm.state.placeholder = null;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clearPlaceholder
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setPlaceholder(cm) {
clearPlaceholder(cm);
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.className = "CodeMirror-placeholder";
var placeHolder = cm.getOption("placeholder")
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
elt.appendChild(placeHolder)
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setPlaceholder
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function onBlur(cm) {
if (isEmpty(cm)) setPlaceholder(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onBlur
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function onChange(cm) {
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
if (empty) setPlaceholder(cm);
else clearPlaceholder(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
isEmpty
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function onCursorActivity(cm) {
cm.operation(function() { update(cm); });
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onCursorActivity
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function onChange(cm) {
if (cm.state.markedSelection.length)
cm.operation(function() { clear(cm); });
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
onChange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function coverRange(cm, from, to, addAt) {
if (cmp(from, to) == 0) return;
var array = cm.state.markedSelection;
var cls = cm.state.markedSelectionStyle;
for (var line = from.line;;) {
var start = line == from.line ? from : Pos(line, 0);
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
var end = atEnd ? to : Pos(endLine, 0);
var mark = cm.markText(start, end, {className: cls});
if (addAt == null) array.push(mark);
else array.splice(addAt++, 0, mark);
if (atEnd) break;
line = endLine;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
coverRange
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function clear(cm) {
var array = cm.state.markedSelection;
for (var i = 0; i < array.length; ++i) array[i].clear();
array.length = 0;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
clear
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function reset(cm) {
clear(cm);
var ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++)
coverRange(cm, ranges[i].from(), ranges[i].to());
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
reset
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function update(cm) {
if (!cm.somethingSelected()) return clear(cm);
if (cm.listSelections().length > 1) return reset(cm);
var from = cm.getCursor("start"), to = cm.getCursor("end");
var array = cm.state.markedSelection;
if (!array.length) return coverRange(cm, from, to);
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
return reset(cm);
while (cmp(from, coverStart.from) > 0) {
array.shift().clear();
coverStart = array[0].find();
}
if (cmp(from, coverStart.from) < 0) {
if (coverStart.to.line - from.line < CHUNK_SIZE) {
array.shift().clear();
coverRange(cm, from, coverStart.to, 0);
} else {
coverRange(cm, from, coverStart.from, 0);
}
}
while (cmp(to, coverEnd.to) < 0) {
array.pop().clear();
coverEnd = array[array.length - 1].find();
}
if (cmp(to, coverEnd.to) > 0) {
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
array.pop().clear();
coverRange(cm, coverEnd.from, to);
} else {
coverRange(cm, coverEnd.to, to);
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
update
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
this.options = options = options ? copyObj(options) : {};
// Determine effective options based on given values and defaults.
copyObj(defaults, options, false);
setGuttersForLineNumbers(options);
var doc = options.value;
if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
this.doc = doc;
var input = new CodeMirror.inputStyles[options.inputStyle](this);
var display = this.display = new Display(place, doc, input);
display.wrapper.CodeMirror = this;
updateGutters(this);
themeChanged(this);
if (options.lineWrapping)
this.display.wrapper.className += " CodeMirror-wrap";
if (options.autofocus && !mobile) display.input.focus();
initScrollbars(this);
this.state = {
keyMaps: [], // stores maps added by addKeyMap
overlays: [], // highlighting overlays, as added by addOverlay
modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
overwrite: false,
delayingBlurEvent: false,
focused: false,
suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
selectingText: false,
draggingText: false,
highlight: new Delayed(), // stores highlight worker timeout
keySeq: null, // Unfinished key sequence
specialChars: null
};
var cm = this;
// Override magic textarea content restore that IE sometimes does
// on our hidden textarea on reload
if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
registerEventHandlers(this);
ensureGlobalHandlers();
startOperation(this);
this.curOp.forceUpdate = true;
attachDoc(this, doc);
if ((options.autofocus && !mobile) || cm.hasFocus())
setTimeout(bind(onFocus, this), 20);
else
onBlur(this);
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
optionHandlers[opt](this, options[opt], Init);
maybeUpdateLineNumberWidth(this);
if (options.finishInit) options.finishInit(this);
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
endOperation(this);
// Suppress optimizelegibility in Webkit, since it breaks text
// measuring on line wrapping boundaries.
if (webkit && options.lineWrapping &&
getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
display.lineDiv.style.textRendering = "auto";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
CodeMirror
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function Display(place, doc, input) {
var d = this;
this.input = input;
// Covers bottom-right square when both scrollbars are present.
d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
d.scrollbarFiller.setAttribute("cm-not-content", "true");
// Covers bottom of gutter when coverGutterNextToScrollbar is on
// and h scrollbar is present.
d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
d.gutterFiller.setAttribute("cm-not-content", "true");
// Will contain the actual code, positioned to cover the viewport.
d.lineDiv = elt("div", null, "CodeMirror-code");
// Elements are added to these to represent selection and cursors.
d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
d.cursorDiv = elt("div", null, "CodeMirror-cursors");
// A visibility: hidden element used to find the size of things.
d.measure = elt("div", null, "CodeMirror-measure");
// When lines outside of the viewport are measured, they are drawn in this.
d.lineMeasure = elt("div", null, "CodeMirror-measure");
// Wraps everything that needs to exist inside the vertically-padded coordinate system
d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
null, "position: relative; outline: none");
// Moved around its parent to cover visible view.
d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
// Set to the height of the document, allowing scrolling.
d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
d.sizerWidth = null;
// Behavior of elts with overflow: auto and padding is
// inconsistent across browsers. This is used to ensure the
// scrollable area is big enough.
d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
// Will contain the gutters, if any.
d.gutters = elt("div", null, "CodeMirror-gutters");
d.lineGutter = null;
// Actual scrollable element.
d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
d.scroller.setAttribute("tabIndex", "-1");
// The element in which the editor lives.
d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
// Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
if (place) {
if (place.appendChild) place.appendChild(d.wrapper);
else place(d.wrapper);
}
// Current rendered range (may be bigger than the view window).
d.viewFrom = d.viewTo = doc.first;
d.reportedViewFrom = d.reportedViewTo = doc.first;
// Information about the rendered lines.
d.view = [];
d.renderedView = null;
// Holds info about a single rendered line when it was rendered
// for measurement, while not in view.
d.externalMeasured = null;
// Empty space (in pixels) above the view
d.viewOffset = 0;
d.lastWrapHeight = d.lastWrapWidth = 0;
d.updateLineNumbers = null;
d.nativeBarWidth = d.barHeight = d.barWidth = 0;
d.scrollbarsClipped = false;
// Used to only resize the line number gutter when necessary (when
// the amount of lines crosses a boundary that makes its width change)
d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
// Set to true when a non-horizontal-scrolling line widget is
// added. As an optimization, line widget aligning is skipped when
// this is false.
d.alignWidgets = false;
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
// Tracks the maximum line length so that the horizontal scrollbar
// can be kept static when scrolling.
d.maxLine = null;
d.maxLineLength = 0;
d.maxLineChanged = false;
// Used for measuring wheel scrolling granularity
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
// True when shift is held down.
d.shift = false;
// Used to track whether anything happened since the context menu
// was opened.
d.selForContextMenu = null;
d.activeTouch = null;
input.init(d);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
Display
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function loadMode(cm) {
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
resetModeState(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
loadMode
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function resetModeState(cm) {
cm.doc.iter(function(line) {
if (line.stateAfter) line.stateAfter = null;
if (line.styles) line.styles = null;
});
cm.doc.frontier = cm.doc.first;
startWorker(cm, 100);
cm.state.modeGen++;
if (cm.curOp) regChange(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
resetModeState
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function wrappingChanged(cm) {
if (cm.options.lineWrapping) {
addClass(cm.display.wrapper, "CodeMirror-wrap");
cm.display.sizer.style.minWidth = "";
cm.display.sizerWidth = null;
} else {
rmClass(cm.display.wrapper, "CodeMirror-wrap");
findMaxLine(cm);
}
estimateLineHeights(cm);
regChange(cm);
clearCaches(cm);
setTimeout(function(){updateScrollbars(cm);}, 100);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
wrappingChanged
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function estimateHeight(cm) {
var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
return function(line) {
if (lineIsHidden(cm.doc, line)) return 0;
var widgetsHeight = 0;
if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
}
if (wrapping)
return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
else
return widgetsHeight + th;
};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
estimateHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function estimateLineHeights(cm) {
var doc = cm.doc, est = estimateHeight(cm);
doc.iter(function(line) {
var estHeight = est(line);
if (estHeight != line.height) updateLineHeight(line, estHeight);
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
estimateLineHeights
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function themeChanged(cm) {
cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
clearCaches(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
themeChanged
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function guttersChanged(cm) {
updateGutters(cm);
regChange(cm);
setTimeout(function(){alignHorizontally(cm);}, 20);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
guttersChanged
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateGutters(cm) {
var gutters = cm.display.gutters, specs = cm.options.gutters;
removeChildren(gutters);
for (var i = 0; i < specs.length; ++i) {
var gutterClass = specs[i];
var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
if (gutterClass == "CodeMirror-linenumbers") {
cm.display.lineGutter = gElt;
gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
}
}
gutters.style.display = i ? "" : "none";
updateGutterSpace(cm);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateGutters
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateGutterSpace(cm) {
var width = cm.display.gutters.offsetWidth;
cm.display.sizer.style.marginLeft = width + "px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateGutterSpace
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function lineLength(line) {
if (line.height == 0) return 0;
var len = line.text.length, merged, cur = line;
while (merged = collapsedSpanAtStart(cur)) {
var found = merged.find(0, true);
cur = found.from.line;
len += found.from.ch - found.to.ch;
}
cur = line;
while (merged = collapsedSpanAtEnd(cur)) {
var found = merged.find(0, true);
len -= cur.text.length - found.from.ch;
cur = found.to.line;
len += cur.text.length - found.to.ch;
}
return len;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
lineLength
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function findMaxLine(cm) {
var d = cm.display, doc = cm.doc;
d.maxLine = getLine(doc, doc.first);
d.maxLineLength = lineLength(d.maxLine);
d.maxLineChanged = true;
doc.iter(function(line) {
var len = lineLength(line);
if (len > d.maxLineLength) {
d.maxLineLength = len;
d.maxLine = line;
}
});
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
findMaxLine
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setGuttersForLineNumbers(options) {
var found = indexOf(options.gutters, "CodeMirror-linenumbers");
if (found == -1 && options.lineNumbers) {
options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
} else if (found > -1 && !options.lineNumbers) {
options.gutters = options.gutters.slice(0);
options.gutters.splice(found, 1);
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setGuttersForLineNumbers
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function measureForScrollbars(cm) {
var d = cm.display, gutterW = d.gutters.offsetWidth;
var docH = Math.round(cm.doc.height + paddingVert(cm.display));
return {
clientHeight: d.scroller.clientHeight,
viewHeight: d.wrapper.clientHeight,
scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
viewWidth: d.wrapper.clientWidth,
barLeft: cm.options.fixedGutter ? gutterW : 0,
docHeight: docH,
scrollHeight: docH + scrollGap(cm) + d.barHeight,
nativeBarWidth: d.nativeBarWidth,
gutterWidth: gutterW
};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
measureForScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function NativeScrollbars(place, scroll, cm) {
this.cm = cm;
var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
place(vert); place(horiz);
on(vert, "scroll", function() {
if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
});
on(horiz, "scroll", function() {
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
});
this.checkedZeroWidth = false;
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
NativeScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function maybeDisable() {
// To find out whether the scrollbar is still visible, we
// check whether the element under the pixel in the bottom
// left corner of the scrollbar box is the scrollbar box
// itself (when the bar is still visible) or its filler child
// (when the bar is hidden). If it is still visible, we keep
// it enabled, if it's hidden, we disable pointer events.
var box = bar.getBoundingClientRect();
var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
if (elt != bar) bar.style.pointerEvents = "none";
else delay.set(1000, maybeDisable);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeDisable
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function initScrollbars(cm) {
if (cm.display.scrollbars) {
cm.display.scrollbars.clear();
if (cm.display.scrollbars.addClass)
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
}
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
// Prevent clicks in the scrollbars from killing focus
on(node, "mousedown", function() {
if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
});
node.setAttribute("cm-not-content", "true");
}, function(pos, axis) {
if (axis == "horizontal") setScrollLeft(cm, pos);
else setScrollTop(cm, pos);
}, cm);
if (cm.display.scrollbars.addClass)
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
initScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateScrollbars(cm, measure) {
if (!measure) measure = measureForScrollbars(cm);
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
updateScrollbarsInner(cm, measure);
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
updateHeightsInViewport(cm);
updateScrollbarsInner(cm, measureForScrollbars(cm));
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateScrollbarsInner(cm, measure) {
var d = cm.display;
var sizes = d.scrollbars.update(measure);
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
if (sizes.right && sizes.bottom) {
d.scrollbarFiller.style.display = "block";
d.scrollbarFiller.style.height = sizes.bottom + "px";
d.scrollbarFiller.style.width = sizes.right + "px";
} else d.scrollbarFiller.style.display = "";
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
d.gutterFiller.style.display = "block";
d.gutterFiller.style.height = sizes.bottom + "px";
d.gutterFiller.style.width = measure.gutterWidth + "px";
} else d.gutterFiller.style.display = "";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateScrollbarsInner
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function visibleLines(display, doc, viewport) {
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
top = Math.floor(top - paddingTop(display));
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
// forces those lines into the viewport (if possible).
if (viewport && viewport.ensure) {
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
if (ensureFrom < from) {
from = ensureFrom;
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
to = ensureTo;
}
}
return {from: from, to: Math.max(to, from + 1)};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
visibleLines
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function alignHorizontally(cm) {
var display = cm.display, view = display.view;
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
var gutterW = display.gutters.offsetWidth, left = comp + "px";
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
if (cm.options.fixedGutter && view[i].gutter)
view[i].gutter.style.left = left;
var align = view[i].alignable;
if (align) for (var j = 0; j < align.length; j++)
align[j].style.left = left;
}
if (cm.options.fixedGutter)
display.gutters.style.left = (comp + gutterW) + "px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
alignHorizontally
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function maybeUpdateLineNumberWidth(cm) {
if (!cm.options.lineNumbers) return false;
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
if (last.length != display.lineNumChars) {
var test = display.measure.appendChild(elt("div", [elt("div", last)],
"CodeMirror-linenumber CodeMirror-gutter-elt"));
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
display.lineGutter.style.width = "";
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
display.lineNumWidth = display.lineNumInnerWidth + padding;
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
display.lineGutter.style.width = display.lineNumWidth + "px";
updateGutterSpace(cm);
return true;
}
return false;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeUpdateLineNumberWidth
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function lineNumberFor(options, i) {
return String(options.lineNumberFormatter(i + options.firstLineNumber));
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
lineNumberFor
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function compensateForHScroll(display) {
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
compensateForHScroll
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function DisplayUpdate(cm, viewport, force) {
var display = cm.display;
this.viewport = viewport;
// Store some values that we'll need later (but don't want to force a relayout for)
this.visible = visibleLines(display, cm.doc, viewport);
this.editorIsHidden = !display.wrapper.offsetWidth;
this.wrapperHeight = display.wrapper.clientHeight;
this.wrapperWidth = display.wrapper.clientWidth;
this.oldDisplayWidth = displayWidth(cm);
this.force = force;
this.dims = getDimensions(cm);
this.events = [];
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
DisplayUpdate
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function maybeClipScrollbars(cm) {
var display = cm.display;
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
display.heightForcer.style.height = scrollGap(cm) + "px";
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
display.scrollbarsClipped = true;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
maybeClipScrollbars
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateDisplayIfNeeded(cm, update) {
var display = cm.display, doc = cm.doc;
if (update.editorIsHidden) {
resetView(cm);
return false;
}
// Bail out if the visible area is already rendered and nothing changed.
if (!update.force &&
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
display.renderedView == display.view && countDirtyView(cm) == 0)
return false;
if (maybeUpdateLineNumberWidth(cm)) {
resetView(cm);
update.dims = getDimensions(cm);
}
// Compute a suitable new viewport (from & to)
var end = doc.first + doc.size;
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
if (sawCollapsedSpans) {
from = visualLineNo(cm.doc, from);
to = visualLineEndNo(cm.doc, to);
}
var different = from != display.viewFrom || to != display.viewTo ||
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
adjustView(cm, from, to);
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
// Position the mover div to align with the current scroll position
cm.display.mover.style.top = display.viewOffset + "px";
var toUpdate = countDirtyView(cm);
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
return false;
// For big changes, we hide the enclosing element during the
// update, since that speeds up the operations on most browsers.
var focused = activeElt();
if (toUpdate > 4) display.lineDiv.style.display = "none";
patchDisplay(cm, display.updateLineNumbers, update.dims);
if (toUpdate > 4) display.lineDiv.style.display = "";
display.renderedView = display.view;
// There might have been a widget with a focused element that got
// hidden or updated, if so re-focus it.
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
// Prevent selection and cursors from interfering with the scroll
// width and height.
removeChildren(display.cursorDiv);
removeChildren(display.selectionDiv);
display.gutters.style.height = display.sizer.style.minHeight = 0;
if (different) {
display.lastWrapHeight = update.wrapperHeight;
display.lastWrapWidth = update.wrapperWidth;
startWorker(cm, 400);
}
display.updateLineNumbers = null;
return true;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateDisplayIfNeeded
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function postUpdateDisplay(cm, update) {
var viewport = update.viewport;
for (var first = true;; first = false) {
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
// Clip forced viewport to actual scrollable area.
if (viewport && viewport.top != null)
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
// Updated line heights might result in the drawn area not
// actually covering the viewport. Keep looping until it does.
update.visible = visibleLines(cm.display, cm.doc, viewport);
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
break;
}
if (!updateDisplayIfNeeded(cm, update)) break;
updateHeightsInViewport(cm);
var barMeasure = measureForScrollbars(cm);
updateSelection(cm);
updateScrollbars(cm, barMeasure);
setDocumentHeight(cm, barMeasure);
}
update.signal(cm, "update", cm);
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
postUpdateDisplay
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateDisplaySimple(cm, viewport) {
var update = new DisplayUpdate(cm, viewport);
if (updateDisplayIfNeeded(cm, update)) {
updateHeightsInViewport(cm);
postUpdateDisplay(cm, update);
var barMeasure = measureForScrollbars(cm);
updateSelection(cm);
updateScrollbars(cm, barMeasure);
setDocumentHeight(cm, barMeasure);
update.finish();
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateDisplaySimple
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function setDocumentHeight(cm, measure) {
cm.display.sizer.style.minHeight = measure.docHeight + "px";
cm.display.heightForcer.style.top = measure.docHeight + "px";
cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
setDocumentHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateHeightsInViewport(cm) {
var display = cm.display;
var prevBottom = display.lineDiv.offsetTop;
for (var i = 0; i < display.view.length; i++) {
var cur = display.view[i], height;
if (cur.hidden) continue;
if (ie && ie_version < 8) {
var bot = cur.node.offsetTop + cur.node.offsetHeight;
height = bot - prevBottom;
prevBottom = bot;
} else {
var box = cur.node.getBoundingClientRect();
height = box.bottom - box.top;
}
var diff = cur.line.height - height;
if (height < 2) height = textHeight(display);
if (diff > .001 || diff < -.001) {
updateLineHeight(cur.line, height);
updateWidgetHeight(cur.line);
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
updateWidgetHeight(cur.rest[j]);
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateHeightsInViewport
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function updateWidgetHeight(line) {
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight;
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
updateWidgetHeight
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
function getDimensions(cm) {
var d = cm.display, left = {}, width = {};
var gutterLeft = d.gutters.clientLeft;
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
width[cm.options.gutters[i]] = n.clientWidth;
}
return {fixedPos: compensateForHScroll(d),
gutterTotalWidth: d.gutters.offsetWidth,
gutterLeft: left,
gutterWidth: width,
wrapperWidth: d.wrapper.clientWidth};
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
getDimensions
|
javascript
|
sparksuite/simplemde-markdown-editor
|
debug/simplemde.js
|
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.