diff --git a/media/editors/codemirror/addon/comment/comment.js b/media/editors/codemirror/addon/comment/comment.js index d7f569cc00534..2dd114d332dc9 100644 --- a/media/editors/codemirror/addon/comment/comment.js +++ b/media/editors/codemirror/addon/comment/comment.js @@ -109,7 +109,7 @@ CodeMirror.defineExtension("uncomment", function(from, to, options) { if (!options) options = noOptions; var self = this, mode = self.getModeAt(from); - var end = Math.min(to.line, self.lastLine()), start = Math.min(from.line, end); + var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end); // Try finding line comments var lineString = options.lineComment || mode.lineComment, lines = []; diff --git a/media/editors/codemirror/addon/dialog/dialog.js b/media/editors/codemirror/addon/dialog/dialog.js index 35a6103c2d786..5a88d99e64f8d 100644 --- a/media/editors/codemirror/addon/dialog/dialog.js +++ b/media/editors/codemirror/addon/dialog/dialog.js @@ -56,7 +56,10 @@ var inp = dialog.getElementsByTagName("input")[0], button; if (inp) { - if (options.value) inp.value = options.value; + if (options.value) { + inp.value = options.value; + inp.select(); + } if (options.onInput) CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); diff --git a/media/editors/codemirror/addon/edit/closebrackets.js b/media/editors/codemirror/addon/edit/closebrackets.js index 1a04f3664ef07..32eca014c55a2 100644 --- a/media/editors/codemirror/addon/edit/closebrackets.js +++ b/media/editors/codemirror/addon/edit/closebrackets.js @@ -78,24 +78,25 @@ for (var i = 0; i < ranges.length; i++) { var range = ranges[i], cur = range.head, curType; var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1)); - if (!range.empty()) + if (!range.empty()) { curType = "surround"; - else if (left == right && next == right) { + } else if (left == right && next == right) { if (cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == left + left + left) curType = "skipThree"; else curType = "skip"; } else if (left == right && cur.ch > 1 && cm.getRange(Pos(cur.line, cur.ch - 2), cur) == left + left && - (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) + (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) { curType = "addFour"; - else if (left == '"' || left == "'") { + } else if (left == '"' || left == "'") { if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, left)) curType = "both"; else return CodeMirror.Pass; - } else if (cm.getLine(cur.line).length == cur.ch || closingBrackets.indexOf(next) >= 0 || SPACE_CHAR_REGEX.test(next)) + } else if (cm.getLine(cur.line).length == cur.ch || closingBrackets.indexOf(next) >= 0 || SPACE_CHAR_REGEX.test(next)) { curType = "both"; - else + } else { return CodeMirror.Pass; + } if (!type) type = curType; else if (type != curType) return CodeMirror.Pass; } diff --git a/media/editors/codemirror/addon/edit/continuelist.js b/media/editors/codemirror/addon/edit/continuelist.js index 8cee761aeeae9..9ad0a98fa097e 100644 --- a/media/editors/codemirror/addon/edit/continuelist.js +++ b/media/editors/codemirror/addon/edit/continuelist.js @@ -11,7 +11,8 @@ })(function(CodeMirror) { "use strict"; - var listRE = /^(\s*)([*+-]|(\d+)\.)(\s+)/, + var listRE = /^(\s*)([> ]+|[*+-]|(\d+)\.)(\s+)/, + emptyListRE = /^(\s*)([> ]+|[*+-]|(\d+)\.)(\s*)$/, unorderedBullets = "*+-"; CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) { @@ -19,18 +20,30 @@ var ranges = cm.listSelections(), replacements = []; for (var i = 0; i < ranges.length; i++) { var pos = ranges[i].head, match; - var inList = cm.getStateAfter(pos.line).list !== false; + var eolState = cm.getStateAfter(pos.line); + var inList = eolState.list !== false; + var inQuote = eolState.quote !== false; - if (!ranges[i].empty() || !inList || !(match = cm.getLine(pos.line).match(listRE))) { + if (!ranges[i].empty() || (!inList && !inQuote) || !(match = cm.getLine(pos.line).match(listRE))) { cm.execCommand("newlineAndIndent"); return; } - var indent = match[1], after = match[4]; - var bullet = unorderedBullets.indexOf(match[2]) >= 0 - ? match[2] - : (parseInt(match[3], 10) + 1) + "."; + if (cm.getLine(pos.line).match(emptyListRE)) { + cm.replaceRange("", { + line: pos.line, ch: 0 + }, { + line: pos.line, ch: pos.ch + 1 + }); + replacements[i] = "\n"; - replacements[i] = "\n" + indent + bullet + after; + } else { + var indent = match[1], after = match[4]; + var bullet = unorderedBullets.indexOf(match[2]) >= 0 || match[2].indexOf(">") >= 0 + ? match[2] + : (parseInt(match[3], 10) + 1) + "."; + + replacements[i] = "\n" + indent + bullet + after; + } } cm.replaceSelections(replacements); diff --git a/media/editors/codemirror/addon/hint/sql-hint.js b/media/editors/codemirror/addon/hint/sql-hint.js index 20653b5318f28..c2b511fa2fc5e 100644 --- a/media/editors/codemirror/addon/hint/sql-hint.js +++ b/media/editors/codemirror/addon/hint/sql-hint.js @@ -12,6 +12,7 @@ "use strict"; var tables; + var defaultTable; var keywords; var CONS = { QUERY_DIV: ";", @@ -43,18 +44,55 @@ } } - function columnCompletion(result, editor) { + function nameCompletion(result, editor) { var cur = editor.getCursor(); var token = editor.getTokenAt(cur); + var useBacktick = (token.string.charAt(0) == "`"); var string = token.string.substr(1); - var prevCur = Pos(cur.line, token.start); - var table = editor.getTokenAt(prevCur).string; - if (!tables.hasOwnProperty(table)) - table = findTableByAlias(table, editor); - var columns = tables[table]; - if (!columns) return; - - addMatches(result, string, columns, function(w) {return "." + w;}); + var prevToken = editor.getTokenAt(Pos(cur.line, token.start)); + if (token.string.charAt(0) == "." || prevToken.string == "."){ + //Suggest colunm names + if (prevToken.string == ".") { + var prevToken = editor.getTokenAt(Pos(cur.line, token.start - 1)); + } + var table = prevToken.string; + //Check if backtick is used in table name. If yes, use it for columns too. + var useBacktickTable = false; + if (table.match(/`/g)) { + useBacktickTable = true; + table = table.replace(/`/g, ""); + } + //Check if table is available. If not, find table by Alias + if (!tables.hasOwnProperty(table)) + table = findTableByAlias(table, editor); + var columns = tables[table]; + if (!columns) return; + + if (useBacktick) { + addMatches(result, string, columns, function(w) {return "`" + w + "`";}); + } + else if(useBacktickTable) { + addMatches(result, string, columns, function(w) {return ".`" + w + "`";}); + } + else { + addMatches(result, string, columns, function(w) {return "." + w;}); + } + } + else { + //Suggest table names or colums in defaultTable + while (token.start && string.charAt(0) == ".") { + token = editor.getTokenAt(Pos(cur.line, token.start - 1)); + string = token.string + string; + } + if (useBacktick) { + addMatches(result, string, tables, function(w) {return "`" + w + "`";}); + addMatches(result, string, defaultTable, function(w) {return "`" + w + "`";}); + } + else { + addMatches(result, string, tables, function(w) {return w;}); + addMatches(result, string, defaultTable, function(w) {return w;}); + } + } } function eachWord(lineText, f) { @@ -128,11 +166,14 @@ CodeMirror.registerHelper("hint", "sql", function(editor, options) { tables = (options && options.tables) || {}; + var defaultTableName = options && options.defaultTable; + defaultTable = (defaultTableName && tables[defaultTableName] || []); keywords = keywords || getKeywords(editor); + var cur = editor.getCursor(); var result = []; var token = editor.getTokenAt(cur), start, end, search; - if (token.string.match(/^[.\w@]\w*$/)) { + if (token.string.match(/^[.`\w@]\w*$/)) { search = token.string; start = token.start; end = token.end; @@ -140,18 +181,11 @@ start = end = cur.ch; search = ""; } - if (search.charAt(0) == ".") { - columnCompletion(result, editor); - if (!result.length) { - while (start && search.charAt(0) == ".") { - token = editor.getTokenAt(Pos(cur.line, token.start - 1)); - start = token.start; - search = token.string + search; - } - addMatches(result, search, tables, function(w) {return w;}); - } + if (search.charAt(0) == "." || search.charAt(0) == "`") { + nameCompletion(result, editor); } else { addMatches(result, search, tables, function(w) {return w;}); + addMatches(result, search, defaultTable, function(w) {return w;}); addMatches(result, search, keywords, function(w) {return w.toUpperCase();}); } diff --git a/media/editors/codemirror/addon/lint/lint.js b/media/editors/codemirror/addon/lint/lint.js index a87e70c09eae2..66f187e22eac8 100644 --- a/media/editors/codemirror/addon/lint/lint.js +++ b/media/editors/codemirror/addon/lint/lint.js @@ -118,10 +118,11 @@ function startLinting(cm) { var state = cm.state.lint, options = state.options; + var passOptions = options.options || options; // Support deprecated passing of `options` property in options if (options.async) - options.getAnnotations(cm, updateLinting, options); + options.getAnnotations(cm.getValue(), updateLinting, passOptions, cm); else - updateLinting(cm, options.getAnnotations(cm.getValue(), options.options)); + updateLinting(cm, options.getAnnotations(cm.getValue(), passOptions, cm)); } function updateLinting(cm, annotationsNotSorted) { @@ -170,20 +171,14 @@ showTooltipFor(e, annotationTooltip(ann), target); } - // When the mouseover fires, the cursor might not actually be over - // the character itself yet. These pairs of x,y offsets are used to - // probe a few nearby points when no suitable marked range is found. - var nearby = [0, 0, 0, 5, 0, -5, 5, 0, -5, 0]; - function onMouseOver(cm, e) { - if (!/\bCodeMirror-lint-mark-/.test((e.target || e.srcElement).className)) return; - for (var i = 0; i < nearby.length; i += 2) { - var spans = cm.findMarksAt(cm.coordsChar({left: e.clientX + nearby[i], - top: e.clientY + nearby[i + 1]}, "client")); - for (var j = 0; j < spans.length; ++j) { - var span = spans[j], ann = span.__annotation; - if (ann) return popupSpanTooltip(ann, e); - } + var target = e.target || e.srcElement; + if (!/\bCodeMirror-lint-mark-/.test(target.className)) return; + var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2; + var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client")); + for (var i = 0; i < spans.length; ++i) { + var ann = spans[i].__annotation; + if (ann) return popupSpanTooltip(ann, e); } } diff --git a/media/editors/codemirror/addon/mode/simple.js b/media/editors/codemirror/addon/mode/simple.js new file mode 100644 index 0000000000000..a4a86b9a657d2 --- /dev/null +++ b/media/editors/codemirror/addon/mode/simple.js @@ -0,0 +1,210 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineSimpleMode = function(name, states, props) { + CodeMirror.defineMode(name, function(config) { + return CodeMirror.simpleMode(config, states, props); + }); + }; + + CodeMirror.simpleMode = function(config, states) { + ensureState(states, "start"); + var states_ = {}, meta = states.meta || {}, hasIndentation = false; + for (var state in states) if (state != meta && states.hasOwnProperty(state)) { + var list = states_[state] = [], orig = states[state]; + for (var i = 0; i < orig.length; i++) { + var data = orig[i]; + list.push(new Rule(data, states)); + if (data.indent || data.dedent) hasIndentation = true; + } + } + var mode = { + startState: function() { + return {state: "start", pending: null, + local: null, localState: null, + indent: hasIndentation ? [] : null}; + }, + copyState: function(state) { + var s = {state: state.state, pending: state.pending, + local: state.local, localState: null, + indent: state.indent && state.indent.slice(0)}; + if (state.localState) + s.localState = CodeMirror.copyState(state.local.mode, state.localState); + if (state.stack) + s.stack = state.stack.slice(0); + for (var pers = state.persistentStates; pers; pers = pers.next) + s.persistentStates = {mode: pers.mode, + spec: pers.spec, + state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state), + next: s.persistentStates}; + return s; + }, + token: tokenFunction(states_, config), + innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; }, + indent: indentFunction(states_, meta) + }; + if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop)) + mode[prop] = meta[prop]; + return mode; + }; + + function ensureState(states, name) { + if (!states.hasOwnProperty(name)) + throw new Error("Undefined state " + name + "in simple mode"); + } + + function toRegex(val, caret) { + if (!val) return /(?:)/; + var flags = ""; + if (val instanceof RegExp) { + if (val.ignoreCase) flags = "i"; + val = val.source; + } else { + val = String(val); + } + return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags); + } + + function asToken(val) { + if (!val) return null; + if (typeof val == "string") return val.replace(/\./g, " "); + var result = []; + for (var i = 0; i < val.length; i++) + result.push(val[i] && val[i].replace(/\./g, " ")); + return result; + } + + function Rule(data, states) { + if (data.next || data.push) ensureState(states, data.next || data.push); + this.regex = toRegex(data.regex); + this.token = asToken(data.token); + this.data = data; + } + + function tokenFunction(states, config) { + return function(stream, state) { + if (state.pending) { + var pend = state.pending.shift(); + if (state.pending.length == 0) state.pending = null; + stream.pos += pend.text.length; + return pend.token; + } + + if (state.local) { + if (state.local.end && stream.match(state.local.end)) { + var tok = state.local.endToken || null; + state.local = state.localState = null; + return tok; + } else { + var tok = state.local.mode.token(stream, state.localState), m; + if (state.local.endScan && (m = state.local.endScan.exec(stream.current()))) + stream.pos = stream.start + m.index; + return tok; + } + } + + var curState = states[state.state]; + for (var i = 0; i < curState.length; i++) { + var rule = curState[i]; + var matches = stream.match(rule.regex); + if (matches) { + if (rule.data.next) { + state.state = rule.data.next; + } else if (rule.data.push) { + (state.stack || (state.stack = [])).push(state.state); + state.state = rule.data.push; + } else if (rule.data.pop && state.stack && state.stack.length) { + state.state = state.stack.pop(); + } + + if (rule.data.mode) + enterLocalMode(config, state, rule.data.mode, rule.token); + if (rule.data.indent) + state.indent.push(stream.indentation() + config.indentUnit); + if (rule.data.dedent) + state.indent.pop(); + if (matches.length > 2) { + state.pending = []; + for (var j = 2; j < matches.length; j++) + if (matches[j]) + state.pending.push({text: matches[j], token: rule.token[j - 1]}); + stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0)); + return rule.token[0]; + } else if (rule.token && rule.token.join) { + return rule.token[0]; + } else { + return rule.token; + } + } + } + stream.next(); + return null; + }; + } + + function cmp(a, b) { + if (a === b) return true; + if (!a || typeof a != "object" || !b || typeof b != "object") return false; + var props = 0; + for (var prop in a) if (a.hasOwnProperty(prop)) { + if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false; + props++; + } + for (var prop in b) if (b.hasOwnProperty(prop)) props--; + return props == 0; + } + + function enterLocalMode(config, state, spec, token) { + var pers; + if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next) + if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p; + var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec); + var lState = pers ? pers.state : CodeMirror.startState(mode); + if (spec.persistent && !pers) + state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates}; + + state.localState = lState; + state.local = {mode: mode, + end: spec.end && toRegex(spec.end), + endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false), + endToken: token && token.join ? token[token.length - 1] : token}; + } + + function indexOf(val, arr) { + for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true; + } + + function indentFunction(states, meta) { + return function(state, textAfter, line) { + if (state.local && state.local.mode.indent) + return state.local.mode.indent(state.localState, textAfter, line); + if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1) + return CodeMirror.Pass; + + var pos = state.indent.length - 1, rules = states[state.state]; + scan: for (;;) { + for (var i = 0; i < rules.length; i++) { + var rule = rules[i], m = rule.regex.exec(textAfter); + if (m && m[0]) { + if (rule.data.dedent && rule.data.dedentIfLineStart !== false) pos--; + if (rule.next || rule.push) rules = states[rule.next || rule.push]; + textAfter = textAfter.slice(m[0].length); + continue scan; + } + } + break; + } + return pos < 0 ? 0 : state.indent[pos]; + }; + } +}); diff --git a/media/editors/codemirror/addon/runmode/runmode-standalone.js b/media/editors/codemirror/addon/runmode/runmode-standalone.js index 0dd0c289b058c..f4f352c803524 100644 --- a/media/editors/codemirror/addon/runmode/runmode-standalone.js +++ b/media/editors/codemirror/addon/runmode/runmode-standalone.js @@ -74,7 +74,11 @@ CodeMirror.startState = function (mode, a1, a2) { }; var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; -CodeMirror.defineMode = function (name, mode) { modes[name] = mode; }; +CodeMirror.defineMode = function (name, mode) { + if (arguments.length > 2) + mode.dependencies = Array.prototype.slice.call(arguments, 2); + modes[name] = mode; +}; CodeMirror.defineMIME = function (mime, spec) { mimeModes[mime] = spec; }; CodeMirror.resolveMode = function(spec) { if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { diff --git a/media/editors/codemirror/addon/runmode/runmode.node.js b/media/editors/codemirror/addon/runmode/runmode.node.js index f64b8a152d3d0..8b8140b4c1ae4 100644 --- a/media/editors/codemirror/addon/runmode/runmode.node.js +++ b/media/editors/codemirror/addon/runmode/runmode.node.js @@ -74,10 +74,8 @@ exports.startState = function(mode, a1, a2) { var modes = exports.modes = {}, mimeModes = exports.mimeModes = {}; exports.defineMode = function(name, mode) { - if (arguments.length > 2) { - mode.dependencies = []; - for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]); - } + if (arguments.length > 2) + mode.dependencies = Array.prototype.slice.call(arguments, 2); modes[name] = mode; }; exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; }; diff --git a/media/editors/codemirror/addon/tern/tern.js b/media/editors/codemirror/addon/tern/tern.js index 4ec976db12df0..9bd69446a2e4a 100644 Binary files a/media/editors/codemirror/addon/tern/tern.js and b/media/editors/codemirror/addon/tern/tern.js differ diff --git a/media/editors/codemirror/keymap/vim.js b/media/editors/codemirror/keymap/vim.js index 0bf2c78248891..a0a01e06c6184 100644 --- a/media/editors/codemirror/keymap/vim.js +++ b/media/editors/codemirror/keymap/vim.js @@ -72,290 +72,205 @@ var defaultKeymap = [ // Key to key mapping. This goes first to make it possible to override // existing mappings. - { keys: [''], type: 'keyToKey', toKeys: ['h'] }, - { keys: [''], type: 'keyToKey', toKeys: ['l'] }, - { keys: [''], type: 'keyToKey', toKeys: ['k'] }, - { keys: [''], type: 'keyToKey', toKeys: ['j'] }, - { keys: [''], type: 'keyToKey', toKeys: ['l'] }, - { keys: [''], type: 'keyToKey', toKeys: ['h'] }, - { keys: [''], type: 'keyToKey', toKeys: ['W'] }, - { keys: [''], type: 'keyToKey', toKeys: ['B'] }, - { keys: [''], type: 'keyToKey', toKeys: ['w'] }, - { keys: [''], type: 'keyToKey', toKeys: ['b'] }, - { keys: [''], type: 'keyToKey', toKeys: ['j'] }, - { keys: [''], type: 'keyToKey', toKeys: ['k'] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: ['s'], type: 'keyToKey', toKeys: ['c', 'l'], context: 'normal' }, - { keys: ['s'], type: 'keyToKey', toKeys: ['x', 'i'], context: 'visual'}, - { keys: ['S'], type: 'keyToKey', toKeys: ['c', 'c'], context: 'normal' }, - { keys: ['S'], type: 'keyToKey', toKeys: ['d', 'c', 'c'], context: 'visual' }, - { keys: [''], type: 'keyToKey', toKeys: ['0'] }, - { keys: [''], type: 'keyToKey', toKeys: ['$'] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: [''], type: 'keyToKey', toKeys: ['j', '^'], context: 'normal' }, + { keys: '', type: 'keyToKey', toKeys: 'h' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'h' }, + { keys: '', type: 'keyToKey', toKeys: 'W' }, + { keys: '', type: 'keyToKey', toKeys: 'B' }, + { keys: '', type: 'keyToKey', toKeys: 'w' }, + { keys: '', type: 'keyToKey', toKeys: 'b' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' }, + { keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'}, + { keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' }, + { keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' }, + { keys: '', type: 'keyToKey', toKeys: '0' }, + { keys: '', type: 'keyToKey', toKeys: '$' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: 'j^', context: 'normal' }, // Motions - { keys: ['H'], type: 'motion', - motion: 'moveToTopLine', - motionArgs: { linewise: true, toJumplist: true }}, - { keys: ['M'], type: 'motion', - motion: 'moveToMiddleLine', - motionArgs: { linewise: true, toJumplist: true }}, - { keys: ['L'], type: 'motion', - motion: 'moveToBottomLine', - motionArgs: { linewise: true, toJumplist: true }}, - { keys: ['h'], type: 'motion', - motion: 'moveByCharacters', - motionArgs: { forward: false }}, - { keys: ['l'], type: 'motion', - motion: 'moveByCharacters', - motionArgs: { forward: true }}, - { keys: ['j'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: true, linewise: true }}, - { keys: ['k'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: false, linewise: true }}, - { keys: ['g','j'], type: 'motion', - motion: 'moveByDisplayLines', - motionArgs: { forward: true }}, - { keys: ['g','k'], type: 'motion', - motion: 'moveByDisplayLines', - motionArgs: { forward: false }}, - { keys: ['w'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: false }}, - { keys: ['W'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: false, bigWord: true }}, - { keys: ['e'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: true, inclusive: true }}, - { keys: ['E'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: true, bigWord: true, - inclusive: true }}, - { keys: ['b'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: false }}, - { keys: ['B'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: false, bigWord: true }}, - { keys: ['g', 'e'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: true, inclusive: true }}, - { keys: ['g', 'E'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: true, bigWord: true, - inclusive: true }}, - { keys: ['{'], type: 'motion', motion: 'moveByParagraph', - motionArgs: { forward: false, toJumplist: true }}, - { keys: ['}'], type: 'motion', motion: 'moveByParagraph', - motionArgs: { forward: true, toJumplist: true }}, - { keys: [''], type: 'motion', - motion: 'moveByPage', motionArgs: { forward: true }}, - { keys: [''], type: 'motion', - motion: 'moveByPage', motionArgs: { forward: false }}, - { keys: [''], type: 'motion', - motion: 'moveByScroll', - motionArgs: { forward: true, explicitRepeat: true }}, - { keys: [''], type: 'motion', - motion: 'moveByScroll', - motionArgs: { forward: false, explicitRepeat: true }}, - { keys: ['g', 'g'], type: 'motion', - motion: 'moveToLineOrEdgeOfDocument', - motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }}, - { keys: ['G'], type: 'motion', - motion: 'moveToLineOrEdgeOfDocument', - motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }}, - { keys: ['0'], type: 'motion', motion: 'moveToStartOfLine' }, - { keys: ['^'], type: 'motion', - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['+'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: true, toFirstChar:true }}, - { keys: ['-'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: false, toFirstChar:true }}, - { keys: ['_'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }}, - { keys: ['$'], type: 'motion', - motion: 'moveToEol', - motionArgs: { inclusive: true }}, - { keys: ['%'], type: 'motion', - motion: 'moveToMatchedSymbol', - motionArgs: { inclusive: true, toJumplist: true }}, - { keys: ['f', 'character'], type: 'motion', - motion: 'moveToCharacter', - motionArgs: { forward: true , inclusive: true }}, - { keys: ['F', 'character'], type: 'motion', - motion: 'moveToCharacter', - motionArgs: { forward: false }}, - { keys: ['t', 'character'], type: 'motion', - motion: 'moveTillCharacter', - motionArgs: { forward: true, inclusive: true }}, - { keys: ['T', 'character'], type: 'motion', - motion: 'moveTillCharacter', - motionArgs: { forward: false }}, - { keys: [';'], type: 'motion', motion: 'repeatLastCharacterSearch', - motionArgs: { forward: true }}, - { keys: [','], type: 'motion', motion: 'repeatLastCharacterSearch', - motionArgs: { forward: false }}, - { keys: ['\'', 'character'], type: 'motion', motion: 'goToMark', - motionArgs: {toJumplist: true, linewise: true}}, - { keys: ['`', 'character'], type: 'motion', motion: 'goToMark', - motionArgs: {toJumplist: true}}, - { keys: [']', '`'], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } }, - { keys: ['[', '`'], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } }, - { keys: [']', '\''], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } }, - { keys: ['[', '\''], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } }, + { keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'L', type: 'motion', motion: 'moveToBottomLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'h', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: false }}, + { keys: 'l', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: 'j', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, linewise: true }}, + { keys: 'k', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, linewise: true }}, + { keys: 'gj', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: true }}, + { keys: 'gk', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: false }}, + { keys: 'w', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false }}, + { keys: 'W', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false, bigWord: true }}, + { keys: 'e', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, inclusive: true }}, + { keys: 'E', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: 'b', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }}, + { keys: 'B', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false, bigWord: true }}, + { keys: 'ge', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, inclusive: true }}, + { keys: 'gE', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: '{', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: false, toJumplist: true }}, + { keys: '}', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: true, toJumplist: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: false }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: true, explicitRepeat: true }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: false, explicitRepeat: true }}, + { keys: 'gg', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: 'G', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: '0', type: 'motion', motion: 'moveToStartOfLine' }, + { keys: '^', type: 'motion', motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '+', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true }}, + { keys: '-', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, toFirstChar:true }}, + { keys: '_', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }}, + { keys: '$', type: 'motion', motion: 'moveToEol', motionArgs: { inclusive: true }}, + { keys: '%', type: 'motion', motion: 'moveToMatchedSymbol', motionArgs: { inclusive: true, toJumplist: true }}, + { keys: 'f', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: true , inclusive: true }}, + { keys: 'F', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: false }}, + { keys: 't', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: true, inclusive: true }}, + { keys: 'T', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: false }}, + { keys: ';', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: true }}, + { keys: ',', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: false }}, + { keys: '\'', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true, linewise: true}}, + { keys: '`', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true}}, + { keys: ']`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } }, + { keys: '[`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } }, + { keys: ']\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } }, + { keys: '[\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } }, // the next two aren't motions but must come before more general motion declarations - { keys: [']', 'p'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: true, isEdit: true, matchIndent: true}}, - { keys: ['[', 'p'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: false, isEdit: true, matchIndent: true}}, - { keys: [']', 'character'], type: 'motion', - motion: 'moveToSymbol', - motionArgs: { forward: true, toJumplist: true}}, - { keys: ['[', 'character'], type: 'motion', - motion: 'moveToSymbol', - motionArgs: { forward: false, toJumplist: true}}, - { keys: ['|'], type: 'motion', - motion: 'moveToColumn', - motionArgs: { }}, - { keys: ['o'], type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: { }, context:'visual'}, - { keys: ['O'], type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: {sameLine: true}, context:'visual'}, + { keys: ']p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true, matchIndent: true}}, + { keys: '[p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true, matchIndent: true}}, + { keys: ']', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: true, toJumplist: true}}, + { keys: '[', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: false, toJumplist: true}}, + { keys: '|', type: 'motion', motion: 'moveToColumn'}, + { keys: 'o', type: 'motion', motion: 'moveToOtherHighlightedEnd', context:'visual'}, + { keys: 'O', type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: {sameLine: true}, context:'visual'}, // Operators - { keys: ['d'], type: 'operator', operator: 'delete' }, - { keys: ['y'], type: 'operator', operator: 'yank' }, - { keys: ['c'], type: 'operator', operator: 'change' }, - { keys: ['>'], type: 'operator', operator: 'indent', - operatorArgs: { indentRight: true }}, - { keys: ['<'], type: 'operator', operator: 'indent', - operatorArgs: { indentRight: false }}, - { keys: ['g', '~'], type: 'operator', operator: 'swapcase' }, - { keys: ['n'], type: 'motion', motion: 'findNext', - motionArgs: { forward: true, toJumplist: true }}, - { keys: ['N'], type: 'motion', motion: 'findNext', - motionArgs: { forward: false, toJumplist: true }}, + { keys: 'd', type: 'operator', operator: 'delete' }, + { keys: 'y', type: 'operator', operator: 'yank' }, + { keys: 'c', type: 'operator', operator: 'change' }, + { keys: '>', type: 'operator', operator: 'indent', operatorArgs: { indentRight: true }}, + { keys: '<', type: 'operator', operator: 'indent', operatorArgs: { indentRight: false }}, + { keys: 'g~', type: 'operator', operator: 'swapcase' }, + { keys: 'n', type: 'motion', motion: 'findNext', motionArgs: { forward: true, toJumplist: true }}, + { keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true }}, // Operator-Motion dual commands - { keys: ['x'], type: 'operatorMotion', operator: 'delete', - motion: 'moveByCharacters', motionArgs: { forward: true }, - operatorMotionArgs: { visualLine: false }}, - { keys: ['X'], type: 'operatorMotion', operator: 'delete', - motion: 'moveByCharacters', motionArgs: { forward: false }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['D'], type: 'operatorMotion', operator: 'delete', - motion: 'moveToEol', motionArgs: { inclusive: true }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['Y'], type: 'operatorMotion', operator: 'yank', - motion: 'moveToEol', motionArgs: { inclusive: true }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['C'], type: 'operatorMotion', - operator: 'change', - motion: 'moveToEol', motionArgs: { inclusive: true }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['~'], type: 'operatorMotion', - operator: 'swapcase', operatorArgs: { shouldMoveCursor: true }, - motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false }}, + { keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true }}, + { keys: 'D', type: 'operatorMotion', operator: 'delete', motion: 'moveToEol', motionArgs: { inclusive: true }, operatorMotionArgs: { visualLine: true }}, + { keys: 'Y', type: 'operatorMotion', operator: 'yank', motion: 'moveToEol', motionArgs: { inclusive: true }, operatorMotionArgs: { visualLine: true }}, + { keys: 'C', type: 'operatorMotion', operator: 'change', motion: 'moveToEol', motionArgs: { inclusive: true }, operatorMotionArgs: { visualLine: true }}, + { keys: '~', type: 'operatorMotion', operator: 'swapcase', operatorArgs: { shouldMoveCursor: true }, motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: '', type: 'operatorMotion', operator: 'delete', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }, context: 'insert' }, // Actions - { keys: [''], type: 'action', action: 'jumpListWalk', - actionArgs: { forward: true }}, - { keys: [''], type: 'action', action: 'jumpListWalk', - actionArgs: { forward: false }}, - { keys: [''], type: 'action', - action: 'scroll', - actionArgs: { forward: true, linewise: true }}, - { keys: [''], type: 'action', - action: 'scroll', - actionArgs: { forward: false, linewise: true }}, - { keys: ['a'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'charAfter' }}, - { keys: ['A'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'eol' }}, - { keys: ['A'], type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'endOfSelectedArea' }, context: 'visual' }, - { keys: ['i'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'inplace' }}, - { keys: ['I'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'firstNonBlank' }}, - { keys: ['o'], type: 'action', action: 'newLineAndEnterInsertMode', - isEdit: true, interlaceInsertRepeat: true, - actionArgs: { after: true }}, - { keys: ['O'], type: 'action', action: 'newLineAndEnterInsertMode', - isEdit: true, interlaceInsertRepeat: true, - actionArgs: { after: false }}, - { keys: ['v'], type: 'action', action: 'toggleVisualMode' }, - { keys: ['V'], type: 'action', action: 'toggleVisualMode', - actionArgs: { linewise: true }}, - { keys: [''], type: 'action', action: 'toggleVisualMode', - actionArgs: { blockwise: true }}, - { keys: ['g', 'v'], type: 'action', action: 'reselectLastSelection' }, - { keys: ['J'], type: 'action', action: 'joinLines', isEdit: true }, - { keys: ['p'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: true, isEdit: true }}, - { keys: ['P'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: false, isEdit: true }}, - { keys: ['r', 'character'], type: 'action', action: 'replace', isEdit: true }, - { keys: ['@', 'character'], type: 'action', action: 'replayMacro' }, - { keys: ['q', 'character'], type: 'action', action: 'enterMacroRecordMode' }, + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: true }}, + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: false }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: true, linewise: true }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: false, linewise: true }}, + { keys: 'a', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'charAfter' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'eol' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'endOfSelectedArea' }, context: 'visual' }, + { keys: 'i', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'inplace' }, context: 'normal' }, + { keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'firstNonBlank' }}, + { keys: 'o', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: true }, context: 'normal' }, + { keys: 'O', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: false }, context: 'normal' }, + { keys: 'v', type: 'action', action: 'toggleVisualMode' }, + { keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }}, + { keys: '', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }}, + { keys: 'gv', type: 'action', action: 'reselectLastSelection' }, + { keys: 'J', type: 'action', action: 'joinLines', isEdit: true }, + { keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }}, + { keys: 'P', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true }}, + { keys: 'r', type: 'action', action: 'replace', isEdit: true }, + { keys: '@', type: 'action', action: 'replayMacro' }, + { keys: 'q', type: 'action', action: 'enterMacroRecordMode' }, // Handle Replace-mode as a special case of insert mode. - { keys: ['R'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { replace: true }}, - { keys: ['u'], type: 'action', action: 'undo' }, - { keys: ['u'], type: 'action', action: 'changeCase', actionArgs: {toLower: true}, context: 'visual', isEdit: true }, - { keys: ['U'],type: 'action', action: 'changeCase', actionArgs: {toLower: false}, context: 'visual', isEdit: true }, - { keys: [''], type: 'action', action: 'redo' }, - { keys: ['m', 'character'], type: 'action', action: 'setMark' }, - { keys: ['"', 'character'], type: 'action', action: 'setRegister' }, - { keys: ['z', 'z'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'center' }}, - { keys: ['z', '.'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'center' }, - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['z', 't'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'top' }}, - { keys: ['z', ''], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'top' }, - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['z', '-'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'bottom' }}, - { keys: ['z', 'b'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'bottom' }, - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['.'], type: 'action', action: 'repeatLastEdit' }, - { keys: [''], type: 'action', action: 'incrementNumberToken', - isEdit: true, - actionArgs: {increase: true, backtrack: false}}, - { keys: [''], type: 'action', action: 'incrementNumberToken', - isEdit: true, - actionArgs: {increase: false, backtrack: false}}, + { keys: 'R', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { replace: true }}, + { keys: 'u', type: 'action', action: 'undo', context: 'normal' }, + { keys: 'u', type: 'action', action: 'changeCase', actionArgs: {toLower: true}, context: 'visual', isEdit: true }, + { keys: 'U',type: 'action', action: 'changeCase', actionArgs: {toLower: false}, context: 'visual', isEdit: true }, + { keys: '', type: 'action', action: 'redo' }, + { keys: 'm', type: 'action', action: 'setMark' }, + { keys: '"', type: 'action', action: 'setRegister' }, + { keys: 'zz', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }}, + { keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }}, + { keys: 'z', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'z-', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }}, + { keys: 'zb', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '.', type: 'action', action: 'repeatLastEdit' }, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}}, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}}, // Text object motions - { keys: ['a', 'character'], type: 'motion', - motion: 'textObjectManipulation' }, - { keys: ['i', 'character'], type: 'motion', - motion: 'textObjectManipulation', - motionArgs: { textObjectInner: true }}, + { keys: 'a', type: 'motion', motion: 'textObjectManipulation' }, + { keys: 'i', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }}, // Search - { keys: ['/'], type: 'search', - searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }}, - { keys: ['?'], type: 'search', - searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }}, - { keys: ['*'], type: 'search', - searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, - { keys: ['#'], type: 'search', - searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, - { keys: ['g', '*'], type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }}, - { keys: ['g', '#'], type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }}, + { keys: '/', type: 'search', searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }}, + { keys: '?', type: 'search', searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }}, + { keys: '*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: '#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: 'g*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }}, + { keys: 'g#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }}, // Ex command - { keys: [':'], type: 'ex' } + { keys: ':', type: 'ex' } ]; var Pos = CodeMirror.Pos; + var modifierCodes = [16, 17, 18, 91]; + var specialKey = {Enter:'CR',Backspace:'BS',Delete:'Del'}; + var mac = /Mac/.test(navigator.platform); var Vim = function() { CodeMirror.defineOption('vimMode', false, function(cm, val) { + function lookupKey(e) { + var keyCode = e.keyCode; + if (modifierCodes.indexOf(keyCode) != -1) { return; } + var hasModifier = e.ctrlKey || e.metaKey; + var key = CodeMirror.keyNames[keyCode]; + key = specialKey[key] || key; + var name = ''; + if (e.ctrlKey) { name += 'C-'; } + if (e.altKey) { name += 'A-'; } + if (mac && e.metaKey || (!hasModifier && e.shiftKey) && key.length < 2) { + // Shift key bindings can only specified for special characters. + return; + } else if (e.shiftKey && !/^[A-Za-z]$/.test(key)) { + name += 'S-'; + } + if (key.length == 1) { key = key.toLowerCase(); } + name += key; + if (name.length > 1) { name = '<' + name + '>'; } + return name; + } + // Keys with modifiers are handled using keydown due to limitations of + // keypress event. + function handleKeyDown(cm, e) { + var name = lookupKey(e); + if (!name) { return; } + + CodeMirror.signal(cm, 'vim-keypress', name); + if (CodeMirror.Vim.handleKey(cm, name, 'user')) { + CodeMirror.e_stop(e); + } + } + // Keys without modifiers are handled using keypress to work best with + // non-standard keyboard layouts. + function handleKeyPress(cm, e) { + var code = e.charCode || e.keyCode; + if (e.ctrlKey || e.metaKey || e.altKey || + e.shiftKey && code < 32) { return; } + var name = String.fromCharCode(code); + + CodeMirror.signal(cm, 'vim-keypress', name); + if (CodeMirror.Vim.handleKey(cm, name, 'user')) { + CodeMirror.e_stop(e); + } + } if (val) { cm.setOption('keyMap', 'vim'); cm.setOption('disableInput', true); @@ -364,12 +279,16 @@ cm.on('cursorActivity', onCursorActivity); maybeInitVimState(cm); CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm)); + cm.on('keypress', handleKeyPress); + cm.on('keydown', handleKeyDown); } else if (cm.state.vim) { cm.setOption('keyMap', 'default'); cm.setOption('disableInput', false); cm.off('cursorActivity', onCursorActivity); CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm)); cm.state.vim = null; + cm.off('keypress', handleKeyPress); + cm.off('keydown', handleKeyDown); } }); function getOnPasteFn(cm) { @@ -397,9 +316,6 @@ var upperCaseAlphabet = makeKeyRange(65, 26); var lowerCaseAlphabet = makeKeyRange(97, 26); var numbers = makeKeyRange(48, 10); - var specialSymbols = '~`!@#$%^&*()_-+=[{}]\\|/?.,<>:;"\''.split(''); - var specialKeys = ['Left', 'Right', 'Up', 'Down', 'Space', 'Backspace', - 'Esc', 'Home', 'End', 'PageUp', 'PageDown', 'Enter']; var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']); var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '/']); @@ -648,6 +564,7 @@ } } + var lastInsertModeKeyTimer; var vimApi= { buildKeyMap: function() { // TODO: Convert keymap into dictionary format for fast lookup. @@ -685,58 +602,111 @@ }, // This is the outermost function called by CodeMirror, after keys have // been mapped to their Vim equivalents. - handleKey: function(cm, key) { - var command; + handleKey: function(cm, key, origin) { var vim = maybeInitVimState(cm); - var macroModeState = vimGlobalState.macroModeState; - if (macroModeState.isRecording) { - if (key == 'q') { - macroModeState.exitMacroRecordMode(); - clearInputState(cm); - return; + function handleMacroRecording() { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isRecording) { + if (key == 'q') { + macroModeState.exitMacroRecordMode(); + clearInputState(cm); + return true; + } + if (origin != 'mapping') { + logKey(macroModeState, key); + } } } - if (key == '') { - // Clear input state and get back to normal mode. - clearInputState(cm); - if (vim.visualMode) { - exitVisualMode(cm); + function handleEsc() { + if (key == '') { + // Clear input state and get back to normal mode. + clearInputState(cm); + if (vim.visualMode) { + exitVisualMode(cm); + } else if (vim.insertMode) { + exitInsertMode(cm); + } + return true; } - return; } - // Enter visual mode when the mouse selects text. - if (!vim.visualMode && - !cursorEqual(cm.getCursor('head'), cm.getCursor('anchor'))) { - vim.visualMode = true; - vim.visualLine = false; - CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"}); - cm.on('mousedown', exitVisualMode); - } - if (key != '0' || (key == '0' && vim.inputState.getRepeat() === 0)) { - // Have to special case 0 since it's both a motion and a number. - command = commandDispatcher.matchCommand(key, defaultKeymap, vim); + function doKeyToKey(keys) { + // TODO: prevent infinite recursion. + var match; + while (keys) { + // Pull off one command key, which is either a single character + // or a special sequence wrapped in '<' and '>', e.g. ''. + match = (/<\w+-.+?>|<\w+>|./).exec(keys); + key = match[0]; + keys = keys.substring(match.index + key.length); + CodeMirror.Vim.handleKey(cm, key, 'mapping'); + } } - if (!command) { - if (isNumber(key)) { - // Increment count unless count is 0 and key is 0. - vim.inputState.pushRepeatDigit(key); + + function handleKeyInsertMode() { + if (handleEsc()) { return true; } + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + var keysAreChars = key.length == 1; + var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + // Need to check all key substrings in insert mode. + while (keys.length > 1 && match.type != 'full') { + var keys = vim.inputState.keyBuffer = keys.slice(1); + var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + if (thisMatch.type != 'none') { match = thisMatch; } } - if (macroModeState.isRecording) { - logKey(macroModeState, key); + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + lastInsertModeKeyTimer = window.setTimeout( + function() { if (vim.insertMode && vim.inputState.keyBuffer) { clearInputState(cm); } }, + getOption('insertModeEscKeysTimeout')); + return !keysAreChars; } - return; + + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + if (keysAreChars) { + var here = cm.getCursor(); + cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input'); + } + clearInputState(cm); + var command = match.command; + if (command.type == 'keyToKey') { + doKeyToKey(command.toKeys); + } else { + commandDispatcher.processCommand(cm, vim, command); + } + return !keysAreChars; } - if (command.type == 'keyToKey') { - // TODO: prevent infinite recursion. - for (var i = 0; i < command.toKeys.length; i++) { - this.handleKey(cm, command.toKeys[i]); + + function handleKeyNonInsertMode() { + if (handleMacroRecording() || handleEsc()) { return true; }; + + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + if (/^[1-9]\d*$/.test(keys)) { return true; } + + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (!keysMatcher) { clearInputState(cm); return false; } + var context = vim.visualMode ? 'visual' : + 'normal'; + var match = commandDispatcher.matchCommand(keysMatcher[2] || keysMatcher[1], defaultKeymap, vim.inputState, context); + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { return true; } + + vim.inputState.keyBuffer = ''; + var command = match.command; + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (keysMatcher[1] && keysMatcher[1] != '0') { + vim.inputState.pushRepeatDigit(keysMatcher[1]); } - } else { - if (macroModeState.isRecording) { - logKey(macroModeState, key); + if (command.type == 'keyToKey') { + doKeyToKey(command.toKeys); + } else { + commandDispatcher.processCommand(cm, vim, command); } - commandDispatcher.processCommand(cm, vim, command); + return true; } + + if (vim.insertMode) { return handleKeyInsertMode(); } + else { return handleKeyNonInsertMode(); } }, handleEx: function(cm, input) { exCommandDispatcher.processCommand(cm, input); @@ -953,83 +923,25 @@ } }; var commandDispatcher = { - matchCommand: function(key, keyMap, vim) { - var inputState = vim.inputState; - var keys = inputState.keyBuffer.concat(key); - var matchedCommands = []; - var selectedCharacter; - for (var i = 0; i < keyMap.length; i++) { - var command = keyMap[i]; - if (matchKeysPartial(keys, command.keys)) { - if (inputState.operator && command.type == 'action') { - // Ignore matched action commands after an operator. Operators - // only operate on motions. This check is really for text - // objects since aW, a[ etcs conflicts with a. - continue; - } - // Match commands that take as an argument. - if (command.keys[keys.length - 1] == 'character') { - selectedCharacter = keys[keys.length - 1]; - if (selectedCharacter.length>1){ - switch(selectedCharacter){ - case '': - selectedCharacter='\n'; - break; - case '': - selectedCharacter=' '; - break; - default: - continue; - } - } - } - // Add the command to the list of matched commands. Choose the best - // command later. - matchedCommands.push(command); - } + matchCommand: function(keys, keyMap, inputState, context) { + var matches = commandMatches(keys, keyMap, context, inputState); + if (!matches.full && !matches.partial) { + return {type: 'none'}; + } else if (!matches.full && matches.partial) { + return {type: 'partial'}; } - // Returns the command if it is a full match, or null if not. - function getFullyMatchedCommandOrNull(command) { - if (keys.length < command.keys.length) { - // Matches part of a multi-key command. Buffer and wait for next - // stroke. - inputState.keyBuffer.push(key); - return null; - } else { - if (command.keys[keys.length - 1] == 'character') { - inputState.selectedCharacter = selectedCharacter; - } - // Clear the buffer since a full match was found. - inputState.keyBuffer = []; - return command; + var bestMatch; + for (var i = 0; i < matches.full.length; i++) { + var match = matches.full[i]; + if (!bestMatch) { + bestMatch = match; } } - - if (!matchedCommands.length) { - // Clear the buffer since there were no matches. - inputState.keyBuffer = []; - return null; - } else if (matchedCommands.length == 1) { - return getFullyMatchedCommandOrNull(matchedCommands[0]); - } else { - // Find the best match in the list of matchedCommands. - var context = vim.visualMode ? 'visual' : 'normal'; - var bestMatch; // Default to first in the list. - for (var i = 0; i < matchedCommands.length; i++) { - var current = matchedCommands[i]; - if (current.context == context) { - bestMatch = current; - break; - } else if (!bestMatch && !current.context) { - // Only set an imperfect match to best match if no best match is - // set and the imperfect match is not restricted to another - // context. - bestMatch = current; - } - } - return getFullyMatchedCommandOrNull(bestMatch); + if (bestMatch.keys.slice(-11) == '') { + inputState.selectedCharacter = lastChar(keys); } + return {type: 'full', command: bestMatch}; }, processCommand: function(cm, vim, command) { vim.inputState.repeatOverride = command.repeatOverride; @@ -1584,8 +1496,8 @@ var equal = cursorEqual(cursor, best); var between = (motionArgs.forward) ? - cusrorIsBetween(cursor, mark, best) : - cusrorIsBetween(best, mark, cursor); + cursorIsBetween(cursor, mark, best) : + cursorIsBetween(best, mark, cursor); if (equal || between) { best = mark; @@ -1837,7 +1749,11 @@ return null; } - return [tmp.start, tmp.end]; + if (!cm.state.vim.visualMode) { + return [tmp.start, tmp.end]; + } else { + return expandSelection(cm, tmp.start, tmp.end); + } }, repeatLastCharacterSearch: function(cm, motionArgs) { @@ -1944,10 +1860,15 @@ // including the trailing \n, include the \n before the starting line if (operatorArgs.linewise && curEnd.line == cm.lastLine() && curStart.line == curEnd.line) { - var tmp = copyCursor(curEnd); - curStart.line--; - curStart.ch = lineLength(cm, curStart.line); - curEnd = tmp; + if (curEnd.line == 0) { + curStart.ch = 0; + } + else { + var tmp = copyCursor(curEnd); + curStart.line--; + curStart.ch = lineLength(cm, curStart.line); + curEnd = tmp; + } cm.replaceRange('', curStart, curEnd); } else { cm.replaceSelections(replacement); @@ -2604,7 +2525,8 @@ if (vim.visualMode) { exitVisualMode(cm); } - } + }, + exitInsertMode: exitInsertMode }; /* @@ -2634,14 +2556,54 @@ function offsetCursor(cur, offsetLine, offsetCh) { return Pos(cur.line + offsetLine, cur.ch + offsetCh); } - function matchKeysPartial(pressed, mapped) { - for (var i = 0; i < pressed.length; i++) { - // 'character' means any character. For mark, register commads, etc. - if (pressed[i] != mapped[i] && mapped[i] != 'character') { - return false; + function commandMatches(keys, keyMap, context, inputState) { + // Partial matches are not applied. They inform the key handler + // that the current key sequence is a subsequence of a valid key + // sequence, so that the key buffer is not cleared. + var match, partial = [], full = []; + for (var i = 0; i < keyMap.length; i++) { + var command = keyMap[i]; + if (context == 'insert' && command.context != 'insert' || + command.context && command.context != context || + inputState.operator && command.type == 'action' || + !(match = commandMatch(keys, command.keys))) { continue; } + if (match == 'partial') { partial.push(command); } + if (match == 'full') { full.push(command); } + } + return { + partial: partial.length && partial, + full: full.length && full + }; + } + function commandMatch(pressed, mapped) { + if (mapped.slice(-11) == '') { + // Last character matches anything. + var prefixLen = mapped.length - 11; + var pressedPrefix = pressed.slice(0, prefixLen); + var mappedPrefix = mapped.slice(0, prefixLen); + return pressedPrefix == mappedPrefix && pressed.length > prefixLen ? 'full' : + mappedPrefix.indexOf(pressedPrefix) == 0 ? 'partial' : false; + } else { + return pressed == mapped ? 'full' : + mapped.indexOf(pressed) == 0 ? 'partial' : false; + } + } + function lastChar(keys) { + var match = /^.*(<[\w\-]+>)$/.exec(keys); + var selectedCharacter = match ? match[1] : keys.slice(-1); + if (selectedCharacter.length > 1){ + switch(selectedCharacter){ + case '': + selectedCharacter='\n'; + break; + case '': + selectedCharacter=' '; + break; + default: + break; } } - return true; + return selectedCharacter; } function repeatFn(cm, fn, repeat) { return function() { @@ -2665,7 +2627,13 @@ } return false; } - function cusrorIsBetween(cur1, cur2, cur3) { + function cursorMin(cur1, cur2) { + return cursorIsBefore(cur1, cur2) ? cur1 : cur2; + } + function cursorMax(cur1, cur2) { + return cursorIsBefore(cur1, cur2) ? cur2 : cur1; + } + function cursorIsBetween(cur1, cur2, cur3) { // returns true if cur2 is between cur1 and cur3. var cur1before2 = cursorIsBefore(cur1, cur2); var cur2before3 = cursorIsBefore(cur2, cur3); @@ -2892,6 +2860,33 @@ 'visualLine': vim.visualLine, 'visualBlock': block}; } + function expandSelection(cm, start, end) { + var head = cm.getCursor('head'); + var anchor = cm.getCursor('anchor'); + var tmp; + if (cursorIsBefore(end, start)) { + tmp = end; + end = start; + start = tmp; + } + if (cursorIsBefore(head, anchor)) { + head = cursorMin(start, head); + anchor = cursorMax(anchor, end); + } else { + anchor = cursorMin(start, anchor); + head = cursorMax(head, end); + } + return [anchor, head]; + } + function getHead(cm) { + var cur = cm.getCursor('head'); + if (cm.getSelection().length == 1) { + // Small corner case when only 1 character is selected. The "real" + // head is the left of head and anchor. + cur = cursorMin(cur, cm.getCursor('anchor')); + } + return cur; + } function exitVisualMode(cm) { cm.off('mousedown', exitVisualMode); @@ -2964,7 +2959,7 @@ } function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) { - var cur = cm.getCursor(); + var cur = getHead(cm); var line = cm.getLine(cur.line); var idx = cur.ch; @@ -3350,7 +3345,7 @@ // TODO: perhaps this finagling of start and end positions belonds // in codmirror/replaceRange? function selectCompanionObject(cm, symb, inclusive) { - var cur = cm.getCursor(), start, end; + var cur = getHead(cm), start, end; var bracketRegexp = ({ '(': /[()]/, ')': /[()]/, @@ -3395,7 +3390,7 @@ // have identical opening and closing symbols // TODO support across multiple lines function findBeginningAndEnd(cm, symb, inclusive) { - var cur = copyCursor(cm.getCursor()); + var cur = copyCursor(getHead(cm)); var line = cm.getLine(cur.line); var chars = line.split(''); var start, end, i, len; @@ -3828,6 +3823,7 @@ // shortNames must not match the prefix of the other command. var defaultExCommandMap = [ { name: 'map' }, + { name: 'imap', shortName: 'im' }, { name: 'nmap', shortName: 'nm' }, { name: 'vmap', shortName: 'vm' }, { name: 'unmap' }, @@ -3882,7 +3878,7 @@ if (command.type == 'exToKey') { // Handle Ex to Key mapping. for (var i = 0; i < command.toKeys.length; i++) { - CodeMirror.Vim.handleKey(cm, command.toKeys[i]); + CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping'); } return; } else if (command.type == 'exToEx') { @@ -4006,7 +4002,7 @@ this.commandMap_[commandName] = { name: commandName, type: 'exToKey', - toKeys: parseKeyString(rhs), + toKeys: rhs, user: true }; } @@ -4014,7 +4010,7 @@ if (rhs != ':' && rhs.charAt(0) == ':') { // Key to Ex mapping. var mapping = { - keys: parseKeyString(lhs), + keys: lhs, type: 'keyToEx', exArgs: { input: rhs.substring(1) }, user: true}; @@ -4023,9 +4019,9 @@ } else { // Key to key mapping var mapping = { - keys: parseKeyString(lhs), + keys: lhs, type: 'keyToKey', - toKeys: parseKeyString(rhs), + toKeys: rhs, user: true }; if (ctx) { mapping.context = ctx; } @@ -4034,15 +4030,6 @@ } }, unmap: function(lhs, ctx) { - var arrayEquals = function(a, b) { - if (a === b) return true; - if (a == null || b == null) return true; - if (a.length != b.length) return false; - for (var i = 0; i < a.length; i++) { - if (a[i] !== b[i]) return false; - } - return true; - }; if (lhs != ':' && lhs.charAt(0) == ':') { // Ex to Ex or Ex to key mapping if (ctx) { throw Error('Mode not supported for ex mappings'); } @@ -4053,9 +4040,9 @@ } } else { // Key to Ex or key to key mapping - var keys = parseKeyString(lhs); + var keys = lhs; for (var i = 0; i < defaultKeymap.length; i++) { - if (arrayEquals(keys, defaultKeymap[i].keys) + if (keys == defaultKeymap[i].keys && defaultKeymap[i].context === ctx && defaultKeymap[i].user) { defaultKeymap.splice(i, 1); @@ -4067,21 +4054,6 @@ } }; - // Converts a key string sequence of the form abd into Vim's - // keymap representation. - function parseKeyString(str) { - var key, match; - var keys = []; - while (str) { - match = (/<\w+-.+?>|<\w+>|./).exec(str); - if (match === null)break; - key = match[0]; - str = str.substring(match.index + key.length); - keys.push(key); - } - return keys; - } - var exCommands = { map: function(cm, params, ctx) { var mapArgs = params.args; @@ -4093,6 +4065,7 @@ } exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx); }, + imap: function(cm, params) { this.map(cm, params, 'insert'); }, nmap: function(cm, params) { this.map(cm, params, 'normal'); }, vmap: function(cm, params) { this.map(cm, params, 'visual'); }, unmap: function(cm, params, ctx) { @@ -4574,65 +4547,10 @@ }); } - // Register Vim with CodeMirror - function buildVimKeyMap() { - /** - * Handle the raw key event from CodeMirror. Translate the - * Shift + key modifier to the resulting letter, while preserving other - * modifers. - */ - function cmKeyToVimKey(key, modifier) { - var vimKey = key; - if (isUpperCase(vimKey) && modifier == 'Ctrl') { - vimKey = vimKey.toLowerCase(); - } - if (modifier) { - // Vim will parse modifier+key combination as a single key. - vimKey = modifier.charAt(0) + '-' + vimKey; - } - var specialKey = ({Enter:'CR',Backspace:'BS',Delete:'Del'})[vimKey]; - vimKey = specialKey ? specialKey : vimKey; - vimKey = vimKey.length > 1 ? '<'+ vimKey + '>' : vimKey; - return vimKey; - } - - // Closure to bind CodeMirror, key, modifier. - function keyMapper(vimKey) { - return function(cm) { - CodeMirror.signal(cm, 'vim-keypress', vimKey); - CodeMirror.Vim.handleKey(cm, vimKey); - }; - } - - var cmToVimKeymap = { + CodeMirror.keyMap.vim = { 'nofallthrough': true, 'style': 'fat-cursor' }; - function bindKeys(keys, modifier) { - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (!modifier && key.length == 1) { - // Wrap all keys without modifiers with '' to identify them by their - // key characters instead of key identifiers. - key = "'" + key + "'"; - } - var vimKey = cmKeyToVimKey(keys[i], modifier); - var cmKey = modifier ? modifier + '-' + key : key; - cmToVimKeymap[cmKey] = keyMapper(vimKey); - } - } - bindKeys(upperCaseAlphabet); - bindKeys(lowerCaseAlphabet); - bindKeys(upperCaseAlphabet, 'Ctrl'); - bindKeys(specialSymbols); - bindKeys(specialSymbols, 'Ctrl'); - bindKeys(numbers); - bindKeys(numbers, 'Ctrl'); - bindKeys(specialKeys); - bindKeys(specialKeys, 'Ctrl'); - return cmToVimKeymap; - } - CodeMirror.keyMap.vim = buildVimKeyMap(); function exitInsertMode(cm) { var vim = cm.state.vim; @@ -4688,63 +4606,13 @@ } } - defineOption('enableInsertModeEscKeys', false, 'boolean'); - // Use this option to customize the two-character ESC keymap. - // If you want to use characters other than i j or k you'll have to add - // lines to the vim-insert and await-second keymaps later in this file. - defineOption('insertModeEscKeys', 'kj', 'string'); // The timeout in milliseconds for the two-character ESC keymap should be // adjusted according to your typing speed to prevent false positives. defineOption('insertModeEscKeysTimeout', 200, 'number'); - function firstEscCharacterHandler(ch) { - return function(cm){ - var keys = getOption('insertModeEscKeys'); - var firstEscCharacter = keys && keys.length > 1 && keys.charAt(0); - if (!getOption('enableInsertModeEscKeys')|| firstEscCharacter !== ch) { - return CodeMirror.Pass; - } else { - cm.replaceRange(ch, cm.getCursor(), cm.getCursor(), "+input"); - cm.setOption('keyMap', 'await-second'); - cm.state.vim.awaitingEscapeSecondCharacter = true; - setTimeout( - function(){ - if(cm.state.vim.awaitingEscapeSecondCharacter) { - cm.state.vim.awaitingEscapeSecondCharacter = false; - cm.setOption('keyMap', 'vim-insert'); - } - }, - getOption('insertModeEscKeysTimeout')); - } - }; - } - function secondEscCharacterHandler(ch){ - return function(cm) { - var keys = getOption('insertModeEscKeys'); - var secondEscCharacter = keys && keys.length > 1 && keys.charAt(1); - if (!getOption('enableInsertModeEscKeys')|| secondEscCharacter !== ch) { - return CodeMirror.Pass; - // This is not the handler you're looking for. Just insert as usual. - } else { - if (cm.state.vim.insertMode) { - var lastChange = vimGlobalState.macroModeState.lastInsertModeChanges; - if (lastChange && lastChange.changes.length) { - lastChange.changes.pop(); - } - } - cm.state.vim.awaitingEscapeSecondCharacter = false; - cm.replaceRange('', {ch: cm.getCursor().ch - 1, line: cm.getCursor().line}, - cm.getCursor(), "+input"); - exitInsertMode(cm); - } - }; - } CodeMirror.keyMap['vim-insert'] = { // TODO: override navigation keys so that Esc will cancel automatic // indentation from o, O, i_ - 'Esc': exitInsertMode, - 'Ctrl-[': exitInsertMode, - 'Ctrl-C': exitInsertMode, 'Ctrl-N': 'autocomplete', 'Ctrl-P': 'autocomplete', 'Enter': function(cm) { @@ -4752,20 +4620,10 @@ CodeMirror.commands.newlineAndIndent; fn(cm); }, - // The next few lines are where you'd add additional handlers if - // you wanted to use keys other than i j and k for two-character - // escape sequences. Don't forget to add them in the await-second - // section as well. - "'i'": firstEscCharacterHandler('i'), - "'j'": firstEscCharacterHandler('j'), - "'k'": firstEscCharacterHandler('k'), fallthrough: ['default'] }; CodeMirror.keyMap['await-second'] = { - "'i'": secondEscCharacterHandler('i'), - "'j'": secondEscCharacterHandler('j'), - "'k'": secondEscCharacterHandler('k'), fallthrough: ['vim-insert'] }; @@ -4789,7 +4647,7 @@ match = (/<\w+-.+?>|<\w+>|./).exec(text); key = match[0]; text = text.substring(match.index + key.length); - CodeMirror.Vim.handleKey(cm, key); + CodeMirror.Vim.handleKey(cm, key, 'macro'); if (vim.insertMode) { var changes = register.insertModeChanges[imc++].changes; vimGlobalState.macroModeState.lastInsertModeChanges.changes = @@ -4869,10 +4727,7 @@ } else if (cm.doc.history.lastSelOrigin == '*mouse') { // Reset lastHPos if mouse click was done in normal mode. vim.lastHPos = cm.doc.getCursor().ch; - if (cm.somethingSelected()) { - // If something is still selected, enter visual mode. - vim.visualMode = true; - } + handleExternalSelection(cm, vim); } if (vim.visualMode) { var from, head; @@ -4891,6 +4746,22 @@ } } + function handleExternalSelection(cm, vim) { + var anchor = cm.getCursor('anchor'); + var head = cm.getCursor('head'); + // Enter visual mode when the mouse selects text. + if (!vim.visualMode && !vim.insertMode && cm.somethingSelected()) { + vim.visualMode = true; + vim.visualLine = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"}); + cm.on('mousedown', exitVisualMode); + } + if (vim.visualMode) { + updateMark(cm, vim, '<', cursorMin(head, anchor)); + updateMark(cm, vim, '>', cursorMax(head, anchor)); + } + } + /** Wrapper for special keys pressed in insert mode */ function InsertModeKey(keyName) { this.keyName = keyName; diff --git a/media/editors/codemirror/lib/addons-uncompressed.js b/media/editors/codemirror/lib/addons-uncompressed.js index a35cf1e9b8723..5ebce7432e073 100644 --- a/media/editors/codemirror/lib/addons-uncompressed.js +++ b/media/editors/codemirror/lib/addons-uncompressed.js @@ -134,24 +134,25 @@ for (var i = 0; i < ranges.length; i++) { var range = ranges[i], cur = range.head, curType; var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1)); - if (!range.empty()) + if (!range.empty()) { curType = "surround"; - else if (left == right && next == right) { + } else if (left == right && next == right) { if (cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == left + left + left) curType = "skipThree"; else curType = "skip"; } else if (left == right && cur.ch > 1 && cm.getRange(Pos(cur.line, cur.ch - 2), cur) == left + left && - (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) + (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) { curType = "addFour"; - else if (left == '"' || left == "'") { + } else if (left == '"' || left == "'") { if (!CodeMirror.isWordChar(next) && enteringString(cm, cur, left)) curType = "both"; else return CodeMirror.Pass; - } else if (cm.getLine(cur.line).length == cur.ch || closingBrackets.indexOf(next) >= 0 || SPACE_CHAR_REGEX.test(next)) + } else if (cm.getLine(cur.line).length == cur.ch || closingBrackets.indexOf(next) >= 0 || SPACE_CHAR_REGEX.test(next)) { curType = "both"; - else + } else { return CodeMirror.Pass; + } if (!type) type = curType; else if (type != curType) return CodeMirror.Pass; } @@ -1447,290 +1448,205 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { var defaultKeymap = [ // Key to key mapping. This goes first to make it possible to override // existing mappings. - { keys: [''], type: 'keyToKey', toKeys: ['h'] }, - { keys: [''], type: 'keyToKey', toKeys: ['l'] }, - { keys: [''], type: 'keyToKey', toKeys: ['k'] }, - { keys: [''], type: 'keyToKey', toKeys: ['j'] }, - { keys: [''], type: 'keyToKey', toKeys: ['l'] }, - { keys: [''], type: 'keyToKey', toKeys: ['h'] }, - { keys: [''], type: 'keyToKey', toKeys: ['W'] }, - { keys: [''], type: 'keyToKey', toKeys: ['B'] }, - { keys: [''], type: 'keyToKey', toKeys: ['w'] }, - { keys: [''], type: 'keyToKey', toKeys: ['b'] }, - { keys: [''], type: 'keyToKey', toKeys: ['j'] }, - { keys: [''], type: 'keyToKey', toKeys: ['k'] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: ['s'], type: 'keyToKey', toKeys: ['c', 'l'], context: 'normal' }, - { keys: ['s'], type: 'keyToKey', toKeys: ['x', 'i'], context: 'visual'}, - { keys: ['S'], type: 'keyToKey', toKeys: ['c', 'c'], context: 'normal' }, - { keys: ['S'], type: 'keyToKey', toKeys: ['d', 'c', 'c'], context: 'visual' }, - { keys: [''], type: 'keyToKey', toKeys: ['0'] }, - { keys: [''], type: 'keyToKey', toKeys: ['$'] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: [''], type: 'keyToKey', toKeys: [''] }, - { keys: [''], type: 'keyToKey', toKeys: ['j', '^'], context: 'normal' }, + { keys: '', type: 'keyToKey', toKeys: 'h' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'h' }, + { keys: '', type: 'keyToKey', toKeys: 'W' }, + { keys: '', type: 'keyToKey', toKeys: 'B' }, + { keys: '', type: 'keyToKey', toKeys: 'w' }, + { keys: '', type: 'keyToKey', toKeys: 'b' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' }, + { keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'}, + { keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' }, + { keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' }, + { keys: '', type: 'keyToKey', toKeys: '0' }, + { keys: '', type: 'keyToKey', toKeys: '$' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: 'j^', context: 'normal' }, // Motions - { keys: ['H'], type: 'motion', - motion: 'moveToTopLine', - motionArgs: { linewise: true, toJumplist: true }}, - { keys: ['M'], type: 'motion', - motion: 'moveToMiddleLine', - motionArgs: { linewise: true, toJumplist: true }}, - { keys: ['L'], type: 'motion', - motion: 'moveToBottomLine', - motionArgs: { linewise: true, toJumplist: true }}, - { keys: ['h'], type: 'motion', - motion: 'moveByCharacters', - motionArgs: { forward: false }}, - { keys: ['l'], type: 'motion', - motion: 'moveByCharacters', - motionArgs: { forward: true }}, - { keys: ['j'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: true, linewise: true }}, - { keys: ['k'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: false, linewise: true }}, - { keys: ['g','j'], type: 'motion', - motion: 'moveByDisplayLines', - motionArgs: { forward: true }}, - { keys: ['g','k'], type: 'motion', - motion: 'moveByDisplayLines', - motionArgs: { forward: false }}, - { keys: ['w'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: false }}, - { keys: ['W'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: false, bigWord: true }}, - { keys: ['e'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: true, inclusive: true }}, - { keys: ['E'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: true, wordEnd: true, bigWord: true, - inclusive: true }}, - { keys: ['b'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: false }}, - { keys: ['B'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: false, bigWord: true }}, - { keys: ['g', 'e'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: true, inclusive: true }}, - { keys: ['g', 'E'], type: 'motion', - motion: 'moveByWords', - motionArgs: { forward: false, wordEnd: true, bigWord: true, - inclusive: true }}, - { keys: ['{'], type: 'motion', motion: 'moveByParagraph', - motionArgs: { forward: false, toJumplist: true }}, - { keys: ['}'], type: 'motion', motion: 'moveByParagraph', - motionArgs: { forward: true, toJumplist: true }}, - { keys: [''], type: 'motion', - motion: 'moveByPage', motionArgs: { forward: true }}, - { keys: [''], type: 'motion', - motion: 'moveByPage', motionArgs: { forward: false }}, - { keys: [''], type: 'motion', - motion: 'moveByScroll', - motionArgs: { forward: true, explicitRepeat: true }}, - { keys: [''], type: 'motion', - motion: 'moveByScroll', - motionArgs: { forward: false, explicitRepeat: true }}, - { keys: ['g', 'g'], type: 'motion', - motion: 'moveToLineOrEdgeOfDocument', - motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }}, - { keys: ['G'], type: 'motion', - motion: 'moveToLineOrEdgeOfDocument', - motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }}, - { keys: ['0'], type: 'motion', motion: 'moveToStartOfLine' }, - { keys: ['^'], type: 'motion', - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['+'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: true, toFirstChar:true }}, - { keys: ['-'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: false, toFirstChar:true }}, - { keys: ['_'], type: 'motion', - motion: 'moveByLines', - motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }}, - { keys: ['$'], type: 'motion', - motion: 'moveToEol', - motionArgs: { inclusive: true }}, - { keys: ['%'], type: 'motion', - motion: 'moveToMatchedSymbol', - motionArgs: { inclusive: true, toJumplist: true }}, - { keys: ['f', 'character'], type: 'motion', - motion: 'moveToCharacter', - motionArgs: { forward: true , inclusive: true }}, - { keys: ['F', 'character'], type: 'motion', - motion: 'moveToCharacter', - motionArgs: { forward: false }}, - { keys: ['t', 'character'], type: 'motion', - motion: 'moveTillCharacter', - motionArgs: { forward: true, inclusive: true }}, - { keys: ['T', 'character'], type: 'motion', - motion: 'moveTillCharacter', - motionArgs: { forward: false }}, - { keys: [';'], type: 'motion', motion: 'repeatLastCharacterSearch', - motionArgs: { forward: true }}, - { keys: [','], type: 'motion', motion: 'repeatLastCharacterSearch', - motionArgs: { forward: false }}, - { keys: ['\'', 'character'], type: 'motion', motion: 'goToMark', - motionArgs: {toJumplist: true, linewise: true}}, - { keys: ['`', 'character'], type: 'motion', motion: 'goToMark', - motionArgs: {toJumplist: true}}, - { keys: [']', '`'], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } }, - { keys: ['[', '`'], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } }, - { keys: [']', '\''], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } }, - { keys: ['[', '\''], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } }, + { keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'L', type: 'motion', motion: 'moveToBottomLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'h', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: false }}, + { keys: 'l', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: 'j', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, linewise: true }}, + { keys: 'k', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, linewise: true }}, + { keys: 'gj', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: true }}, + { keys: 'gk', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: false }}, + { keys: 'w', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false }}, + { keys: 'W', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false, bigWord: true }}, + { keys: 'e', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, inclusive: true }}, + { keys: 'E', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: 'b', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }}, + { keys: 'B', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false, bigWord: true }}, + { keys: 'ge', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, inclusive: true }}, + { keys: 'gE', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: '{', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: false, toJumplist: true }}, + { keys: '}', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: true, toJumplist: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: false }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: true, explicitRepeat: true }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: false, explicitRepeat: true }}, + { keys: 'gg', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: 'G', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: '0', type: 'motion', motion: 'moveToStartOfLine' }, + { keys: '^', type: 'motion', motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '+', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true }}, + { keys: '-', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, toFirstChar:true }}, + { keys: '_', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }}, + { keys: '$', type: 'motion', motion: 'moveToEol', motionArgs: { inclusive: true }}, + { keys: '%', type: 'motion', motion: 'moveToMatchedSymbol', motionArgs: { inclusive: true, toJumplist: true }}, + { keys: 'f', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: true , inclusive: true }}, + { keys: 'F', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: false }}, + { keys: 't', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: true, inclusive: true }}, + { keys: 'T', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: false }}, + { keys: ';', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: true }}, + { keys: ',', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: false }}, + { keys: '\'', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true, linewise: true}}, + { keys: '`', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true}}, + { keys: ']`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } }, + { keys: '[`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } }, + { keys: ']\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } }, + { keys: '[\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } }, // the next two aren't motions but must come before more general motion declarations - { keys: [']', 'p'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: true, isEdit: true, matchIndent: true}}, - { keys: ['[', 'p'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: false, isEdit: true, matchIndent: true}}, - { keys: [']', 'character'], type: 'motion', - motion: 'moveToSymbol', - motionArgs: { forward: true, toJumplist: true}}, - { keys: ['[', 'character'], type: 'motion', - motion: 'moveToSymbol', - motionArgs: { forward: false, toJumplist: true}}, - { keys: ['|'], type: 'motion', - motion: 'moveToColumn', - motionArgs: { }}, - { keys: ['o'], type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: { }, context:'visual'}, - { keys: ['O'], type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: {sameLine: true}, context:'visual'}, + { keys: ']p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true, matchIndent: true}}, + { keys: '[p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true, matchIndent: true}}, + { keys: ']', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: true, toJumplist: true}}, + { keys: '[', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: false, toJumplist: true}}, + { keys: '|', type: 'motion', motion: 'moveToColumn'}, + { keys: 'o', type: 'motion', motion: 'moveToOtherHighlightedEnd', context:'visual'}, + { keys: 'O', type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: {sameLine: true}, context:'visual'}, // Operators - { keys: ['d'], type: 'operator', operator: 'delete' }, - { keys: ['y'], type: 'operator', operator: 'yank' }, - { keys: ['c'], type: 'operator', operator: 'change' }, - { keys: ['>'], type: 'operator', operator: 'indent', - operatorArgs: { indentRight: true }}, - { keys: ['<'], type: 'operator', operator: 'indent', - operatorArgs: { indentRight: false }}, - { keys: ['g', '~'], type: 'operator', operator: 'swapcase' }, - { keys: ['n'], type: 'motion', motion: 'findNext', - motionArgs: { forward: true, toJumplist: true }}, - { keys: ['N'], type: 'motion', motion: 'findNext', - motionArgs: { forward: false, toJumplist: true }}, + { keys: 'd', type: 'operator', operator: 'delete' }, + { keys: 'y', type: 'operator', operator: 'yank' }, + { keys: 'c', type: 'operator', operator: 'change' }, + { keys: '>', type: 'operator', operator: 'indent', operatorArgs: { indentRight: true }}, + { keys: '<', type: 'operator', operator: 'indent', operatorArgs: { indentRight: false }}, + { keys: 'g~', type: 'operator', operator: 'swapcase' }, + { keys: 'n', type: 'motion', motion: 'findNext', motionArgs: { forward: true, toJumplist: true }}, + { keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true }}, // Operator-Motion dual commands - { keys: ['x'], type: 'operatorMotion', operator: 'delete', - motion: 'moveByCharacters', motionArgs: { forward: true }, - operatorMotionArgs: { visualLine: false }}, - { keys: ['X'], type: 'operatorMotion', operator: 'delete', - motion: 'moveByCharacters', motionArgs: { forward: false }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['D'], type: 'operatorMotion', operator: 'delete', - motion: 'moveToEol', motionArgs: { inclusive: true }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['Y'], type: 'operatorMotion', operator: 'yank', - motion: 'moveToEol', motionArgs: { inclusive: true }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['C'], type: 'operatorMotion', - operator: 'change', - motion: 'moveToEol', motionArgs: { inclusive: true }, - operatorMotionArgs: { visualLine: true }}, - { keys: ['~'], type: 'operatorMotion', - operator: 'swapcase', operatorArgs: { shouldMoveCursor: true }, - motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false }}, + { keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true }}, + { keys: 'D', type: 'operatorMotion', operator: 'delete', motion: 'moveToEol', motionArgs: { inclusive: true }, operatorMotionArgs: { visualLine: true }}, + { keys: 'Y', type: 'operatorMotion', operator: 'yank', motion: 'moveToEol', motionArgs: { inclusive: true }, operatorMotionArgs: { visualLine: true }}, + { keys: 'C', type: 'operatorMotion', operator: 'change', motion: 'moveToEol', motionArgs: { inclusive: true }, operatorMotionArgs: { visualLine: true }}, + { keys: '~', type: 'operatorMotion', operator: 'swapcase', operatorArgs: { shouldMoveCursor: true }, motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: '', type: 'operatorMotion', operator: 'delete', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }, context: 'insert' }, // Actions - { keys: [''], type: 'action', action: 'jumpListWalk', - actionArgs: { forward: true }}, - { keys: [''], type: 'action', action: 'jumpListWalk', - actionArgs: { forward: false }}, - { keys: [''], type: 'action', - action: 'scroll', - actionArgs: { forward: true, linewise: true }}, - { keys: [''], type: 'action', - action: 'scroll', - actionArgs: { forward: false, linewise: true }}, - { keys: ['a'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'charAfter' }}, - { keys: ['A'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'eol' }}, - { keys: ['A'], type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'endOfSelectedArea' }, context: 'visual' }, - { keys: ['i'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'inplace' }}, - { keys: ['I'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { insertAt: 'firstNonBlank' }}, - { keys: ['o'], type: 'action', action: 'newLineAndEnterInsertMode', - isEdit: true, interlaceInsertRepeat: true, - actionArgs: { after: true }}, - { keys: ['O'], type: 'action', action: 'newLineAndEnterInsertMode', - isEdit: true, interlaceInsertRepeat: true, - actionArgs: { after: false }}, - { keys: ['v'], type: 'action', action: 'toggleVisualMode' }, - { keys: ['V'], type: 'action', action: 'toggleVisualMode', - actionArgs: { linewise: true }}, - { keys: [''], type: 'action', action: 'toggleVisualMode', - actionArgs: { blockwise: true }}, - { keys: ['g', 'v'], type: 'action', action: 'reselectLastSelection' }, - { keys: ['J'], type: 'action', action: 'joinLines', isEdit: true }, - { keys: ['p'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: true, isEdit: true }}, - { keys: ['P'], type: 'action', action: 'paste', isEdit: true, - actionArgs: { after: false, isEdit: true }}, - { keys: ['r', 'character'], type: 'action', action: 'replace', isEdit: true }, - { keys: ['@', 'character'], type: 'action', action: 'replayMacro' }, - { keys: ['q', 'character'], type: 'action', action: 'enterMacroRecordMode' }, + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: true }}, + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: false }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: true, linewise: true }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: false, linewise: true }}, + { keys: 'a', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'charAfter' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'eol' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'endOfSelectedArea' }, context: 'visual' }, + { keys: 'i', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'inplace' }, context: 'normal' }, + { keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'firstNonBlank' }}, + { keys: 'o', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: true }, context: 'normal' }, + { keys: 'O', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: false }, context: 'normal' }, + { keys: 'v', type: 'action', action: 'toggleVisualMode' }, + { keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }}, + { keys: '', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }}, + { keys: 'gv', type: 'action', action: 'reselectLastSelection' }, + { keys: 'J', type: 'action', action: 'joinLines', isEdit: true }, + { keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }}, + { keys: 'P', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true }}, + { keys: 'r', type: 'action', action: 'replace', isEdit: true }, + { keys: '@', type: 'action', action: 'replayMacro' }, + { keys: 'q', type: 'action', action: 'enterMacroRecordMode' }, // Handle Replace-mode as a special case of insert mode. - { keys: ['R'], type: 'action', action: 'enterInsertMode', isEdit: true, - actionArgs: { replace: true }}, - { keys: ['u'], type: 'action', action: 'undo' }, - { keys: ['u'], type: 'action', action: 'changeCase', actionArgs: {toLower: true}, context: 'visual', isEdit: true }, - { keys: ['U'],type: 'action', action: 'changeCase', actionArgs: {toLower: false}, context: 'visual', isEdit: true }, - { keys: [''], type: 'action', action: 'redo' }, - { keys: ['m', 'character'], type: 'action', action: 'setMark' }, - { keys: ['"', 'character'], type: 'action', action: 'setRegister' }, - { keys: ['z', 'z'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'center' }}, - { keys: ['z', '.'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'center' }, - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['z', 't'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'top' }}, - { keys: ['z', ''], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'top' }, - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['z', '-'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'bottom' }}, - { keys: ['z', 'b'], type: 'action', action: 'scrollToCursor', - actionArgs: { position: 'bottom' }, - motion: 'moveToFirstNonWhiteSpaceCharacter' }, - { keys: ['.'], type: 'action', action: 'repeatLastEdit' }, - { keys: [''], type: 'action', action: 'incrementNumberToken', - isEdit: true, - actionArgs: {increase: true, backtrack: false}}, - { keys: [''], type: 'action', action: 'incrementNumberToken', - isEdit: true, - actionArgs: {increase: false, backtrack: false}}, + { keys: 'R', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { replace: true }}, + { keys: 'u', type: 'action', action: 'undo', context: 'normal' }, + { keys: 'u', type: 'action', action: 'changeCase', actionArgs: {toLower: true}, context: 'visual', isEdit: true }, + { keys: 'U',type: 'action', action: 'changeCase', actionArgs: {toLower: false}, context: 'visual', isEdit: true }, + { keys: '', type: 'action', action: 'redo' }, + { keys: 'm', type: 'action', action: 'setMark' }, + { keys: '"', type: 'action', action: 'setRegister' }, + { keys: 'zz', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }}, + { keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }}, + { keys: 'z', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'z-', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }}, + { keys: 'zb', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '.', type: 'action', action: 'repeatLastEdit' }, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}}, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}}, // Text object motions - { keys: ['a', 'character'], type: 'motion', - motion: 'textObjectManipulation' }, - { keys: ['i', 'character'], type: 'motion', - motion: 'textObjectManipulation', - motionArgs: { textObjectInner: true }}, + { keys: 'a', type: 'motion', motion: 'textObjectManipulation' }, + { keys: 'i', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }}, // Search - { keys: ['/'], type: 'search', - searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }}, - { keys: ['?'], type: 'search', - searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }}, - { keys: ['*'], type: 'search', - searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, - { keys: ['#'], type: 'search', - searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, - { keys: ['g', '*'], type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }}, - { keys: ['g', '#'], type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }}, + { keys: '/', type: 'search', searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }}, + { keys: '?', type: 'search', searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }}, + { keys: '*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: '#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: 'g*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }}, + { keys: 'g#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }}, // Ex command - { keys: [':'], type: 'ex' } + { keys: ':', type: 'ex' } ]; var Pos = CodeMirror.Pos; + var modifierCodes = [16, 17, 18, 91]; + var specialKey = {Enter:'CR',Backspace:'BS',Delete:'Del'}; + var mac = /Mac/.test(navigator.platform); var Vim = function() { CodeMirror.defineOption('vimMode', false, function(cm, val) { + function lookupKey(e) { + var keyCode = e.keyCode; + if (modifierCodes.indexOf(keyCode) != -1) { return; } + var hasModifier = e.ctrlKey || e.metaKey; + var key = CodeMirror.keyNames[keyCode]; + key = specialKey[key] || key; + var name = ''; + if (e.ctrlKey) { name += 'C-'; } + if (e.altKey) { name += 'A-'; } + if (mac && e.metaKey || (!hasModifier && e.shiftKey) && key.length < 2) { + // Shift key bindings can only specified for special characters. + return; + } else if (e.shiftKey && !/^[A-Za-z]$/.test(key)) { + name += 'S-'; + } + if (key.length == 1) { key = key.toLowerCase(); } + name += key; + if (name.length > 1) { name = '<' + name + '>'; } + return name; + } + // Keys with modifiers are handled using keydown due to limitations of + // keypress event. + function handleKeyDown(cm, e) { + var name = lookupKey(e); + if (!name) { return; } + + CodeMirror.signal(cm, 'vim-keypress', name); + if (CodeMirror.Vim.handleKey(cm, name, 'user')) { + CodeMirror.e_stop(e); + } + } + // Keys without modifiers are handled using keypress to work best with + // non-standard keyboard layouts. + function handleKeyPress(cm, e) { + var code = e.charCode || e.keyCode; + if (e.ctrlKey || e.metaKey || e.altKey || + e.shiftKey && code < 32) { return; } + var name = String.fromCharCode(code); + + CodeMirror.signal(cm, 'vim-keypress', name); + if (CodeMirror.Vim.handleKey(cm, name, 'user')) { + CodeMirror.e_stop(e); + } + } if (val) { cm.setOption('keyMap', 'vim'); cm.setOption('disableInput', true); @@ -1739,12 +1655,16 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { cm.on('cursorActivity', onCursorActivity); maybeInitVimState(cm); CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm)); + cm.on('keypress', handleKeyPress); + cm.on('keydown', handleKeyDown); } else if (cm.state.vim) { cm.setOption('keyMap', 'default'); cm.setOption('disableInput', false); cm.off('cursorActivity', onCursorActivity); CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm)); cm.state.vim = null; + cm.off('keypress', handleKeyPress); + cm.off('keydown', handleKeyDown); } }); function getOnPasteFn(cm) { @@ -1772,9 +1692,6 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { var upperCaseAlphabet = makeKeyRange(65, 26); var lowerCaseAlphabet = makeKeyRange(97, 26); var numbers = makeKeyRange(48, 10); - var specialSymbols = '~`!@#$%^&*()_-+=[{}]\\|/?.,<>:;"\''.split(''); - var specialKeys = ['Left', 'Right', 'Up', 'Down', 'Space', 'Backspace', - 'Esc', 'Home', 'End', 'PageUp', 'PageDown', 'Enter']; var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']); var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '/']); @@ -2023,6 +1940,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } } + var lastInsertModeKeyTimer; var vimApi= { buildKeyMap: function() { // TODO: Convert keymap into dictionary format for fast lookup. @@ -2060,58 +1978,111 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { }, // This is the outermost function called by CodeMirror, after keys have // been mapped to their Vim equivalents. - handleKey: function(cm, key) { - var command; + handleKey: function(cm, key, origin) { var vim = maybeInitVimState(cm); - var macroModeState = vimGlobalState.macroModeState; - if (macroModeState.isRecording) { - if (key == 'q') { - macroModeState.exitMacroRecordMode(); - clearInputState(cm); - return; + function handleMacroRecording() { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isRecording) { + if (key == 'q') { + macroModeState.exitMacroRecordMode(); + clearInputState(cm); + return true; + } + if (origin != 'mapping') { + logKey(macroModeState, key); + } } } - if (key == '') { - // Clear input state and get back to normal mode. - clearInputState(cm); - if (vim.visualMode) { - exitVisualMode(cm); + function handleEsc() { + if (key == '') { + // Clear input state and get back to normal mode. + clearInputState(cm); + if (vim.visualMode) { + exitVisualMode(cm); + } else if (vim.insertMode) { + exitInsertMode(cm); + } + return true; } - return; - } - // Enter visual mode when the mouse selects text. - if (!vim.visualMode && - !cursorEqual(cm.getCursor('head'), cm.getCursor('anchor'))) { - vim.visualMode = true; - vim.visualLine = false; - CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"}); - cm.on('mousedown', exitVisualMode); - } - if (key != '0' || (key == '0' && vim.inputState.getRepeat() === 0)) { - // Have to special case 0 since it's both a motion and a number. - command = commandDispatcher.matchCommand(key, defaultKeymap, vim); } - if (!command) { - if (isNumber(key)) { - // Increment count unless count is 0 and key is 0. - vim.inputState.pushRepeatDigit(key); + function doKeyToKey(keys) { + // TODO: prevent infinite recursion. + var match; + while (keys) { + // Pull off one command key, which is either a single character + // or a special sequence wrapped in '<' and '>', e.g. ''. + match = (/<\w+-.+?>|<\w+>|./).exec(keys); + key = match[0]; + keys = keys.substring(match.index + key.length); + CodeMirror.Vim.handleKey(cm, key, 'mapping'); + } + } + + function handleKeyInsertMode() { + if (handleEsc()) { return true; } + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + var keysAreChars = key.length == 1; + var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + // Need to check all key substrings in insert mode. + while (keys.length > 1 && match.type != 'full') { + var keys = vim.inputState.keyBuffer = keys.slice(1); + var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + if (thisMatch.type != 'none') { match = thisMatch; } + } + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + lastInsertModeKeyTimer = window.setTimeout( + function() { if (vim.insertMode && vim.inputState.keyBuffer) { clearInputState(cm); } }, + getOption('insertModeEscKeysTimeout')); + return !keysAreChars; } - if (macroModeState.isRecording) { - logKey(macroModeState, key); + + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + if (keysAreChars) { + var here = cm.getCursor(); + cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input'); } - return; + clearInputState(cm); + var command = match.command; + if (command.type == 'keyToKey') { + doKeyToKey(command.toKeys); + } else { + commandDispatcher.processCommand(cm, vim, command); + } + return !keysAreChars; } - if (command.type == 'keyToKey') { - // TODO: prevent infinite recursion. - for (var i = 0; i < command.toKeys.length; i++) { - this.handleKey(cm, command.toKeys[i]); + + function handleKeyNonInsertMode() { + if (handleMacroRecording() || handleEsc()) { return true; }; + + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + if (/^[1-9]\d*$/.test(keys)) { return true; } + + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (!keysMatcher) { clearInputState(cm); return false; } + var context = vim.visualMode ? 'visual' : + 'normal'; + var match = commandDispatcher.matchCommand(keysMatcher[2] || keysMatcher[1], defaultKeymap, vim.inputState, context); + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { return true; } + + vim.inputState.keyBuffer = ''; + var command = match.command; + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (keysMatcher[1] && keysMatcher[1] != '0') { + vim.inputState.pushRepeatDigit(keysMatcher[1]); } - } else { - if (macroModeState.isRecording) { - logKey(macroModeState, key); + if (command.type == 'keyToKey') { + doKeyToKey(command.toKeys); + } else { + commandDispatcher.processCommand(cm, vim, command); } - commandDispatcher.processCommand(cm, vim, command); + return true; } + + if (vim.insertMode) { return handleKeyInsertMode(); } + else { return handleKeyNonInsertMode(); } }, handleEx: function(cm, input) { exCommandDispatcher.processCommand(cm, input); @@ -2328,83 +2299,25 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } }; var commandDispatcher = { - matchCommand: function(key, keyMap, vim) { - var inputState = vim.inputState; - var keys = inputState.keyBuffer.concat(key); - var matchedCommands = []; - var selectedCharacter; - for (var i = 0; i < keyMap.length; i++) { - var command = keyMap[i]; - if (matchKeysPartial(keys, command.keys)) { - if (inputState.operator && command.type == 'action') { - // Ignore matched action commands after an operator. Operators - // only operate on motions. This check is really for text - // objects since aW, a[ etcs conflicts with a. - continue; - } - // Match commands that take as an argument. - if (command.keys[keys.length - 1] == 'character') { - selectedCharacter = keys[keys.length - 1]; - if (selectedCharacter.length>1){ - switch(selectedCharacter){ - case '': - selectedCharacter='\n'; - break; - case '': - selectedCharacter=' '; - break; - default: - continue; - } - } - } - // Add the command to the list of matched commands. Choose the best - // command later. - matchedCommands.push(command); - } + matchCommand: function(keys, keyMap, inputState, context) { + var matches = commandMatches(keys, keyMap, context, inputState); + if (!matches.full && !matches.partial) { + return {type: 'none'}; + } else if (!matches.full && matches.partial) { + return {type: 'partial'}; } - // Returns the command if it is a full match, or null if not. - function getFullyMatchedCommandOrNull(command) { - if (keys.length < command.keys.length) { - // Matches part of a multi-key command. Buffer and wait for next - // stroke. - inputState.keyBuffer.push(key); - return null; - } else { - if (command.keys[keys.length - 1] == 'character') { - inputState.selectedCharacter = selectedCharacter; - } - // Clear the buffer since a full match was found. - inputState.keyBuffer = []; - return command; + var bestMatch; + for (var i = 0; i < matches.full.length; i++) { + var match = matches.full[i]; + if (!bestMatch) { + bestMatch = match; } } - - if (!matchedCommands.length) { - // Clear the buffer since there were no matches. - inputState.keyBuffer = []; - return null; - } else if (matchedCommands.length == 1) { - return getFullyMatchedCommandOrNull(matchedCommands[0]); - } else { - // Find the best match in the list of matchedCommands. - var context = vim.visualMode ? 'visual' : 'normal'; - var bestMatch; // Default to first in the list. - for (var i = 0; i < matchedCommands.length; i++) { - var current = matchedCommands[i]; - if (current.context == context) { - bestMatch = current; - break; - } else if (!bestMatch && !current.context) { - // Only set an imperfect match to best match if no best match is - // set and the imperfect match is not restricted to another - // context. - bestMatch = current; - } - } - return getFullyMatchedCommandOrNull(bestMatch); + if (bestMatch.keys.slice(-11) == '') { + inputState.selectedCharacter = lastChar(keys); } + return {type: 'full', command: bestMatch}; }, processCommand: function(cm, vim, command) { vim.inputState.repeatOverride = command.repeatOverride; @@ -2959,8 +2872,8 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { var equal = cursorEqual(cursor, best); var between = (motionArgs.forward) ? - cusrorIsBetween(cursor, mark, best) : - cusrorIsBetween(best, mark, cursor); + cursorIsBetween(cursor, mark, best) : + cursorIsBetween(best, mark, cursor); if (equal || between) { best = mark; @@ -3212,7 +3125,11 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { return null; } - return [tmp.start, tmp.end]; + if (!cm.state.vim.visualMode) { + return [tmp.start, tmp.end]; + } else { + return expandSelection(cm, tmp.start, tmp.end); + } }, repeatLastCharacterSearch: function(cm, motionArgs) { @@ -3319,10 +3236,15 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { // including the trailing \n, include the \n before the starting line if (operatorArgs.linewise && curEnd.line == cm.lastLine() && curStart.line == curEnd.line) { - var tmp = copyCursor(curEnd); - curStart.line--; - curStart.ch = lineLength(cm, curStart.line); - curEnd = tmp; + if (curEnd.line == 0) { + curStart.ch = 0; + } + else { + var tmp = copyCursor(curEnd); + curStart.line--; + curStart.ch = lineLength(cm, curStart.line); + curEnd = tmp; + } cm.replaceRange('', curStart, curEnd); } else { cm.replaceSelections(replacement); @@ -3979,7 +3901,8 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { if (vim.visualMode) { exitVisualMode(cm); } - } + }, + exitInsertMode: exitInsertMode }; /* @@ -4009,14 +3932,54 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { function offsetCursor(cur, offsetLine, offsetCh) { return Pos(cur.line + offsetLine, cur.ch + offsetCh); } - function matchKeysPartial(pressed, mapped) { - for (var i = 0; i < pressed.length; i++) { - // 'character' means any character. For mark, register commads, etc. - if (pressed[i] != mapped[i] && mapped[i] != 'character') { - return false; + function commandMatches(keys, keyMap, context, inputState) { + // Partial matches are not applied. They inform the key handler + // that the current key sequence is a subsequence of a valid key + // sequence, so that the key buffer is not cleared. + var match, partial = [], full = []; + for (var i = 0; i < keyMap.length; i++) { + var command = keyMap[i]; + if (context == 'insert' && command.context != 'insert' || + command.context && command.context != context || + inputState.operator && command.type == 'action' || + !(match = commandMatch(keys, command.keys))) { continue; } + if (match == 'partial') { partial.push(command); } + if (match == 'full') { full.push(command); } + } + return { + partial: partial.length && partial, + full: full.length && full + }; + } + function commandMatch(pressed, mapped) { + if (mapped.slice(-11) == '') { + // Last character matches anything. + var prefixLen = mapped.length - 11; + var pressedPrefix = pressed.slice(0, prefixLen); + var mappedPrefix = mapped.slice(0, prefixLen); + return pressedPrefix == mappedPrefix && pressed.length > prefixLen ? 'full' : + mappedPrefix.indexOf(pressedPrefix) == 0 ? 'partial' : false; + } else { + return pressed == mapped ? 'full' : + mapped.indexOf(pressed) == 0 ? 'partial' : false; + } + } + function lastChar(keys) { + var match = /^.*(<[\w\-]+>)$/.exec(keys); + var selectedCharacter = match ? match[1] : keys.slice(-1); + if (selectedCharacter.length > 1){ + switch(selectedCharacter){ + case '': + selectedCharacter='\n'; + break; + case '': + selectedCharacter=' '; + break; + default: + break; } } - return true; + return selectedCharacter; } function repeatFn(cm, fn, repeat) { return function() { @@ -4040,7 +4003,13 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } return false; } - function cusrorIsBetween(cur1, cur2, cur3) { + function cursorMin(cur1, cur2) { + return cursorIsBefore(cur1, cur2) ? cur1 : cur2; + } + function cursorMax(cur1, cur2) { + return cursorIsBefore(cur1, cur2) ? cur2 : cur1; + } + function cursorIsBetween(cur1, cur2, cur3) { // returns true if cur2 is between cur1 and cur3. var cur1before2 = cursorIsBefore(cur1, cur2); var cur2before3 = cursorIsBefore(cur2, cur3); @@ -4267,6 +4236,33 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { 'visualLine': vim.visualLine, 'visualBlock': block}; } + function expandSelection(cm, start, end) { + var head = cm.getCursor('head'); + var anchor = cm.getCursor('anchor'); + var tmp; + if (cursorIsBefore(end, start)) { + tmp = end; + end = start; + start = tmp; + } + if (cursorIsBefore(head, anchor)) { + head = cursorMin(start, head); + anchor = cursorMax(anchor, end); + } else { + anchor = cursorMin(start, anchor); + head = cursorMax(head, end); + } + return [anchor, head]; + } + function getHead(cm) { + var cur = cm.getCursor('head'); + if (cm.getSelection().length == 1) { + // Small corner case when only 1 character is selected. The "real" + // head is the left of head and anchor. + cur = cursorMin(cur, cm.getCursor('anchor')); + } + return cur; + } function exitVisualMode(cm) { cm.off('mousedown', exitVisualMode); @@ -4339,7 +4335,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) { - var cur = cm.getCursor(); + var cur = getHead(cm); var line = cm.getLine(cur.line); var idx = cur.ch; @@ -4725,7 +4721,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { // TODO: perhaps this finagling of start and end positions belonds // in codmirror/replaceRange? function selectCompanionObject(cm, symb, inclusive) { - var cur = cm.getCursor(), start, end; + var cur = getHead(cm), start, end; var bracketRegexp = ({ '(': /[()]/, ')': /[()]/, @@ -4770,7 +4766,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { // have identical opening and closing symbols // TODO support across multiple lines function findBeginningAndEnd(cm, symb, inclusive) { - var cur = copyCursor(cm.getCursor()); + var cur = copyCursor(getHead(cm)); var line = cm.getLine(cur.line); var chars = line.split(''); var start, end, i, len; @@ -5203,6 +5199,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { // shortNames must not match the prefix of the other command. var defaultExCommandMap = [ { name: 'map' }, + { name: 'imap', shortName: 'im' }, { name: 'nmap', shortName: 'nm' }, { name: 'vmap', shortName: 'vm' }, { name: 'unmap' }, @@ -5257,7 +5254,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { if (command.type == 'exToKey') { // Handle Ex to Key mapping. for (var i = 0; i < command.toKeys.length; i++) { - CodeMirror.Vim.handleKey(cm, command.toKeys[i]); + CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping'); } return; } else if (command.type == 'exToEx') { @@ -5381,7 +5378,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { this.commandMap_[commandName] = { name: commandName, type: 'exToKey', - toKeys: parseKeyString(rhs), + toKeys: rhs, user: true }; } @@ -5389,7 +5386,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { if (rhs != ':' && rhs.charAt(0) == ':') { // Key to Ex mapping. var mapping = { - keys: parseKeyString(lhs), + keys: lhs, type: 'keyToEx', exArgs: { input: rhs.substring(1) }, user: true}; @@ -5398,9 +5395,9 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } else { // Key to key mapping var mapping = { - keys: parseKeyString(lhs), + keys: lhs, type: 'keyToKey', - toKeys: parseKeyString(rhs), + toKeys: rhs, user: true }; if (ctx) { mapping.context = ctx; } @@ -5409,15 +5406,6 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } }, unmap: function(lhs, ctx) { - var arrayEquals = function(a, b) { - if (a === b) return true; - if (a == null || b == null) return true; - if (a.length != b.length) return false; - for (var i = 0; i < a.length; i++) { - if (a[i] !== b[i]) return false; - } - return true; - }; if (lhs != ':' && lhs.charAt(0) == ':') { // Ex to Ex or Ex to key mapping if (ctx) { throw Error('Mode not supported for ex mappings'); } @@ -5428,9 +5416,9 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } } else { // Key to Ex or key to key mapping - var keys = parseKeyString(lhs); + var keys = lhs; for (var i = 0; i < defaultKeymap.length; i++) { - if (arrayEquals(keys, defaultKeymap[i].keys) + if (keys == defaultKeymap[i].keys && defaultKeymap[i].context === ctx && defaultKeymap[i].user) { defaultKeymap.splice(i, 1); @@ -5442,21 +5430,6 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } }; - // Converts a key string sequence of the form abd into Vim's - // keymap representation. - function parseKeyString(str) { - var key, match; - var keys = []; - while (str) { - match = (/<\w+-.+?>|<\w+>|./).exec(str); - if (match === null)break; - key = match[0]; - str = str.substring(match.index + key.length); - keys.push(key); - } - return keys; - } - var exCommands = { map: function(cm, params, ctx) { var mapArgs = params.args; @@ -5468,6 +5441,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx); }, + imap: function(cm, params) { this.map(cm, params, 'insert'); }, nmap: function(cm, params) { this.map(cm, params, 'normal'); }, vmap: function(cm, params) { this.map(cm, params, 'visual'); }, unmap: function(cm, params, ctx) { @@ -5949,65 +5923,10 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { }); } - // Register Vim with CodeMirror - function buildVimKeyMap() { - /** - * Handle the raw key event from CodeMirror. Translate the - * Shift + key modifier to the resulting letter, while preserving other - * modifers. - */ - function cmKeyToVimKey(key, modifier) { - var vimKey = key; - if (isUpperCase(vimKey) && modifier == 'Ctrl') { - vimKey = vimKey.toLowerCase(); - } - if (modifier) { - // Vim will parse modifier+key combination as a single key. - vimKey = modifier.charAt(0) + '-' + vimKey; - } - var specialKey = ({Enter:'CR',Backspace:'BS',Delete:'Del'})[vimKey]; - vimKey = specialKey ? specialKey : vimKey; - vimKey = vimKey.length > 1 ? '<'+ vimKey + '>' : vimKey; - return vimKey; - } - - // Closure to bind CodeMirror, key, modifier. - function keyMapper(vimKey) { - return function(cm) { - CodeMirror.signal(cm, 'vim-keypress', vimKey); - CodeMirror.Vim.handleKey(cm, vimKey); - }; - } - - var cmToVimKeymap = { + CodeMirror.keyMap.vim = { 'nofallthrough': true, 'style': 'fat-cursor' }; - function bindKeys(keys, modifier) { - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (!modifier && key.length == 1) { - // Wrap all keys without modifiers with '' to identify them by their - // key characters instead of key identifiers. - key = "'" + key + "'"; - } - var vimKey = cmKeyToVimKey(keys[i], modifier); - var cmKey = modifier ? modifier + '-' + key : key; - cmToVimKeymap[cmKey] = keyMapper(vimKey); - } - } - bindKeys(upperCaseAlphabet); - bindKeys(lowerCaseAlphabet); - bindKeys(upperCaseAlphabet, 'Ctrl'); - bindKeys(specialSymbols); - bindKeys(specialSymbols, 'Ctrl'); - bindKeys(numbers); - bindKeys(numbers, 'Ctrl'); - bindKeys(specialKeys); - bindKeys(specialKeys, 'Ctrl'); - return cmToVimKeymap; - } - CodeMirror.keyMap.vim = buildVimKeyMap(); function exitInsertMode(cm) { var vim = cm.state.vim; @@ -6063,63 +5982,13 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } } - defineOption('enableInsertModeEscKeys', false, 'boolean'); - // Use this option to customize the two-character ESC keymap. - // If you want to use characters other than i j or k you'll have to add - // lines to the vim-insert and await-second keymaps later in this file. - defineOption('insertModeEscKeys', 'kj', 'string'); // The timeout in milliseconds for the two-character ESC keymap should be // adjusted according to your typing speed to prevent false positives. defineOption('insertModeEscKeysTimeout', 200, 'number'); - function firstEscCharacterHandler(ch) { - return function(cm){ - var keys = getOption('insertModeEscKeys'); - var firstEscCharacter = keys && keys.length > 1 && keys.charAt(0); - if (!getOption('enableInsertModeEscKeys')|| firstEscCharacter !== ch) { - return CodeMirror.Pass; - } else { - cm.replaceRange(ch, cm.getCursor(), cm.getCursor(), "+input"); - cm.setOption('keyMap', 'await-second'); - cm.state.vim.awaitingEscapeSecondCharacter = true; - setTimeout( - function(){ - if(cm.state.vim.awaitingEscapeSecondCharacter) { - cm.state.vim.awaitingEscapeSecondCharacter = false; - cm.setOption('keyMap', 'vim-insert'); - } - }, - getOption('insertModeEscKeysTimeout')); - } - }; - } - function secondEscCharacterHandler(ch){ - return function(cm) { - var keys = getOption('insertModeEscKeys'); - var secondEscCharacter = keys && keys.length > 1 && keys.charAt(1); - if (!getOption('enableInsertModeEscKeys')|| secondEscCharacter !== ch) { - return CodeMirror.Pass; - // This is not the handler you're looking for. Just insert as usual. - } else { - if (cm.state.vim.insertMode) { - var lastChange = vimGlobalState.macroModeState.lastInsertModeChanges; - if (lastChange && lastChange.changes.length) { - lastChange.changes.pop(); - } - } - cm.state.vim.awaitingEscapeSecondCharacter = false; - cm.replaceRange('', {ch: cm.getCursor().ch - 1, line: cm.getCursor().line}, - cm.getCursor(), "+input"); - exitInsertMode(cm); - } - }; - } CodeMirror.keyMap['vim-insert'] = { // TODO: override navigation keys so that Esc will cancel automatic // indentation from o, O, i_ - 'Esc': exitInsertMode, - 'Ctrl-[': exitInsertMode, - 'Ctrl-C': exitInsertMode, 'Ctrl-N': 'autocomplete', 'Ctrl-P': 'autocomplete', 'Enter': function(cm) { @@ -6127,20 +5996,10 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { CodeMirror.commands.newlineAndIndent; fn(cm); }, - // The next few lines are where you'd add additional handlers if - // you wanted to use keys other than i j and k for two-character - // escape sequences. Don't forget to add them in the await-second - // section as well. - "'i'": firstEscCharacterHandler('i'), - "'j'": firstEscCharacterHandler('j'), - "'k'": firstEscCharacterHandler('k'), fallthrough: ['default'] }; CodeMirror.keyMap['await-second'] = { - "'i'": secondEscCharacterHandler('i'), - "'j'": secondEscCharacterHandler('j'), - "'k'": secondEscCharacterHandler('k'), fallthrough: ['vim-insert'] }; @@ -6164,7 +6023,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { match = (/<\w+-.+?>|<\w+>|./).exec(text); key = match[0]; text = text.substring(match.index + key.length); - CodeMirror.Vim.handleKey(cm, key); + CodeMirror.Vim.handleKey(cm, key, 'macro'); if (vim.insertMode) { var changes = register.insertModeChanges[imc++].changes; vimGlobalState.macroModeState.lastInsertModeChanges.changes = @@ -6244,10 +6103,7 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } else if (cm.doc.history.lastSelOrigin == '*mouse') { // Reset lastHPos if mouse click was done in normal mode. vim.lastHPos = cm.doc.getCursor().ch; - if (cm.somethingSelected()) { - // If something is still selected, enter visual mode. - vim.visualMode = true; - } + handleExternalSelection(cm, vim); } if (vim.visualMode) { var from, head; @@ -6266,6 +6122,22 @@ CodeMirror.multiplexingMode = function(outer /*, others */) { } } + function handleExternalSelection(cm, vim) { + var anchor = cm.getCursor('anchor'); + var head = cm.getCursor('head'); + // Enter visual mode when the mouse selects text. + if (!vim.visualMode && !vim.insertMode && cm.somethingSelected()) { + vim.visualMode = true; + vim.visualLine = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"}); + cm.on('mousedown', exitVisualMode); + } + if (vim.visualMode) { + updateMark(cm, vim, '<', cursorMin(head, anchor)); + updateMark(cm, vim, '>', cursorMax(head, anchor)); + } + } + /** Wrapper for special keys pressed in insert mode */ function InsertModeKey(keyName) { this.keyName = keyName; diff --git a/media/editors/codemirror/lib/addons.js b/media/editors/codemirror/lib/addons.js index b8a2f6e274ef9..fd62a3eefe74e 100644 --- a/media/editors/codemirror/lib/addons.js +++ b/media/editors/codemirror/lib/addons.js @@ -1 +1 @@ -(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(a){a.defineOption("fullScreen",false,function(d,f,e){if(e==a.Init){e=false}if(!e==!f){return}if(f){b(d)}else{c(d)}});function b(d){var e=d.getWrapperElement();d.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:e.style.width,height:e.style.height};e.style.width="";e.style.height="auto";e.className+=" CodeMirror-fullscreen";document.documentElement.style.overflow="hidden";d.refresh()}function c(d){var e=d.getWrapperElement();e.className=e.className.replace(/\s*CodeMirror-fullscreen\b/,"");document.documentElement.style.overflow="";var f=d.state.fullScreenRestore;e.style.width=f.width;e.style.height=f.height;window.scrollTo(f.scrollLeft,f.scrollTop);d.refresh()}});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(c){var h="()[]{}''\"\"";var g="[]{}";var i=/\s/;var f=c.Pos;c.defineOption("autoCloseBrackets",false,function(j,o,k){if(k!=c.Init&&k){j.removeKeyMap("autoCloseBrackets")}if(!o){return}var m=h,l=g;if(typeof o=="string"){m=o}else{if(typeof o=="object"){if(o.pairs!=null){m=o.pairs}if(o.explode!=null){l=o.explode}}}var n=b(m);if(l){n.Enter=a(l)}j.addKeyMap(n)});function d(j,l){var k=j.getRange(f(l.line,l.ch-1),f(l.line,l.ch+1));return k.length==2?k:null}function e(j,p,n){var k=j.getLine(p.line);var m=j.getTokenAt(p);if(/\bstring2?\b/.test(m.type)){return false}var o=new c.StringStream(k.slice(0,p.ch)+n+k.slice(p.ch),4);o.pos=o.start=m.start;for(;;){var l=j.getMode().token(o,m.state);if(o.pos>=p.ch+1){return/\bstring2?\b/.test(l)}o.start=o.pos}}function b(l){var m={name:"autoCloseBrackets",Backspace:function(n){if(n.getOption("disableInput")){return c.Pass}var o=n.listSelections();for(var p=0;p=0;p--){var r=o[p].head;n.replaceRange("",f(r.line,r.ch-1),f(r.line,r.ch+1))}}};var k="";for(var j=0;j1&&p.getRange(f(w.line,w.ch-2),w)==o+o&&(w.ch<=2||p.getRange(f(w.line,w.ch-3),f(w.line,w.ch-2))!=o)){s="addFour"}else{if(o=='"'||o=="'"){if(!c.isWordChar(u)&&e(p,w,o)){s="both"}else{return c.Pass}}else{if(p.getLine(w.line).length==w.ch||k.indexOf(u)>=0||i.test(u)){s="both"}else{return c.Pass}}}}}if(!v){v=s}else{if(v!=s){return c.Pass}}}p.operation(function(){if(v=="skip"){p.execCommand("goCharRight")}else{if(v=="skipThree"){for(var y=0;y<3;y++){p.execCommand("goCharRight")}}else{if(v=="surround"){var x=p.getSelections();for(var y=0;y'"]=function(l){return a(l)}}h.addKeyMap(j)});var d=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];var c=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function a(w){if(w.getOption("disableInput")){return b.Pass}var j=w.listSelections(),q=[];for(var r=0;rv.ch){p=p.slice(0,p.length-x.end+v.ch)}var t=p.toLowerCase();if(!p||x.type=="string"&&(x.end!=v.ch||!/[\"\']/.test(x.string.charAt(x.string.length-1))||x.string.length==1)||x.type=="tag"&&h.type=="closeTag"||x.string.indexOf("/")==(x.string.length-1)||m&&g(m,t)>-1||f(w,p,v,h,true)){return b.Pass}var o=u&&g(u,t)>-1;q[r]={indent:o,text:">"+(o?"\n\n":"")+"",newPos:o?b.Pos(v.line+1,0):b.Pos(v.line,v.ch+1)}}for(var r=j.length-1;r>=0;r--){var n=q[r];w.replaceRange(n.text,j[r].head,j[r].anchor,"+insert");var l=w.listSelections().slice(0);l[r]={head:n.newPos,anchor:n.newPos};w.setSelections(l);if(n.indent){w.indentLine(n.newPos.line,null,true);w.indentLine(n.newPos.line+1,null,true)}}}function e(h){if(h.getOption("disableInput")){return b.Pass}var j=h.listSelections(),n=[];for(var m=0;m"}else{if(h.getMode().name=="htmlmixed"&&k.mode.name=="css"){n[m]="/style>"}else{return b.Pass}}}else{if(!o.context||!o.context.tagName||f(h,o.context.tagName,p,o)){return b.Pass}n[m]="/"+o.context.tagName+">"}}h.replaceSelections(n);j=h.listSelections();for(var m=0;m",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"};function f(q,m,p,k){var s=q.getLineHandle(m.line),o=m.ch-1;var n=(o>=0&&a[s.text.charAt(o)])||a[s.text.charAt(++o)];if(!n){return null}var l=n.charAt(1)==">"?1:-1;if(p&&(l>0)!=(o==m.ch)){return null}var j=q.getTokenTypeAt(i(m.line,o+1));var r=g(q,i(m.line,o+(l>0?1:0)),l,j||null,k);if(r==null){return null}return{from:i(m.line,o),to:r&&r.pos,match:r&&r.ch==n.charAt(0),forward:l>0}}function g(w,r,n,k,m){var l=(m&&m.maxScanLineLength)||10000;var t=(m&&m.maxScanLines)||1000;var v=[];var x=m&&m.bracketRegex?m.bracketRegex:/[(){}[\]]/;var q=n>0?Math.min(r.line+t,w.lastLine()+1):Math.max(w.firstLine()-1,r.line-t);for(var o=r.line;o!=q;o+=n){var y=w.getLine(o);if(!y){continue}var u=n>0?0:y.length-1,p=n>0?y.length:-1;if(y.length>l){continue}if(o==r.line){u=r.ch-(n<0?1:0)}for(;u!=p;u+=n){var j=y.charAt(u);if(x.test(j)&&(k===undefined||w.getTokenTypeAt(i(o,u+1))==k)){var s=a[j];if((s.charAt(1)==">")==(n>0)){v.push(j)}else{if(!v.length){return{pos:i(o,u),ch:j}}else{v.pop()}}}}}return o-n==(n>0?w.lastLine():w.firstLine())?false:null}function b(s,n,m){var k=s.state.matchBrackets.maxHighlightLineLength||1000;var r=[],l=s.listSelections();for(var o=0;ob.lastLine()){return null}var o=b.getTokenAt(a.Pos(k,1));if(!/\S/.test(o.string)){o=b.getTokenAt(a.Pos(k,o.end+1))}if(o.type!="keyword"||o.string!="import"){return null}for(var l=k,m=Math.min(b.lastLine(),k+10);l<=m;++l){var n=b.getLine(l),j=n.indexOf(";");if(j!=-1){return{startCh:o.end,end:a.Pos(l,j)}}}}var h=h.line,d=g(h),f;if(!d||g(h-1)||((f=g(h-2))&&f.end.line==h-1)){return null}for(var c=d.end;;){var e=g(c.line+1);if(e==null){break}c=e.end}return{from:b.clipPos(a.Pos(h,d.startCh+1)),to:c}});a.registerHelper("fold","include",function(b,g){function f(h){if(hb.lastLine()){return null}var i=b.getTokenAt(a.Pos(h,1));if(!/\S/.test(i.string)){i=b.getTokenAt(a.Pos(h,i.end+1))}if(i.type=="meta"&&i.string.slice(0,8)=="#include"){return i.start+8}}var g=g.line,d=f(g);if(d==null||f(g-1)!=null){return null}for(var c=g;;){var e=f(c+1);if(e==null){break}++c}return{from:a.Pos(g,d+1),to:b.clipPos(a.Pos(c))}})});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(b){function d(n,m,o,i){if(o&&o.call){var g=o;o=null}else{var g=c(n,o,"rangeFinder")}if(typeof m=="number"){m=b.Pos(m,0)}var h=c(n,o,"minFoldSize");function f(p){var q=g(n,m);if(!q||q.to.line-q.from.linen.firstLine()){m=b.Pos(m.line-1,0);k=f(false)}}if(!k||k.cleared||i==="unfold"){return}var l=e(n,o);b.on(l,"mousedown",function(p){j.clear();b.e_preventDefault(p)});var j=n.markText(k.from,k.to,{replacedWith:l,clearOnEnter:true,__isFold:true});j.on("clear",function(q,p){b.signal(n,"unfold",n,q,p)});b.signal(n,"fold",n,k.from,k.to)}function e(f,g){var h=c(f,g,"widget");if(typeof h=="string"){var i=document.createTextNode(h);h=document.createElement("span");h.appendChild(i);h.className="CodeMirror-foldmarker"}return h}b.newFoldFunction=function(g,f){return function(h,i){d(h,i,{rangeFinder:g,widget:f})}};b.defineExtension("foldCode",function(h,f,g){d(this,h,f,g)});b.defineExtension("isFolded",function(h){var g=this.findMarksAt(h);for(var f=0;f20||o.from-p.to>20){b(m)}else{m.operation(function(){if(p.fromo.to){a(m,o.to,p.to);o.to=p.to}})}},n.updateViewportTimeSpan||400)}function e(m,p){var o=m.state.foldGutter,n=p.line;if(n>=o.from&&n=q.max){return}q.ch=0;q.text=q.cm.getLine(++q.line);return true}function n(q){if(q.line<=q.min){return}q.text=q.cm.getLine(--q.line);q.ch=q.text.length;return true}function g(s){for(;;){var r=s.text.indexOf(">",s.ch);if(r==-1){if(a(s)){continue}else{return}}if(!h(s,r+1)){s.ch=r+1;continue}var q=s.text.lastIndexOf("/",r);var t=q>-1&&!/\S/.test(s.text.slice(q+1,r));s.ch=r+1;return t?"selfClose":"regular"}}function k(r){for(;;){var q=r.ch?r.text.lastIndexOf("<",r.ch-1):-1;if(q==-1){if(n(r)){continue}else{return}}if(!h(r,q+1)){r.ch=q;continue}d.lastIndex=q;r.ch=q;var s=d.exec(r.text);if(s&&s.index==q){return s}}}function p(q){for(;;){d.lastIndex=q.ch;var r=d.exec(q.text);if(!r){if(a(q)){continue}else{return}}if(!h(q,r.index+1)){q.ch=r.index+1;continue}q.ch=r.index+r[0].length;return r}}function e(s){for(;;){var r=s.ch?s.text.lastIndexOf(">",s.ch-1):-1;if(r==-1){if(n(s)){continue}else{return}}if(!h(s,r+1)){s.ch=r;continue}var q=s.text.lastIndexOf("/",r);var t=q>-1&&!/\S/.test(s.text.slice(q+1,r));s.ch=r+1;return t?"selfClose":"regular"}}function f(t,r){var q=[];for(;;){var v=p(t),s,x=t.line,w=t.ch-(v?v[0].length:0);if(!v||!(s=g(t))){return}if(s=="selfClose"){continue}if(v[1]){for(var u=q.length-1;u>=0;--u){if(q[u]==v[2]){q.length=u;break}}if(u<0&&(!r||r==v[2])){return{tag:v[2],from:m(x,w),to:m(t.line,t.ch)}}}else{q.push(v[2])}}}function c(s,r){var q=[];for(;;){var w=e(s);if(!w){return}if(w=="selfClose"){k(s);continue}var v=s.line,u=s.ch;var x=k(s);if(!x){return}if(x[1]){q.push(x[2])}else{for(var t=q.length-1;t>=0;--t){if(q[t]==x[2]){q.length=t;break}}if(t<0&&(!r||r==x[2])){return{tag:x[2],from:m(s.line,s.ch),to:m(v,u)}}}}}i.registerHelper("fold","xml",function(q,v){var s=new b(q,v.line,0);for(;;){var t=p(s),r;if(!t||s.line!=v.line||!(r=g(s))){return}if(!t[1]&&r!="selfClose"){var v=m(s.line,s.ch);var u=f(s,t[2]);return u&&{from:v,to:u.from}}}});i.findMatchingTag=function(q,x,t){var s=new b(q,x.line,x.ch,t);if(s.text.indexOf(">")==-1&&s.text.indexOf("<")==-1){return}var r=g(s),w=r&&m(s.line,s.ch);var v=r&&k(s);if(!r||!v||l(s,x)>0){return}var u={from:m(s.line,s.ch),to:w,tag:v[2]};if(r=="selfClose"){return{open:u,close:null,at:"open"}}if(v[1]){return{open:c(s,v[2]),close:u,at:"close"}}else{s=new b(q,w.line,w.ch,t);return{open:u,close:f(s,v[2]),at:"open"}}};i.findEnclosingTag=function(q,w,s){var r=new b(q,w.line,w.ch,s);for(;;){var u=c(r);if(!u){break}var t=new b(q,w.line,w.ch,s);var v=f(t,u.tag);if(v){return{open:u,close:v}}}};i.scanForClosingTag=function(q,u,t,s){var r=new b(q,u.line,u.ch,s?{from:0,to:s}:null);return f(r,t)}});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(a){if(!a.modeURL){a.modeURL="../mode/%N/%N.js"}var d={};function c(e,g){var f=g;return function(){if(--f==0){e()}}}function b(k,e){var j=a.modes[k].dependencies;if(!j){return e()}var h=[];for(var g=0;g100){return clearInterval(j)}if(a.modes.hasOwnProperty(k)){clearInterval(j);d[k]=null;b(k,function(){for(var l=0;l-1){o.string=m.slice(0,p)}var n=k.mode.token(o,f.inner);if(p>-1){o.string=m}if(k.innerStyle){if(n){n=n+" "+k.innerStyle}else{n=k.innerStyle}}return n}},indent:function(g,f){var h=g.innerActive?g.innerActive.mode:c;if(!h.indent){return a.Pass}return h.indent(g.innerActive?g.inner:g.outer,f)},blankLine:function(h){var j=h.innerActive?h.innerActive.mode:c;if(j.blankLine){j.blankLine(h.innerActive?h.inner:h.outer)}if(!h.innerActive){for(var g=0;g"],type:"keyToKey",toKeys:["h"]},{keys:[""],type:"keyToKey",toKeys:["l"]},{keys:[""],type:"keyToKey",toKeys:["k"]},{keys:[""],type:"keyToKey",toKeys:["j"]},{keys:[""],type:"keyToKey",toKeys:["l"]},{keys:[""],type:"keyToKey",toKeys:["h"]},{keys:[""],type:"keyToKey",toKeys:["W"]},{keys:[""],type:"keyToKey",toKeys:["B"]},{keys:[""],type:"keyToKey",toKeys:["w"]},{keys:[""],type:"keyToKey",toKeys:["b"]},{keys:[""],type:"keyToKey",toKeys:["j"]},{keys:[""],type:"keyToKey",toKeys:["k"]},{keys:[""],type:"keyToKey",toKeys:[""]},{keys:[""],type:"keyToKey",toKeys:[""]},{keys:["s"],type:"keyToKey",toKeys:["c","l"],context:"normal"},{keys:["s"],type:"keyToKey",toKeys:["x","i"],context:"visual"},{keys:["S"],type:"keyToKey",toKeys:["c","c"],context:"normal"},{keys:["S"],type:"keyToKey",toKeys:["d","c","c"],context:"visual"},{keys:[""],type:"keyToKey",toKeys:["0"]},{keys:[""],type:"keyToKey",toKeys:["$"]},{keys:[""],type:"keyToKey",toKeys:[""]},{keys:[""],type:"keyToKey",toKeys:[""]},{keys:[""],type:"keyToKey",toKeys:["j","^"],context:"normal"},{keys:["H"],type:"motion",motion:"moveToTopLine",motionArgs:{linewise:true,toJumplist:true}},{keys:["M"],type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:true,toJumplist:true}},{keys:["L"],type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:true,toJumplist:true}},{keys:["h"],type:"motion",motion:"moveByCharacters",motionArgs:{forward:false}},{keys:["l"],type:"motion",motion:"moveByCharacters",motionArgs:{forward:true}},{keys:["j"],type:"motion",motion:"moveByLines",motionArgs:{forward:true,linewise:true}},{keys:["k"],type:"motion",motion:"moveByLines",motionArgs:{forward:false,linewise:true}},{keys:["g","j"],type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:true}},{keys:["g","k"],type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:false}},{keys:["w"],type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:false}},{keys:["W"],type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:false,bigWord:true}},{keys:["e"],type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:true,inclusive:true}},{keys:["E"],type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:true,bigWord:true,inclusive:true}},{keys:["b"],type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:false}},{keys:["B"],type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:false,bigWord:true}},{keys:["g","e"],type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:true,inclusive:true}},{keys:["g","E"],type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:true,bigWord:true,inclusive:true}},{keys:["{"],type:"motion",motion:"moveByParagraph",motionArgs:{forward:false,toJumplist:true}},{keys:["}"],type:"motion",motion:"moveByParagraph",motionArgs:{forward:true,toJumplist:true}},{keys:[""],type:"motion",motion:"moveByPage",motionArgs:{forward:true}},{keys:[""],type:"motion",motion:"moveByPage",motionArgs:{forward:false}},{keys:[""],type:"motion",motion:"moveByScroll",motionArgs:{forward:true,explicitRepeat:true}},{keys:[""],type:"motion",motion:"moveByScroll",motionArgs:{forward:false,explicitRepeat:true}},{keys:["g","g"],type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:false,explicitRepeat:true,linewise:true,toJumplist:true}},{keys:["G"],type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:true,explicitRepeat:true,linewise:true,toJumplist:true}},{keys:["0"],type:"motion",motion:"moveToStartOfLine"},{keys:["^"],type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:["+"],type:"motion",motion:"moveByLines",motionArgs:{forward:true,toFirstChar:true}},{keys:["-"],type:"motion",motion:"moveByLines",motionArgs:{forward:false,toFirstChar:true}},{keys:["_"],type:"motion",motion:"moveByLines",motionArgs:{forward:true,toFirstChar:true,repeatOffset:-1}},{keys:["$"],type:"motion",motion:"moveToEol",motionArgs:{inclusive:true}},{keys:["%"],type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:true,toJumplist:true}},{keys:["f","character"],type:"motion",motion:"moveToCharacter",motionArgs:{forward:true,inclusive:true}},{keys:["F","character"],type:"motion",motion:"moveToCharacter",motionArgs:{forward:false}},{keys:["t","character"],type:"motion",motion:"moveTillCharacter",motionArgs:{forward:true,inclusive:true}},{keys:["T","character"],type:"motion",motion:"moveTillCharacter",motionArgs:{forward:false}},{keys:[";"],type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:true}},{keys:[","],type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:false}},{keys:["'","character"],type:"motion",motion:"goToMark",motionArgs:{toJumplist:true,linewise:true}},{keys:["`","character"],type:"motion",motion:"goToMark",motionArgs:{toJumplist:true}},{keys:["]","`"],type:"motion",motion:"jumpToMark",motionArgs:{forward:true}},{keys:["[","`"],type:"motion",motion:"jumpToMark",motionArgs:{forward:false}},{keys:["]","'"],type:"motion",motion:"jumpToMark",motionArgs:{forward:true,linewise:true}},{keys:["[","'"],type:"motion",motion:"jumpToMark",motionArgs:{forward:false,linewise:true}},{keys:["]","p"],type:"action",action:"paste",isEdit:true,actionArgs:{after:true,isEdit:true,matchIndent:true}},{keys:["[","p"],type:"action",action:"paste",isEdit:true,actionArgs:{after:false,isEdit:true,matchIndent:true}},{keys:["]","character"],type:"motion",motion:"moveToSymbol",motionArgs:{forward:true,toJumplist:true}},{keys:["[","character"],type:"motion",motion:"moveToSymbol",motionArgs:{forward:false,toJumplist:true}},{keys:["|"],type:"motion",motion:"moveToColumn",motionArgs:{}},{keys:["o"],type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{},context:"visual"},{keys:["O"],type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:true},context:"visual"},{keys:["d"],type:"operator",operator:"delete"},{keys:["y"],type:"operator",operator:"yank"},{keys:["c"],type:"operator",operator:"change"},{keys:[">"],type:"operator",operator:"indent",operatorArgs:{indentRight:true}},{keys:["<"],type:"operator",operator:"indent",operatorArgs:{indentRight:false}},{keys:["g","~"],type:"operator",operator:"swapcase"},{keys:["n"],type:"motion",motion:"findNext",motionArgs:{forward:true,toJumplist:true}},{keys:["N"],type:"motion",motion:"findNext",motionArgs:{forward:false,toJumplist:true}},{keys:["x"],type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:true},operatorMotionArgs:{visualLine:false}},{keys:["X"],type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:false},operatorMotionArgs:{visualLine:true}},{keys:["D"],type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:true},operatorMotionArgs:{visualLine:true}},{keys:["Y"],type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:true},operatorMotionArgs:{visualLine:true}},{keys:["C"],type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:true},operatorMotionArgs:{visualLine:true}},{keys:["~"],type:"operatorMotion",operator:"swapcase",operatorArgs:{shouldMoveCursor:true},motion:"moveByCharacters",motionArgs:{forward:true}},{keys:[""],type:"action",action:"jumpListWalk",actionArgs:{forward:true}},{keys:[""],type:"action",action:"jumpListWalk",actionArgs:{forward:false}},{keys:[""],type:"action",action:"scroll",actionArgs:{forward:true,linewise:true}},{keys:[""],type:"action",action:"scroll",actionArgs:{forward:false,linewise:true}},{keys:["a"],type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"charAfter"}},{keys:["A"],type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"eol"}},{keys:["A"],type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:["i"],type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"inplace"}},{keys:["I"],type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"firstNonBlank"}},{keys:["o"],type:"action",action:"newLineAndEnterInsertMode",isEdit:true,interlaceInsertRepeat:true,actionArgs:{after:true}},{keys:["O"],type:"action",action:"newLineAndEnterInsertMode",isEdit:true,interlaceInsertRepeat:true,actionArgs:{after:false}},{keys:["v"],type:"action",action:"toggleVisualMode"},{keys:["V"],type:"action",action:"toggleVisualMode",actionArgs:{linewise:true}},{keys:[""],type:"action",action:"toggleVisualMode",actionArgs:{blockwise:true}},{keys:["g","v"],type:"action",action:"reselectLastSelection"},{keys:["J"],type:"action",action:"joinLines",isEdit:true},{keys:["p"],type:"action",action:"paste",isEdit:true,actionArgs:{after:true,isEdit:true}},{keys:["P"],type:"action",action:"paste",isEdit:true,actionArgs:{after:false,isEdit:true}},{keys:["r","character"],type:"action",action:"replace",isEdit:true},{keys:["@","character"],type:"action",action:"replayMacro"},{keys:["q","character"],type:"action",action:"enterMacroRecordMode"},{keys:["R"],type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{replace:true}},{keys:["u"],type:"action",action:"undo"},{keys:["u"],type:"action",action:"changeCase",actionArgs:{toLower:true},context:"visual",isEdit:true},{keys:["U"],type:"action",action:"changeCase",actionArgs:{toLower:false},context:"visual",isEdit:true},{keys:[""],type:"action",action:"redo"},{keys:["m","character"],type:"action",action:"setMark"},{keys:['"',"character"],type:"action",action:"setRegister"},{keys:["z","z"],type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:["z","."],type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:["z","t"],type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:["z",""],type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:["z","-"],type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:["z","b"],type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:["."],type:"action",action:"repeatLastEdit"},{keys:[""],type:"action",action:"incrementNumberToken",isEdit:true,actionArgs:{increase:true,backtrack:false}},{keys:[""],type:"action",action:"incrementNumberToken",isEdit:true,actionArgs:{increase:false,backtrack:false}},{keys:["a","character"],type:"motion",motion:"textObjectManipulation"},{keys:["i","character"],type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:true}},{keys:["/"],type:"search",searchArgs:{forward:true,querySrc:"prompt",toJumplist:true}},{keys:["?"],type:"search",searchArgs:{forward:false,querySrc:"prompt",toJumplist:true}},{keys:["*"],type:"search",searchArgs:{forward:true,querySrc:"wordUnderCursor",wholeWordOnly:true,toJumplist:true}},{keys:["#"],type:"search",searchArgs:{forward:false,querySrc:"wordUnderCursor",wholeWordOnly:true,toJumplist:true}},{keys:["g","*"],type:"search",searchArgs:{forward:true,querySrc:"wordUnderCursor",toJumplist:true}},{keys:["g","#"],type:"search",searchArgs:{forward:false,querySrc:"wordUnderCursor",toJumplist:true}},{keys:[":"],type:"ex"}];var c=b.Pos;var d=function(){b.defineOption("vimMode",false,function(bg,bh){if(bh){bg.setOption("keyMap","vim");bg.setOption("disableInput",true);bg.setOption("showCursorWhenSelecting",false);b.signal(bg,"vim-mode-change",{mode:"normal"});bg.on("cursorActivity",Q);B(bg);b.on(bg.getInputField(),"paste",L(bg))}else{if(bg.state.vim){bg.setOption("keyMap","default");bg.setOption("disableInput",false);bg.off("cursorActivity",Q);b.off(bg.getInputField(),"paste",L(bg));bg.state.vim=null}}});function L(bg){var bh=bg.state.vim;if(!bh.onPasteFn){bh.onPasteFn=function(){if(!bh.insertMode){bg.setCursor(y(bg.getCursor(),0,1));o.enterInsertMode(bg,{},bh)}}}return bh.onPasteFn}var aL=/[\d]/;var ah=[(/\w/),(/[^\w\s]/)],a6=[(/\S/)];function ag(bj,bh){var bi=[];for(var bg=bj;bg"]);var k=[].concat(W,ad,M,["-",'"',".",":","/"]);function e(bg,bh){return bh>=bg.firstLine()&&bh<=bg.lastLine()}function z(bg){return(/^[a-z]$/).test(bg)}function G(bg){return"()[]{}".indexOf(bg)!=-1}function V(bg){return aL.test(bg)}function v(bg){return(/^[A-Z]$/).test(bg)}function J(bg){return(/^\s*$/).test(bg)}function E(bi,bg){for(var bh=0;bhbj){bm=bj}else{if(bm0?1:-1;var bp;var bo=bn.getCursor();do{bm+=bq;bs=bh[(bk+bm)%bk];if(bs&&(bp=bs.find())&&!be(bo,bp)){break}}while(bmbi)}return bs}return{cachedCursor:undefined,add:bl,move:bg}};var g=function(bg){if(bg){return{changes:bg.changes,expectCursorActivityForChange:bg.expectCursorActivityForChange}}return{changes:[],expectCursorActivityForChange:false}};function am(){this.latestRegister=undefined;this.isPlaying=false;this.isRecording=false;this.replaySearchQueries=[];this.onRecordingDone=undefined;this.lastInsertModeChanges=g()}am.prototype={exitMacroRecordMode:function(){var bg=p.macroModeState;if(bg.onRecordingDone){bg.onRecordingDone()}bg.onRecordingDone=undefined;bg.isRecording=false},enterMacroRecordMode:function(bg,bi){var bh=p.registerController.getRegister(bi);if(bh){bh.clear();this.latestRegister=bi;if(bg.openDialog){this.onRecordingDone=bg.openDialog("(recording)["+bi+"]",null,{bottom:true})}this.isRecording=true}}};function B(bg){if(!bg.state.vim){bg.state.vim={inputState:new ao(),lastEditInputState:undefined,lastEditActionCommand:undefined,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:false,insertModeRepeat:undefined,visualMode:false,visualLine:false,visualBlock:false,lastSelection:null,lastPastedText:null,awaitingEscapeSecondCharacter:false}}return bg.state.vim}var p;function u(){p={searchQuery:null,searchIsReversed:false,lastSubstituteReplacePart:undefined,jumpList:af(),macroModeState:new am,lastChararacterSearch:{increment:0,forward:true,selectedCharacter:""},registerController:new Y({}),searchHistoryController:new aQ({}),exCommandHistoryController:new aQ({})};for(var bg in aj){var bh=aj[bg];bh.value=bh.defaultValue}}var aD={buildKeyMap:function(){},getRegisterController:function(){return p.registerController},resetVimGlobalState_:u,getVimGlobalState_:function(){return p},maybeInitVimState_:B,InsertModeKey:a3,map:function(bh,bi,bg){l.map(bh,bi,bg)},setOption:ax,getOption:n,defineOption:az,defineEx:function(bg,bi,bh){if(bg.indexOf(bi)!==0){throw new Error('(Vim.defineEx) "'+bi+'" is not a prefix of "'+bg+'", command not registered')}aR[bg]=bh;l.commandMap_[bi]={name:bg,shortName:bi,type:"api"}},handleKey:function(bg,bj){var bl;var bh=B(bg);var bk=p.macroModeState;if(bk.isRecording){if(bj=="q"){bk.exitMacroRecordMode();i(bg);return}}if(bj==""){i(bg);if(bh.visualMode){aG(bg)}return}if(!bh.visualMode&&!be(bg.getCursor("head"),bg.getCursor("anchor"))){bh.visualMode=true;bh.visualLine=false;b.signal(bg,"vim-mode-change",{mode:"visual"});bg.on("mousedown",aG)}if(bj!="0"||(bj=="0"&&bh.inputState.getRepeat()===0)){bl=aW.matchCommand(bj,a,bh)}if(!bl){if(V(bj)){bh.inputState.pushRepeatDigit(bj)}if(bk.isRecording){D(bk,bj)}return}if(bl.type=="keyToKey"){for(var bi=0;bi0||this.motionRepeat.length>0){bg=1;if(this.prefixRepeat.length>0){bg*=parseInt(this.prefixRepeat.join(""),10)}if(this.motionRepeat.length>0){bg*=parseInt(this.motionRepeat.join(""),10)}}return bg};function i(bg,bh){bg.state.vim.inputState=new ao();b.signal(bg,"vim-command-done",bh)}function a7(bi,bh,bg){this.clear();this.keyBuffer=[bi||""];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!!bh;this.blockwise=!!bg}a7.prototype={setText:function(bi,bh,bg){this.keyBuffer=[bi||""];this.linewise=!!bh;this.blockwise=!!bg},pushText:function(bh,bg){if(bg){if(!this.linewise){this.keyBuffer.push("\n")}this.linewise=true}this.keyBuffer.push(bh)},pushInsertModeChanges:function(bg){this.insertModeChanges.push(g(bg))},pushSearchQuery:function(bg){this.searchQueries.push(bg)},clear:function(){this.keyBuffer=[];this.insertModeChanges=[];this.searchQueries=[];this.linewise=false},toString:function(){return this.keyBuffer.join("")}};function Y(bg){this.registers=bg;this.unnamedRegister=bg['"']=new a7();bg["."]=new a7();bg[":"]=new a7();bg["/"]=new a7()}Y.prototype={pushText:function(bk,bh,bm,bl,bi){if(bl&&bm.charAt(0)=="\n"){bm=bm.slice(1)+"\n"}if(bl&&bm.charAt(bm.length-1)!=="\n"){bm+="\n"}var bj=this.isValidRegister(bk)?this.getRegister(bk):null;if(!bj){switch(bh){case"yank":this.registers["0"]=new a7(bm,bl,bi);break;case"delete":case"change":if(bm.indexOf("\n")==-1){this.registers["-"]=new a7(bm,bl)}else{this.shiftNumericRegisters_();this.registers["1"]=new a7(bm,bl)}break}this.unnamedRegister.setText(bm,bl,bi);return}var bg=v(bk);if(bg){bj.pushText(bm,bl)}else{bj.setText(bm,bl,bi)}this.unnamedRegister.setText(bj.toString(),bl)},getRegister:function(bg){if(!this.isValidRegister(bg)){return this.unnamedRegister}bg=bg.toLowerCase();if(!this.registers[bg]){this.registers[bg]=new a7()}return this.registers[bg]},isValidRegister:function(bg){return bg&&E(bg,k)},shiftNumericRegisters_:function(){for(var bg=9;bg>=2;bg--){this.registers[bg]=this.getRegister(""+(bg-1))}}};function aQ(){this.historyBuffer=[];this.iterator;this.initialPrefix=null}aQ.prototype={nextMatch:function(bh,bg){var bm=this.historyBuffer;var bj=bg?-1:1;if(this.initialPrefix===null){this.initialPrefix=bh}for(var bl=this.iterator+bj;bg?bl>=0:bl=bm.length){this.iterator=bm.length;return this.initialPrefix}if(bl<0){return bh}},pushInput:function(bg){var bh=this.historyBuffer.indexOf(bg);if(bh>-1){this.historyBuffer.splice(bh,1)}if(bg.length){this.historyBuffer.push(bg)}},reset:function(){this.initialPrefix=null;this.iterator=this.historyBuffer.length}};var aW={matchCommand:function(br,bq,bj){var bn=bj.inputState;var bs=bn.keyBuffer.concat(br);var bm=[];var bg;for(var bk=0;bk1){switch(bg){case"":bg="\n";break;case"":bg=" ";break;default:continue}}}bm.push(bi)}}function bp(bt){if(bs.length",onKeyDown:bi})}else{aO(bg,{onClose:bj,prefix:":",onKeyDown:bi})}}},evalInput:function(bp,bG){var bv=bG.inputState;var bD=bv.motion;var bw=bv.motionArgs||{};var bq=bv.operator;var bM=bv.operatorArgs||{};var bx=bv.registerName;var bh=x(bp.getCursor("head"));var bE=x(bp.getCursor("anchor"));var bn=x(bh);var bu=x(bn);var bH;var br;if(bq){this.recordLastEdit(bG,bv)}if(bv.repeatOverride!==undefined){br=bv.repeatOverride}else{br=bv.getRepeat()}if(br>0&&bw.explicitRepeat){bw.repeatIsExplicit=true}else{if(bw.noRepeat||(!bw.explicitRepeat&&br===0)){br=1;bw.repeatIsExplicit=false}}if(bv.selectedCharacter){bw.selectedCharacter=bM.selectedCharacter=bv.selectedCharacter}bw.repeat=br;i(bp);if(bD){var bF=aP[bD](bp,bw,bG);bG.lastMotion=aP[bD];if(!bF){return}if(bw.toJumplist){var bL=p.jumpList;var bs=bL.cachedCursor;if(bs){a0(bp,bs,bF);delete bL.cachedCursor}else{a0(bp,bu,bF)}}if(bF instanceof Array){bn=bF[0];bH=bF[1]}else{bH=bF}if(!bH){bH=c(bn.line,bn.ch)}if(bG.visualMode){var bl=0;if(aC(bE,bh)&&(be(bE,bH)||aC(bH,bE))){bE.ch+=1;bl=-1}else{if(aC(bh,bE)&&(be(bE,bH)||aC(bE,bH))){bE.ch-=1;bl=1}}if(!bG.visualBlock&&!(bF instanceof Array)){bH.ch+=bl}if(bG.lastHPos!=Infinity){bG.lastHPos=bH.ch}bh=bH;bE=(bF instanceof Array)?bn:bE;if(bG.visualLine){if(aC(bE,bh)){bE.ch=0;var bg=bp.lastLine();if(bh.line>bg){bh.line=bg}bh.ch=aJ(bp,bh.line)}else{bh.ch=0;bE.ch=aJ(bp,bE.line)}}else{if(bG.visualBlock){bE=A(bp,bh)}}if(!bG.visualBlock){bp.setSelection(bE,bh)}aF(bp,bG,"<",aC(bE,bh)?bE:bh);aF(bp,bG,">",aC(bE,bh)?bh:bE)}else{if(!bq){bH=P(bp,bH);bp.setCursor(bH.line,bH.ch)}}}if(bq){var bA=false;bG.lastMotion=null;var bt=bG.lastSelection;bM.repeat=br;if(bG.visualMode){bn=bE;bH=bh;bw.inclusive=true;bM.shouldMoveCursor=false}if(bH&&aC(bH,bn)){var bK=bn;bn=bH;bH=bK;bA=true}else{if(!bH){bH=x(bn)}}if(bw.inclusive&&!bG.visualMode){bH.ch++}if(bM.selOffset){bH.line=bn.line+bM.selOffset.line;if(bM.selOffset.line){bH.ch=bM.selOffset.ch}else{bH.ch=bn.ch+bM.selOffset.ch}if(bt&&bt.visualBlock){var bo=bt.visualBlock;var bC=bo.width;var bB=bo.height;bH=c(bn.line+bB,bn.ch+bC);var bi=[];for(var bI=bn.line;bIbm&&bn.line==bm)){return}if(bh.toFirstChar){bj=aN(bl.getLine(bo));bi.lastHPos=bj}bi.lastHSPos=bl.charCoords(c(bo,bj),"div").left;return c(bo,bj)},moveByDisplayLines:function(bn,bi,bj){var bo=bn.getCursor();switch(bj.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:bj.lastHSPos=bn.charCoords(bo,"div").left}var bg=bi.repeat;var bm=bn.findPosV(bo,(bi.forward?bg:-bg),"line",bj.lastHSPos);if(bm.hitSide){if(bi.forward){var bh=bn.charCoords(bm,"div");var bk={top:bh.top+8,left:bj.lastHSPos};var bm=bn.coordsChar(bk,"div")}else{var bl=bn.charCoords(c(bn.firstLine(),0),"div");bl.left=bj.lastHSPos;bm=bn.coordsChar(bl,"div")}}bj.lastHPos=bm.ch;return bm},moveByPage:function(bh,bi){var bg=bh.getCursor();var bj=bi.repeat;return bh.findPosV(bg,(bi.forward?bj:-bj),"page")},moveByParagraph:function(bg,bi){var bh=bg.getCursor().line;var bk=bi.repeat;var bl=bi.forward?1:-1;for(var bj=0;bj"]?bt.marks[">"].find():bp.getCursor("head");p.registerController.pushText(bx.registerName,"change",bq,bx.linewise);if(bx.linewise){if(bw){var bu=bo.line;while(bu<=bv.line){var br=aJ(bp,bu);var bl=c(bu,br);var bm=c(bu,bo.ch);bu++;bp.replaceRange("",bm,bl)}}else{bs="\n";if(bv.line==bo.line&&bv.line==bp.lastLine()){bs=""}bp.replaceRange(bs,bo,bv);bp.indentLine(bo.line,"smart");bo.ch=null;bp.setCursor(bo)}}else{var bq=bp.getRange(bo,bv);if(!J(bq)){var bn=(/\s+$/).exec(bq);if(bn){bv=y(bv,0,-bn[0].length)}}if(bw){bp.replaceSelections(bs)}else{bp.setCursor(bo);bp.replaceRange("",bo,bv)}}bt.marks[">"]=bp.setBookmark(bg);o.enterInsertMode(bp,{},bp.state.vim)},"delete":function(bs,bl,bn){var bj=bs.listSelections();var bi=bj[0],bm=bj[bj.length-1];var bp=aC(bi.anchor,bi.head)?bi.anchor:bi.head;var bt=aC(bm.anchor,bm.head)?bm.head:bm.anchor;var bv,br;var bq=bn.visualBlock;if(bn.visualMode){bv=bn.marks[">"].find();br=bn.marks["<"].find()}else{if(bn.lastSelection){bv=bn.lastSelection.curStartMark.find();br=bn.lastSelection.curEndMark.find();bq=bn.lastSelection.visualBlock}}var bu=bs.getSelection();p.registerController.pushText(bl.registerName,"delete",bu,bl.linewise,bq);var bk=new Array(bj.length).join("1").split("1");if(bl.linewise&&bt.line==bs.lastLine()&&bp.line==bt.line){var bo=x(bt);bp.line--;bp.ch=aJ(bs,bp.line);bt=bo;bs.replaceRange("",bp,bt)}else{bs.replaceSelections(bk)}if(bv){var bh=bs.setBookmark(br);var bg=bs.setBookmark(bv);if(bn.visualMode){bn.marks["<"]=bh;bn.marks[">"]=bg}else{bn.lastSelection.curStartMark=bh;bn.lastSelection.curEndMark=bg}}if(bl.linewise){bs.setCursor(aP.moveToFirstNonWhiteSpaceCharacter(bs))}else{bs.setCursor(bp)}},indent:function(bn,bi,bk,bm,bo){var bp=bm.line;var bh=bo.line;var bg=(bk.visualMode)?bi.repeat:1;if(bi.linewise){bh--}for(var bl=bp;bl<=bh;bl++){for(var bj=0;bjbj.top){bq.line+=(bl-bj.top)/bn;bq.line=Math.ceil(bq.line);bo.setCursor(bq);bj=bo.charCoords(bq,"local");bo.scrollTo(null,bj.top)}else{bo.scrollTo(null,bl)}}else{var bh=bl+bo.getScrollInfo().clientHeight;if(bh",aC(bg,bl)?bl:bg)},reselectLastSelection:function(bm,bi,bh){var bj=bh.marks["<"].find();var bn=bh.marks[">"].find();var bg=bh.lastSelection;if(bg){var bl=bg.curStartMark.find();var bo=bg.curEndMark.find();var bk=bg.visualBlock;aZ(bm,bh,bj,bn);if(bk){bm.setCursor(bl);bl=A(bm,bo)}else{bm.setSelection(bl,bo);bl=bm.getCursor("anchor");bo=bm.getCursor("head")}if(bh.visualMode){aF(bm,bh,"<",aC(bl,bo)?bl:bo);aF(bm,bh,">",aC(bl,bo)?bo:bl)}bh.visualMode=true;if(bg.visualLine){bh.visualLine=true;bh.visualBlock=false}else{if(bg.visualBlock){bh.visualLine=false;bh.visualBlock=true}else{bh.visualBlock=bh.visualLine=false}}b.signal(bm,"vim-mode-change",{mode:"visual",subMode:bh.visualLine?"linewise":""})}},joinLines:function(bh,bi,bj){var bg,bl;if(bj.visualMode){bg=bh.getCursor("anchor");bl=bh.getCursor("head");bl.ch=aJ(bh,bl.line)-1}else{var bk=Math.max(bi.repeat,2);bg=bh.getCursor();bl=P(bh,c(bg.line+bk-1,Infinity))}var bm=0;bh.operation(function(){for(var bp=bg.line;bp1){var bx=Array(bt.repeat+1).join(bx)}var bq=bh.linewise;var bs=bh.blockwise;if(bq){if(bB.visualMode){bx=bB.visualLine?bx.slice(0,-1):"\n"+bx.slice(0,bx.length-1)+"\n"}else{if(bt.after){bx="\n"+bx.slice(0,bx.length-1);bn.ch=aJ(bu,bn.line)}else{bn.ch=0}}}else{if(bs){bx=bx.split("\n");for(var bC=0;bCbu.lastLine()){bu.replaceRange("\n",c(bv,0))}var bE=aJ(bu,bv);if(bEbq.length){bm=bq.length}bp=c(bn.line,bm)}if(bj=="\n"){if(!bk.visualMode){bo.replaceRange("",bn,bp)}(b.commands.newlineAndIndentContinueComment||b.commands.newlineAndIndent)(bo)}else{var bg=bo.getRange(bn,bp);bg=bg.replace(/[^\n]/g,bj);if(bk.visualBlock){var bl=new Array(bo.options.tabSize+1).join(" ");bg=bo.getSelection();bg=bg.replace(/\t/g,bl).replace(/[^\n]/g,bj).split("\n");bo.replaceSelections(bg)}else{bo.replaceRange(bg,bn,bp)}if(bk.visualMode){bn=aC(bh[0].anchor,bh[0].head)?bh[0].anchor:bh[0].head;bo.setCursor(bn);aG(bo)}else{bo.setCursor(y(bp,0,-1))}}},incrementNumberToken:function(bq,bh){var br=bq.getCursor();var bm=bq.getLine(br.line);var bt=/-?\d+/g;var bl;var bg;var bk;var bs;var bi;while((bl=bt.exec(bm))!==null){bi=bl[0];bg=bl.index;bk=bg+bi.length;if(br.chbv.line){bw="down"}else{if(bh.ch!=bv.ch){bw=bh.ch>bv.ch?"right":"left"}bu=br.getCursor("anchor")}}var bx=q(bi,bv);bh=br.clipPos(bh);var bs=q(bi,bh)<0?false:true;var by=!be(bo,bh);var bj=function(){if(by){if(bv.ch>=bu.ch){bu.ch++}}else{if(bv.ch==aJ(br,bv.line)){if(be(bi[bx].anchor,bi[bx].head)&&bi.length>1){if(bw=="up"){if(bs||bx>0){bm=bp.line;bk=bh.line;bu=bi[bx-1].anchor}}else{if(bs||bx==0){bk=bg.line;bm=bh.line;bu=bi[bx+1].anchor}}if(bh.ch>=bu.ch){bu.ch--}}}}};switch(bw){case"up":bm=bs?bp.line:bh.line;bk=bs?bh.line:bg.line;bu=bg;bj();break;case"down":bm=bs?bh.line:bp.line;bk=bs?bg.line:bh.line;bu=bp;bj();break;case"left":if((bh.ch<=bu.ch)&&(bv.ch>bu.ch)){bu.ch++;bh.ch--}break;case"right":if((bu.ch<=bh.ch)&&(bv.ch"].find()||bm.getCursor("head")}if(bk.lastPastedText){bn=bm.posFromIndex(bm.indexFromPos(bl)+bk.lastPastedText.length);bk.lastPastedText=null}var bg=bm.listSelections();var bi=q(bg,bl,"head")>-1;if(bk.visualBlock){var bo=Math.abs(bl.line-bn.line)+1;var bh=Math.abs(bl.ch-bn.ch);var bj={height:bo,width:bh}}bk.lastSelection={curStartMark:bm.setBookmark(bi?bn:bl),curEndMark:bm.setBookmark(bi?bl:bn),visualMode:bk.visualMode,visualLine:bk.visualLine,visualBlock:bj}}function aG(bg){bg.off("mousedown",aG);var bh=bg.state.vim;var bi=bg.getCursor("anchor");var bj=bg.getCursor("head");if(bh.visualBlock&&(aC(bi,bj))){bj.ch--}aZ(bg,bh);bh.visualMode=false;bh.visualLine=false;bh.visualBlock=false;if(!be(bi,bj)){bg.setCursor(P(bg,bj))}b.signal(bg,"vim-mode-change",{mode:"normal"});if(bh.fakeCursor){bh.fakeCursor.clear()}}function ac(bh,bg,bl){var bk=bh.getRange(bg,bl);if(/\n\s*$/.test(bk)){var bj=bk.split("\n");bj.pop();var bi;for(var bi=bj.pop();bj.length>0&&bi&&J(bi);bi=bj.pop()){bl.line--;bl.ch=0}if(bi){bl.line--;bl.ch=aJ(bh,bl.line)}else{bl.ch=0}}}function aY(bh,bg,bi){bg.ch=0;bi.ch=0;bi.line++}function aN(bh){if(!bh){return 0}var bg=bh.search(/\S/);return bg==-1?bh.length:bg}function at(bp,bl,bz,bh,bA){var bj=bp.getCursor();var bs=bp.getLine(bj.line);var bv=bj.ch;var bu=bs.substring(bv);var bw;if(bA){bw=bu.search(/\w/)}else{bw=bu.search(/\S/)}if(bw==-1){return null}bv+=bw;bu=bs.substring(bv);var by=bs.substring(0,bv);var bB;if(bh){bB=/^\S+/}else{if((/\w/).test(bs.charAt(bv))){bB=/^\w+/}else{bB=/^[^\w\s]+/}}var bm=bB.exec(bu);var bt=bv;var bi=bv+bm[0].length;var bk=j(by);var bq=bB.exec(bk);if(bq){bt-=bq[0].length}if(bl){var br=bs.substring(bi);var bg=br.match(/^\s*/)[0].length;if(bg>0){bi+=bg}else{var bo=bk.length-bt;var bn=bk.substring(bo);var bx=bn.match(/^\s*/)[0].length;bt-=bx}}return{start:c(bj.line,bt),end:c(bj.line,bi)}}function a0(bg,bh,bi){if(!be(bh,bi)){p.jumpList.add(bg,bh,bi)}}function aq(bg,bh){p.lastChararacterSearch.increment=bg;p.lastChararacterSearch.forward=bh.forward;p.lastChararacterSearch.selectedCharacter=bh.selectedCharacter}var K={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"};var aM={bracket:{isComplete:function(bg){if(bg.nextCh===bg.symb){bg.depth++;if(bg.depth>=1){return true}}else{if(bg.nextCh===bg.reverseSymb){bg.depth--}}return false}},section:{init:function(bg){bg.curMoveThrough=true;bg.symb=(bg.forward?"]":"[")===bg.symb?"{":"}"},isComplete:function(bg){return bg.index===0&&bg.nextCh===bg.symb}},comment:{isComplete:function(bh){var bg=bh.lastCh==="*"&&bh.nextCh==="/";bh.lastCh=bh.nextCh;return bg}},method:{init:function(bg){bg.symb=(bg.symb==="m"?"{":"}");bg.reverseSymb=bg.symb==="{"?"}":"{"},isComplete:function(bg){if(bg.nextCh===bg.symb){return true}return false}},preprocess:{init:function(bg){bg.index=0},isComplete:function(bh){if(bh.nextCh==="#"){var bg=bh.lineText.match(/#(\w+)/)[1];if(bg==="endif"){if(bh.forward&&bh.depth===0){return true}bh.depth++}else{if(bg==="if"){if(!bh.forward&&bh.depth===0){return true}bh.depth--}}if(bg==="else"&&bh.depth===0){return true}}return false}}};function ba(bp,bh,bk,bi){var bs=x(bp.getCursor());var bq=bk?1:-1;var bj=bk?bp.lineCount():-1;var bo=bs.ch;var bu=bs.line;var bn=bp.getLine(bu);var bg={lineText:bn,nextCh:bn.charAt(bo),lastCh:null,index:bo,symb:bi,reverseSymb:(bk?{")":"(","}":"{"}:{"(":")","{":"}"})[bi],forward:bk,depth:0,curMoveThrough:false};var bl=K[bi];if(!bl){return bs}var bt=aM[bl].init;var br=aM[bl].isComplete;if(bt){bt(bg)}while(bu!==bj&&bh){bg.index+=bq;bg.nextCh=bg.lineText.charAt(bg.index);if(!bg.nextCh){bu+=bq;bg.lineText=bp.getLine(bu)||"";if(bq>0){bg.index=0}else{var bm=bg.lineText.length;bg.index=(bm>0)?(bm-1):0}bg.nextCh=bg.lineText.charAt(bg.index)}if(br(bg)){bs.line=bu;bs.ch=bg.index;bh--}}if(bg.nextCh||bg.curMoveThrough){return c(bu,bg.index)}return bs}function bc(bq,br,bj,bo,bp){var bk=br.line;var bn=br.ch;var bu=bq.getLine(bk);var bh=bj?1:-1;var bl=bo?a6:ah;if(bp&&bu==""){bk+=bh;bu=bq.getLine(bk);if(!e(bq,bk)){return null}bn=(bj)?0:bu.length}while(true){if(bp&&bu==""){return{from:0,to:0,line:bk}}var bm=(bh>0)?bu.length:-1;var bt=bm,bs=bm;while(bn!=bm){var bg=false;for(var bi=0;bi0)?0:bu.length}throw new Error("The impossible happened.")}function ap(bq,bh,bl,bu,bo){var bs=bq.getCursor();var bm=x(bs);var bn=[];if(bl&&!bu||!bl&&bu){bh++}var bp=!(bl&&bu);for(var bj=0;bjbk.ch)||(bh.line>bk.line)){var bm=bh;bh=bk;bk=bm}if(bo){bk.ch+=1}else{bh.ch+=1}return{start:bh,end:bk}}function aE(bo,bi,bn){var bp=x(bo.getCursor());var bq=bo.getLine(bp.line);var bm=bq.split("");var bh,bj,bk,bl;var bg=bm.indexOf(bi);if(bp.ch-1&&!bh;bk--){if(bm[bk]==bi){bh=bk+1}}}if(bh&&!bj){for(bk=bh,bl=bm.length;bk'+bh+"",{bottom:true,duration:5000})}else{alert(bh)}}function av(bh,bi){var bg="";if(bh){bg+=''+bh+""}bg+=' ';if(bi){bg+='';bg+=bi;bg+=""}return bg}var I="(Javascript regexp)";function aO(bh,bi){var bj=(bi.prefix||"")+" "+(bi.desc||"");var bg=av(bi.prefix,bi.desc);R(bh,bg,bj,bi.onClose,bi)}function O(bh,bg){if(bh instanceof RegExp&&bg instanceof RegExp){var bj=["global","multiline","ignoreCase","source"];for(var bi=0;bi=bh&&bi<=bg)}else{return bi==bh}}}function aX(bg){var bj=bg.getScrollInfo();var bi=6;var bm=10;var bl=bg.coordsChar({left:0,top:bi+bj.top},"local");var bh=bj.clientHeight-bm+bj.top;var bk=bg.coordsChar({left:0,top:bh},"local");return{top:bl.line,bottom:bk.line}}var w=[{name:"map"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"set"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:true},{name:"nohlsearch",shortName:"noh"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:true},{name:"global",shortName:"g"}];d.ExCommandDispatcher=function(){this.buildCommandMap_()};d.ExCommandDispatcher.prototype={processCommand:function(br,bq,bh){var bl=br.state.vim;var bi=p.registerController.getRegister(":");var bo=bi.toString();if(bl.visualMode){aG(br)}var bg=new b.StringStream(bq);bi.setText(bq);var bk=bh||{};bk.input=bq;try{this.parseInput_(br,bg,bk)}catch(bp){a4(br,bp);throw bp}var bj;var bn;if(!bk.commandName){if(bk.line!==undefined){bn="move"}}else{bj=this.matchCommand_(bk.commandName);if(bj){bn=bj.name;if(bj.excludeFromCommandHistory){bi.setText(bo)}this.parseCommandArgs_(bg,bk,bj);if(bj.type=="exToKey"){for(var bm=0;bm0;bg--){var bi=bh.substring(0,bg);if(this.commandMap_[bi]){var bj=this.commandMap_[bi];if(bj.name.indexOf(bh)===0){return bj}}}return null},buildCommandMap_:function(){this.commandMap_={};for(var bh=0;bh|<\w+>|./).exec(bj);if(bg===null){break}bh=bg[0];bj=bj.substring(bg.index+bh.length);bi.push(bh)}return bi}var aR={map:function(bg,bj,bh){var bi=bj.args;if(!bi||bi.length<2){if(bg){a4(bg,"Invalid mapping: "+bj.input)}return}l.map(bi[0],bi[1],bh)},nmap:function(bg,bh){this.map(bg,bh,"normal")},vmap:function(bg,bh){this.map(bg,bh,"visual")},unmap:function(bg,bj,bh){var bi=bj.args;if(!bi||bi.length<1){if(bg){a4(bg,"No such mapping: "+bj.input)}return}l.unmap(bi[0],bh)},move:function(bg,bh){aW.processCommand(bg,bg.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:false,explicitRepeat:true,linewise:true},repeatOverride:bh.line+1})},set:function(bo,bl){var bi=bl.args;if(!bi||bi.length<1){if(bo){a4(bo,"Invalid mapping: "+bl.input)}return}var bm=bi[0].split("=");var bh=bm[0];var bn=bm[1];var bk=false;if(bh.charAt(bh.length-1)=="?"){if(bn){throw Error("Trailing characters: "+bl.argString)}bh=bh.substring(0,bh.length-1);bk=true}if(bn===undefined&&bh.substring(0,2)=="no"){bh=bh.substring(2);bn=false}var bj=aj[bh]&&aj[bh].type=="boolean";if(bj&&bn==undefined){bn=true}if(!bj&&!bn||bk){var bg=n(bh);if(bg===true||bg===false){a4(bo," "+(bg?"":"no")+bh)}else{a4(bo," "+bh+"="+bg)}}else{ax(bh,bn)}},registers:function(bl,bh){var bn=bh.args;var bk=p.registerController.registers;var bi="----------Registers----------

";if(!bn){for(var bg in bk){var bo=bk[bg].toString();if(bo.length){bi+='"'+bg+" "+bo+"
"}}}else{var bg;bn=bn.join("");for(var bj=0;bj"}}a4(bl,bi)},sort:function(bp,bz){var bq,bj,bh,bi;function bk(){if(bz.argString){var bD=new b.StringStream(bz.argString);if(bD.eat("!")){bq=true}if(bD.eol()){return}if(!bD.eatSpace()){return"Invalid arguments"}var bF=bD.match(/[a-z]+/);if(bF){bF=bF[0];bj=bF.indexOf("i")!=-1;bh=bF.indexOf("u")!=-1;var bC=bF.indexOf("d")!=-1&&1;var bE=bF.indexOf("x")!=-1&&1;var bB=bF.indexOf("o")!=-1&&1;if(bC+bE+bB>1){return"Invalid arguments"}bi=bC&&"decimal"||bE&&"hex"||bB&&"octal"}if(bD.eatSpace()&&bD.match(/\/.*\//)){"patterns not supported"}}}var bl=bk();if(bl){a4(bp,bl+": "+bz.argString);return}var bu=bz.line||bp.firstLine();var by=bz.lineEnd||bz.line||bp.lastLine();if(bu==by){return}var bo=c(bu,0);var bw=c(by,aJ(bp,by));var bt=bp.getRange(bo,bw).split("\n");var bm=(bi=="decimal")?/(-?)([\d]+)/:(bi=="hex")?/(-?)(?:0x)?([0-9a-f]+)/i:(bi=="octal")?/([0-7]+)/:null;var bn=(bi=="decimal")?10:(bi=="hex")?16:(bi=="octal")?8:null;var br=[],bv=[];if(bi){for(var bx=0;bx"}}if(!bj){a4(bt,bp);return}var bo=0;var bu=function(){if(bo=bp){a4(bq,"Invalid argument: "+bl.argString.substring(bo));return}for(var bm=0;bm<=bp-bh;bm++){var bk=String.fromCharCode(bh+bm);delete bg.marks[bk]}}else{a4(bq,"Invalid argument: "+bj+"-");return}}else{delete bg.marks[bi]}}}};var l=new d.ExCommandDispatcher();function aT(bu,bh,bj,bp,bn,bi,br,bl,bv){bu.state.vim.exMode=true;var bm=false;var bt=bi.from();function bq(){bu.operation(function(){while(!bm){bk();bo()}bs()})}function bk(){var bx=bu.getRange(bi.from(),bi.to());var bw=bx.replace(br,bl);bi.replace(bw)}function bo(){var bw;while(bw=bi.findNext()&&T(bi.from(),bp,bn)){if(!bj&&bt&&bi.from().line==bt.line){continue}bu.scrollIntoView(bi.from(),30);bu.setSelection(bi.from(),bi.to());bt=bi.from();bm=false;return}bm=true}function bs(bx){if(bx){bx()}bu.focus();if(bt){bu.setCursor(bt);var bw=bu.state.vim;bw.exMode=false;bw.lastHPos=bw.lastHSPos=bt.ch}if(bv){bv()}}function bg(bz,bw,bA){b.e_stop(bz);var bx=b.keyName(bz);switch(bx){case"Y":bk();bo();break;case"N":bo();break;case"A":var by=bv;bv=undefined;bu.operation(bq);bv=by;break;case"L":bk();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":bs(bA);break}if(bm){bs(bA)}}bo();if(bm){a4(bu,"No matches for "+br.source);return}if(!bh){bq();if(bv){bv()}return}aO(bu,{prefix:"replace with "+bl+" (y/n/a/q/l)",onKeyDown:bg})}function ar(){function bi(bm,bl){var bk=bm;if(v(bk)&&bl=="Ctrl"){bk=bk.toLowerCase()}if(bl){bk=bl.charAt(0)+"-"+bk}var bn=({Enter:"CR",Backspace:"BS",Delete:"Del"})[bk];bk=bn?bn:bk;bk=bk.length>1?"<"+bk+">":bk;return bk}function bh(bk){return function(bl){b.signal(bl,"vim-keypress",bk);b.Vim.handleKey(bl,bk)}}var bg={nofallthrough:true,style:"fat-cursor"};function bj(bp,bl){for(var bo=0;bo1){t(bo,bh,bh.insertModeRepeat-1,true);bh.lastEditInputState.repeatOverride=bh.insertModeRepeat}delete bh.insertModeRepeat;bh.insertMode=false;bo.setCursor(bo.getCursor().line,bo.getCursor().ch-1);bo.setOption("keyMap","vim");bo.setOption("disableInput",true);bo.toggleOverwrite(false);bm.setText(bk.changes.join(""));b.signal(bo,"vim-mode-change",{mode:"normal"});if(bj.isRecording){ae(bj)}}az("enableInsertModeEscKeys",false,"boolean");az("insertModeEscKeys","kj","string");az("insertModeEscKeysTimeout",200,"number");function X(bg){return function(bh){var bj=n("insertModeEscKeys");var bi=bj&&bj.length>1&&bj.charAt(0);if(!n("enableInsertModeEscKeys")||bi!==bg){return b.Pass}else{bh.replaceRange(bg,bh.getCursor(),bh.getCursor(),"+input");bh.setOption("keyMap","await-second");bh.state.vim.awaitingEscapeSecondCharacter=true;setTimeout(function(){if(bh.state.vim.awaitingEscapeSecondCharacter){bh.state.vim.awaitingEscapeSecondCharacter=false;bh.setOption("keyMap","vim-insert")}},n("insertModeEscKeysTimeout"))}}}function ak(bg){return function(bh){var bj=n("insertModeEscKeys");var bk=bj&&bj.length>1&&bj.charAt(1);if(!n("enableInsertModeEscKeys")||bk!==bg){return b.Pass}else{if(bh.state.vim.insertMode){var bi=p.macroModeState.lastInsertModeChanges;if(bi&&bi.changes.length){bi.changes.pop()}}bh.state.vim.awaitingEscapeSecondCharacter=false;bh.replaceRange("",{ch:bh.getCursor().ch-1,line:bh.getCursor().line},bh.getCursor(),"+input");r(bh)}}}b.keyMap["vim-insert"]={Esc:r,"Ctrl-[":r,"Ctrl-C":r,"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",Enter:function(bg){var bh=b.commands.newlineAndIndentContinueComment||b.commands.newlineAndIndent;bh(bg)},"'i'":X("i"),"'j'":X("j"),"'k'":X("k"),fallthrough:["default"]};b.keyMap["await-second"]={"'i'":ak("i"),"'j'":ak("j"),"'k'":ak("k"),fallthrough:["vim-insert"]};b.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"]};function C(bo,bi,bj,bg){var bq=p.registerController.getRegister(bg);var bh=bq.keyBuffer;var bm=0;bj.isPlaying=true;bj.replaySearchQueries=bq.searchQueries.slice(0);for(var bk=0;bk|<\w+>|./).exec(br);bp=bl[0];br=br.substring(bl.index+bp.length);b.Vim.handleKey(bo,bp);if(bi.insertMode){var bn=bq.insertModeChanges[bm++].changes;p.macroModeState.lastInsertModeChanges.changes=bn;ai(bo,bn,1);r(bo)}}}bj.isPlaying=false}function D(bj,bg){if(bj.isPlaying){return}var bi=bj.latestRegister;var bh=p.registerController.getRegister(bi);if(bh){bh.pushText(bg)}}function ae(bi){if(bi.isPlaying){return}var bh=bi.latestRegister;var bg=p.registerController.getRegister(bh);if(bg){bg.pushInsertModeChanges(bi.lastInsertModeChanges)}}function H(bj,bi){if(bj.isPlaying){return}var bh=bj.latestRegister;var bg=p.registerController.getRegister(bh);if(bg){bg.pushSearchQuery(bi)}}function a1(bh,bg){var bj=p.macroModeState;var bi=bj.lastInsertModeChanges;if(!bj.isPlaying){while(bg){bi.expectCursorActivityForChange=true;if(bg.origin=="+input"||bg.origin=="paste"||bg.origin===undefined){var bk=bg.text.join("\n");bi.changes.push(bk)}bg=bg.next}}}function Q(bn){var bg=bn.state.vim;if(bg.insertMode){var bh=p.macroModeState;if(bh.isPlaying){return}var bi=bh.lastInsertModeChanges;if(bi.expectCursorActivityForChange){bi.expectCursorActivityForChange=false}else{bi.changes=[]}}else{if(bn.doc.history.lastSelOrigin=="*mouse"){bg.lastHPos=bn.doc.getCursor().ch;if(bn.somethingSelected()){bg.visualMode=true}}}if(bg.visualMode){var bl,bk;bl=bk=bn.getCursor("head");var bj=bn.getCursor("anchor");var bm=c(bk.line,bl.ch+(aC(bj,bk)?-1:1));if(aC(bm,bl)){var bo=bl;bl=bm;bm=bo}if(bg.fakeCursor){bg.fakeCursor.clear()}bg.fakeCursor=bn.markText(bl,bm,{className:"cm-animate-fat-cursor"})}}function a3(bg){this.keyName=bg}function N(bk){var bj=p.macroModeState;var bi=bj.lastInsertModeChanges;var bh=b.keyName(bk);function bg(){bi.changes.push(new a3(bh));return true}if(bh.indexOf("Delete")!=-1||bh.indexOf("Backspace")!=-1){b.lookupKey(bh,["vim-insert"],bg)}}function t(bo,bj,bh,bg){var bl=p.macroModeState;bl.isPlaying=true;var bp=!!bj.lastEditActionCommand;var bm=bj.inputState;function bi(){if(bp){aW.processAction(bo,bj,bj.lastEditActionCommand)}else{aW.evalInput(bo,bj)}}function bn(br){if(bl.lastInsertModeChanges.changes.length>0){br=!bj.lastEditActionCommand?1:br;var bq=bl.lastInsertModeChanges;ai(bo,bq.changes,br)}}bj.inputState=bj.lastEditInputState;if(bp&&bj.lastEditActionCommand.interlaceInsertRepeat){for(var bk=0;bk=p.ch+1){return/\bstring2?\b/.test(l)}o.start=o.pos}}function b(l){var m={name:"autoCloseBrackets",Backspace:function(n){if(n.getOption("disableInput")){return c.Pass}var o=n.listSelections();for(var p=0;p=0;p--){var r=o[p].head;n.replaceRange("",f(r.line,r.ch-1),f(r.line,r.ch+1))}}};var k="";for(var j=0;j1&&p.getRange(f(w.line,w.ch-2),w)==o+o&&(w.ch<=2||p.getRange(f(w.line,w.ch-3),f(w.line,w.ch-2))!=o)){s="addFour"}else{if(o=='"'||o=="'"){if(!c.isWordChar(u)&&e(p,w,o)){s="both"}else{return c.Pass}}else{if(p.getLine(w.line).length==w.ch||k.indexOf(u)>=0||i.test(u)){s="both"}else{return c.Pass}}}}}if(!v){v=s}else{if(v!=s){return c.Pass}}}p.operation(function(){if(v=="skip"){p.execCommand("goCharRight")}else{if(v=="skipThree"){for(var y=0;y<3;y++){p.execCommand("goCharRight")}}else{if(v=="surround"){var x=p.getSelections();for(var y=0;y'"]=function(l){return a(l)}}h.addKeyMap(j)});var d=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];var c=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function a(w){if(w.getOption("disableInput")){return b.Pass}var j=w.listSelections(),q=[];for(var r=0;rv.ch){p=p.slice(0,p.length-x.end+v.ch)}var t=p.toLowerCase();if(!p||x.type=="string"&&(x.end!=v.ch||!/[\"\']/.test(x.string.charAt(x.string.length-1))||x.string.length==1)||x.type=="tag"&&h.type=="closeTag"||x.string.indexOf("/")==(x.string.length-1)||m&&g(m,t)>-1||f(w,p,v,h,true)){return b.Pass}var o=u&&g(u,t)>-1;q[r]={indent:o,text:">"+(o?"\n\n":"")+"",newPos:o?b.Pos(v.line+1,0):b.Pos(v.line,v.ch+1)}}for(var r=j.length-1;r>=0;r--){var n=q[r];w.replaceRange(n.text,j[r].head,j[r].anchor,"+insert");var l=w.listSelections().slice(0);l[r]={head:n.newPos,anchor:n.newPos};w.setSelections(l);if(n.indent){w.indentLine(n.newPos.line,null,true);w.indentLine(n.newPos.line+1,null,true)}}}function e(h){if(h.getOption("disableInput")){return b.Pass}var j=h.listSelections(),n=[];for(var m=0;m"}else{if(h.getMode().name=="htmlmixed"&&k.mode.name=="css"){n[m]="/style>"}else{return b.Pass}}}else{if(!o.context||!o.context.tagName||f(h,o.context.tagName,p,o)){return b.Pass}n[m]="/"+o.context.tagName+">"}}h.replaceSelections(n);j=h.listSelections();for(var m=0;m",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"};function f(q,m,p,k){var s=q.getLineHandle(m.line),o=m.ch-1;var n=(o>=0&&a[s.text.charAt(o)])||a[s.text.charAt(++o)];if(!n){return null}var l=n.charAt(1)==">"?1:-1;if(p&&(l>0)!=(o==m.ch)){return null}var j=q.getTokenTypeAt(i(m.line,o+1));var r=g(q,i(m.line,o+(l>0?1:0)),l,j||null,k);if(r==null){return null}return{from:i(m.line,o),to:r&&r.pos,match:r&&r.ch==n.charAt(0),forward:l>0}}function g(w,r,n,k,m){var l=(m&&m.maxScanLineLength)||10000;var t=(m&&m.maxScanLines)||1000;var v=[];var x=m&&m.bracketRegex?m.bracketRegex:/[(){}[\]]/;var q=n>0?Math.min(r.line+t,w.lastLine()+1):Math.max(w.firstLine()-1,r.line-t);for(var o=r.line;o!=q;o+=n){var y=w.getLine(o);if(!y){continue}var u=n>0?0:y.length-1,p=n>0?y.length:-1;if(y.length>l){continue}if(o==r.line){u=r.ch-(n<0?1:0)}for(;u!=p;u+=n){var j=y.charAt(u);if(x.test(j)&&(k===undefined||w.getTokenTypeAt(i(o,u+1))==k)){var s=a[j];if((s.charAt(1)==">")==(n>0)){v.push(j)}else{if(!v.length){return{pos:i(o,u),ch:j}}else{v.pop()}}}}}return o-n==(n>0?w.lastLine():w.firstLine())?false:null}function b(s,n,m){var k=s.state.matchBrackets.maxHighlightLineLength||1000;var r=[],l=s.listSelections();for(var o=0;ob.lastLine()){return null}var o=b.getTokenAt(a.Pos(k,1));if(!/\S/.test(o.string)){o=b.getTokenAt(a.Pos(k,o.end+1))}if(o.type!="keyword"||o.string!="import"){return null}for(var l=k,m=Math.min(b.lastLine(),k+10);l<=m;++l){var n=b.getLine(l),j=n.indexOf(";");if(j!=-1){return{startCh:o.end,end:a.Pos(l,j)}}}}var h=h.line,d=g(h),f;if(!d||g(h-1)||((f=g(h-2))&&f.end.line==h-1)){return null}for(var c=d.end;;){var e=g(c.line+1);if(e==null){break}c=e.end}return{from:b.clipPos(a.Pos(h,d.startCh+1)),to:c}});a.registerHelper("fold","include",function(b,g){function f(h){if(hb.lastLine()){return null}var i=b.getTokenAt(a.Pos(h,1));if(!/\S/.test(i.string)){i=b.getTokenAt(a.Pos(h,i.end+1))}if(i.type=="meta"&&i.string.slice(0,8)=="#include"){return i.start+8}}var g=g.line,d=f(g);if(d==null||f(g-1)!=null){return null}for(var c=g;;){var e=f(c+1);if(e==null){break}++c}return{from:a.Pos(g,d+1),to:b.clipPos(a.Pos(c))}})});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(b){function d(n,m,o,i){if(o&&o.call){var g=o;o=null}else{var g=c(n,o,"rangeFinder")}if(typeof m=="number"){m=b.Pos(m,0)}var h=c(n,o,"minFoldSize");function f(p){var q=g(n,m);if(!q||q.to.line-q.from.linen.firstLine()){m=b.Pos(m.line-1,0);k=f(false)}}if(!k||k.cleared||i==="unfold"){return}var l=e(n,o);b.on(l,"mousedown",function(p){j.clear();b.e_preventDefault(p)});var j=n.markText(k.from,k.to,{replacedWith:l,clearOnEnter:true,__isFold:true});j.on("clear",function(q,p){b.signal(n,"unfold",n,q,p)});b.signal(n,"fold",n,k.from,k.to)}function e(f,g){var h=c(f,g,"widget");if(typeof h=="string"){var i=document.createTextNode(h);h=document.createElement("span");h.appendChild(i);h.className="CodeMirror-foldmarker"}return h}b.newFoldFunction=function(g,f){return function(h,i){d(h,i,{rangeFinder:g,widget:f})}};b.defineExtension("foldCode",function(h,f,g){d(this,h,f,g)});b.defineExtension("isFolded",function(h){var g=this.findMarksAt(h);for(var f=0;f20||o.from-p.to>20){b(m)}else{m.operation(function(){if(p.fromo.to){a(m,o.to,p.to);o.to=p.to}})}},n.updateViewportTimeSpan||400)}function e(m,p){var o=m.state.foldGutter,n=p.line;if(n>=o.from&&n=q.max){return}q.ch=0;q.text=q.cm.getLine(++q.line);return true}function n(q){if(q.line<=q.min){return}q.text=q.cm.getLine(--q.line);q.ch=q.text.length;return true}function g(s){for(;;){var r=s.text.indexOf(">",s.ch);if(r==-1){if(a(s)){continue}else{return}}if(!h(s,r+1)){s.ch=r+1;continue}var q=s.text.lastIndexOf("/",r);var t=q>-1&&!/\S/.test(s.text.slice(q+1,r));s.ch=r+1;return t?"selfClose":"regular"}}function k(r){for(;;){var q=r.ch?r.text.lastIndexOf("<",r.ch-1):-1;if(q==-1){if(n(r)){continue}else{return}}if(!h(r,q+1)){r.ch=q;continue}d.lastIndex=q;r.ch=q;var s=d.exec(r.text);if(s&&s.index==q){return s}}}function p(q){for(;;){d.lastIndex=q.ch;var r=d.exec(q.text);if(!r){if(a(q)){continue}else{return}}if(!h(q,r.index+1)){q.ch=r.index+1;continue}q.ch=r.index+r[0].length;return r}}function e(s){for(;;){var r=s.ch?s.text.lastIndexOf(">",s.ch-1):-1;if(r==-1){if(n(s)){continue}else{return}}if(!h(s,r+1)){s.ch=r;continue}var q=s.text.lastIndexOf("/",r);var t=q>-1&&!/\S/.test(s.text.slice(q+1,r));s.ch=r+1;return t?"selfClose":"regular"}}function f(t,r){var q=[];for(;;){var v=p(t),s,x=t.line,w=t.ch-(v?v[0].length:0);if(!v||!(s=g(t))){return}if(s=="selfClose"){continue}if(v[1]){for(var u=q.length-1;u>=0;--u){if(q[u]==v[2]){q.length=u;break}}if(u<0&&(!r||r==v[2])){return{tag:v[2],from:m(x,w),to:m(t.line,t.ch)}}}else{q.push(v[2])}}}function c(s,r){var q=[];for(;;){var w=e(s);if(!w){return}if(w=="selfClose"){k(s);continue}var v=s.line,u=s.ch;var x=k(s);if(!x){return}if(x[1]){q.push(x[2])}else{for(var t=q.length-1;t>=0;--t){if(q[t]==x[2]){q.length=t;break}}if(t<0&&(!r||r==x[2])){return{tag:x[2],from:m(s.line,s.ch),to:m(v,u)}}}}}i.registerHelper("fold","xml",function(q,v){var s=new b(q,v.line,0);for(;;){var t=p(s),r;if(!t||s.line!=v.line||!(r=g(s))){return}if(!t[1]&&r!="selfClose"){var v=m(s.line,s.ch);var u=f(s,t[2]);return u&&{from:v,to:u.from}}}});i.findMatchingTag=function(q,x,t){var s=new b(q,x.line,x.ch,t);if(s.text.indexOf(">")==-1&&s.text.indexOf("<")==-1){return}var r=g(s),w=r&&m(s.line,s.ch);var v=r&&k(s);if(!r||!v||l(s,x)>0){return}var u={from:m(s.line,s.ch),to:w,tag:v[2]};if(r=="selfClose"){return{open:u,close:null,at:"open"}}if(v[1]){return{open:c(s,v[2]),close:u,at:"close"}}else{s=new b(q,w.line,w.ch,t);return{open:u,close:f(s,v[2]),at:"open"}}};i.findEnclosingTag=function(q,w,s){var r=new b(q,w.line,w.ch,s);for(;;){var u=c(r);if(!u){break}var t=new b(q,w.line,w.ch,s);var v=f(t,u.tag);if(v){return{open:u,close:v}}}};i.scanForClosingTag=function(q,u,t,s){var r=new b(q,u.line,u.ch,s?{from:0,to:s}:null);return f(r,t)}});(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],a)}else{a(CodeMirror)}}})(function(a){if(!a.modeURL){a.modeURL="../mode/%N/%N.js"}var d={};function c(e,g){var f=g;return function(){if(--f==0){e()}}}function b(k,e){var j=a.modes[k].dependencies;if(!j){return e()}var h=[];for(var g=0;g100){return clearInterval(j)}if(a.modes.hasOwnProperty(k)){clearInterval(j);d[k]=null;b(k,function(){for(var l=0;l-1){o.string=m.slice(0,p)}var n=k.mode.token(o,f.inner);if(p>-1){o.string=m}if(k.innerStyle){if(n){n=n+" "+k.innerStyle}else{n=k.innerStyle}}return n}},indent:function(g,f){var h=g.innerActive?g.innerActive.mode:c;if(!h.indent){return a.Pass}return h.indent(g.innerActive?g.inner:g.outer,f)},blankLine:function(h){var j=h.innerActive?h.innerActive.mode:c;if(j.blankLine){j.blankLine(h.innerActive?h.inner:h.outer)}if(!h.innerActive){for(var g=0;g",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"W"},{keys:"",type:"keyToKey",toKeys:"B"},{keys:"",type:"keyToKey",toKeys:"w"},{keys:"",type:"keyToKey",toKeys:"b"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"xi",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"dcc",context:"visual"},{keys:"",type:"keyToKey",toKeys:"0"},{keys:"",type:"keyToKey",toKeys:"$"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:true,toJumplist:true}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:true,toJumplist:true}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:true,toJumplist:true}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:false}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:true}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:true,linewise:true}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:false,linewise:true}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:true}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:false}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:false}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:false,bigWord:true}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:true,inclusive:true}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:true,wordEnd:true,bigWord:true,inclusive:true}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:false}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:false,bigWord:true}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:true,inclusive:true}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:false,wordEnd:true,bigWord:true,inclusive:true}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:false,toJumplist:true}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:true,toJumplist:true}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:true}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:false}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:true,explicitRepeat:true}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:false,explicitRepeat:true}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:false,explicitRepeat:true,linewise:true,toJumplist:true}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:true,explicitRepeat:true,linewise:true,toJumplist:true}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:true,toFirstChar:true}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:false,toFirstChar:true}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:true,toFirstChar:true,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:true}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:true,toJumplist:true}},{keys:"f",type:"motion",motion:"moveToCharacter",motionArgs:{forward:true,inclusive:true}},{keys:"F",type:"motion",motion:"moveToCharacter",motionArgs:{forward:false}},{keys:"t",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:true,inclusive:true}},{keys:"T",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:false}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:true}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:false}},{keys:"'",type:"motion",motion:"goToMark",motionArgs:{toJumplist:true,linewise:true}},{keys:"`",type:"motion",motion:"goToMark",motionArgs:{toJumplist:true}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:true}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:false}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:true,linewise:true}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:false,linewise:true}},{keys:"]p",type:"action",action:"paste",isEdit:true,actionArgs:{after:true,isEdit:true,matchIndent:true}},{keys:"[p",type:"action",action:"paste",isEdit:true,actionArgs:{after:false,isEdit:true,matchIndent:true}},{keys:"]",type:"motion",motion:"moveToSymbol",motionArgs:{forward:true,toJumplist:true}},{keys:"[",type:"motion",motion:"moveToSymbol",motionArgs:{forward:false,toJumplist:true}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:true},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:true}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:false}},{keys:"g~",type:"operator",operator:"swapcase"},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:true,toJumplist:true}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:false,toJumplist:true}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:true},operatorMotionArgs:{visualLine:false}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:false},operatorMotionArgs:{visualLine:true}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:true},operatorMotionArgs:{visualLine:true}},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:true},operatorMotionArgs:{visualLine:true}},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:true},operatorMotionArgs:{visualLine:true}},{keys:"~",type:"operatorMotion",operator:"swapcase",operatorArgs:{shouldMoveCursor:true},motion:"moveByCharacters",motionArgs:{forward:true}},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:false,wordEnd:false},context:"insert"},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:true}},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:false}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:true,linewise:true}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:false,linewise:true}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{insertAt:"firstNonBlank"}},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:true,interlaceInsertRepeat:true,actionArgs:{after:true},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:true,interlaceInsertRepeat:true,actionArgs:{after:false},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:true}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:true}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:true},{keys:"p",type:"action",action:"paste",isEdit:true,actionArgs:{after:true,isEdit:true}},{keys:"P",type:"action",action:"paste",isEdit:true,actionArgs:{after:false,isEdit:true}},{keys:"r",type:"action",action:"replace",isEdit:true},{keys:"@",type:"action",action:"replayMacro"},{keys:"q",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:true,actionArgs:{replace:true}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"action",action:"changeCase",actionArgs:{toLower:true},context:"visual",isEdit:true},{keys:"U",type:"action",action:"changeCase",actionArgs:{toLower:false},context:"visual",isEdit:true},{keys:"",type:"action",action:"redo"},{keys:"m",type:"action",action:"setMark"},{keys:'"',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"",type:"action",action:"incrementNumberToken",isEdit:true,actionArgs:{increase:true,backtrack:false}},{keys:"",type:"action",action:"incrementNumberToken",isEdit:true,actionArgs:{increase:false,backtrack:false}},{keys:"a",type:"motion",motion:"textObjectManipulation"},{keys:"i",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:true}},{keys:"/",type:"search",searchArgs:{forward:true,querySrc:"prompt",toJumplist:true}},{keys:"?",type:"search",searchArgs:{forward:false,querySrc:"prompt",toJumplist:true}},{keys:"*",type:"search",searchArgs:{forward:true,querySrc:"wordUnderCursor",wholeWordOnly:true,toJumplist:true}},{keys:"#",type:"search",searchArgs:{forward:false,querySrc:"wordUnderCursor",wholeWordOnly:true,toJumplist:true}},{keys:"g*",type:"search",searchArgs:{forward:true,querySrc:"wordUnderCursor",toJumplist:true}},{keys:"g#",type:"search",searchArgs:{forward:false,querySrc:"wordUnderCursor",toJumplist:true}},{keys:":",type:"ex"}];var c=b.Pos;var g=[16,17,18,91];var d={Enter:"CR",Backspace:"BS",Delete:"Del"};var f=/Mac/.test(navigator.platform);var e=function(){b.defineOption("vimMode",false,function(bl,bp){function bn(bu){var bt=bu.keyCode;if(g.indexOf(bt)!=-1){return}var bs=bu.ctrlKey||bu.metaKey;var br=b.keyNames[bt];br=d[br]||br;var bq="";if(bu.ctrlKey){bq+="C-"}if(bu.altKey){bq+="A-"}if(f&&bu.metaKey||(!bs&&bu.shiftKey)&&br.length<2){return}else{if(bu.shiftKey&&!/^[A-Za-z]$/.test(br)){bq+="S-"}}if(br.length==1){br=br.toLowerCase()}bq+=br;if(bq.length>1){bq="<"+bq+">"}return bq}function bm(bq,bs){var br=bn(bs);if(!br){return}b.signal(bq,"vim-keypress",br);if(b.Vim.handleKey(bq,br,"user")){b.e_stop(bs)}}function bo(bq,bt){var bs=bt.charCode||bt.keyCode;if(bt.ctrlKey||bt.metaKey||bt.altKey||bt.shiftKey&&bs<32){return}var br=String.fromCharCode(bs);b.signal(bq,"vim-keypress",br);if(b.Vim.handleKey(bq,br,"user")){b.e_stop(bt)}}if(bp){bl.setOption("keyMap","vim");bl.setOption("disableInput",true);bl.setOption("showCursorWhenSelecting",false);b.signal(bl,"vim-mode-change",{mode:"normal"});bl.on("cursorActivity",X);G(bl);b.on(bl.getInputField(),"paste",S(bl));bl.on("keypress",bo);bl.on("keydown",bm)}else{if(bl.state.vim){bl.setOption("keyMap","default");bl.setOption("disableInput",false);bl.off("cursorActivity",X);b.off(bl.getInputField(),"paste",S(bl));bl.state.vim=null;bl.off("keypress",bo);bl.off("keydown",bm)}}});function S(bl){var bm=bl.state.vim;if(!bm.onPasteFn){bm.onPasteFn=function(){if(!bm.insertMode){bl.setCursor(D(bl.getCursor(),0,1));r.enterInsertMode(bl,{},bm)}}}return bm.onPasteFn}var aO=/[\d]/;var am=[(/\w/),(/[^\w\s]/)],ba=[(/\S/)];function al(bo,bm){var bn=[];for(var bl=bo;bl"]);var n=[].concat(ad,ai,T,["-",'"',".",":","/"]);function h(bl,bm){return bm>=bl.firstLine()&&bm<=bl.lastLine()}function E(bl){return(/^[a-z]$/).test(bl)}function L(bl){return"()[]{}".indexOf(bl)!=-1}function ac(bl){return aO.test(bl)}function A(bl){return(/^[A-Z]$/).test(bl)}function Q(bl){return(/^\s*$/).test(bl)}function J(bn,bl){for(var bm=0;bmbo){br=bo}else{if(br0?1:-1;var bu;var bt=bs.getCursor();do{br+=bv;bx=bm[(bp+br)%bp];if(bx&&(bu=bx.find())&&!bj(bt,bu)){break}}while(brbn)}return bx}return{cachedCursor:undefined,add:bq,move:bl}};var k=function(bl){if(bl){return{changes:bl.changes,expectCursorActivityForChange:bl.expectCursorActivityForChange}}return{changes:[],expectCursorActivityForChange:false}};function at(){this.latestRegister=undefined;this.isPlaying=false;this.isRecording=false;this.replaySearchQueries=[];this.onRecordingDone=undefined;this.lastInsertModeChanges=k()}at.prototype={exitMacroRecordMode:function(){var bl=s.macroModeState;if(bl.onRecordingDone){bl.onRecordingDone()}bl.onRecordingDone=undefined;bl.isRecording=false},enterMacroRecordMode:function(bl,bn){var bm=s.registerController.getRegister(bn);if(bm){bm.clear();this.latestRegister=bn;if(bl.openDialog){this.onRecordingDone=bl.openDialog("(recording)["+bn+"]",null,{bottom:true})}this.isRecording=true}}};function G(bl){if(!bl.state.vim){bl.state.vim={inputState:new av(),lastEditInputState:undefined,lastEditActionCommand:undefined,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:false,insertModeRepeat:undefined,visualMode:false,visualLine:false,visualBlock:false,lastSelection:null,lastPastedText:null,awaitingEscapeSecondCharacter:false}}return bl.state.vim}var s;function z(){s={searchQuery:null,searchIsReversed:false,lastSubstituteReplacePart:undefined,jumpList:ak(),macroModeState:new at,lastChararacterSearch:{increment:0,forward:true,selectedCharacter:""},registerController:new ae({}),searchHistoryController:new aT({}),exCommandHistoryController:new aT({})};for(var bl in ao){var bm=ao[bl];bm.value=bm.defaultValue}}var bh;var aI={buildKeyMap:function(){},getRegisterController:function(){return s.registerController},resetVimGlobalState_:z,getVimGlobalState_:function(){return s},maybeInitVimState_:G,InsertModeKey:a7,map:function(bm,bn,bl){o.map(bm,bn,bl)},setOption:aC,getOption:q,defineOption:aE,defineEx:function(bl,bn,bm){if(bl.indexOf(bn)!==0){throw new Error('(Vim.defineEx) "'+bn+'" is not a prefix of "'+bl+'", command not registered')}aU[bl]=bm;o.commandMap_[bn]={name:bl,shortName:bn,type:"api"}},handleKey:function(bq,br,bp){var bn=G(bq);function bs(){var bu=s.macroModeState;if(bu.isRecording){if(br=="q"){bu.exitMacroRecordMode();l(bq);return true}if(bp!="mapping"){I(bu,br)}}}function bt(){if(br==""){l(bq);if(bn.visualMode){aL(bq)}else{if(bn.insertMode){w(bq)}}return true}}function bl(bv){var bu;while(bv){bu=(/<\w+-.+?>|<\w+>|./).exec(bv);br=bu[0];bv=bv.substring(bu.index+br.length);b.Vim.handleKey(bq,br,"mapping")}}function bo(){if(bt()){return true}var bw=bn.inputState.keyBuffer=bn.inputState.keyBuffer+br;var bx=br.length==1;var bu=a0.matchCommand(bw,a,bn.inputState,"insert");while(bw.length>1&&bu.type!="full"){var bw=bn.inputState.keyBuffer=bw.slice(1);var by=a0.matchCommand(bw,a,bn.inputState,"insert");if(by.type!="none"){bu=by}}if(bu.type=="none"){l(bq);return false}else{if(bu.type=="partial"){if(bh){window.clearTimeout(bh)}bh=window.setTimeout(function(){if(bn.insertMode&&bn.inputState.keyBuffer){l(bq)}},q("insertModeEscKeysTimeout"));return !bx}}if(bh){window.clearTimeout(bh)}if(bx){var bv=bq.getCursor();bq.replaceRange("",D(bv,0,-(bw.length-1)),bv,"+input")}l(bq);var bz=bu.command;if(bz.type=="keyToKey"){bl(bz.toKeys)}else{a0.processCommand(bq,bn,bz)}return !bx}function bm(){if(bs()||bt()){return true}var bw=bn.inputState.keyBuffer=bn.inputState.keyBuffer+br;if(/^[1-9]\d*$/.test(bw)){return true}var by=/^(\d*)(.*)$/.exec(bw);if(!by){l(bq);return false}var bv=bn.visualMode?"visual":"normal";var bu=a0.matchCommand(by[2]||by[1],a,bn.inputState,bv);if(bu.type=="none"){l(bq);return false}else{if(bu.type=="partial"){return true}}bn.inputState.keyBuffer="";var bx=bu.command;var by=/^(\d*)(.*)$/.exec(bw);if(by[1]&&by[1]!="0"){bn.inputState.pushRepeatDigit(by[1])}if(bx.type=="keyToKey"){bl(bx.toKeys)}else{a0.processCommand(bq,bn,bx)}return true}if(bn.insertMode){return bo()}else{return bm()}},handleEx:function(bl,bm){o.processCommand(bl,bm)}};function av(){this.prefixRepeat=[];this.motionRepeat=[];this.operator=null;this.operatorArgs=null;this.motion=null;this.motionArgs=null;this.keyBuffer=[];this.registerName=null}av.prototype.pushRepeatDigit=function(bl){if(!this.operator){this.prefixRepeat=this.prefixRepeat.concat(bl)}else{this.motionRepeat=this.motionRepeat.concat(bl)}};av.prototype.getRepeat=function(){var bl=0;if(this.prefixRepeat.length>0||this.motionRepeat.length>0){bl=1;if(this.prefixRepeat.length>0){bl*=parseInt(this.prefixRepeat.join(""),10)}if(this.motionRepeat.length>0){bl*=parseInt(this.motionRepeat.join(""),10)}}return bl};function l(bl,bm){bl.state.vim.inputState=new av();b.signal(bl,"vim-command-done",bm)}function bb(bn,bm,bl){this.clear();this.keyBuffer=[bn||""];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!!bm;this.blockwise=!!bl}bb.prototype={setText:function(bn,bm,bl){this.keyBuffer=[bn||""];this.linewise=!!bm;this.blockwise=!!bl},pushText:function(bm,bl){if(bl){if(!this.linewise){this.keyBuffer.push("\n")}this.linewise=true}this.keyBuffer.push(bm)},pushInsertModeChanges:function(bl){this.insertModeChanges.push(k(bl))},pushSearchQuery:function(bl){this.searchQueries.push(bl)},clear:function(){this.keyBuffer=[];this.insertModeChanges=[];this.searchQueries=[];this.linewise=false},toString:function(){return this.keyBuffer.join("")}};function ae(bl){this.registers=bl;this.unnamedRegister=bl['"']=new bb();bl["."]=new bb();bl[":"]=new bb();bl["/"]=new bb()}ae.prototype={pushText:function(bp,bm,br,bq,bn){if(bq&&br.charAt(0)=="\n"){br=br.slice(1)+"\n"}if(bq&&br.charAt(br.length-1)!=="\n"){br+="\n"}var bo=this.isValidRegister(bp)?this.getRegister(bp):null;if(!bo){switch(bm){case"yank":this.registers["0"]=new bb(br,bq,bn);break;case"delete":case"change":if(br.indexOf("\n")==-1){this.registers["-"]=new bb(br,bq)}else{this.shiftNumericRegisters_();this.registers["1"]=new bb(br,bq)}break}this.unnamedRegister.setText(br,bq,bn);return}var bl=A(bp);if(bl){bo.pushText(br,bq)}else{bo.setText(br,bq,bn)}this.unnamedRegister.setText(bo.toString(),bq)},getRegister:function(bl){if(!this.isValidRegister(bl)){return this.unnamedRegister}bl=bl.toLowerCase();if(!this.registers[bl]){this.registers[bl]=new bb()}return this.registers[bl]},isValidRegister:function(bl){return bl&&J(bl,n)},shiftNumericRegisters_:function(){for(var bl=9;bl>=2;bl--){this.registers[bl]=this.getRegister(""+(bl-1))}}};function aT(){this.historyBuffer=[];this.iterator;this.initialPrefix=null}aT.prototype={nextMatch:function(bm,bl){var br=this.historyBuffer;var bo=bl?-1:1;if(this.initialPrefix===null){this.initialPrefix=bm}for(var bq=this.iterator+bo;bl?bq>=0:bq=br.length){this.iterator=br.length;return this.initialPrefix}if(bq<0){return bm}},pushInput:function(bl){var bm=this.historyBuffer.indexOf(bl);if(bm>-1){this.historyBuffer.splice(bm,1)}if(bl.length){this.historyBuffer.push(bl)}},reset:function(){this.initialPrefix=null;this.iterator=this.historyBuffer.length}};var a0={matchCommand:function(bq,bs,bl,bo){var br=a8(bq,bs,bo,bl);if(!br.full&&!br.partial){return{type:"none"}}else{if(!br.full&&br.partial){return{type:"partial"}}}var bp;for(var bn=0;bn"){bl.selectedCharacter=O(bq)}return{type:"full",command:bp}},processCommand:function(bl,bm,bn){bm.inputState.repeatOverride=bn.repeatOverride;switch(bn.type){case"motion":this.processMotion(bl,bm,bn);break;case"operator":this.processOperator(bl,bm,bn);break;case"operatorMotion":this.processOperatorMotion(bl,bm,bn);break;case"action":this.processAction(bl,bm,bn);break;case"search":this.processSearch(bl,bm,bn);break;case"ex":case"keyToEx":this.processEx(bl,bm,bn);break;default:break}},processMotion:function(bl,bm,bn){bm.inputState.motion=bn.motion;bm.inputState.motionArgs=a6(bn.motionArgs);this.evalInput(bl,bm)},processOperator:function(bm,bn,bo){var bl=bn.inputState;if(bl.operator){if(bl.operator==bo.operator){bl.motion="expandToLine";bl.motionArgs={linewise:true};this.evalInput(bm,bn);return}else{l(bm)}}bl.operator=bo.operator;bl.operatorArgs=a6(bo.operatorArgs);if(bn.visualMode){this.evalInput(bm,bn)}},processOperatorMotion:function(bl,bo,bp){var bn=bo.visualMode;var bm=a6(bp.operatorMotionArgs);if(bm){if(bn&&bm.visualLine){bo.visualLine=true}}this.processOperator(bl,bo,bp);if(!bn){this.processMotion(bl,bo,bp)}},processAction:function(bm,bo,br){var bl=bo.inputState;var bq=bl.getRepeat();var bp=!!bq;var bn=a6(br.actionArgs)||{};if(bl.selectedCharacter){bn.selectedCharacter=bl.selectedCharacter}if(br.operator){this.processOperator(bm,bo,br)}if(br.motion){this.processMotion(bm,bo,br)}if(br.motion||br.operator){this.evalInput(bm,bo)}bn.repeat=bq||1;bn.repeatIsExplicit=bp;bn.registerName=bl.registerName;l(bm);bo.lastMotion=null;if(br.isEdit){this.recordLastEdit(bo,bl,br)}r[br.action](bm,bn,bo)},processSearch:function(bA,bt,bs){if(!bA.getSearchCursor){return}var bv=bs.searchArgs.forward;var bq=bs.searchArgs.wholeWordOnly;aB(bA).setReversed(!bv);var bw=(bv)?"/":"?";var by=aB(bA).getQuery();var bn=bA.getScrollInfo();function br(bD,bB,bC){s.searchHistoryController.pushInput(bD);s.searchHistoryController.reset();try{bi(bA,bD,bB,bC)}catch(bE){a9(bA,"Invalid regex: "+bD);return}a0.processMotion(bA,bt,{type:"motion",motion:"findNext",motionArgs:{forward:true,toJumplist:bs.searchArgs.toJumplist}})}function bz(bB){bA.scrollTo(bn.left,bn.top);br(bB,true,true);var bC=s.macroModeState;if(bC.isRecording){M(bC,bB)}}function bp(bF,bE,bG){var bD=b.keyName(bF),bB;if(bD=="Up"||bD=="Down"){bB=bD=="Up"?true:false;bE=s.searchHistoryController.nextMatch(bE,bB)||"";bG(bE)}else{if(bD!="Left"&&bD!="Right"&&bD!="Ctrl"&&bD!="Alt"&&bD!="Shift"){s.searchHistoryController.reset()}}var bC;try{bC=bi(bA,bE,true,true)}catch(bF){}if(bC){bA.scrollIntoView(bk(bA,!bv,bC),30)}else{aF(bA);bA.scrollTo(bn.left,bn.top)}}function bm(bD,bC,bE){var bB=b.keyName(bD);if(bB=="Esc"||bB=="Ctrl-C"||bB=="Ctrl-["){s.searchHistoryController.pushInput(bC);s.searchHistoryController.reset();bi(bA,by);aF(bA);bA.scrollTo(bn.left,bn.top);b.e_stop(bD);bE();bA.focus()}}switch(bs.searchArgs.querySrc){case"prompt":var bu=s.macroModeState;if(bu.isPlaying){var bx=bu.replaySearchQueries.shift();br(bx,true,false)}else{aR(bA,{onClose:bz,prefix:bw,desc:N,onKeyUp:bp,onKeyDown:bm})}break;case"wordUnderCursor":var bo=ay(bA,false,true,false,true);var bl=true;if(!bo){bo=ay(bA,false,true,false,false);bl=false}if(!bo){return}var bx=bA.getLine(bo.start.line).substring(bo.start.ch,bo.end.ch);if(bl&&bq){bx="\\b"+bx+"\\b"}else{bx=j(bx)}s.jumpList.cachedCursor=bA.getCursor();bA.setCursor(bo.start);br(bx,true,false);break}},processEx:function(bl,bm,bp){function bo(bq){s.exCommandHistoryController.pushInput(bq);s.exCommandHistoryController.reset();o.processCommand(bl,bq)}function bn(bt,br,bu){var bs=b.keyName(bt),bq;if(bs=="Esc"||bs=="Ctrl-C"||bs=="Ctrl-["){s.exCommandHistoryController.pushInput(br);s.exCommandHistoryController.reset();b.e_stop(bt);bu();bl.focus()}if(bs=="Up"||bs=="Down"){bq=bs=="Up"?true:false;br=s.exCommandHistoryController.nextMatch(br,bq)||"";bu(br)}else{if(bs!="Left"&&bs!="Right"&&bs!="Ctrl"&&bs!="Alt"&&bs!="Shift"){s.exCommandHistoryController.reset()}}}if(bp.type=="keyToEx"){o.processCommand(bl,bp.exArgs.input)}else{if(bm.visualMode){aR(bl,{onClose:bo,prefix:":",value:"'<,'>",onKeyDown:bn})}else{aR(bl,{onClose:bo,prefix:":",onKeyDown:bn})}}},evalInput:function(bu,bL){var bA=bL.inputState;var bI=bA.motion;var bB=bA.motionArgs||{};var bv=bA.operator;var bR=bA.operatorArgs||{};var bC=bA.registerName;var bm=C(bu.getCursor("head"));var bJ=C(bu.getCursor("anchor"));var bs=C(bm);var bz=C(bs);var bM;var bw;if(bv){this.recordLastEdit(bL,bA)}if(bA.repeatOverride!==undefined){bw=bA.repeatOverride}else{bw=bA.getRepeat()}if(bw>0&&bB.explicitRepeat){bB.repeatIsExplicit=true}else{if(bB.noRepeat||(!bB.explicitRepeat&&bw===0)){bw=1;bB.repeatIsExplicit=false}}if(bA.selectedCharacter){bB.selectedCharacter=bR.selectedCharacter=bA.selectedCharacter}bB.repeat=bw;l(bu);if(bI){var bK=aS[bI](bu,bB,bL);bL.lastMotion=aS[bI];if(!bK){return}if(bB.toJumplist){var bQ=s.jumpList;var bx=bQ.cachedCursor;if(bx){a4(bu,bx,bK);delete bQ.cachedCursor}else{a4(bu,bz,bK)}}if(bK instanceof Array){bs=bK[0];bM=bK[1]}else{bM=bK}if(!bM){bM=c(bs.line,bs.ch)}if(bL.visualMode){var bq=0;if(aH(bJ,bm)&&(bj(bJ,bM)||aH(bM,bJ))){bJ.ch+=1;bq=-1}else{if(aH(bm,bJ)&&(bj(bJ,bM)||aH(bJ,bM))){bJ.ch-=1;bq=1}}if(!bL.visualBlock&&!(bK instanceof Array)){bM.ch+=bq}if(bL.lastHPos!=Infinity){bL.lastHPos=bM.ch}bm=bM;bJ=(bK instanceof Array)?bs:bJ;if(bL.visualLine){if(aH(bJ,bm)){bJ.ch=0;var bl=bu.lastLine();if(bm.line>bl){bm.line=bl}bm.ch=aM(bu,bm.line)}else{bm.ch=0;bJ.ch=aM(bu,bJ.line)}}else{if(bL.visualBlock){bJ=F(bu,bm)}}if(!bL.visualBlock){bu.setSelection(bJ,bm)}aK(bu,bL,"<",aH(bJ,bm)?bJ:bm);aK(bu,bL,">",aH(bJ,bm)?bm:bJ)}else{if(!bv){bM=W(bu,bM);bu.setCursor(bM.line,bM.ch)}}}if(bv){var bF=false;bL.lastMotion=null;var by=bL.lastSelection;bR.repeat=bw;if(bL.visualMode){bs=bJ;bM=bm;bB.inclusive=true;bR.shouldMoveCursor=false}if(bM&&aH(bM,bs)){var bP=bs;bs=bM;bM=bP;bF=true}else{if(!bM){bM=C(bs)}}if(bB.inclusive&&!bL.visualMode){bM.ch++}if(bR.selOffset){bM.line=bs.line+bR.selOffset.line;if(bR.selOffset.line){bM.ch=bR.selOffset.ch}else{bM.ch=bs.ch+bR.selOffset.ch}if(by&&by.visualBlock){var bt=by.visualBlock;var bH=bt.width;var bG=bt.height;bM=c(bs.line+bG,bs.ch+bH);var bn=[];for(var bN=bs.line;bNbr&&bs.line==br)){return}if(bm.toFirstChar){bo=aQ(bq.getLine(bt));bn.lastHPos=bo}bn.lastHSPos=bq.charCoords(c(bt,bo),"div").left;return c(bt,bo)},moveByDisplayLines:function(bs,bn,bo){var bt=bs.getCursor();switch(bo.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:bo.lastHSPos=bs.charCoords(bt,"div").left}var bl=bn.repeat;var br=bs.findPosV(bt,(bn.forward?bl:-bl),"line",bo.lastHSPos);if(br.hitSide){if(bn.forward){var bm=bs.charCoords(br,"div");var bp={top:bm.top+8,left:bo.lastHSPos};var br=bs.coordsChar(bp,"div")}else{var bq=bs.charCoords(c(bs.firstLine(),0),"div");bq.left=bo.lastHSPos;br=bs.coordsChar(bq,"div")}}bo.lastHPos=br.ch;return br},moveByPage:function(bm,bn){var bl=bm.getCursor();var bo=bn.repeat;return bm.findPosV(bl,(bn.forward?bo:-bo),"page")},moveByParagraph:function(bl,bn){var bm=bl.getCursor().line;var bp=bn.repeat;var bq=bn.forward?1:-1;for(var bo=0;bo"]?by.marks[">"].find():bu.getCursor("head");s.registerController.pushText(bC.registerName,"change",bv,bC.linewise);if(bC.linewise){if(bB){var bz=bt.line;while(bz<=bA.line){var bw=aM(bu,bz);var bq=c(bz,bw);var br=c(bz,bt.ch);bz++;bu.replaceRange("",br,bq)}}else{bx="\n";if(bA.line==bt.line&&bA.line==bu.lastLine()){bx=""}bu.replaceRange(bx,bt,bA);bu.indentLine(bt.line,"smart");bt.ch=null;bu.setCursor(bt)}}else{var bv=bu.getRange(bt,bA);if(!Q(bv)){var bs=(/\s+$/).exec(bv);if(bs){bA=D(bA,0,-bs[0].length)}}if(bB){bu.replaceSelections(bx)}else{bu.setCursor(bt);bu.replaceRange("",bt,bA)}}by.marks[">"]=bu.setBookmark(bl);r.enterInsertMode(bu,{},bu.state.vim)},"delete":function(bx,bq,bs){var bo=bx.listSelections();var bn=bo[0],br=bo[bo.length-1];var bu=aH(bn.anchor,bn.head)?bn.anchor:bn.head;var by=aH(br.anchor,br.head)?br.head:br.anchor;var bA,bw;var bv=bs.visualBlock;if(bs.visualMode){bA=bs.marks[">"].find();bw=bs.marks["<"].find()}else{if(bs.lastSelection){bA=bs.lastSelection.curStartMark.find();bw=bs.lastSelection.curEndMark.find();bv=bs.lastSelection.visualBlock}}var bz=bx.getSelection();s.registerController.pushText(bq.registerName,"delete",bz,bq.linewise,bv);var bp=new Array(bo.length).join("1").split("1");if(bq.linewise&&by.line==bx.lastLine()&&bu.line==by.line){if(by.line==0){bu.ch=0}else{var bt=C(by);bu.line--;bu.ch=aM(bx,bu.line);by=bt}bx.replaceRange("",bu,by)}else{bx.replaceSelections(bp)}if(bA){var bm=bx.setBookmark(bw);var bl=bx.setBookmark(bA);if(bs.visualMode){bs.marks["<"]=bm;bs.marks[">"]=bl}else{bs.lastSelection.curStartMark=bm;bs.lastSelection.curEndMark=bl}}if(bq.linewise){bx.setCursor(aS.moveToFirstNonWhiteSpaceCharacter(bx))}else{bx.setCursor(bu)}},indent:function(bs,bn,bp,br,bt){var bu=br.line;var bm=bt.line;var bl=(bp.visualMode)?bn.repeat:1;if(bn.linewise){bm--}for(var bq=bu;bq<=bm;bq++){for(var bo=0;bobo.top){bv.line+=(bq-bo.top)/bs;bv.line=Math.ceil(bv.line);bt.setCursor(bv);bo=bt.charCoords(bv,"local");bt.scrollTo(null,bo.top)}else{bt.scrollTo(null,bq)}}else{var bm=bq+bt.getScrollInfo().clientHeight;if(bm",aH(bl,bq)?bq:bl)},reselectLastSelection:function(br,bn,bm){var bo=bm.marks["<"].find();var bs=bm.marks[">"].find();var bl=bm.lastSelection;if(bl){var bq=bl.curStartMark.find();var bt=bl.curEndMark.find();var bp=bl.visualBlock;a3(br,bm,bo,bs);if(bp){br.setCursor(bq);bq=F(br,bt)}else{br.setSelection(bq,bt);bq=br.getCursor("anchor");bt=br.getCursor("head")}if(bm.visualMode){aK(br,bm,"<",aH(bq,bt)?bq:bt);aK(br,bm,">",aH(bq,bt)?bt:bq)}bm.visualMode=true;if(bl.visualLine){bm.visualLine=true;bm.visualBlock=false}else{if(bl.visualBlock){bm.visualLine=false;bm.visualBlock=true}else{bm.visualBlock=bm.visualLine=false}}b.signal(br,"vim-mode-change",{mode:"visual",subMode:bm.visualLine?"linewise":""})}},joinLines:function(bm,bn,bo){var bl,bq;if(bo.visualMode){bl=bm.getCursor("anchor");bq=bm.getCursor("head");bq.ch=aM(bm,bq.line)-1}else{var bp=Math.max(bn.repeat,2);bl=bm.getCursor();bq=W(bm,c(bl.line+bp-1,Infinity))}var br=0;bm.operation(function(){for(var bu=bl.line;bu1){var bC=Array(by.repeat+1).join(bC)}var bv=bm.linewise;var bx=bm.blockwise;if(bv){if(bG.visualMode){bC=bG.visualLine?bC.slice(0,-1):"\n"+bC.slice(0,bC.length-1)+"\n"}else{if(by.after){bC="\n"+bC.slice(0,bC.length-1);bs.ch=aM(bz,bs.line)}else{bs.ch=0}}}else{if(bx){bC=bC.split("\n");for(var bH=0;bHbz.lastLine()){bz.replaceRange("\n",c(bA,0))}var bJ=aM(bz,bA);if(bJbv.length){br=bv.length}bu=c(bs.line,br)}if(bo=="\n"){if(!bp.visualMode){bt.replaceRange("",bs,bu)}(b.commands.newlineAndIndentContinueComment||b.commands.newlineAndIndent)(bt)}else{var bl=bt.getRange(bs,bu);bl=bl.replace(/[^\n]/g,bo);if(bp.visualBlock){var bq=new Array(bt.options.tabSize+1).join(" ");bl=bt.getSelection();bl=bl.replace(/\t/g,bq).replace(/[^\n]/g,bo).split("\n");bt.replaceSelections(bl)}else{bt.replaceRange(bl,bs,bu)}if(bp.visualMode){bs=aH(bm[0].anchor,bm[0].head)?bm[0].anchor:bm[0].head;bt.setCursor(bs);aL(bt)}else{bt.setCursor(D(bu,0,-1))}}},incrementNumberToken:function(bv,bm){var bw=bv.getCursor();var br=bv.getLine(bw.line);var by=/-?\d+/g;var bq;var bl;var bp;var bx;var bn;while((bq=by.exec(br))!==null){bn=bq[0];bl=bq.index;bp=bl+bn.length;if(bw.ch"){var bm=bl.length-11;var bp=bo.slice(0,bm);var bn=bl.slice(0,bm);return bp==bn&&bo.length>bm?"full":bn.indexOf(bp)==0?"partial":false}else{return bo==bl?"full":bl.indexOf(bo)==0?"partial":false}}function O(bn){var bm=/^.*(<[\w\-]+>)$/.exec(bn);var bl=bm?bm[1]:bn.slice(-1);if(bl.length>1){switch(bl){case"":bl="\n";break;case"":bl=" ";break;default:break}}return bl}function ar(bl,bm,bn){return function(){for(var bo=0;bobA.line){bB="down"}else{if(bm.ch!=bA.ch){bB=bm.ch>bA.ch?"right":"left"}bz=bw.getCursor("anchor")}}var bC=u(bn,bA);bm=bw.clipPos(bm);var bx=u(bn,bm)<0?false:true;var bD=!bj(bt,bm);var bo=function(){if(bD){if(bA.ch>=bz.ch){bz.ch++}}else{if(bA.ch==aM(bw,bA.line)){if(bj(bn[bC].anchor,bn[bC].head)&&bn.length>1){if(bB=="up"){if(bx||bC>0){br=bu.line;bp=bm.line;bz=bn[bC-1].anchor}}else{if(bx||bC==0){bp=bl.line;br=bm.line;bz=bn[bC+1].anchor}}if(bm.ch>=bz.ch){bz.ch--}}}}};switch(bB){case"up":br=bx?bu.line:bm.line;bp=bx?bm.line:bl.line;bz=bl;bo();break;case"down":br=bx?bm.line:bu.line;bp=bx?bl.line:bm.line;bz=bu;bo();break;case"left":if((bm.ch<=bz.ch)&&(bA.ch>bz.ch)){bz.ch++;bm.ch--}break;case"right":if((bz.ch<=bm.ch)&&(bA.ch"].find()||br.getCursor("head")}if(bp.lastPastedText){bs=br.posFromIndex(br.indexFromPos(bq)+bp.lastPastedText.length);bp.lastPastedText=null}var bl=br.listSelections();var bn=u(bl,bq,"head")>-1;if(bp.visualBlock){var bt=Math.abs(bq.line-bs.line)+1;var bm=Math.abs(bq.ch-bs.ch);var bo={height:bt,width:bm}}bp.lastSelection={curStartMark:br.setBookmark(bn?bs:bq),curEndMark:br.setBookmark(bn?bq:bs),visualMode:bp.visualMode,visualLine:bp.visualLine,visualBlock:bo}}function v(bl,bq,bm){var bp=bl.getCursor("head");var bn=bl.getCursor("anchor");var bo;if(aH(bm,bq)){bo=bm;bm=bq;bq=bo}if(aH(bp,bn)){bp=aq(bq,bp);bn=aY(bn,bm)}else{bn=aq(bq,bn);bp=aY(bp,bm)}return[bn,bp]}function i(bl){var bm=bl.getCursor("head");if(bl.getSelection().length==1){bm=aq(bm,bl.getCursor("anchor"))}return bm}function aL(bl){bl.off("mousedown",aL);var bm=bl.state.vim;var bn=bl.getCursor("anchor");var bo=bl.getCursor("head");if(bm.visualBlock&&(aH(bn,bo))){bo.ch--}a3(bl,bm);bm.visualMode=false;bm.visualLine=false;bm.visualBlock=false;if(!bj(bn,bo)){bl.setCursor(W(bl,bo))}b.signal(bl,"vim-mode-change",{mode:"normal"});if(bm.fakeCursor){bm.fakeCursor.clear()}}function ah(bm,bl,bq){var bp=bm.getRange(bl,bq);if(/\n\s*$/.test(bp)){var bo=bp.split("\n");bo.pop();var bn;for(var bn=bo.pop();bo.length>0&&bn&&Q(bn);bn=bo.pop()){bq.line--;bq.ch=0}if(bn){bq.line--;bq.ch=aM(bm,bq.line)}else{bq.ch=0}}}function a2(bm,bl,bn){bl.ch=0;bn.ch=0;bn.line++}function aQ(bm){if(!bm){return 0}var bl=bm.search(/\S/);return bl==-1?bm.length:bl}function ay(bu,bq,bE,bm,bF){var bo=i(bu);var bx=bu.getLine(bo.line);var bA=bo.ch;var bz=bx.substring(bA);var bB;if(bF){bB=bz.search(/\w/)}else{bB=bz.search(/\S/)}if(bB==-1){return null}bA+=bB;bz=bx.substring(bA);var bD=bx.substring(0,bA);var bG;if(bm){bG=/^\S+/}else{if((/\w/).test(bx.charAt(bA))){bG=/^\w+/}else{bG=/^[^\w\s]+/}}var br=bG.exec(bz);var by=bA;var bn=bA+br[0].length;var bp=m(bD);var bv=bG.exec(bp);if(bv){by-=bv[0].length}if(bq){var bw=bx.substring(bn);var bl=bw.match(/^\s*/)[0].length;if(bl>0){bn+=bl}else{var bt=bp.length-by;var bs=bp.substring(bt);var bC=bs.match(/^\s*/)[0].length;by-=bC}}return{start:c(bo.line,by),end:c(bo.line,bn)}}function a4(bl,bm,bn){if(!bj(bm,bn)){s.jumpList.add(bl,bm,bn)}}function ax(bl,bm){s.lastChararacterSearch.increment=bl;s.lastChararacterSearch.forward=bm.forward;s.lastChararacterSearch.selectedCharacter=bm.selectedCharacter}var R={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"};var aP={bracket:{isComplete:function(bl){if(bl.nextCh===bl.symb){bl.depth++;if(bl.depth>=1){return true}}else{if(bl.nextCh===bl.reverseSymb){bl.depth--}}return false}},section:{init:function(bl){bl.curMoveThrough=true;bl.symb=(bl.forward?"]":"[")===bl.symb?"{":"}"},isComplete:function(bl){return bl.index===0&&bl.nextCh===bl.symb}},comment:{isComplete:function(bm){var bl=bm.lastCh==="*"&&bm.nextCh==="/";bm.lastCh=bm.nextCh;return bl}},method:{init:function(bl){bl.symb=(bl.symb==="m"?"{":"}");bl.reverseSymb=bl.symb==="{"?"}":"{"},isComplete:function(bl){if(bl.nextCh===bl.symb){return true}return false}},preprocess:{init:function(bl){bl.index=0},isComplete:function(bm){if(bm.nextCh==="#"){var bl=bm.lineText.match(/#(\w+)/)[1];if(bl==="endif"){if(bm.forward&&bm.depth===0){return true}bm.depth++}else{if(bl==="if"){if(!bm.forward&&bm.depth===0){return true}bm.depth--}}if(bl==="else"&&bm.depth===0){return true}}return false}}};function be(bu,bm,bp,bn){var bx=C(bu.getCursor());var bv=bp?1:-1;var bo=bp?bu.lineCount():-1;var bt=bx.ch;var bz=bx.line;var bs=bu.getLine(bz);var bl={lineText:bs,nextCh:bs.charAt(bt),lastCh:null,index:bt,symb:bn,reverseSymb:(bp?{")":"(","}":"{"}:{"(":")","{":"}"})[bn],forward:bp,depth:0,curMoveThrough:false};var bq=R[bn];if(!bq){return bx}var by=aP[bq].init;var bw=aP[bq].isComplete;if(by){by(bl)}while(bz!==bo&&bm){bl.index+=bv;bl.nextCh=bl.lineText.charAt(bl.index);if(!bl.nextCh){bz+=bv;bl.lineText=bu.getLine(bz)||"";if(bv>0){bl.index=0}else{var br=bl.lineText.length;bl.index=(br>0)?(br-1):0}bl.nextCh=bl.lineText.charAt(bl.index)}if(bw(bl)){bx.line=bz;bx.ch=bl.index;bm--}}if(bl.nextCh||bl.curMoveThrough){return c(bz,bl.index)}return bx}function bg(bv,bw,bo,bt,bu){var bp=bw.line;var bs=bw.ch;var bz=bv.getLine(bp);var bm=bo?1:-1;var bq=bt?ba:am;if(bu&&bz==""){bp+=bm;bz=bv.getLine(bp);if(!h(bv,bp)){return null}bs=(bo)?0:bz.length}while(true){if(bu&&bz==""){return{from:0,to:0,line:bp}}var br=(bm>0)?bz.length:-1;var by=br,bx=br;while(bs!=br){var bl=false;for(var bn=0;bn0)?0:bz.length}throw new Error("The impossible happened.")}function aw(bv,bm,bq,bz,bt){var bx=bv.getCursor();var br=C(bx);var bs=[];if(bq&&!bz||!bq&&bz){bm++}var bu=!(bq&&bz);for(var bo=0;bobp.ch)||(bm.line>bp.line)){var br=bm;bm=bp;bp=br}if(bt){bp.ch+=1}else{bm.ch+=1}return{start:bm,end:bp}}function aJ(bt,bn,bs){var bu=C(i(bt));var bv=bt.getLine(bu.line);var br=bv.split("");var bm,bo,bp,bq;var bl=br.indexOf(bn);if(bu.ch-1&&!bm;bp--){if(br[bp]==bn){bm=bp+1}}}if(bm&&!bo){for(bp=bm,bq=br.length;bp'+bm+"
",{bottom:true,duration:5000})}else{alert(bm)}}function aA(bm,bn){var bl="";if(bm){bl+=''+bm+""}bl+=' ';if(bn){bl+='';bl+=bn;bl+=""}return bl}var N="(Javascript regexp)";function aR(bm,bn){var bo=(bn.prefix||"")+" "+(bn.desc||"");var bl=aA(bn.prefix,bn.desc);Y(bm,bl,bo,bn.onClose,bn)}function V(bm,bl){if(bm instanceof RegExp&&bl instanceof RegExp){var bo=["global","multiline","ignoreCase","source"];for(var bn=0;bn=bm&&bn<=bl)}else{return bn==bm}}}function a1(bl){var bo=bl.getScrollInfo();var bn=6;var br=10;var bq=bl.coordsChar({left:0,top:bn+bo.top},"local");var bm=bo.clientHeight-br+bo.top;var bp=bl.coordsChar({left:0,top:bm},"local");return{top:bq.line,bottom:bp.line}}var B=[{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"set"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:true},{name:"nohlsearch",shortName:"noh"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:true},{name:"global",shortName:"g"}];e.ExCommandDispatcher=function(){this.buildCommandMap_()};e.ExCommandDispatcher.prototype={processCommand:function(bw,bv,bm){var bq=bw.state.vim;var bn=s.registerController.getRegister(":");var bt=bn.toString();if(bq.visualMode){aL(bw)}var bl=new b.StringStream(bv);bn.setText(bv);var bp=bm||{};bp.input=bv;try{this.parseInput_(bw,bl,bp)}catch(bu){a9(bw,bu);throw bu}var bo;var bs;if(!bp.commandName){if(bp.line!==undefined){bs="move"}}else{bo=this.matchCommand_(bp.commandName);if(bo){bs=bo.name;if(bo.excludeFromCommandHistory){bn.setText(bt)}this.parseCommandArgs_(bl,bp,bo);if(bo.type=="exToKey"){for(var br=0;br0;bl--){var bn=bm.substring(0,bl);if(this.commandMap_[bn]){var bo=this.commandMap_[bn];if(bo.name.indexOf(bm)===0){return bo}}}return null},buildCommandMap_:function(){this.commandMap_={};for(var bm=0;bm
";if(!bs){for(var bl in bp){var bt=bp[bl].toString();if(bt.length){bn+='"'+bl+" "+bt+"
"}}}else{var bl;bs=bs.join("");for(var bo=0;bo"}}a9(bq,bn)},sort:function(bu,bE){var bv,bo,bm,bn;function bp(){if(bE.argString){var bI=new b.StringStream(bE.argString);if(bI.eat("!")){bv=true}if(bI.eol()){return}if(!bI.eatSpace()){return"Invalid arguments"}var bK=bI.match(/[a-z]+/);if(bK){bK=bK[0];bo=bK.indexOf("i")!=-1;bm=bK.indexOf("u")!=-1;var bH=bK.indexOf("d")!=-1&&1;var bJ=bK.indexOf("x")!=-1&&1;var bG=bK.indexOf("o")!=-1&&1;if(bH+bJ+bG>1){return"Invalid arguments"}bn=bH&&"decimal"||bJ&&"hex"||bG&&"octal"}if(bI.eatSpace()&&bI.match(/\/.*\//)){"patterns not supported"}}}var bq=bp();if(bq){a9(bu,bq+": "+bE.argString);return}var bz=bE.line||bu.firstLine();var bD=bE.lineEnd||bE.line||bu.lastLine();if(bz==bD){return}var bt=c(bz,0);var bB=c(bD,aM(bu,bD));var by=bu.getRange(bt,bB).split("\n");var br=(bn=="decimal")?/(-?)([\d]+)/:(bn=="hex")?/(-?)(?:0x)?([0-9a-f]+)/i:(bn=="octal")?/([0-7]+)/:null;var bs=(bn=="decimal")?10:(bn=="hex")?16:(bn=="octal")?8:null;var bw=[],bA=[];if(bn){for(var bC=0;bC"}}if(!bo){a9(by,bu);return}var bt=0;var bz=function(){if(bt=bu){a9(bv,"Invalid argument: "+bq.argString.substring(bt));return}for(var br=0;br<=bu-bm;br++){var bp=String.fromCharCode(bm+br);delete bl.marks[bp]}}else{a9(bv,"Invalid argument: "+bo+"-");return}}else{delete bl.marks[bn]}}}};var o=new e.ExCommandDispatcher();function aW(bz,bm,bo,bu,bs,bn,bw,bq,bA){bz.state.vim.exMode=true;var br=false;var by=bn.from();function bv(){bz.operation(function(){while(!br){bp();bt()}bx()})}function bp(){var bC=bz.getRange(bn.from(),bn.to());var bB=bC.replace(bw,bq);bn.replace(bB)}function bt(){var bB;while(bB=bn.findNext()&&aa(bn.from(),bu,bs)){if(!bo&&by&&bn.from().line==by.line){continue}bz.scrollIntoView(bn.from(),30);bz.setSelection(bn.from(),bn.to());by=bn.from();br=false;return}br=true}function bx(bC){if(bC){bC()}bz.focus();if(by){bz.setCursor(by);var bB=bz.state.vim;bB.exMode=false;bB.lastHPos=bB.lastHSPos=by.ch}if(bA){bA()}}function bl(bE,bB,bF){b.e_stop(bE);var bC=b.keyName(bE);switch(bC){case"Y":bp();bt();break;case"N":bt();break;case"A":var bD=bA;bA=undefined;bz.operation(bv);bA=bD;break;case"L":bp();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":bx(bF);break}if(br){bx(bF)}}bt();if(br){a9(bz,"No matches for "+bw.source);return}if(!bm){bv();if(bA){bA()}return}aR(bz,{prefix:"replace with "+bq+" (y/n/a/q/l)",onKeyDown:bl})}b.keyMap.vim={nofallthrough:true,style:"fat-cursor"};function w(bt){var bm=bt.state.vim;var bo=s.macroModeState;var br=s.registerController.getRegister(".");var bl=bo.isPlaying;var bp=bo.lastInsertModeChanges;var bu=[];if(!bl){var bq=bp.inVisualBlock?bm.lastSelection.visualBlock.height:1;var bs=bp.changes;var bu=[];var bn=0;while(bn1){y(bt,bm,bm.insertModeRepeat-1,true);bm.lastEditInputState.repeatOverride=bm.insertModeRepeat}delete bm.insertModeRepeat;bm.insertMode=false;bt.setCursor(bt.getCursor().line,bt.getCursor().ch-1);bt.setOption("keyMap","vim");bt.setOption("disableInput",true);bt.toggleOverwrite(false);br.setText(bp.changes.join(""));b.signal(bt,"vim-mode-change",{mode:"normal"});if(bo.isRecording){aj(bo)}}aE("insertModeEscKeysTimeout",200,"number");b.keyMap["vim-insert"]={"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",Enter:function(bl){var bm=b.commands.newlineAndIndentContinueComment||b.commands.newlineAndIndent;bm(bl)},fallthrough:["default"]};b.keyMap["await-second"]={fallthrough:["vim-insert"]};b.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"]};function H(bt,bn,bo,bl){var bv=s.registerController.getRegister(bl);var bm=bv.keyBuffer;var br=0;bo.isPlaying=true;bo.replaySearchQueries=bv.searchQueries.slice(0);for(var bp=0;bp|<\w+>|./).exec(bw);bu=bq[0];bw=bw.substring(bq.index+bu.length);b.Vim.handleKey(bt,bu,"macro");if(bn.insertMode){var bs=bv.insertModeChanges[br++].changes;s.macroModeState.lastInsertModeChanges.changes=bs;an(bt,bs,1);w(bt)}}}bo.isPlaying=false}function I(bo,bl){if(bo.isPlaying){return}var bn=bo.latestRegister;var bm=s.registerController.getRegister(bn);if(bm){bm.pushText(bl)}}function aj(bn){if(bn.isPlaying){return}var bm=bn.latestRegister;var bl=s.registerController.getRegister(bm);if(bl){bl.pushInsertModeChanges(bn.lastInsertModeChanges)}}function M(bo,bn){if(bo.isPlaying){return}var bm=bo.latestRegister;var bl=s.registerController.getRegister(bm);if(bl){bl.pushSearchQuery(bn)}}function a5(bm,bl){var bo=s.macroModeState;var bn=bo.lastInsertModeChanges;if(!bo.isPlaying){while(bl){bn.expectCursorActivityForChange=true;if(bl.origin=="+input"||bl.origin=="paste"||bl.origin===undefined){var bp=bl.text.join("\n");bn.changes.push(bp)}bl=bl.next}}}function X(bs){var bl=bs.state.vim;if(bl.insertMode){var bm=s.macroModeState;if(bm.isPlaying){return}var bn=bm.lastInsertModeChanges;if(bn.expectCursorActivityForChange){bn.expectCursorActivityForChange=false}else{bn.changes=[]}}else{if(bs.doc.history.lastSelOrigin=="*mouse"){bl.lastHPos=bs.doc.getCursor().ch;t(bs,bl)}}if(bl.visualMode){var bq,bp;bq=bp=bs.getCursor("head");var bo=bs.getCursor("anchor");var br=c(bp.line,bq.ch+(aH(bo,bp)?-1:1));if(aH(br,bq)){var bt=bq;bq=br;br=bt}if(bl.fakeCursor){bl.fakeCursor.clear()}bl.fakeCursor=bs.markText(bq,br,{className:"cm-animate-fat-cursor"})}}function t(bl,bm){var bn=bl.getCursor("anchor");var bo=bl.getCursor("head");if(!bm.visualMode&&!bm.insertMode&&bl.somethingSelected()){bm.visualMode=true;bm.visualLine=false;b.signal(bl,"vim-mode-change",{mode:"visual"});bl.on("mousedown",aL)}if(bm.visualMode){aK(bl,bm,"<",aq(bo,bn));aK(bl,bm,">",aY(bo,bn))}}function a7(bl){this.keyName=bl}function U(bp){var bo=s.macroModeState;var bn=bo.lastInsertModeChanges;var bm=b.keyName(bp);function bl(){bn.changes.push(new a7(bm));return true}if(bm.indexOf("Delete")!=-1||bm.indexOf("Backspace")!=-1){b.lookupKey(bm,["vim-insert"],bl)}}function y(bt,bo,bm,bl){var bq=s.macroModeState;bq.isPlaying=true;var bu=!!bo.lastEditActionCommand;var br=bo.inputState;function bn(){if(bu){a0.processAction(bt,bo,bo.lastEditActionCommand)}else{a0.evalInput(bt,bo)}}function bs(bw){if(bq.lastInsertModeChanges.changes.length>0){bw=!bo.lastEditActionCommand?1:bw;var bv=bq.lastInsertModeChanges;an(bt,bv.changes,bw)}}bo.inputState=bo.lastEditInputState;if(bu&&bo.lastEditActionCommand.interlaceInsertRepeat){for(var bp=0;bp screenw; - if (tooWide) x2 = y1 + screen; + if (tooWide) x2 = x1 + screenw; if (x1 < 10) result.scrollLeft = 0; else if (x1 < screenleft) @@ -4570,10 +4570,8 @@ // load a mode. (Preferred mechanism is the require/define calls.) CodeMirror.defineMode = function(name, mode) { if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name; - if (arguments.length > 2) { - mode.dependencies = []; - for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]); - } + if (arguments.length > 2) + mode.dependencies = Array.prototype.slice.call(arguments, 2); modes[name] = mode; }; @@ -4865,7 +4863,7 @@ // are simply ignored. keyMap.pcDefault = { "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", - "Ctrl-Home": "goDocStart", "Ctrl-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd", + "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", @@ -4880,7 +4878,7 @@ "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", - "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", + "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", fallthrough: ["basic", "emacsy"] }; // Very basic readline/emacs-style bindings, which are standard on Mac. @@ -4988,6 +4986,7 @@ cm.save = save; cm.getTextArea = function() { return textarea; }; cm.toTextArea = function() { + cm.toTextArea = isNaN; // Prevent this from being ran twice save(); textarea.parentNode.removeChild(cm.getWrapperElement()); textarea.style.display = ""; @@ -7825,7 +7824,7 @@ // THE END - CodeMirror.version = "4.6.0"; + CodeMirror.version = "4.7.0"; return CodeMirror; }); diff --git a/media/editors/codemirror/lib/codemirror.css b/media/editors/codemirror/lib/codemirror.css index b58ef2c8bb814..572b6938d1a31 100644 --- a/media/editors/codemirror/lib/codemirror.css +++ b/media/editors/codemirror/lib/codemirror.css @@ -1 +1 @@ -.CodeMirror{font-family:monospace;height:300px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:white}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-guttermarker{color:black}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror div.CodeMirror-cursor{border-left:1px solid black}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}@-moz-keyframes blink{0%{background:#7e7}50%{background:0}100%{background:#7e7}}@-webkit-keyframes blink{0%{background:#7e7}50%{background:0}100%{background:#7e7}}@keyframes blink{0%{background:#7e7}50%{background:0}100%{background:#7e7}}.cm-tab{display:inline-block}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:blue}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:bold}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-s-default .cm-error{color:#f00}.cm-invalidchar{color:#f00}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{line-height:1;position:relative;overflow:hidden;background:white;color:black}.CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block;*zoom:1;*display:inline}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{position:absolute;border-right:0;width:0}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.CodeMirror span{*vertical-align:text-bottom}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}span.CodeMirror-selectedtext{background:0} \ No newline at end of file +.CodeMirror{font-family:monospace;height:300px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:white}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-guttermarker{color:black}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror div.CodeMirror-cursor{border-left:1px solid black}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}@-moz-keyframes blink{0%{background:#7e7}50%{background:0}100%{background:#7e7}}@-webkit-keyframes blink{0%{background:#7e7}50%{background:0}100%{background:#7e7}}@keyframes blink{0%{background:#7e7}50%{background:0}100%{background:#7e7}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:blue}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:bold}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-s-default .cm-error{color:#f00}.cm-invalidchar{color:#f00}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{line-height:1;position:relative;overflow:hidden;background:white;color:black}.CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block;*zoom:1;*display:inline}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{position:absolute;border-right:0;width:0}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.CodeMirror span{*vertical-align:text-bottom}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}span.CodeMirror-selectedtext{background:0} \ No newline at end of file diff --git a/media/editors/codemirror/lib/codemirror.js b/media/editors/codemirror/lib/codemirror.js index 22a1e9f27f1dd..695e7c87758dd 100644 --- a/media/editors/codemirror/lib/codemirror.js +++ b/media/editors/codemirror/lib/codemirror.js @@ -1 +1 @@ -(function(a){if(typeof exports=="object"&&typeof module=="object"){module.exports=a()}else{if(typeof define=="function"&&define.amd){return define([],a)}else{this.CodeMirror=a()}}})(function(){var cn=/gecko\/\d/i.test(navigator.userAgent);var ey=/MSIE \d/.test(navigator.userAgent);var bH=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);var dz=ey||bH;var l=dz&&(ey?document.documentMode||6:bH[1]);var cU=/WebKit\//.test(navigator.userAgent);var dB=cU&&/Qt\/\d+\.\d+/.test(navigator.userAgent);var c6=/Chrome\//.test(navigator.userAgent);var dQ=/Opera\//.test(navigator.userAgent);var aB=/Apple Computer/.test(navigator.vendor);var a7=/KHTML\//.test(navigator.userAgent);var c1=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);var fi=/PhantomJS/.test(navigator.userAgent);var eP=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent);var d3=eP||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);var b5=eP||/Mac/.test(navigator.platform);var aM=/win/i.test(navigator.platform);var aU=dQ&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);if(aU){aU=Number(aU[1])}if(aU&&aU>=15){dQ=false;cU=true}var bO=b5&&(dB||dQ&&(aU==null||aU<12.11));var fS=cn||(dz&&l>=9);var fV=false,a3=false;function J(f2,f3){if(!(this instanceof J)){return new J(f2,f3)}this.options=f3=f3||{};aK(eR,f3,false);cc(f3);var f5=f3.value;if(typeof f5=="string"){f5=new at(f5,f3.mode)}this.doc=f5;var f4=this.display=new ew(f2,f5);f4.wrapper.CodeMirror=this;dZ(this);cK(this);if(f3.lineWrapping){this.display.wrapper.className+=" CodeMirror-wrap"}if(f3.autofocus&&!d3){en(this)}this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:false,focused:false,suppressEdits:false,pasteIncoming:false,cutIncoming:false,draggingText:false,highlight:new f0()};if(dz&&l<11){setTimeout(ct(fc,this,true),20)}fD(this);be();var f1=this;cI(this,function(){f1.curOp.forceUpdate=true;dY(f1,f5);if((f3.autofocus&&!d3)||dC()==f4.input){setTimeout(ct(cy,f1),20)}else{aR(f1)}for(var f7 in ba){if(ba.hasOwnProperty(f7)){ba[f7](f1,f3[f7],ca)}}dT(f1);for(var f6=0;f6f3.maxLineLength){f3.maxLineLength=f4;f3.maxLine=f5}})}function cc(f1){var f2=db(f1.gutters,"CodeMirror-linenumbers");if(f2==-1&&f1.lineNumbers){f1.gutters=f1.gutters.concat(["CodeMirror-linenumbers"])}else{if(f2>-1&&!f1.lineNumbers){f1.gutters=f1.gutters.slice(0);f1.gutters.splice(f2,1)}}}function cM(f1){return f1.display.scroller.clientHeight-f1.display.wrapper.clientHeightf1.clientWidth;if(f3&&f1.scrollWidth<=f1.clientWidth+1&&f2>0&&!f1.hScrollbarTakesSpace){f3=false}var f4=f9>f1.clientHeight;if(f4){f5.scrollbarV.style.display="block";f5.scrollbarV.style.bottom=f3?f2+"px":"0";f5.scrollbarV.firstChild.style.height=Math.max(0,f9-f1.clientHeight+(f1.barHeight||f5.scrollbarV.clientHeight))+"px"}else{f5.scrollbarV.style.display="";f5.scrollbarV.firstChild.style.height="0"}if(f3){f5.scrollbarH.style.display="block";f5.scrollbarH.style.right=f4?f2+"px":"0";f5.scrollbarH.firstChild.style.width=(f1.scrollWidth-f1.clientWidth+(f1.barWidth||f5.scrollbarH.clientWidth))+"px"}else{f5.scrollbarH.style.display="";f5.scrollbarH.firstChild.style.width="0"}if(f3&&f4){f5.scrollbarFiller.style.display="block";f5.scrollbarFiller.style.height=f5.scrollbarFiller.style.width=f2+"px"}else{f5.scrollbarFiller.style.display=""}if(f3&&f8.options.coverGutterNextToScrollbar&&f8.options.fixedGutter){f5.gutterFiller.style.display="block";f5.gutterFiller.style.height=f2+"px";f5.gutterFiller.style.width=f5.gutters.offsetWidth+"px"}else{f5.gutterFiller.style.display=""}if(!f8.state.checkedOverlayScrollbar&&f1.clientHeight>0){if(f2===0){var f7=b5&&!c1?"12px":"18px";f5.scrollbarV.style.minWidth=f5.scrollbarH.style.minHeight=f7;var f6=function(ga){if(M(ga)!=f5.scrollbarV&&M(ga)!=f5.scrollbarH){cW(f8,eg)(ga)}};bV(f5.scrollbarV,"mousedown",f6);bV(f5.scrollbarH,"mousedown",f6)}f8.state.checkedOverlayScrollbar=true}}function b4(f4,f8,f3){var f5=f3&&f3.top!=null?Math.max(0,f3.top):f4.scroller.scrollTop;f5=Math.floor(f5-eV(f4));var f1=f3&&f3.bottom!=null?f3.bottom:f5+f4.wrapper.clientHeight;var f6=bE(f8,f5),f7=bE(f8,f1);if(f3&&f3.ensure){var f2=f3.ensure.from.line,f9=f3.ensure.to.line;if(f2=f7){return{from:bE(f8,bK(e2(f8,f9))-f4.wrapper.clientHeight),to:f9}}}return{from:f6,to:Math.max(f7,f6+1)}}function es(f9){var f7=f9.display,f8=f7.view;if(!f7.alignWidgets&&(!f7.gutters.firstChild||!f9.options.fixedGutter)){return}var f5=dL(f7)-f7.scroller.scrollLeft+f9.doc.scrollLeft;var f1=f7.gutters.offsetWidth,f2=f5+"px";for(var f4=0;f4=f5.viewFrom&&f4.visible.to<=f5.viewTo&&(f5.updateLineNumbers==null||f5.updateLineNumbers>=f5.viewTo)&&c5(ga)==0){return false}if(dT(ga)){ek(ga);f4.dims=e0(ga)}var f3=f9.first+f9.size;var f7=Math.max(f4.visible.from-ga.options.viewportMargin,f9.first);var f8=Math.min(f3,f4.visible.to+ga.options.viewportMargin);if(f5.viewFromf8&&f5.viewTo-f8<20){f8=Math.min(f3,f5.viewTo)}if(a3){f7=aS(ga.doc,f7);f8=dR(ga.doc,f8)}var f2=f7!=f5.viewFrom||f8!=f5.viewTo||f5.lastSizeC!=f4.wrapperHeight;cN(ga,f7,f8);f5.viewOffset=bK(e2(ga.doc,f5.viewFrom));ga.display.mover.style.top=f5.viewOffset+"px";var f1=c5(ga);if(!f2&&f1==0&&!f4.force&&(f5.updateLineNumbers==null||f5.updateLineNumbers>=f5.viewTo)){return false}var f6=dC();if(f1>4){f5.lineDiv.style.display="none"}cl(ga,f5.updateLineNumbers,f4.dims);if(f1>4){f5.lineDiv.style.display=""}if(f6&&dC()!=f6&&f6.offsetHeight){f6.focus()}dP(f5.cursorDiv);dP(f5.selectionDiv);if(f2){f5.lastSizeC=f4.wrapperHeight;d2(ga,400)}f5.updateLineNumbers=null;return true}function ci(f2,f6){var f4=f6.force,f1=f6.viewport;for(var f5=true;;f5=false){if(f5&&f2.options.lineWrapping&&f6.oldScrollerWidth!=f2.display.scroller.clientWidth){f4=true}else{f4=false;if(f1&&f1.top!=null){f1={top:Math.min(f2.doc.height+bG(f2.display)-bg-f2.display.scroller.clientHeight,f1.top)}}f6.visible=b4(f2.display,f2.doc,f1);if(f6.visible.from>=f2.display.viewFrom&&f6.visible.to<=f2.display.viewTo){break}}if(!D(f2,f6)){break}a5(f2);var f3=dq(f2);bA(f2);dp(f2,f3);eM(f2,f3)}ad(f2,"update",f2);if(f2.display.viewFrom!=f6.oldViewFrom||f2.display.viewTo!=f6.oldViewTo){ad(f2,"viewportChange",f2,f2.display.viewFrom,f2.display.viewTo)}}function dH(f2,f1){var f4=new aG(f2,f1);if(D(f2,f4)){a5(f2);ci(f2,f4);var f3=dq(f2);bA(f2);dp(f2,f3);eM(f2,f3)}}function dp(f1,f2){f1.display.sizer.style.minHeight=f1.display.heightForcer.style.top=f2.docHeight+"px";f1.display.gutters.style.height=Math.max(f2.docHeight,f2.clientHeight-bg)+"px"}function fN(f1,f2){if(f1.display.sizer.offsetWidth+f1.display.gutters.offsetWidth0.001||f7<-0.001){fO(f9.line,ga);b9(f9.line);if(f9.rest){for(var f1=0;f1-1){ga=false}aa(gc,f5,f6,gb)}if(ga){dP(f5.lineNumber);f5.lineNumber.appendChild(document.createTextNode(ef(gc.options,f6)))}gd=f5.node.nextSibling}}f6+=f5.size}while(gd){gd=f7(gd)}}function aa(f1,f3,f5,f6){for(var f2=0;f2=0&&cd(f4,f2.to())<=0){return f3}}return -1}};function dM(f1,f2){this.anchor=f1;this.head=f2}dM.prototype={from:function(){return aq(this.anchor,this.head)},to:function(){return bv(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};function cu(f1,f8){var f3=f1[f8];f1.sort(function(gb,ga){return cd(gb.from(),ga.from())});f8=db(f1,f3);for(var f5=1;f5=0){var f6=aq(f2.from(),f9.from()),f7=bv(f2.to(),f9.to());var f4=f2.empty()?f9.from()==f9.head:f2.from()==f2.head;if(f5<=f8){--f8}f1.splice(--f5,2,new dM(f4?f7:f6,f4?f6:f7))}}return new fL(f1,f8)}function eG(f1,f2){return new fL([new dM(f1,f2||f1)],0)}function cZ(f1,f2){return Math.max(f1.first,Math.min(f2,f1.first+f1.size-1))}function fx(f2,f3){if(f3.linef1){return X(f1,e2(f2,f1).text.length)}return fg(f3,e2(f2,f3.line).text.length)}function fg(f3,f2){var f1=f3.ch;if(f1==null||f1>f2){return X(f3.line,f2)}else{if(f1<0){return X(f3.line,0)}else{return f3}}}function b7(f2,f1){return f1>=f2.first&&f1=f3.ch:f1.to>f3.ch))){if(f7){aC(f2,"beforeCursorEnter");if(f2.explicitlyCleared){if(!gc.markedSpans){break}else{--f5;continue}}}if(!f2.atomic){continue}var f8=f2.find(f4<0?-1:1);if(cd(f8,f3)==0){f8.ch+=f4;if(f8.ch<0){if(f8.line>ga.first){f8=fx(ga,X(f8.line-1))}else{f8=null}}else{if(f8.ch>gc.text.length){if(f8.line3){gc(gw,gu.top,null,gu.bottom);gw=f4;if(gu.bottomgj.bottom||gv.bottom==gj.bottom&&gv.right>gj.right){gj=gv}if(gw0){f3.blinker=setInterval(function(){f3.cursorDiv.style.visibility=(f2=!f2)?"":"hidden"},f1.options.cursorBlinkRate)}else{if(f1.options.cursorBlinkRate<0){f3.cursorDiv.style.visibility="hidden"}}}function d2(f1,f2){if(f1.doc.mode.startState&&f1.doc.frontier=f1.display.viewTo){return}var f3=+new Date+f1.options.workTime;var f4=b1(f5.mode,dr(f1,f5.frontier));var f2=[];f5.iter(f5.frontier,Math.min(f5.first+f5.size,f1.display.viewTo+500),function(f6){if(f5.frontier>=f1.display.viewFrom){var f9=f6.styles;var gb=fn(f1,f6,f4,true);f6.styles=gb.styles;var f8=f6.styleClasses,ga=gb.classes;if(ga){f6.styleClasses=ga}else{if(f8){f6.styleClasses=null}}var gc=!f9||f9.length!=f6.styles.length||f8!=ga&&(!f8||!ga||f8.bgClass!=ga.bgClass||f8.textClass!=ga.textClass);for(var f7=0;!gc&&f7f3){d2(f1,f1.options.workDelay);return true}});if(f2.length){cI(f1,function(){for(var f6=0;f6f3;--ga){if(ga<=f6.first){return f6.first}var f9=e2(f6,ga-1);if(f9.stateAfter&&(!f4||ga<=f6.frontier)){return ga}var f8=bR(f9.text,null,f7.options.tabSize);if(f5==null||f2>f8){f5=ga-1;f2=f8}}return f5}function dr(f1,f7,f2){var f5=f1.doc,f4=f1.display;if(!f5.mode.startState){return true}var f6=cw(f1,f7,f2),f3=f6>f5.first&&e2(f5,f6-1).stateAfter;if(!f3){f3=bY(f5.mode)}else{f3=b1(f5.mode,f3)}f5.iter(f6,f7,function(f8){dm(f1,f8.text,f3);var f9=f6==f7-1||f6%5==0||f6>=f4.viewFrom&&f62){f6.push((f9.bottom+f2.top)/2-f7.top)}}}f6.push(f7.bottom-f7.top)}}function cr(f3,f1,f4){if(f3.line==f1){return{map:f3.measure.map,cache:f3.measure.cache}}for(var f2=0;f2f4){return{map:f3.measure.maps[f2],cache:f3.measure.caches[f2],before:true}}}}function cV(f1,f3){f3=z(f3);var f5=bL(f3);var f2=f1.display.externalMeasured=new bt(f1.doc,f3,f5);f2.lineN=f5;var f4=f2.built=eF(f1,f2);f2.text=f4.pre;bP(f1.display.lineMeasure,f4.pre);return f2}function d4(f1,f2,f4,f3){return E(f1,a0(f1,f2),f4,f3)}function eY(f1,f3){if(f3>=f1.display.viewFrom&&f3=f2.lineN&&f3ga){f4=gg-gk;f5=f4-1;if(ga>=gg){f1="right"}}}}if(f5!=null){gf=gm[gh+2];if(gk==gg&&f6==(gf.insertLeft?"left":"right")){f1=f6}if(f6=="left"&&f5==0){while(gh&&gm[gh-2]==gm[gh-3]&&gm[gh-1].insertLeft){gf=gm[(gh-=3)+2];f1="left"}}if(f6=="right"&&f5==gg-gk){while(gh0){f1=f6="right"}var f3;if(f8.options.lineWrapping&&(f3=gf.getClientRects()).length>1){f2=f3[f6=="right"?f3.length-1:0]}else{f2=gf.getBoundingClientRect()}}if(dz&&l<9&&!f5&&(!f2||!f2.left&&!f2.right)){var f7=gf.parentNode.getClientRects()[0];if(f7){f2={left:f7.left,right:f7.left+dt(f8.display),top:f7.top,bottom:f7.bottom}}else{f2=eo}}var gd=f2.top-gi.rect.top,gb=f2.bottom-gi.rect.top;var gl=(gd+gb)/2;var gj=gi.view.measure.heights;for(var gh=0;ghge.from){return f5(gg-1)}return f5(gg,gf)}var f6=a(f7),f1=f9.ch;if(!f6){return f5(f1)}var f2=aE(f6,f1);var f4=gb(f1,f2);if(eQ!=null){f4.other=gb(f1,eQ)}return f4}function dx(f1,f5){var f4=0,f5=fx(f1.doc,f5);if(!f1.options.lineWrapping){f4=dt(f1.display)*f5.ch}var f2=e2(f1.doc,f5.line);var f3=bK(f2)+eV(f1.display);return{left:f4,right:f4,top:f3,bottom:f3+f2.height}}function fJ(f1,f2,f3,f5){var f4=X(f1,f2);f4.xRel=f5;if(f3){f4.outside=true}return f4}function fC(f8,f5,f4){var f7=f8.doc;f4+=f8.display.viewOffset;if(f4<0){return fJ(f7.first,0,true,-1)}var f3=bE(f7,f4),f9=f7.first+f7.size-1;if(f3>f9){return fJ(f7.first+f7.size-1,e2(f7,f9).text.length,true,1)}if(f5<0){f5=0}var f2=e2(f7,f3);for(;;){var ga=cT(f8,f2,f3,f5,f4);var f6=ei(f2);var f1=f6&&f6.find(0,true);if(f6&&(ga.ch>f1.from.ch||ga.ch==f1.from.ch&&ga.xRel>0)){f3=bL(f2=f1.to.line)}else{return ga}}}function cT(gb,f3,ge,gd,gc){var ga=gc-bK(f3);var f7=false,gk=2*gb.display.wrapper.clientWidth;var gh=a0(gb,f3);function go(gq){var gr=dI(gb,X(ge,gq),"line",f3,gh);f7=true;if(ga>gr.bottom){return gr.left-gk}else{if(gaf2){return fJ(ge,f4,f6,1)}for(;;){if(gg?f4==gl||f4==v(f3,gl,1):f4-gl<=1){var gf=gd1?1:0);return f9}var f8=Math.ceil(gj/2),gp=gl+f8;if(gg){gp=gl;for(var gm=0;gmgd){f4=gp;f2=f5;if(f6=f7){f2+=1000}gj=f8}else{gl=gp;gi=f5;f1=f7;gj-=f8}}}var aF;function aT(f3){if(f3.cachedTextHeight!=null){return f3.cachedTextHeight}if(aF==null){aF=fK("pre");for(var f2=0;f2<49;++f2){aF.appendChild(document.createTextNode("x"));aF.appendChild(fK("br"))}aF.appendChild(document.createTextNode("x"))}bP(f3.measure,aF);var f1=aF.offsetHeight/50;if(f1>3){f3.cachedTextHeight=f1}dP(f3.measure);return f1||1}function dt(f5){if(f5.cachedCharWidth!=null){return f5.cachedCharWidth}var f1=fK("span","xxxxxxxxxx");var f4=fK("pre",[f1]);bP(f5.measure,f4);var f3=f1.getBoundingClientRect(),f2=(f3.right-f3.left)/10;if(f2>2){f5.cachedCharWidth=f2}return f2||10}var bn=null;var dW=0;function cE(f1){f1.curOp={cm:f1,viewChanged:false,startHeight:f1.doc.height,forceUpdate:false,updateInput:null,typing:false,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:false,updateMaxLine:false,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++dW};if(bn){bn.ops.push(f1.curOp)}else{f1.curOp.ownsGroup=bn={ops:[f1.curOp],delayedCallbacks:[]}}}function cP(f4){var f3=f4.delayedCallbacks,f2=0;do{for(;f2=f2.viewTo)||f2.maxLineChanged&&f1.options.lineWrapping;f3.update=f3.mustUpdate&&new aG(f1,f3.mustUpdate&&{top:f3.scrollTop,ensure:f3.scrollToPos},f3.forceUpdate)}function ap(f1){f1.updatedDisplay=f1.mustUpdate&&D(f1.cm,f1.update)}function b0(f3){var f1=f3.cm,f2=f1.display;if(f3.updatedDisplay){a5(f1)}f3.barMeasure=dq(f1);if(f2.maxLineChanged&&!f1.options.lineWrapping){f3.adjustWidthTo=d4(f1,f2.maxLine,f2.maxLine.text.length).left+3;f3.maxScrollLeft=Math.max(0,f2.sizer.offsetLeft+f3.adjustWidthTo+bg-f2.scroller.clientWidth)}if(f3.updatedDisplay||f3.selectionChanged){f3.newSelectionNodes=bj(f1)}}function ao(f2){var f1=f2.cm;if(f2.adjustWidthTo!=null){f1.display.sizer.style.minWidth=f2.adjustWidthTo+"px";if(f2.maxScrollLeft1){eM(ga)}if(f4.updatedDisplay){ci(ga,f4.update)}if(f6.wheelStartX!=null&&(f4.scrollTop!=null||f4.scrollLeft!=null||f4.scrollToPos)){f6.wheelStartX=f6.wheelStartY=null}if(f4.scrollTop!=null&&(f6.scroller.scrollTop!=f4.scrollTop||f4.forceScroll)){var f7=Math.max(0,Math.min(f6.scroller.scrollHeight-f6.scroller.clientHeight,f4.scrollTop));f6.scroller.scrollTop=f6.scrollbarV.scrollTop=f9.scrollTop=f7}if(f4.scrollLeft!=null&&(f6.scroller.scrollLeft!=f4.scrollLeft||f4.forceScroll)){var f2=Math.max(0,Math.min(f6.scroller.scrollWidth-f6.scroller.clientWidth,f4.scrollLeft));f6.scroller.scrollLeft=f6.scrollbarH.scrollLeft=f9.scrollLeft=f2;es(ga)}if(f4.scrollToPos){var f8=F(ga,fx(f9,f4.scrollToPos.from),fx(f9,f4.scrollToPos.to),f4.scrollToPos.margin);if(f4.scrollToPos.isCursor&&ga.state.focused){dU(ga,f8)}}var f5=f4.maybeHiddenMarkers,f1=f4.maybeUnhiddenMarkers;if(f5){for(var f3=0;f3f4.barMeasure.clientWidth&&f4.barMeasure.scrollWidthf6)){f3.updateLineNumbers=f6}f8.curOp.viewChanged=true;if(f6>=f3.viewTo){if(a3&&aS(f8.doc,f6)f3.viewFrom){ek(f8)}else{f3.viewFrom+=f9;f3.viewTo+=f9}}else{if(f6<=f3.viewFrom&&f7>=f3.viewTo){ek(f8)}else{if(f6<=f3.viewFrom){var f5=c8(f8,f7,f7+f9,1);if(f5){f3.view=f3.view.slice(f5.index);f3.viewFrom=f5.lineN;f3.viewTo+=f9}else{ek(f8)}}else{if(f7>=f3.viewTo){var f5=c8(f8,f6,f6,-1);if(f5){f3.view=f3.view.slice(0,f5.index);f3.viewTo=f5.lineN}else{ek(f8)}}else{var f4=c8(f8,f6,f6,-1);var f2=c8(f8,f7,f7+f9,1);if(f4&&f2){f3.view=f3.view.slice(0,f4.index).concat(eJ(f8,f4.lineN,f2.lineN)).concat(f3.view.slice(f2.index));f3.viewTo+=f9}else{ek(f8)}}}}}}var f1=f3.externalMeasured;if(f1){if(f7=f5.lineN&&f3=f7.viewTo){return}var f4=f7.view[dh(f2,f3)];if(f4.node==null){return}var f1=f4.changes||(f4.changes=[]);if(db(f1,f6)==-1){f1.push(f6)}}function ek(f1){f1.display.viewFrom=f1.display.viewTo=f1.doc.first;f1.display.view=[];f1.display.viewOffset=0}function dh(f1,f4){if(f4>=f1.display.viewTo){return null}f4-=f1.display.viewFrom;if(f4<0){return null}var f2=f1.display.view;for(var f3=0;f30){if(f6==f7.length-1){return null}f8=(f1+f7[f6].size)-f3;f6++}else{f8=f1-f3}f3+=f8;f5+=f8}while(aS(f9.doc,f5)!=f5){if(f6==(f2<0?0:f7.length-1)){return null}f5+=f2*f7[f6-(f2<0?1:0)].size;f6+=f2}return{index:f6,lineN:f5}}function cN(f1,f5,f4){var f3=f1.display,f2=f3.view;if(f2.length==0||f5>=f3.viewTo||f4<=f3.viewFrom){f3.view=eJ(f1,f5,f4);f3.viewFrom=f5}else{if(f3.viewFrom>f5){f3.view=eJ(f1,f5,f3.viewFrom).concat(f3.view)}else{if(f3.viewFromf4){f3.view=f3.view.slice(0,dh(f1,f4))}}}f3.viewTo=f4}function c5(f1){var f2=f1.display.view,f5=0;for(var f4=0;f4=9&&f5.display.inputHasSelection===f8||b5&&/[\uf700-\uf7ff]/.test(f8)){fc(f5);return false}var gg=!f5.curOp;if(gg){cE(f5)}f5.display.shift=false;if(f8.charCodeAt(0)==8203&&gk.sel==f5.display.selForContextMenu&&!f9){f9="\u200b"}var gf=0,gc=Math.min(f9.length,f8.length);while(gf1){if(bi&&bi.join("\n")==f2){gj=gk.sel.ranges.length%bi.length==0&&bQ(bi,aW)}else{if(ga.length==gk.sel.ranges.length){gj=bQ(ga,function(gl){return[gl]})}}}for(var gh=gk.sel.ranges.length-1;gh>=0;gh--){var gb=gk.sel.ranges[gh];var gd=gb.from(),f1=gb.to();if(gf-1){ac(f5,f3.line,"smart");break}}}else{if(f7.electricInput){if(f7.electricInput.test(e2(gk,f3.line).text.slice(0,f3.ch))){ac(f5,f3.line,"smart")}}}}}fu(f5);f5.curOp.updateInput=f4;f5.curOp.typing=true;if(f8.length>1000||f8.indexOf("\n")>-1){f6.value=f5.display.prevInput=""}else{f5.display.prevInput=f8}if(gg){al(f5)}f5.state.pasteIncoming=f5.state.cutIncoming=false;return true}function fc(f1,f5){var f2,f4,f7=f1.doc;if(f1.somethingSelected()){f1.display.prevInput="";var f3=f7.sel.primary();f2=c4&&(f3.to().line-f3.from().line>100||(f4=f1.getSelection()).length>1000);var f6=f2?"-":f4||f1.getSelection();f1.display.input.value=f6;if(f1.state.focused){dA(f1.display.input)}if(dz&&l>=9){f1.display.inputHasSelection=f6}}else{if(!f5){f1.display.prevInput=f1.display.input.value="";if(dz&&l>=9){f1.display.inputHasSelection=null}}}f1.display.inaccurateSelection=f2}function en(f1){if(f1.options.readOnly!="nocursor"&&(!d3||dC()!=f1.display.input)){f1.display.input.focus()}}function s(f1){if(!f1.state.focused){en(f1);cy(f1)}}function ai(f1){return f1.options.readOnly||f1.doc.cantEdit}function fD(f1){var f3=f1.display;bV(f3.scroller,"mousedown",cW(f1,eg));if(dz&&l<11){bV(f3.scroller,"dblclick",cW(f1,function(f7){if(aO(f1,f7)){return}var f8=cm(f1,f7);if(!f8||m(f1,f7)||a6(f1.display,f7)){return}cC(f7);var f6=f1.findWordAt(f8);fH(f1.doc,f6.anchor,f6.head)}))}else{bV(f3.scroller,"dblclick",function(f6){aO(f1,f6)||cC(f6)})}bV(f3.lineSpace,"selectstart",function(f6){if(!a6(f3,f6)){cC(f6)}});if(!fS){bV(f3.scroller,"contextmenu",function(f6){ay(f1,f6)})}bV(f3.scroller,"scroll",function(){if(f3.scroller.clientHeight){O(f1,f3.scroller.scrollTop);bC(f1,f3.scroller.scrollLeft,true);aC(f1,"scroll",f1)}});bV(f3.scrollbarV,"scroll",function(){if(f3.scroller.clientHeight){O(f1,f3.scrollbarV.scrollTop)}});bV(f3.scrollbarH,"scroll",function(){if(f3.scroller.clientHeight){bC(f1,f3.scrollbarH.scrollLeft)}});bV(f3.scroller,"mousewheel",function(f6){b(f1,f6)});bV(f3.scroller,"DOMMouseScroll",function(f6){b(f1,f6)});function f5(){if(f1.state.focused){setTimeout(ct(en,f1),0)}}bV(f3.scrollbarH,"mousedown",f5);bV(f3.scrollbarV,"mousedown",f5);bV(f3.wrapper,"scroll",function(){f3.wrapper.scrollTop=f3.wrapper.scrollLeft=0});bV(f3.input,"keyup",function(f6){bd.call(f1,f6)});bV(f3.input,"input",function(){if(dz&&l>=9&&f1.display.inputHasSelection){f1.display.inputHasSelection=null}C(f1)});bV(f3.input,"keydown",cW(f1,q));bV(f3.input,"keypress",cW(f1,cv));bV(f3.input,"focus",ct(cy,f1));bV(f3.input,"blur",ct(aR,f1));function f2(f6){if(!aO(f1,f6)){ee(f6)}}if(f1.options.dragDrop){bV(f3.scroller,"dragstart",function(f6){R(f1,f6)});bV(f3.scroller,"dragenter",f2);bV(f3.scroller,"dragover",f2);bV(f3.scroller,"drop",cW(f1,bf))}bV(f3.scroller,"paste",function(f6){if(a6(f3,f6)){return}f1.state.pasteIncoming=true;en(f1);C(f1)});bV(f3.input,"paste",function(){if(cU&&!f1.state.fakedLastChar&&!(new Date-f1.state.lastMiddleDown<200)){var f7=f3.input.selectionStart,f6=f3.input.selectionEnd;f3.input.value+="$";f3.input.selectionEnd=f6;f3.input.selectionStart=f7;f1.state.fakedLastChar=true}f1.state.pasteIncoming=true;C(f1)});function f4(ga){if(f1.somethingSelected()){bi=f1.getSelections();if(f3.inaccurateSelection){f3.prevInput="";f3.inaccurateSelection=false;f3.input.value=bi.join("\n");dA(f3.input)}}else{var gb=[],f7=[];for(var f8=0;f8f3-400&&cd(c7.pos,f7)==0){f4="triple"}else{if(de&&de.time>f3-400&&cd(de.pos,f7)==0){f4="double";c7={time:f3,pos:f7}}else{f4="single";de={time:f3,pos:f7}}}var f5=f2.doc.sel,f1=b5?f6.metaKey:f6.ctrlKey;if(f2.options.dragDrop&&ez&&!ai(f2)&&f4=="single"&&f5.contains(f7)>-1&&f5.somethingSelected()){aZ(f2,f6,f7,f1)}else{n(f2,f6,f7,f4,f1)}}function aZ(f3,f5,f6,f2){var f4=f3.display;var f1=cW(f3,function(f7){if(cU){f4.scroller.draggable=false}f3.state.draggingText=false;d0(document,"mouseup",f1);d0(f4.scroller,"drop",f1);if(Math.abs(f5.clientX-f7.clientX)+Math.abs(f5.clientY-f7.clientY)<10){cC(f7);if(!f2){fH(f3.doc,f6)}en(f3);if(dz&&l==9){setTimeout(function(){document.body.focus();en(f3)},20)}}});if(cU){f4.scroller.draggable=true}f3.state.draggingText=f1;if(f4.scroller.dragDrop){f4.scroller.dragDrop()}bV(document,"mouseup",f1);bV(f4.scroller,"drop",f1)}function n(f4,gi,f3,f1,f6){var gf=f4.display,gk=f4.doc;cC(gi);var f2,gj,f5=gk.sel;if(f6&&!gi.shiftKey){gj=gk.sel.contains(f3);if(gj>-1){f2=gk.sel.ranges[gj]}else{f2=new dM(f3,f3)}}else{f2=gk.sel.primary()}if(gi.altKey){f1="rect";if(!f6){f2=new dM(f3,f3)}f3=cm(f4,gi,true,true);gj=-1}else{if(f1=="double"){var gg=f4.findWordAt(f3);if(f4.display.shift||gk.extend){f2=fj(gk,f2,gg.anchor,gg.head)}else{f2=gg}}else{if(f1=="triple"){var f9=new dM(X(f3.line,0),fx(gk,X(f3.line+1,0)));if(f4.display.shift||gk.extend){f2=fj(gk,f2,f9.anchor,f9.head)}else{f2=f9}}else{f2=fj(gk,f2,f3)}}}if(!f6){gj=0;bS(gk,new fL([f2],0),N);f5=gk.sel}else{if(gj>-1){e(gk,gj,f2,N)}else{gj=gk.sel.ranges.length;bS(gk,cu(gk.sel.ranges.concat([f2]),gj),{scroll:false,origin:"*mouse"})}}var ge=f3;function gd(gv){if(cd(ge,gv)==0){return}ge=gv;if(f1=="rect"){var gm=[],gs=f4.options.tabSize;var gl=bR(e2(gk,f3.line).text,f3.ch,gs);var gy=bR(e2(gk,gv.line).text,gv.ch,gs);var gn=Math.min(gl,gy),gw=Math.max(gl,gy);for(var gz=Math.min(f3.line,gv.line),gp=Math.min(f4.lastLine(),Math.max(f3.line,gv.line));gz<=gp;gz++){var gx=e2(gk,gz).text,go=ed(gx,gn,gs);if(gn==gw){gm.push(new dM(X(gz,go),X(gz,go)))}else{if(gx.length>go){gm.push(new dM(X(gz,go),X(gz,ed(gx,gw,gs))))}}}if(!gm.length){gm.push(new dM(f3,f3))}bS(gk,cu(f5.ranges.slice(0,gj).concat(gm),gj),{origin:"*mouse",scroll:false});f4.scrollIntoView(gv)}else{var gt=f2;var gq=gt.anchor,gu=gv;if(f1!="single"){if(f1=="double"){var gr=f4.findWordAt(gv)}else{var gr=new dM(X(gv.line,0),fx(gk,X(gv.line+1,0)))}if(cd(gr.anchor,gq)>0){gu=gr.head;gq=aq(gt.from(),gr.anchor)}else{gu=gr.anchor;gq=bv(gt.to(),gr.head)}}var gm=f5.ranges.slice(0);gm[gj]=new dM(fx(gk,gq),gu);bS(gk,cu(gm,gj),N)}}var gb=gf.wrapper.getBoundingClientRect();var f7=0;function gh(gn){var gl=++f7;var gp=cm(f4,gn,true,f1=="rect");if(!gp){return}if(cd(gp,ge)!=0){s(f4);gd(gp);var go=b4(gf,gk);if(gp.line>=go.to||gp.linegb.bottom?20:0;if(gm){setTimeout(cW(f4,function(){if(f7!=gl){return}gf.scroller.scrollTop+=gm;gh(gn)}),50)}}}function ga(gl){f7=Infinity;cC(gl);en(f4);d0(document,"mousemove",gc);d0(document,"mouseup",f8);gk.history.lastSelOrigin=null}var gc=cW(f4,function(gl){if(!fB(gl)){ga(gl)}else{gh(gl)}});var f8=cW(f4,ga);bV(document,"mousemove",gc);bV(document,"mouseup",f8)}function fZ(gc,f8,ga,gb,f4){try{var f2=f8.clientX,f1=f8.clientY}catch(f8){return false}if(f2>=Math.floor(gc.display.gutters.getBoundingClientRect().right)){return false}if(gb){cC(f8)}var f9=gc.display;var f7=f9.lineDiv.getBoundingClientRect();if(f1>f7.bottom||!e5(gc,ga)){return bJ(f8)}f1-=f7.top-f9.viewOffset;for(var f5=0;f5=f2){var gd=bE(gc.doc,f1);var f3=gc.options.gutters[f5];f4(gc,ga,gc,gd,f3,f8);return bJ(f8)}}}function m(f1,f2){return fZ(f1,f2,"gutterClick",true,ad)}var af=0;function bf(f7){var f9=this;if(aO(f9,f7)||a6(f9.display,f7)){return}cC(f7);if(dz){af=+new Date}var f8=cm(f9,f7,true),f1=f7.dataTransfer.files;if(!f8||ai(f9)){return}if(f1&&f1.length&&window.FileReader&&window.File){var f3=f1.length,ga=Array(f3),f2=0;var f5=function(gd,gc){var gb=new FileReader;gb.onload=cW(f9,function(){ga[gc]=gb.result;if(++f2==f3){f8=fx(f9.doc,f8);var ge={from:f8,to:f8,text:aW(ga.join("\n")),origin:"paste"};bb(f9.doc,ge);eU(f9.doc,eG(f8,cR(ge)))}});gb.readAsText(gd)};for(var f6=0;f6-1){f9.state.draggingText(f7);setTimeout(ct(en,f9),20);return}try{var ga=f7.dataTransfer.getData("Text");if(ga){if(f9.state.draggingText&&!(b5?f7.metaKey:f7.ctrlKey)){var f4=f9.listSelections()}ec(f9.doc,eG(f8,f8));if(f4){for(var f6=0;f6f8.clientWidth||gb&&f8.scrollHeight>f8.clientHeight)){return}if(gb&&b5&&cU){outer:for(var ga=f3.target,f7=f5.view;ga!=f8;ga=ga.parentNode){for(var f2=0;f2=9){f1.display.inputHasSelection=null}C(f1)}function cy(f1){if(f1.options.readOnly=="nocursor"){return}if(!f1.state.focused){aC(f1,"focus",f1);f1.state.focused=true;fo(f1.display.wrapper,"CodeMirror-focused");if(!f1.curOp&&f1.display.selForContextMenu!=f1.doc.sel){fc(f1);if(cU){setTimeout(ct(fc,f1,true),0)}}}bk(f1);p(f1)}function aR(f1){if(f1.state.focused){aC(f1,"blur",f1);f1.state.focused=false;f(f1.display.wrapper,"CodeMirror-focused")}clearInterval(f1.display.blinker);setTimeout(function(){if(!f1.state.focused){f1.display.shift=false}},150)}function ay(ga,f5){if(aO(ga,f5,"contextmenu")){return}var f7=ga.display;if(a6(f7,f5)||da(ga,f5)){return}var f9=cm(ga,f5),f1=f7.scroller.scrollTop;if(!f9||dQ){return}var f4=ga.options.resetSelectionOnContextMenu;if(f4&&ga.doc.sel.contains(f9)==-1){cW(ga,bS)(ga.doc,eG(f9),Z)}var f6=f7.input.style.cssText;f7.inputDiv.style.position="absolute";f7.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(f5.clientY-5)+"px; left: "+(f5.clientX-5)+"px; z-index: 1000; background: "+(dz?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(cU){var gb=window.scrollY}en(ga);if(cU){window.scrollTo(null,gb)}fc(ga);if(!ga.somethingSelected()){f7.input.value=f7.prevInput=" "}f7.selForContextMenu=ga.doc.sel;clearTimeout(f7.detectingSelectAll);function f3(){if(f7.input.selectionStart!=null){var gc=ga.somethingSelected();var gd=f7.input.value="\u200b"+(gc?f7.input.value:"");f7.prevInput=gc?"":"\u200b";f7.input.selectionStart=1;f7.input.selectionEnd=gd.length;f7.selForContextMenu=ga.doc.sel}}function f8(){f7.inputDiv.style.position="relative";f7.input.style.cssText=f6;if(dz&&l<9){f7.scrollbarV.scrollTop=f7.scroller.scrollTop=f1}bk(ga);if(f7.input.selectionStart!=null){if(!dz||(dz&&l<9)){f3()}var gc=0,gd=function(){if(f7.selForContextMenu==ga.doc.sel&&f7.input.selectionStart==0){cW(ga,er.selectAll)(ga)}else{if(gc++<10){f7.detectingSelectAll=setTimeout(gd,500)}else{fc(ga)}}};f7.detectingSelectAll=setTimeout(gd,200)}}if(dz&&l>=9){f3()}if(fS){ee(f5);var f2=function(){d0(window,"mouseup",f2);setTimeout(f8,20)};bV(window,"mouseup",f2)}else{setTimeout(f8,50)}}function da(f1,f2){if(!e5(f1,"gutterContextMenu")){return false}return fZ(f1,f2,"gutterContextMenu",false,aC)}var cR=J.changeEnd=function(f1){if(!f1.text){return f1.to}return X(f1.from.line+f1.text.length-1,fv(f1.text).length+(f1.text.length==1?f1.from.ch:0))};function bX(f4,f3){if(cd(f4,f3.from)<0){return f4}if(cd(f4,f3.to)<=0){return cR(f3)}var f1=f4.line+f3.text.length-(f3.to.line-f3.from.line)-1,f2=f4.ch;if(f4.line==f3.to.line){f2+=cR(f3).ch-f3.to.ch}return X(f1,f2)}function e7(f4,f5){var f2=[];for(var f3=0;f3=0;--f1){L(f4,{from:f2[f1].from,to:f2[f1].to,text:f1?[""]:f5.text})}}else{L(f4,f5)}}function L(f3,f4){if(f4.text.length==1&&f4.text[0]==""&&cd(f4.from,f4.to)==0){return}var f2=e7(f3,f4);fA(f3,f4,f2,f3.cm?f3.cm.curOp.id:NaN);d1(f3,f4,f2,d7(f3,f4));var f1=[];dV(f3,function(f6,f5){if(!f5&&db(f1,f6.history)==-1){du(f6.history,f4);f1.push(f6.history)}d1(f6,f4,null,d7(f6,f4))})}function b6(gc,ga,ge){if(gc.cm&&gc.cm.state.suppressEdits){return}var f9=gc.history,f3,f5=gc.sel;var f1=ga=="undo"?f9.done:f9.undone,gd=ga=="undo"?f9.undone:f9.done;for(var f6=0;f6=0;--f6){var gb=f3.changes[f6];gb.origin=ga;if(f4&&!dF(gc,gb,false)){f1.length=0;return}f8.push(dk(gc,gb));var f2=f6?e7(gc,gb):fv(f1);d1(gc,gb,f2,dX(gc,gb));if(!f6&&gc.cm){gc.cm.scrollIntoView({from:gb.from,to:cR(gb)})}var f7=[];dV(gc,function(gg,gf){if(!gf&&db(f7,gg.history)==-1){du(gg.history,gb);f7.push(gg.history)}d1(gg,gb,null,dX(gg,gb))})}}function fa(f2,f4){if(f4==0){return}f2.first+=f4;f2.sel=new fL(bQ(f2.sel.ranges,function(f5){return new dM(X(f5.anchor.line+f4,f5.anchor.ch),X(f5.head.line+f4,f5.head.ch))}),f2.sel.primIndex);if(f2.cm){ag(f2.cm,f2.first,f2.first-f4,f4);for(var f3=f2.cm.display,f1=f3.viewFrom;f1f5.lastLine()){return}if(f6.from.linef3){f6={from:f6.from,to:X(f3,e2(f5,f3).text.length),text:[f6.text[0]],origin:f6.origin}}f6.removed=fM(f5,f6.from,f6.to);if(!f4){f4=e7(f5,f6)}if(f5.cm){aH(f5.cm,f6,f2)}else{fm(f5,f6,f2)}ec(f5,f4,Z)}function aH(gc,f8,f6){var gb=gc.doc,f7=gc.display,f9=f8.from,ga=f8.to;var f1=false,f5=f9.line;if(!gc.options.lineWrapping){f5=bL(z(e2(gb,f9.line)));gb.iter(f5,ga.line+1,function(ge){if(ge==f7.maxLine){f1=true;return true}})}if(gb.sel.contains(f8.from,f8.to)>-1){W(gc)}fm(gb,f8,f6,a9(gc));if(!gc.options.lineWrapping){gb.iter(f5,f9.line+f8.text.length,function(gf){var ge=d9(gf);if(ge>f7.maxLineLength){f7.maxLine=gf;f7.maxLineLength=ge;f7.maxLineChanged=true;f1=false}});if(f1){gc.curOp.updateMaxLine=true}}gb.frontier=Math.min(gb.frontier,f9.line);d2(gc,400);var gd=f8.text.length-(ga.line-f9.line)-1;if(f9.line==ga.line&&f8.text.length==1&&!dG(gc.doc,f8)){S(gc,f9.line,"text")}else{ag(gc,f9.line,ga.line+1,gd)}var f3=e5(gc,"changes"),f4=e5(gc,"change");if(f4||f3){var f2={from:f9,to:ga,text:f8.text,removed:f8.removed,origin:f8.origin};if(f4){ad(gc,"change",gc,f2)}if(f3){(gc.curOp.changeObjs||(gc.curOp.changeObjs=[])).push(f2)}}gc.display.selForContextMenu=null}function aX(f4,f3,f6,f5,f1){if(!f5){f5=f6}if(cd(f5,f6)<0){var f2=f5;f5=f6;f6=f2}if(typeof f3=="string"){f3=aW(f3)}bb(f4,{from:f6,to:f5,text:f3,origin:f1})}function dU(f2,f5){var f6=f2.display,f3=f6.sizer.getBoundingClientRect(),f1=null;if(f5.top+f3.top<0){f1=true}else{if(f5.bottom+f3.top>(window.innerHeight||document.documentElement.clientHeight)){f1=false}}if(f1!=null&&!fi){var f4=fK("div","\u200b",null,"position: absolute; top: "+(f5.top-f6.viewOffset-eV(f2.display))+"px; height: "+(f5.bottom-f5.top+bg)+"px; left: "+f5.left+"px; width: 2px;");f2.display.lineSpace.appendChild(f4);f4.scrollIntoView(f1);f2.display.lineSpace.removeChild(f4)}}function F(ga,f8,f5,f4){if(f4==null){f4=0}for(;;){var f6=false,f9=dI(ga,f8);var f1=!f5||f5==f8?f9:dI(ga,f5);var f3=I(ga,Math.min(f9.left,f1.left),Math.min(f9.top,f1.top)-f4,Math.max(f9.left,f1.left),Math.max(f9.bottom,f1.bottom)+f4);var f7=ga.doc.scrollTop,f2=ga.doc.scrollLeft;if(f3.scrollTop!=null){O(ga,f3.scrollTop);if(Math.abs(ga.doc.scrollTop-f7)>1){f6=true}}if(f3.scrollLeft!=null){bC(ga,f3.scrollLeft);if(Math.abs(ga.doc.scrollLeft-f2)>1){f6=true}}if(!f6){return f9}}}function G(f1,f3,f5,f2,f4){var f6=I(f1,f3,f5,f2,f4);if(f6.scrollTop!=null){O(f1,f6.scrollTop)}if(f6.scrollLeft!=null){bC(f1,f6.scrollLeft)}}function I(gd,f4,gc,f2,gb){var f9=gd.display,f7=aT(gd.display);if(gc<0){gc=0}var f5=gd.curOp&&gd.curOp.scrollTop!=null?gd.curOp.scrollTop:f9.scroller.scrollTop;var gf=f9.scroller.clientHeight-bg,gh={};if(gb-gc>gf){gb=gc+gf}var f3=gd.doc.height+bG(f9);var f1=gcf3-f7;if(gcf5+gf){var ga=Math.min(gc,(f8?f3:gb)-gf);if(ga!=f5){gh.scrollTop=ga}}}var gg=gd.curOp&&gd.curOp.scrollLeft!=null?gd.curOp.scrollLeft:f9.scroller.scrollLeft;var ge=f9.scroller.clientWidth-bg-f9.gutters.offsetWidth;var f6=f2-f4>ge;if(f6){f2=gc+gf}if(f4<10){gh.scrollLeft=0}else{if(f4ge+gg-3){gh.scrollLeft=f2+(f6?0:10)-ge}}}return gh}function cH(f1,f3,f2){if(f3!=null||f2!=null){fq(f1)}if(f3!=null){f1.curOp.scrollLeft=(f1.curOp.scrollLeft==null?f1.doc.scrollLeft:f1.curOp.scrollLeft)+f3}if(f2!=null){f1.curOp.scrollTop=(f1.curOp.scrollTop==null?f1.doc.scrollTop:f1.curOp.scrollTop)+f2}}function fu(f1){fq(f1);var f2=f1.getCursor(),f4=f2,f3=f2;if(!f1.options.lineWrapping){f4=f2.ch?X(f2.line,f2.ch-1):f2;f3=X(f2.line,f2.ch+1)}f1.curOp.scrollToPos={from:f4,to:f3,margin:f1.options.cursorScrollMargin,isCursor:true}}function fq(f1){var f3=f1.curOp.scrollToPos;if(f3){f1.curOp.scrollToPos=null;var f5=dx(f1,f3.from),f4=dx(f1,f3.to);var f2=I(f1,Math.min(f5.left,f4.left),Math.min(f5.top,f4.top)-f3.margin,Math.max(f5.right,f4.right),Math.max(f5.bottom,f4.bottom)+f3.margin);f1.scrollTo(f2.scrollLeft,f2.scrollTop)}}function ac(ge,f4,gd,f3){var gc=ge.doc,f2;if(gd==null){gd="add"}if(gd=="smart"){if(!gc.mode.indent){gd="prev"}else{f2=dr(ge,f4)}}var f8=ge.options.tabSize;var gf=e2(gc,f4),f7=bR(gf.text,null,f8);if(gf.stateAfter){gf.stateAfter=null}var f1=gf.text.match(/^\s*/)[0],ga;if(!f3&&!/\S/.test(gf.text)){ga=0;gd="not"}else{if(gd=="smart"){ga=gc.mode.indent(f2,gf.text.slice(f1.length),gf.text);if(ga==b8||ga>150){if(!f3){return}gd="prev"}}}if(gd=="prev"){if(f4>gc.first){ga=bR(e2(gc,f4-1).text,null,f8)}else{ga=0}}else{if(gd=="add"){ga=f7+ge.options.indentUnit}else{if(gd=="subtract"){ga=f7-ge.options.indentUnit}else{if(typeof gd=="number"){ga=f7+gd}}}}ga=Math.max(0,ga);var gb="",f9=0;if(ge.options.indentWithTabs){for(var f5=Math.floor(ga/f8);f5;--f5){f9+=f8;gb+="\t"}}if(f9=0;f8--){aX(f1.doc,"",f5[f8].from,f5[f8].to,"+delete")}fu(f1)})}function bu(gj,f5,gd,gc,f7){var ga=f5.line,gb=f5.ch,gi=gd;var f2=e2(gj,ga);var gg=true;function gh(){var gk=ga+gd;if(gk=gj.first+gj.size){return(gg=false)}ga=gk;return f2=e2(gj,gk)}function gf(gl){var gk=(f7?v:ah)(f2,gb,gd,true);if(gk==null){if(!gl&&gh()){if(f7){gb=(gd<0?cO:cB)(f2)}else{gb=gd<0?f2.text.length:0}}else{return(gg=false)}}else{gb=gk}return true}if(gc=="char"){gf()}else{if(gc=="column"){gf(true)}else{if(gc=="word"||gc=="group"){var ge=null,f8=gc=="group";var f1=gj.cm&&gj.cm.getHelper(f5,"wordChars");for(var f6=true;;f6=false){if(gd<0&&!gf(!f6)){break}var f3=f2.text.charAt(gb)||"\n";var f4=cx(f3,f1)?"w":f8&&f3=="\n"?"n":!f8||/\s/.test(f3)?null:"p";if(f8&&!f6&&!f4){f4="s"}if(ge&&ge!=f4){if(gd<0){gd=1;gf()}break}if(f4){ge=f4}if(gd>0&&!gf(!f6)){break}}}}}var f9=bT(gj,X(ga,gb),gi,true);if(!gg){f9.hitSide=true}return f9}function bo(f9,f4,f1,f8){var f7=f9.doc,f6=f4.left,f5;if(f8=="page"){var f3=Math.min(f9.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);f5=f4.top+f1*(f3-(f1<0?1.5:0.5)*aT(f9.display))}else{if(f8=="line"){f5=f1>0?f4.bottom+3:f4.top-3}}for(;;){var f2=fC(f9,f6,f5);if(!f2.outside){break}if(f1<0?f5<=0:f5>=f7.height){f2.hitSide=true;break}f5+=f1*5}return f2}J.prototype={constructor:J,focus:function(){window.focus();en(this);C(this)},setOption:function(f3,f4){var f2=this.options,f1=f2[f3];if(f2[f3]==f4&&f3!="mode"){return}f2[f3]=f4;if(ba.hasOwnProperty(f3)){cW(this,ba[f3])(this,f4,f1)}},getOption:function(f1){return this.options[f1]},getDoc:function(){return this.doc},addKeyMap:function(f2,f1){this.state.keyMaps[f1?"push":"unshift"](f2)},removeKeyMap:function(f2){var f3=this.state.keyMaps;for(var f1=0;f10){e(this.doc,f6,new dM(f8,f3[f6].to()),Z)}}else{if(f7.head.line>f4){ac(this,f7.head.line,ga,true);f4=f7.head.line;if(f6==this.doc.sel.primIndex){fu(this)}}}}}),getTokenAt:function(f8,f2){var f5=this.doc;f8=fx(f5,f8);var f4=dr(this,f8.line,f2),f7=this.doc.mode;var f1=e2(f5,f8.line);var f6=new eH(f1.text,this.options.tabSize);while(f6.pos>1;if((f1?f4[f1*2-1]:0)>=f3){f7=f1}else{if(f4[f1*2+1]f4){f2=f4;f1=true}}var f3=e2(this.doc,f2);return eE(this,f3,{top:0,left:0},f5||"page").top+(f1?this.doc.height-bK(f3):0)},defaultTextHeight:function(){return aT(this.display)},defaultCharWidth:function(){return dt(this.display)},setGutterMarker:c2(function(f1,f2,f3){return em(this.doc,f1,"gutter",function(f4){var f5=f4.gutterMarkers||(f4.gutterMarkers={});f5[f2]=f3;if(!f3&&eI(f5)){f4.gutterMarkers=null}return true})}),clearGutter:c2(function(f3){var f1=this,f4=f1.doc,f2=f4.first;f4.iter(function(f5){if(f5.gutterMarkers&&f5.gutterMarkers[f3]){f5.gutterMarkers[f3]=null;S(f1,f2,"gutter");if(eI(f5.gutterMarkers)){f5.gutterMarkers=null}}++f2})}),addLineWidget:c2(function(f3,f2,f1){return bF(this,f3,f2,f1)}),removeLineWidget:function(f1){f1.clear()},lineInfo:function(f1){if(typeof f1=="number"){if(!b7(this.doc,f1)){return null}var f2=f1;f1=e2(this.doc,f1);if(!f1){return null}}else{var f2=bL(f1);if(f2==null){return null}}return{line:f2,handle:f1,text:f1.text,gutterMarkers:f1.gutterMarkers,textClass:f1.textClass,bgClass:f1.bgClass,wrapClass:f1.wrapClass,widgets:f1.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(f6,f3,f8,f4,ga){var f5=this.display;f6=dI(this,fx(this.doc,f6));var f7=f6.bottom,f2=f6.left;f3.style.position="absolute";f5.sizer.appendChild(f3);if(f4=="over"){f7=f6.top}else{if(f4=="above"||f4=="near"){var f1=Math.max(f5.wrapper.clientHeight,this.doc.height),f9=Math.max(f5.sizer.clientWidth,f5.lineSpace.clientWidth);if((f4=="above"||f6.bottom+f3.offsetHeight>f1)&&f6.top>f3.offsetHeight){f7=f6.top-f3.offsetHeight}else{if(f6.bottom+f3.offsetHeight<=f1){f7=f6.bottom}}if(f2+f3.offsetWidth>f9){f2=f9-f3.offsetWidth}}}f3.style.top=f7+"px";f3.style.left=f3.style.right="";if(ga=="right"){f2=f5.sizer.clientWidth-f3.offsetWidth;f3.style.right="0px"}else{if(ga=="left"){f2=0}else{if(ga=="middle"){f2=(f5.sizer.clientWidth-f3.offsetWidth)/2}}f3.style.left=f2+"px"}if(f8){G(this,f2,f7,f2+f3.offsetWidth,f7+f3.offsetHeight)}},triggerOnKeyDown:c2(q),triggerOnKeyPress:c2(cv),triggerOnKeyUp:bd,execCommand:function(f1){if(er.hasOwnProperty(f1)){return er[f1](this)}},findPosH:function(f7,f4,f5,f2){var f1=1;if(f4<0){f1=-1;f4=-f4}for(var f3=0,f6=fx(this.doc,f7);f30&&f1(f4.charAt(f7-1))){--f7}while(f30.5){Y(this)}aC(this,"refresh",this)}),swapDoc:c2(function(f2){var f1=this.doc;f1.cm=null;dY(this,f2);aj(this);fc(this);this.scrollTo(f2.scrollLeft,f2.scrollTop);this.curOp.forceScroll=true;ad(this,"swapDoc",this,f1);return f1}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};bw(J);var eR=J.defaults={};var ba=J.optionHandlers={};function t(f1,f4,f3,f2){J.defaults[f1]=f4;if(f3){ba[f1]=f2?function(f5,f7,f6){if(f6!=ca){f3(f5,f7,f6)}}:f3}}var ca=J.Init={toString:function(){return"CodeMirror.Init"}};t("value","",function(f1,f2){f1.setValue(f2)},true);t("mode",null,function(f1,f2){f1.doc.modeOption=f2;bp(f1)},true);t("indentUnit",2,bp,true);t("indentWithTabs",false);t("smartIndent",true);t("tabSize",4,function(f1){d8(f1);aj(f1);ag(f1)},true);t("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(f1,f2){f1.options.specialChars=new RegExp(f2.source+(f2.test("\t")?"":"|\t"),"g");f1.refresh()},true);t("specialCharPlaceholder",eZ,function(f1){f1.refresh()},true);t("electricChars",true);t("rtlMoveVisually",!aM);t("wholeLineUpdateBefore",true);t("theme","default",function(f1){cK(f1);dl(f1)},true);t("keyMap","default",fY);t("extraKeys",null);t("lineWrapping",false,eu,true);t("gutters",[],function(f1){cc(f1.options);dl(f1)},true);t("fixedGutter",true,function(f1,f2){f1.display.gutters.style.left=f2?dL(f1.display)+"px":"0";f1.refresh()},true);t("coverGutterNextToScrollbar",false,eM,true);t("lineNumbers",false,function(f1){cc(f1.options);dl(f1)},true);t("firstLineNumber",1,dl,true);t("lineNumberFormatter",function(f1){return f1},dl,true);t("showCursorWhenSelecting",false,bA,true);t("resetSelectionOnContextMenu",true);t("readOnly",false,function(f1,f2){if(f2=="nocursor"){aR(f1);f1.display.input.blur();f1.display.disabled=true}else{f1.display.disabled=false;if(!f2){fc(f1)}}});t("disableInput",false,function(f1,f2){if(!f2){fc(f1)}},true);t("dragDrop",true);t("cursorBlinkRate",530);t("cursorScrollMargin",0);t("cursorHeight",1,bA,true);t("singleCursorHeightPerLine",true,bA,true);t("workTime",100);t("workDelay",100);t("flattenSpans",true,d8,true);t("addModeClass",false,d8,true);t("pollInterval",100);t("undoDepth",200,function(f1,f2){f1.doc.history.undoDepth=f2});t("historyEventDelay",1250);t("viewportMargin",10,function(f1){f1.refresh()},true);t("maxHighlightLength",10000,d8,true);t("moveInputWithCursor",true,function(f1,f2){if(!f2){f1.display.inputDiv.style.top=f1.display.inputDiv.style.left=0}});t("tabindex",null,function(f1,f2){f1.display.input.tabIndex=f2||""});t("autofocus",null);var di=J.modes={},aP=J.mimeModes={};J.defineMode=function(f1,f3){if(!J.defaults.mode&&f1!="null"){J.defaults.mode=f1}if(arguments.length>2){f3.dependencies=[];for(var f2=2;f20){f7=new X(f7.line,f7.ch+1);f1.replaceRange(f2.charAt(f7.ch-1)+f2.charAt(f7.ch-2),X(f7.line,f7.ch-2),f7,"+transpose")}else{if(f7.line>f1.doc.first){var f6=e2(f1.doc,f7.line-1).text;if(f6){f1.replaceRange(f2.charAt(0)+"\n"+f6.charAt(f6.length-1),X(f7.line-1,f6.length-1),X(f7.line,1),"+transpose")}}}}f3.push(new dM(f7,f7))}f1.setSelections(f3)})},newlineAndIndent:function(f1){cI(f1,function(){var f2=f1.listSelections().length;for(var f4=0;f4=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.posf2},eatSpace:function(){var f1=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this.pos}return this.pos>f1},skipToEnd:function(){this.pos=this.string.length},skipTo:function(f1){var f2=this.string.indexOf(f1,this.pos);if(f2>-1){this.pos=f2;return true}},backUp:function(f1){this.pos-=f1},column:function(){if(this.lastColumnPos0){return null}if(f3&&f2!==false){this.pos+=f3[0].length}return f3}},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(f2,f1){this.lineStart+=f2;try{return f1()}finally{this.lineStart-=f2}}};var Q=J.TextMarker=function(f2,f1){this.lines=[];this.type=f1;this.doc=f2};bw(Q);Q.prototype.clear=function(){if(this.explicitlyCleared){return}var f8=this.doc.cm,f2=f8&&!f8.curOp;if(f2){cE(f8)}if(e5(this,"clear")){var f9=this.find();if(f9){ad(this,"clear",f9.from,f9.to)}}var f3=null,f6=null;for(var f4=0;f4f8.display.maxLineLength){f8.display.maxLine=f1;f8.display.maxLineLength=f5;f8.display.maxLineChanged=true}}}if(f3!=null&&f8&&this.collapsed){ag(f8,f3,f6+1)}this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=false;if(f8){el(f8.doc)}}if(f8){ad(f8,"markerCleared",f8,this)}if(f2){al(f8)}if(this.parent){this.parent.clear()}};Q.prototype.find=function(f4,f2){if(f4==null&&this.type=="bookmark"){f4=1}var f7,f6;for(var f3=0;f30||ga==0&&f4.clearWhenEmpty!==false){return f4}if(f4.replacedWith){f4.collapsed=true;f4.widgetNode=fK("span",[f4.replacedWith],"CodeMirror-widget");if(!gb.handleMouseEvents){f4.widgetNode.ignoreEvents=true}if(gb.insertLeft){f4.widgetNode.insertLeft=true}}if(f4.collapsed){if(A(f9,f7.line,f7,f8,f4)||f7.line!=f8.line&&A(f9,f8.line,f7,f8,f4)){throw new Error("Inserting collapsed marker partially overlapping an existing one")}a3=true}if(f4.addToHistory){fA(f9,{from:f7,to:f8,origin:"markText"},f9.sel,NaN)}var f2=f7.line,f6=f9.cm,f1;f9.iter(f2,f8.line+1,function(gc){if(f6&&f4.collapsed&&!f6.options.lineWrapping&&z(gc)==f6.display.maxLine){f1=true}if(f4.collapsed&&f2!=f7.line){fO(gc,0)}cb(gc,new d5(f4,f2==f7.line?f7.ch:null,f2==f8.line?f8.ch:null));++f2});if(f4.collapsed){f9.iter(f7.line,f8.line+1,function(gc){if(fk(f9,gc)){fO(gc,0)}})}if(f4.clearOnEnter){bV(f4,"beforeCursorEnter",function(){f4.clear()})}if(f4.readOnly){fV=true;if(f9.history.done.length||f9.history.undone.length){f9.clearHistory()}}if(f4.collapsed){f4.id=++a1;f4.atomic=true}if(f6){if(f1){f6.curOp.updateMaxLine=true}if(f4.collapsed){ag(f6,f7.line,f8.line+1)}else{if(f4.className||f4.title||f4.startStyle||f4.endStyle){for(var f3=f7.line;f3<=f8.line;f3++){S(f6,f3,"text")}}}if(f4.atomic){el(f6.doc)}ad(f6,"markerAdded",f6,f4)}return f4}var y=J.SharedTextMarker=function(f3,f2){this.markers=f3;this.primary=f2;for(var f1=0;f1=f3:f9.to>f3);(f8||(f8=[])).push(new d5(f6,f9.from,f4?null:f9.to))}}}return f8}function aA(f2,f4,f7){if(f2){for(var f5=0,f8;f5=f4:f9.to>f4);if(f3||f9.from==f4&&f6.type=="bookmark"&&(!f7||f9.marker.insertLeft)){var f1=f9.from==null||(f6.inclusiveLeft?f9.from<=f4:f9.from0&&f7){for(var f4=0;f40){continue}var ga=[f4,1],f1=cd(f2.from,f3.from),f9=cd(f2.to,f3.to);if(f1<0||!f8.inclusiveLeft&&!f1){ga.push({from:f2.from,to:f3.from})}if(f9>0||!f8.inclusiveRight&&!f9){ga.push({from:f3.to,to:f2.to})}f6.splice.apply(f6,ga);f4+=ga.length-1}}return f6}function fR(f1){var f3=f1.markedSpans;if(!f3){return}for(var f2=0;f2=0&&f6<=0||ga<=0&&f6>=0){continue}if(ga<=0&&(cd(gb.to,f7)>0||(f2.marker.inclusiveRight&&f5.inclusiveLeft))||ga>=0&&(cd(gb.from,f8)<0||(f2.marker.inclusiveLeft&&f5.inclusiveRight))){return true}}}}function z(f2){var f1;while(f1=eC(f2)){f2=f1.find(-1,true).line}return f2}function h(f3){var f1,f2;while(f1=ei(f3)){f3=f1.find(1,true).line;(f2||(f2=[])).push(f3)}return f2}function aS(f4,f2){var f1=e2(f4,f2),f3=z(f1);if(f1==f3){return f2}return bL(f3)}function dR(f4,f3){if(f3>f4.lastLine()){return f3}var f2=e2(f4,f3),f1;if(!fk(f4,f2)){return f3}while(f1=ei(f2)){f2=f1.find(1,true).line}return bL(f2)+1}function fk(f5,f2){var f1=a3&&f2.markedSpans;if(f1){for(var f4,f3=0;f3f4.start){return f2}}throw new Error("Mode "+f5.name+" failed to advance stream.")}function x(gb,gd,f6,f2,f7,f4,f5){var f3=f6.flattenSpans;if(f3==null){f3=gb.options.flattenSpans}var f9=0,f8=null;var gc=new eH(gd,gb.options.tabSize),f1;if(gd==""){dc(fe(f6,f2),f4)}while(!gc.eol()){if(gc.pos>gb.options.maxHighlightLength){f3=false;if(f5){dm(gb,gd,f2,gc.pos)}gc.pos=gd.length;f1=null}else{f1=dc(ep(f6,gc,f2),f4)}if(gb.options.addModeClass){var ge=J.innerMode(f6,f2).mode.name;if(ge){f1="m-"+(f1?ge+" "+f1:ge)}}if(!f3||f8!=f1){if(f9gb){f9.splice(f7,1,gb,f9[f7+1],gc)}f7+=2;f3=Math.min(gb,gc)}if(!gd){return}if(f6.opaque){f9.splice(gf,f7-gf,gb,"cm-overlay "+gd);f7=gf+2}else{for(;gff4&&f5.from<=f4){break}}if(f5.to>=f6){return f2(f9,gb,f3,f7,gc,ga)}f2(f9,gb.slice(0,f5.to-f4),f3,f7,null,ga);f7=null;gb=gb.slice(f5.to-f4);f4=f5.to}}}function ab(f2,f4,f1,f3){var f5=!f3&&f1.widgetNode;if(f5){f2.map.push(f2.pos,f2.pos+f4,f5);f2.content.appendChild(f5)}f2.pos+=f4}function bm(ga,gg,f9){var f6=ga.markedSpans,f8=ga.text,ge=0;if(!f6){for(var gj=1;gjf5)){if(gi.to!=null&&gn>gi.to){gn=gi.to;gm=""}if(gf.className){f1+=" "+gf.className}if(gf.startStyle&&gi.from==f5){gd+=" "+gf.startStyle}if(gf.endStyle&&gi.to==gn){gm+=" "+gf.endStyle}if(gf.title&&!go){go=gf.title}if(gf.collapsed&&(!f3||dE(f3.marker,gf)<0)){f3=gi}}else{if(gi.from>f5&&gn>gi.from){gn=gi.from}}if(gf.type=="bookmark"&&gi.from==f5&&gf.widgetNode){f7.push(gf)}}if(f3&&(f3.from||0)==f5){ab(gg,(f3.to==null?gk+1:f3.to)-f5,f3.marker,f3.from==null);if(f3.to==null){return}}if(!f3&&f7.length){for(var gh=0;gh=gk){break}var gb=Math.min(gk,gn);while(true){if(gc){var f2=f5+gc.length;if(!f3){var f4=f2>gb?gc.slice(0,gb-f5):gc;gg.addToken(gg,f4,gl?gl+f1:f1,gd,f5+f4.length==gn?gm:"",go)}if(f2>=gb){gc=gc.slice(gb-f5);f5=gb;break}f5=f2;gd=""}gc=f8.slice(ge,ge=f9[gj++]);gl=eK(f9[gj++],gg.cm.options)}}}function dG(f1,f2){return f2.from.ch==0&&f2.to.ch==0&&fv(f2.text)==""&&(!f1.cm||f1.cm.options.wholeLineUpdateBefore)}function fm(ge,f9,f1,f5){function gf(gh){return f1?f1[gh]:null}function f2(gh,gj,gi){ea(gh,gj,gi,f5);ad(gh,"change",gh,f9)}var gc=f9.from,gd=f9.to,gg=f9.text;var ga=e2(ge,gc.line),gb=e2(ge,gd.line);var f8=fv(gg),f4=gf(gg.length-1),f7=gd.line-gc.line;if(dG(ge,f9)){for(var f3=0,f6=[];f31){ge.remove(gc.line+1,f7-1)}ge.insert(gc.line+1,f6)}}}ad(ge,"change",ge,f9)}function eN(f2){this.lines=f2;this.parent=null;for(var f3=0,f1=0;f31||!(this.children[0] instanceof eN))){var f2=[];this.collapse(f2);this.children=[new eN(f2)];this.children[0].parent=this}},collapse:function(f1){for(var f2=0;f250){while(f8.lines.length>50){var f5=f8.lines.splice(f8.lines.length-25,25);var f4=new eN(f5);f8.height-=f4.height;this.children.splice(f6+1,0,f4);f4.parent=this}this.maybeSpill()}break}f2-=f7}},maybeSpill:function(){if(this.children.length<=10){return}var f4=this;do{var f2=f4.children.splice(f4.children.length-5,5);var f3=new fl(f2);if(!f4.parent){var f5=new fl(f4.children);f5.parent=f4;f4.children=[f5,f3];f4=f5}else{f4.size-=f3.size;f4.height-=f3.height;var f1=db(f4.parent.children,f4);f4.parent.children.splice(f1+1,0,f3)}f3.parent=f4.parent}while(f4.children.length>10);f4.parent.maybeSpill()},iterN:function(f1,f7,f6){for(var f2=0;f2=0;f4--){bb(this,f5[f4])}if(f1){eU(this,f1)}else{if(this.cm){fu(this.cm)}}}),undo:cA(function(){b6(this,"undo")}),redo:cA(function(){b6(this,"redo")}),undoSelection:cA(function(){b6(this,"undo",true)}),redoSelection:cA(function(){b6(this,"redo",true)}),setExtending:function(f1){this.extend=f1},getExtending:function(){return this.extend},historySize:function(){var f4=this.history,f1=0,f3=0;for(var f2=0;f2=f5.ch)){f4.push(f3.marker.parent||f3.marker)}}}return f4},findMarks:function(f5,f4,f1){f5=fx(this,f5);f4=fx(this,f4);var f2=[],f3=f5.line;this.iter(f5.line,f4.line+1,function(f6){var f8=f6.markedSpans;if(f8){for(var f7=0;f7f9.to||f9.from==null&&f3!=f5.line||f3==f4.line&&f9.from>f4.ch)&&(!f1||f1(f9.marker))){f2.push(f9.marker.parent||f9.marker)}}}++f3});return f2},getAllMarks:function(){var f1=[];this.iter(function(f3){var f2=f3.markedSpans;if(f2){for(var f4=0;f4f2){f1=f2;return true}f2-=f5;++f3});return fx(this,X(f3,f1))},indexFromPos:function(f2){f2=fx(this,f2);var f1=f2.ch;if(f2.linef4){f4=f1.from}if(f1.to!=null&&f1.to=f4.size){throw new Error("There is no line "+(f6+f4.first)+" in the document.")}for(var f1=f4;!f1.lines;){for(var f2=0;;++f2){var f5=f1.children[f2],f3=f5.chunkSize();if(f61&&!f2.done[f2.done.length-2].ranges){f2.done.pop();return fv(f2.done)}}}}function fA(f7,f5,f1,f4){var f3=f7.history;f3.undone.length=0;var f2=+new Date,f8;if((f3.lastOp==f4||f3.lastOrigin==f5.origin&&f5.origin&&((f5.origin.charAt(0)=="+"&&f7.cm&&f3.lastModTime>f2-f7.cm.options.historyEventDelay)||f5.origin.charAt(0)=="*"))&&(f8=eA(f3,f3.lastOp==f4))){var f9=fv(f8.changes);if(cd(f5.from,f5.to)==0&&cd(f5.from,f9.to)==0){f9.to=cR(f5)}else{f8.changes.push(dk(f7,f5))}}else{var f6=fv(f3.done);if(!f6||!f6.ranges){cJ(f7.sel,f3.done)}f8={changes:[dk(f7,f5)],generation:f3.generation};f3.done.push(f8);while(f3.done.length>f3.undoDepth){f3.done.shift();if(!f3.done[0].ranges){f3.done.shift()}}}f3.done.push(f1);f3.generation=++f3.maxGeneration;f3.lastModTime=f3.lastSelTime=f2;f3.lastOp=f3.lastSelOp=f4;f3.lastOrigin=f3.lastSelOrigin=f5.origin;if(!f9){aC(f7,"historyAdded")}}function by(f5,f1,f3,f4){var f2=f1.charAt(0);return f2=="*"||f2=="+"&&f3.ranges.length==f4.ranges.length&&f3.somethingSelected()==f4.somethingSelected()&&new Date-f5.history.lastSelTime<=(f5.cm?f5.cm.options.historyEventDelay:500)}function fU(f6,f4,f1,f3){var f5=f6.history,f2=f3&&f3.origin;if(f1==f5.lastSelOp||(f2&&f5.lastSelOrigin==f2&&(f5.lastModTime==f5.lastSelTime&&f5.lastOrigin==f2||by(f6,f2,fv(f5.done),f4)))){f5.done[f5.done.length-1]=f4}else{cJ(f4,f5.done)}f5.lastSelTime=+new Date;f5.lastSelOrigin=f2;f5.lastSelOp=f1;if(f3&&f3.clearRedo!==false){fp(f5.undone)}}function cJ(f2,f1){var f3=fv(f1);if(!(f3&&f3.ranges&&f3.equals(f2))){f1.push(f2)}}function bW(f2,f6,f5,f4){var f1=f6["spans_"+f2.id],f3=0;f2.iter(Math.max(f2.first,f5),Math.min(f2.first+f2.size,f4),function(f7){if(f7.markedSpans){(f1||(f1=f6["spans_"+f2.id]={}))[f3]=f7.markedSpans}++f3})}function bh(f3){if(!f3){return null}for(var f2=0,f1;f2-1){fv(ga)[f1]=f8[f1];delete f8[f1]}}}}}}return f2}function K(f4,f3,f2,f1){if(f20}function bw(f1){f1.prototype.on=function(f2,f3){bV(this,f2,f3)};f1.prototype.off=function(f2,f3){d0(this,f2,f3)}}var bg=30;var b8=J.Pass={toString:function(){return"CodeMirror.Pass"}};var Z={scroll:false},N={origin:"*mouse"},cQ={origin:"+move"};function f0(){this.id=null}f0.prototype.set=function(f1,f2){clearTimeout(this.id);this.id=setTimeout(f2,f1)};var bR=J.countColumn=function(f4,f2,f6,f7,f3){if(f2==null){f2=f4.search(/[^\s\u00a0]/);if(f2==-1){f2=f4.length}}for(var f5=f7||0,f8=f3||0;;){var f1=f4.indexOf("\t",f5);if(f1<0||f1>=f2){return f8+(f2-f5)}f8+=f1-f5;f8+=f6-(f8%f6);f5=f1+1}};function ed(f5,f4,f6){for(var f7=0,f3=0;;){var f2=f5.indexOf("\t",f7);if(f2==-1){f2=f5.length}var f1=f2-f7;if(f2==f5.length||f3+f1>=f4){return f7+Math.min(f1,f4-f3)}f3+=f2-f7;f3+=f6-(f3%f6);f7=f2+1;if(f3>=f4){return f7}}}var aV=[""];function co(f1){while(aV.length<=f1){aV.push(fv(aV)+" ")}return aV[f1]}function fv(f1){return f1[f1.length-1]}var dA=function(f1){f1.select()};if(eP){dA=function(f1){f1.selectionStart=0;f1.selectionEnd=f1.value.length}}else{if(dz){dA=function(f2){try{f2.select()}catch(f1){}}}}function db(f3,f1){for(var f2=0;f2"\x80"&&(f1.toUpperCase()!=f1.toLowerCase()||a8.test(f1))};function cx(f1,f2){if(!f2){return fr(f1)}if(f2.source.indexOf("\\w")>-1&&fr(f1)){return true}return f2.test(f1)}function eI(f1){for(var f2 in f1){if(f1.hasOwnProperty(f2)&&f1[f2]){return false}}return true}var ex=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function fd(f1){return f1.charCodeAt(0)>=768&&ex.test(f1)}function fK(f1,f5,f4,f3){var f6=document.createElement(f1);if(f4){f6.className=f4}if(f3){f6.style.cssText=f3}if(typeof f5=="string"){f6.appendChild(document.createTextNode(f5))}else{if(f5){for(var f2=0;f20;--f1){f2.removeChild(f2.firstChild)}return f2}function bP(f1,f2){return dP(f1).appendChild(f2)}function fT(f1,f2){if(f1.contains){return f1.contains(f2)}while(f2=f2.parentNode){if(f2==f1){return true}}}function dC(){return document.activeElement}if(dz&&l<11){dC=function(){try{return document.activeElement}catch(f1){return document.body}}}function T(f1){return new RegExp("\\b"+f1+"\\b\\s*")}function f(f2,f1){var f3=T(f1);if(f3.test(f2.className)){f2.className=f2.className.replace(f3,"")}}function fo(f2,f1){if(!T(f1).test(f2.className)){f2.className+=" "+f1}}function fF(f3,f1){var f2=f3.split(" ");for(var f4=0;f42&&!(dz&&l<8)}}if(fz){return fK("span","\u200b")}else{return fK("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px")}}var fy;function bM(f4){if(fy!=null){return fy}var f1=bP(f4,document.createTextNode("A\u062eA"));var f3=ck(f1,0,1).getBoundingClientRect();if(!f3||f3.left==f3.right){return false}var f2=ck(f1,1,2).getBoundingClientRect();return fy=(f2.right-f3.right<3)}var aW=J.splitLines="\n\nb".split(/\n/).length!=3?function(f6){var f7=0,f1=[],f5=f6.length;while(f7<=f5){var f4=f6.indexOf("\n",f7);if(f4==-1){f4=f6.length}var f3=f6.slice(f7,f6.charAt(f4-1)=="\r"?f4-1:f4);var f2=f3.indexOf("\r");if(f2!=-1){f1.push(f3.slice(0,f2));f7+=f2+1}else{f1.push(f3);f7=f4+1}}return f1}:function(f1){return f1.split(/\r\n?|\n/)};var bq=window.getSelection?function(f2){try{return f2.selectionStart!=f2.selectionEnd}catch(f1){return false}}:function(f3){try{var f1=f3.ownerDocument.selection.createRange()}catch(f2){}if(!f1||f1.parentElement()!=f3){return false}return f1.compareEndPoints("StartToEnd",f1)!=0};var c4=(function(){var f1=fK("div");if("oncopy" in f1){return true}f1.setAttribute("oncopy","return;");return typeof f1.oncopy=="function"})();var eT=null;function aI(f2){if(eT!=null){return eT}var f3=bP(f2,fK("span","x"));var f4=f3.getBoundingClientRect();var f1=ck(f3,0,1).getBoundingClientRect();return eT=Math.abs(f4.left-f1.left)>1}var e3={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};J.keyNames=e3;(function(){for(var f1=0;f1<10;f1++){e3[f1+48]=e3[f1+96]=String(f1)}for(var f1=65;f1<=90;f1++){e3[f1]=String.fromCharCode(f1)}for(var f1=1;f1<=12;f1++){e3[f1+111]=e3[f1+63235]="F"+f1}})();function dS(f1,f7,f6,f5){if(!f1){return f5(f7,f6,"ltr")}var f4=false;for(var f3=0;f3f7||f7==f6&&f2.to==f7){f5(Math.max(f2.from,f7),Math.min(f2.to,f6),f2.level==1?"rtl":"ltr");f4=true}}if(!f4){f5(f7,f6,"ltr")}}function dn(f1){return f1.level%2?f1.to:f1.from}function fW(f1){return f1.level%2?f1.from:f1.to}function cB(f2){var f1=a(f2);return f1?dn(f1[0]):0}function cO(f2){var f1=a(f2);if(!f1){return f2.text.length}return fW(fv(f1))}function br(f2,f5){var f3=e2(f2.doc,f5);var f6=z(f3);if(f6!=f3){f5=bL(f6)}var f1=a(f6);var f4=!f1?0:f1[0].level%2?cO(f6):cB(f6);return X(f5,f4)}function dD(f3,f6){var f2,f4=e2(f3.doc,f6);while(f2=ei(f4)){f4=f2.find(1,true).line;f6=null}var f1=a(f4);var f5=!f1?f4.text.length:f1[0].level%2?cB(f4):cO(f4);return X(f6==null?bL(f4):f6,f5)}function dy(f2,f7){var f6=br(f2,f7.line);var f3=e2(f2.doc,f6.line);var f1=a(f3);if(!f1||f1[0].level==0){var f5=Math.max(0,f3.text.search(/\S/));var f4=f7.line==f6.line&&f7.ch<=f5&&f7.ch;return X(f6.line,f4?0:f5)}return f6}function am(f2,f3,f1){var f4=f2[0].level;if(f3==f4){return true}if(f1==f4){return false}return f3f5){return f2}if((f4.from==f5||f4.to==f5)){if(f3==null){f3=f2}else{if(am(f1,f4.level,f1[f3].level)){if(f4.from!=f4.to){eQ=f3}return f2}else{if(f4.from!=f4.to){eQ=f2}return f3}}}}return f3}function e1(f1,f4,f2,f3){if(!f3){return f4+f2}do{f4+=f2}while(f4>0&&fd(f1.text.charAt(f4)));return f4}function v(f1,f8,f3,f4){var f5=a(f1);if(!f5){return ah(f1,f8,f3,f4)}var f7=aE(f5,f8),f2=f5[f7];var f6=e1(f1,f8,f2.level%2?-f3:f3,f4);for(;;){if(f6>f2.from&&f60)==f2.level%2?f2.to:f2.from}else{f2=f5[f7+=f3];if(!f2){return null}if((f3>0)==f2.level%2){f6=e1(f1,f2.to,-1,f4)}else{f6=e1(f1,f2.from,1,f4)}}}}function ah(f1,f5,f2,f3){var f4=f5+f2;if(f3){while(f4>0&&fd(f1.text.charAt(f4))){f4+=f2}}return f4<0||f4>f1.text.length?null:f4}var bc=(function(){var f7="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";var f5="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";function f4(gb){if(gb<=247){return f7.charAt(gb)}else{if(1424<=gb&&gb<=1524){return"R"}else{if(1536<=gb&&gb<=1773){return f5.charAt(gb-1536)}else{if(1774<=gb&&gb<=2220){return"r"}else{if(8192<=gb&&gb<=8203){return"w"}else{if(gb==8204){return"b"}else{return"L"}}}}}}}var f1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;var ga=/[stwN]/,f3=/[LRr]/,f2=/[Lb1n]/,f6=/[1n]/;var f9="L";function f8(gd,gc,gb){this.level=gd;this.from=gc;this.to=gb}return function(gl){if(!f1.test(gl)){return false}var gr=gl.length,gh=[];for(var gq=0,gd;gq=15){dQ=false;cU=true}var bO=b5&&(dB||dQ&&(aU==null||aU<12.11));var fS=cn||(dz&&l>=9);var fV=false,a3=false;function J(f1,f2){if(!(this instanceof J)){return new J(f1,f2)}this.options=f2=f2?aK(f2):{};aK(eR,f2,false);cc(f2);var f6=f2.value;if(typeof f6=="string"){f6=new at(f6,f2.mode)}this.doc=f6;var f5=this.display=new ew(f1,f6);f5.wrapper.CodeMirror=this;dZ(this);cK(this);if(f2.lineWrapping){this.display.wrapper.className+=" CodeMirror-wrap"}if(f2.autofocus&&!d3){en(this)}this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:false,focused:false,suppressEdits:false,pasteIncoming:false,cutIncoming:false,draggingText:false,highlight:new f0()};if(dz&&l<11){setTimeout(ct(fc,this,true),20)}fD(this);be();cE(this);this.curOp.forceUpdate=true;dY(this,f6);if((f2.autofocus&&!d3)||dC()==f5.input){setTimeout(ct(cy,this),20)}else{aR(this)}for(var f4 in ba){if(ba.hasOwnProperty(f4)){ba[f4](this,f2[f4],ca)}}dT(this);for(var f3=0;f3f3.maxLineLength){f3.maxLineLength=f4;f3.maxLine=f5}})}function cc(f1){var f2=db(f1.gutters,"CodeMirror-linenumbers");if(f2==-1&&f1.lineNumbers){f1.gutters=f1.gutters.concat(["CodeMirror-linenumbers"])}else{if(f2>-1&&!f1.lineNumbers){f1.gutters=f1.gutters.slice(0);f1.gutters.splice(f2,1)}}}function cM(f1){return f1.display.scroller.clientHeight-f1.display.wrapper.clientHeightf1.clientWidth;if(f3&&f1.scrollWidth<=f1.clientWidth+1&&f2>0&&!f1.hScrollbarTakesSpace){f3=false}var f4=f9>f1.clientHeight;if(f4){f5.scrollbarV.style.display="block";f5.scrollbarV.style.bottom=f3?f2+"px":"0";f5.scrollbarV.firstChild.style.height=Math.max(0,f9-f1.clientHeight+(f1.barHeight||f5.scrollbarV.clientHeight))+"px"}else{f5.scrollbarV.style.display="";f5.scrollbarV.firstChild.style.height="0"}if(f3){f5.scrollbarH.style.display="block";f5.scrollbarH.style.right=f4?f2+"px":"0";f5.scrollbarH.firstChild.style.width=(f1.scrollWidth-f1.clientWidth+(f1.barWidth||f5.scrollbarH.clientWidth))+"px"}else{f5.scrollbarH.style.display="";f5.scrollbarH.firstChild.style.width="0"}if(f3&&f4){f5.scrollbarFiller.style.display="block";f5.scrollbarFiller.style.height=f5.scrollbarFiller.style.width=f2+"px"}else{f5.scrollbarFiller.style.display=""}if(f3&&f8.options.coverGutterNextToScrollbar&&f8.options.fixedGutter){f5.gutterFiller.style.display="block";f5.gutterFiller.style.height=f2+"px";f5.gutterFiller.style.width=f5.gutters.offsetWidth+"px"}else{f5.gutterFiller.style.display=""}if(!f8.state.checkedOverlayScrollbar&&f1.clientHeight>0){if(f2===0){var f7=b5&&!c1?"12px":"18px";f5.scrollbarV.style.minWidth=f5.scrollbarH.style.minHeight=f7;var f6=function(ga){if(M(ga)!=f5.scrollbarV&&M(ga)!=f5.scrollbarH){cW(f8,eg)(ga)}};bV(f5.scrollbarV,"mousedown",f6);bV(f5.scrollbarH,"mousedown",f6)}f8.state.checkedOverlayScrollbar=true}}function b4(f4,f8,f3){var f5=f3&&f3.top!=null?Math.max(0,f3.top):f4.scroller.scrollTop;f5=Math.floor(f5-eV(f4));var f1=f3&&f3.bottom!=null?f3.bottom:f5+f4.wrapper.clientHeight;var f6=bE(f8,f5),f7=bE(f8,f1);if(f3&&f3.ensure){var f2=f3.ensure.from.line,f9=f3.ensure.to.line;if(f2=f7){return{from:bE(f8,bK(e2(f8,f9))-f4.wrapper.clientHeight),to:f9}}}return{from:f6,to:Math.max(f7,f6+1)}}function es(f9){var f7=f9.display,f8=f7.view;if(!f7.alignWidgets&&(!f7.gutters.firstChild||!f9.options.fixedGutter)){return}var f5=dL(f7)-f7.scroller.scrollLeft+f9.doc.scrollLeft;var f1=f7.gutters.offsetWidth,f2=f5+"px";for(var f4=0;f4=f5.viewFrom&&f4.visible.to<=f5.viewTo&&(f5.updateLineNumbers==null||f5.updateLineNumbers>=f5.viewTo)&&c5(ga)==0){return false}if(dT(ga)){ek(ga);f4.dims=e0(ga)}var f3=f9.first+f9.size;var f7=Math.max(f4.visible.from-ga.options.viewportMargin,f9.first);var f8=Math.min(f3,f4.visible.to+ga.options.viewportMargin);if(f5.viewFromf8&&f5.viewTo-f8<20){f8=Math.min(f3,f5.viewTo)}if(a3){f7=aS(ga.doc,f7);f8=dR(ga.doc,f8)}var f2=f7!=f5.viewFrom||f8!=f5.viewTo||f5.lastSizeC!=f4.wrapperHeight;cN(ga,f7,f8);f5.viewOffset=bK(e2(ga.doc,f5.viewFrom));ga.display.mover.style.top=f5.viewOffset+"px";var f1=c5(ga);if(!f2&&f1==0&&!f4.force&&(f5.updateLineNumbers==null||f5.updateLineNumbers>=f5.viewTo)){return false}var f6=dC();if(f1>4){f5.lineDiv.style.display="none"}cl(ga,f5.updateLineNumbers,f4.dims);if(f1>4){f5.lineDiv.style.display=""}if(f6&&dC()!=f6&&f6.offsetHeight){f6.focus()}dP(f5.cursorDiv);dP(f5.selectionDiv);if(f2){f5.lastSizeC=f4.wrapperHeight;d2(ga,400)}f5.updateLineNumbers=null;return true}function ci(f2,f6){var f4=f6.force,f1=f6.viewport;for(var f5=true;;f5=false){if(f5&&f2.options.lineWrapping&&f6.oldScrollerWidth!=f2.display.scroller.clientWidth){f4=true}else{f4=false;if(f1&&f1.top!=null){f1={top:Math.min(f2.doc.height+bG(f2.display)-bg-f2.display.scroller.clientHeight,f1.top)}}f6.visible=b4(f2.display,f2.doc,f1);if(f6.visible.from>=f2.display.viewFrom&&f6.visible.to<=f2.display.viewTo){break}}if(!D(f2,f6)){break}a5(f2);var f3=dq(f2);bA(f2);dp(f2,f3);eM(f2,f3)}ad(f2,"update",f2);if(f2.display.viewFrom!=f6.oldViewFrom||f2.display.viewTo!=f6.oldViewTo){ad(f2,"viewportChange",f2,f2.display.viewFrom,f2.display.viewTo)}}function dH(f2,f1){var f4=new aG(f2,f1);if(D(f2,f4)){a5(f2);ci(f2,f4);var f3=dq(f2);bA(f2);dp(f2,f3);eM(f2,f3)}}function dp(f1,f2){f1.display.sizer.style.minHeight=f1.display.heightForcer.style.top=f2.docHeight+"px";f1.display.gutters.style.height=Math.max(f2.docHeight,f2.clientHeight-bg)+"px"}function fN(f1,f2){if(f1.display.sizer.offsetWidth+f1.display.gutters.offsetWidth0.001||f7<-0.001){fO(f9.line,ga);b9(f9.line);if(f9.rest){for(var f1=0;f1-1){ga=false}aa(gc,f5,f6,gb)}if(ga){dP(f5.lineNumber);f5.lineNumber.appendChild(document.createTextNode(ef(gc.options,f6)))}gd=f5.node.nextSibling}}f6+=f5.size}while(gd){gd=f7(gd)}}function aa(f1,f3,f5,f6){for(var f2=0;f2=0&&cd(f4,f2.to())<=0){return f3}}return -1}};function dM(f1,f2){this.anchor=f1;this.head=f2}dM.prototype={from:function(){return aq(this.anchor,this.head)},to:function(){return bv(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};function cu(f1,f8){var f3=f1[f8];f1.sort(function(gb,ga){return cd(gb.from(),ga.from())});f8=db(f1,f3);for(var f5=1;f5=0){var f6=aq(f2.from(),f9.from()),f7=bv(f2.to(),f9.to());var f4=f2.empty()?f9.from()==f9.head:f2.from()==f2.head;if(f5<=f8){--f8}f1.splice(--f5,2,new dM(f4?f7:f6,f4?f6:f7))}}return new fL(f1,f8)}function eG(f1,f2){return new fL([new dM(f1,f2||f1)],0)}function cZ(f1,f2){return Math.max(f1.first,Math.min(f2,f1.first+f1.size-1))}function fx(f2,f3){if(f3.linef1){return X(f1,e2(f2,f1).text.length)}return fg(f3,e2(f2,f3.line).text.length)}function fg(f3,f2){var f1=f3.ch;if(f1==null||f1>f2){return X(f3.line,f2)}else{if(f1<0){return X(f3.line,0)}else{return f3}}}function b7(f2,f1){return f1>=f2.first&&f1=f3.ch:f1.to>f3.ch))){if(f7){aC(f2,"beforeCursorEnter");if(f2.explicitlyCleared){if(!gc.markedSpans){break}else{--f5;continue}}}if(!f2.atomic){continue}var f8=f2.find(f4<0?-1:1);if(cd(f8,f3)==0){f8.ch+=f4;if(f8.ch<0){if(f8.line>ga.first){f8=fx(ga,X(f8.line-1))}else{f8=null}}else{if(f8.ch>gc.text.length){if(f8.line3){gc(gw,gu.top,null,gu.bottom);gw=f4;if(gu.bottomgj.bottom||gv.bottom==gj.bottom&&gv.right>gj.right){gj=gv}if(gw0){f3.blinker=setInterval(function(){f3.cursorDiv.style.visibility=(f2=!f2)?"":"hidden"},f1.options.cursorBlinkRate)}else{if(f1.options.cursorBlinkRate<0){f3.cursorDiv.style.visibility="hidden"}}}function d2(f1,f2){if(f1.doc.mode.startState&&f1.doc.frontier=f1.display.viewTo){return}var f3=+new Date+f1.options.workTime;var f4=b1(f5.mode,dr(f1,f5.frontier));var f2=[];f5.iter(f5.frontier,Math.min(f5.first+f5.size,f1.display.viewTo+500),function(f6){if(f5.frontier>=f1.display.viewFrom){var f9=f6.styles;var gb=fn(f1,f6,f4,true);f6.styles=gb.styles;var f8=f6.styleClasses,ga=gb.classes;if(ga){f6.styleClasses=ga}else{if(f8){f6.styleClasses=null}}var gc=!f9||f9.length!=f6.styles.length||f8!=ga&&(!f8||!ga||f8.bgClass!=ga.bgClass||f8.textClass!=ga.textClass);for(var f7=0;!gc&&f7f3){d2(f1,f1.options.workDelay);return true}});if(f2.length){cI(f1,function(){for(var f6=0;f6f3;--ga){if(ga<=f6.first){return f6.first}var f9=e2(f6,ga-1);if(f9.stateAfter&&(!f4||ga<=f6.frontier)){return ga}var f8=bR(f9.text,null,f7.options.tabSize);if(f5==null||f2>f8){f5=ga-1;f2=f8}}return f5}function dr(f1,f7,f2){var f5=f1.doc,f4=f1.display;if(!f5.mode.startState){return true}var f6=cw(f1,f7,f2),f3=f6>f5.first&&e2(f5,f6-1).stateAfter;if(!f3){f3=bY(f5.mode)}else{f3=b1(f5.mode,f3)}f5.iter(f6,f7,function(f8){dm(f1,f8.text,f3);var f9=f6==f7-1||f6%5==0||f6>=f4.viewFrom&&f62){f6.push((f9.bottom+f2.top)/2-f7.top)}}}f6.push(f7.bottom-f7.top)}}function cr(f3,f1,f4){if(f3.line==f1){return{map:f3.measure.map,cache:f3.measure.cache}}for(var f2=0;f2f4){return{map:f3.measure.maps[f2],cache:f3.measure.caches[f2],before:true}}}}function cV(f1,f3){f3=z(f3);var f5=bL(f3);var f2=f1.display.externalMeasured=new bt(f1.doc,f3,f5);f2.lineN=f5;var f4=f2.built=eF(f1,f2);f2.text=f4.pre;bP(f1.display.lineMeasure,f4.pre);return f2}function d4(f1,f2,f4,f3){return E(f1,a0(f1,f2),f4,f3)}function eY(f1,f3){if(f3>=f1.display.viewFrom&&f3=f2.lineN&&f3ga){f4=gg-gk;f5=f4-1;if(ga>=gg){f1="right"}}}}if(f5!=null){gf=gm[gh+2];if(gk==gg&&f6==(gf.insertLeft?"left":"right")){f1=f6}if(f6=="left"&&f5==0){while(gh&&gm[gh-2]==gm[gh-3]&&gm[gh-1].insertLeft){gf=gm[(gh-=3)+2];f1="left"}}if(f6=="right"&&f5==gg-gk){while(gh0){f1=f6="right"}var f3;if(f8.options.lineWrapping&&(f3=gf.getClientRects()).length>1){f2=f3[f6=="right"?f3.length-1:0]}else{f2=gf.getBoundingClientRect()}}if(dz&&l<9&&!f5&&(!f2||!f2.left&&!f2.right)){var f7=gf.parentNode.getClientRects()[0];if(f7){f2={left:f7.left,right:f7.left+dt(f8.display),top:f7.top,bottom:f7.bottom}}else{f2=eo}}var gd=f2.top-gi.rect.top,gb=f2.bottom-gi.rect.top;var gl=(gd+gb)/2;var gj=gi.view.measure.heights;for(var gh=0;ghge.from){return f5(gg-1)}return f5(gg,gf)}var f6=a(f7),f1=f9.ch;if(!f6){return f5(f1)}var f2=aE(f6,f1);var f4=gb(f1,f2);if(eQ!=null){f4.other=gb(f1,eQ)}return f4}function dx(f1,f5){var f4=0,f5=fx(f1.doc,f5);if(!f1.options.lineWrapping){f4=dt(f1.display)*f5.ch}var f2=e2(f1.doc,f5.line);var f3=bK(f2)+eV(f1.display);return{left:f4,right:f4,top:f3,bottom:f3+f2.height}}function fJ(f1,f2,f3,f5){var f4=X(f1,f2);f4.xRel=f5;if(f3){f4.outside=true}return f4}function fC(f8,f5,f4){var f7=f8.doc;f4+=f8.display.viewOffset;if(f4<0){return fJ(f7.first,0,true,-1)}var f3=bE(f7,f4),f9=f7.first+f7.size-1;if(f3>f9){return fJ(f7.first+f7.size-1,e2(f7,f9).text.length,true,1)}if(f5<0){f5=0}var f2=e2(f7,f3);for(;;){var ga=cT(f8,f2,f3,f5,f4);var f6=ei(f2);var f1=f6&&f6.find(0,true);if(f6&&(ga.ch>f1.from.ch||ga.ch==f1.from.ch&&ga.xRel>0)){f3=bL(f2=f1.to.line)}else{return ga}}}function cT(gb,f3,ge,gd,gc){var ga=gc-bK(f3);var f7=false,gk=2*gb.display.wrapper.clientWidth;var gh=a0(gb,f3);function go(gq){var gr=dI(gb,X(ge,gq),"line",f3,gh);f7=true;if(ga>gr.bottom){return gr.left-gk}else{if(gaf2){return fJ(ge,f4,f6,1)}for(;;){if(gg?f4==gl||f4==v(f3,gl,1):f4-gl<=1){var gf=gd1?1:0);return f9}var f8=Math.ceil(gj/2),gp=gl+f8;if(gg){gp=gl;for(var gm=0;gmgd){f4=gp;f2=f5;if(f6=f7){f2+=1000}gj=f8}else{gl=gp;gi=f5;f1=f7;gj-=f8}}}var aF;function aT(f3){if(f3.cachedTextHeight!=null){return f3.cachedTextHeight}if(aF==null){aF=fK("pre");for(var f2=0;f2<49;++f2){aF.appendChild(document.createTextNode("x"));aF.appendChild(fK("br"))}aF.appendChild(document.createTextNode("x"))}bP(f3.measure,aF);var f1=aF.offsetHeight/50;if(f1>3){f3.cachedTextHeight=f1}dP(f3.measure);return f1||1}function dt(f5){if(f5.cachedCharWidth!=null){return f5.cachedCharWidth}var f1=fK("span","xxxxxxxxxx");var f4=fK("pre",[f1]);bP(f5.measure,f4);var f3=f1.getBoundingClientRect(),f2=(f3.right-f3.left)/10;if(f2>2){f5.cachedCharWidth=f2}return f2||10}var bn=null;var dW=0;function cE(f1){f1.curOp={cm:f1,viewChanged:false,startHeight:f1.doc.height,forceUpdate:false,updateInput:null,typing:false,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:false,updateMaxLine:false,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++dW};if(bn){bn.ops.push(f1.curOp)}else{f1.curOp.ownsGroup=bn={ops:[f1.curOp],delayedCallbacks:[]}}}function cP(f4){var f3=f4.delayedCallbacks,f2=0;do{for(;f2=f2.viewTo)||f2.maxLineChanged&&f1.options.lineWrapping;f3.update=f3.mustUpdate&&new aG(f1,f3.mustUpdate&&{top:f3.scrollTop,ensure:f3.scrollToPos},f3.forceUpdate)}function ap(f1){f1.updatedDisplay=f1.mustUpdate&&D(f1.cm,f1.update)}function b0(f3){var f1=f3.cm,f2=f1.display;if(f3.updatedDisplay){a5(f1)}f3.barMeasure=dq(f1);if(f2.maxLineChanged&&!f1.options.lineWrapping){f3.adjustWidthTo=d4(f1,f2.maxLine,f2.maxLine.text.length).left+3;f3.maxScrollLeft=Math.max(0,f2.sizer.offsetLeft+f3.adjustWidthTo+bg-f2.scroller.clientWidth)}if(f3.updatedDisplay||f3.selectionChanged){f3.newSelectionNodes=bj(f1)}}function ao(f2){var f1=f2.cm;if(f2.adjustWidthTo!=null){f1.display.sizer.style.minWidth=f2.adjustWidthTo+"px";if(f2.maxScrollLeft1){eM(ga)}if(f4.updatedDisplay){ci(ga,f4.update)}if(f6.wheelStartX!=null&&(f4.scrollTop!=null||f4.scrollLeft!=null||f4.scrollToPos)){f6.wheelStartX=f6.wheelStartY=null}if(f4.scrollTop!=null&&(f6.scroller.scrollTop!=f4.scrollTop||f4.forceScroll)){var f7=Math.max(0,Math.min(f6.scroller.scrollHeight-f6.scroller.clientHeight,f4.scrollTop));f6.scroller.scrollTop=f6.scrollbarV.scrollTop=f9.scrollTop=f7}if(f4.scrollLeft!=null&&(f6.scroller.scrollLeft!=f4.scrollLeft||f4.forceScroll)){var f2=Math.max(0,Math.min(f6.scroller.scrollWidth-f6.scroller.clientWidth,f4.scrollLeft));f6.scroller.scrollLeft=f6.scrollbarH.scrollLeft=f9.scrollLeft=f2;es(ga)}if(f4.scrollToPos){var f8=F(ga,fx(f9,f4.scrollToPos.from),fx(f9,f4.scrollToPos.to),f4.scrollToPos.margin);if(f4.scrollToPos.isCursor&&ga.state.focused){dU(ga,f8)}}var f5=f4.maybeHiddenMarkers,f1=f4.maybeUnhiddenMarkers;if(f5){for(var f3=0;f3f4.barMeasure.clientWidth&&f4.barMeasure.scrollWidthf6)){f3.updateLineNumbers=f6}f8.curOp.viewChanged=true;if(f6>=f3.viewTo){if(a3&&aS(f8.doc,f6)f3.viewFrom){ek(f8)}else{f3.viewFrom+=f9;f3.viewTo+=f9}}else{if(f6<=f3.viewFrom&&f7>=f3.viewTo){ek(f8)}else{if(f6<=f3.viewFrom){var f5=c8(f8,f7,f7+f9,1);if(f5){f3.view=f3.view.slice(f5.index);f3.viewFrom=f5.lineN;f3.viewTo+=f9}else{ek(f8)}}else{if(f7>=f3.viewTo){var f5=c8(f8,f6,f6,-1);if(f5){f3.view=f3.view.slice(0,f5.index);f3.viewTo=f5.lineN}else{ek(f8)}}else{var f4=c8(f8,f6,f6,-1);var f2=c8(f8,f7,f7+f9,1);if(f4&&f2){f3.view=f3.view.slice(0,f4.index).concat(eJ(f8,f4.lineN,f2.lineN)).concat(f3.view.slice(f2.index));f3.viewTo+=f9}else{ek(f8)}}}}}}var f1=f3.externalMeasured;if(f1){if(f7=f5.lineN&&f3=f7.viewTo){return}var f4=f7.view[dh(f2,f3)];if(f4.node==null){return}var f1=f4.changes||(f4.changes=[]);if(db(f1,f6)==-1){f1.push(f6)}}function ek(f1){f1.display.viewFrom=f1.display.viewTo=f1.doc.first;f1.display.view=[];f1.display.viewOffset=0}function dh(f1,f4){if(f4>=f1.display.viewTo){return null}f4-=f1.display.viewFrom;if(f4<0){return null}var f2=f1.display.view;for(var f3=0;f30){if(f6==f7.length-1){return null}f8=(f1+f7[f6].size)-f3;f6++}else{f8=f1-f3}f3+=f8;f5+=f8}while(aS(f9.doc,f5)!=f5){if(f6==(f2<0?0:f7.length-1)){return null}f5+=f2*f7[f6-(f2<0?1:0)].size;f6+=f2}return{index:f6,lineN:f5}}function cN(f1,f5,f4){var f3=f1.display,f2=f3.view;if(f2.length==0||f5>=f3.viewTo||f4<=f3.viewFrom){f3.view=eJ(f1,f5,f4);f3.viewFrom=f5}else{if(f3.viewFrom>f5){f3.view=eJ(f1,f5,f3.viewFrom).concat(f3.view)}else{if(f3.viewFromf4){f3.view=f3.view.slice(0,dh(f1,f4))}}}f3.viewTo=f4}function c5(f1){var f2=f1.display.view,f5=0;for(var f4=0;f4=9&&f5.display.inputHasSelection===f8||b5&&/[\uf700-\uf7ff]/.test(f8)){fc(f5);return false}var gg=!f5.curOp;if(gg){cE(f5)}f5.display.shift=false;if(f8.charCodeAt(0)==8203&&gk.sel==f5.display.selForContextMenu&&!f9){f9="\u200b"}var gf=0,gc=Math.min(f9.length,f8.length);while(gf1){if(bi&&bi.join("\n")==f2){gj=gk.sel.ranges.length%bi.length==0&&bQ(bi,aW)}else{if(ga.length==gk.sel.ranges.length){gj=bQ(ga,function(gl){return[gl]})}}}for(var gh=gk.sel.ranges.length-1;gh>=0;gh--){var gb=gk.sel.ranges[gh];var gd=gb.from(),f1=gb.to();if(gf-1){ac(f5,f3.line,"smart");break}}}else{if(f7.electricInput){if(f7.electricInput.test(e2(gk,f3.line).text.slice(0,f3.ch))){ac(f5,f3.line,"smart")}}}}}fu(f5);f5.curOp.updateInput=f4;f5.curOp.typing=true;if(f8.length>1000||f8.indexOf("\n")>-1){f6.value=f5.display.prevInput=""}else{f5.display.prevInput=f8}if(gg){al(f5)}f5.state.pasteIncoming=f5.state.cutIncoming=false;return true}function fc(f1,f5){var f2,f4,f7=f1.doc;if(f1.somethingSelected()){f1.display.prevInput="";var f3=f7.sel.primary();f2=c4&&(f3.to().line-f3.from().line>100||(f4=f1.getSelection()).length>1000);var f6=f2?"-":f4||f1.getSelection();f1.display.input.value=f6;if(f1.state.focused){dA(f1.display.input)}if(dz&&l>=9){f1.display.inputHasSelection=f6}}else{if(!f5){f1.display.prevInput=f1.display.input.value="";if(dz&&l>=9){f1.display.inputHasSelection=null}}}f1.display.inaccurateSelection=f2}function en(f1){if(f1.options.readOnly!="nocursor"&&(!d3||dC()!=f1.display.input)){f1.display.input.focus()}}function s(f1){if(!f1.state.focused){en(f1);cy(f1)}}function ai(f1){return f1.options.readOnly||f1.doc.cantEdit}function fD(f1){var f3=f1.display;bV(f3.scroller,"mousedown",cW(f1,eg));if(dz&&l<11){bV(f3.scroller,"dblclick",cW(f1,function(f7){if(aO(f1,f7)){return}var f8=cm(f1,f7);if(!f8||m(f1,f7)||a6(f1.display,f7)){return}cC(f7);var f6=f1.findWordAt(f8);fH(f1.doc,f6.anchor,f6.head)}))}else{bV(f3.scroller,"dblclick",function(f6){aO(f1,f6)||cC(f6)})}bV(f3.lineSpace,"selectstart",function(f6){if(!a6(f3,f6)){cC(f6)}});if(!fS){bV(f3.scroller,"contextmenu",function(f6){ay(f1,f6)})}bV(f3.scroller,"scroll",function(){if(f3.scroller.clientHeight){O(f1,f3.scroller.scrollTop);bC(f1,f3.scroller.scrollLeft,true);aC(f1,"scroll",f1)}});bV(f3.scrollbarV,"scroll",function(){if(f3.scroller.clientHeight){O(f1,f3.scrollbarV.scrollTop)}});bV(f3.scrollbarH,"scroll",function(){if(f3.scroller.clientHeight){bC(f1,f3.scrollbarH.scrollLeft)}});bV(f3.scroller,"mousewheel",function(f6){b(f1,f6)});bV(f3.scroller,"DOMMouseScroll",function(f6){b(f1,f6)});function f5(){if(f1.state.focused){setTimeout(ct(en,f1),0)}}bV(f3.scrollbarH,"mousedown",f5);bV(f3.scrollbarV,"mousedown",f5);bV(f3.wrapper,"scroll",function(){f3.wrapper.scrollTop=f3.wrapper.scrollLeft=0});bV(f3.input,"keyup",function(f6){bd.call(f1,f6)});bV(f3.input,"input",function(){if(dz&&l>=9&&f1.display.inputHasSelection){f1.display.inputHasSelection=null}C(f1)});bV(f3.input,"keydown",cW(f1,q));bV(f3.input,"keypress",cW(f1,cv));bV(f3.input,"focus",ct(cy,f1));bV(f3.input,"blur",ct(aR,f1));function f2(f6){if(!aO(f1,f6)){ee(f6)}}if(f1.options.dragDrop){bV(f3.scroller,"dragstart",function(f6){R(f1,f6)});bV(f3.scroller,"dragenter",f2);bV(f3.scroller,"dragover",f2);bV(f3.scroller,"drop",cW(f1,bf))}bV(f3.scroller,"paste",function(f6){if(a6(f3,f6)){return}f1.state.pasteIncoming=true;en(f1);C(f1)});bV(f3.input,"paste",function(){if(cU&&!f1.state.fakedLastChar&&!(new Date-f1.state.lastMiddleDown<200)){var f7=f3.input.selectionStart,f6=f3.input.selectionEnd;f3.input.value+="$";f3.input.selectionEnd=f6;f3.input.selectionStart=f7;f1.state.fakedLastChar=true}f1.state.pasteIncoming=true;C(f1)});function f4(ga){if(f1.somethingSelected()){bi=f1.getSelections();if(f3.inaccurateSelection){f3.prevInput="";f3.inaccurateSelection=false;f3.input.value=bi.join("\n");dA(f3.input)}}else{var gb=[],f7=[];for(var f8=0;f8f3-400&&cd(c7.pos,f7)==0){f4="triple"}else{if(de&&de.time>f3-400&&cd(de.pos,f7)==0){f4="double";c7={time:f3,pos:f7}}else{f4="single";de={time:f3,pos:f7}}}var f5=f2.doc.sel,f1=b5?f6.metaKey:f6.ctrlKey;if(f2.options.dragDrop&&ez&&!ai(f2)&&f4=="single"&&f5.contains(f7)>-1&&f5.somethingSelected()){aZ(f2,f6,f7,f1)}else{n(f2,f6,f7,f4,f1)}}function aZ(f3,f5,f6,f2){var f4=f3.display;var f1=cW(f3,function(f7){if(cU){f4.scroller.draggable=false}f3.state.draggingText=false;d0(document,"mouseup",f1);d0(f4.scroller,"drop",f1);if(Math.abs(f5.clientX-f7.clientX)+Math.abs(f5.clientY-f7.clientY)<10){cC(f7);if(!f2){fH(f3.doc,f6)}en(f3);if(dz&&l==9){setTimeout(function(){document.body.focus();en(f3)},20)}}});if(cU){f4.scroller.draggable=true}f3.state.draggingText=f1;if(f4.scroller.dragDrop){f4.scroller.dragDrop()}bV(document,"mouseup",f1);bV(f4.scroller,"drop",f1)}function n(f4,gi,f3,f1,f6){var gf=f4.display,gk=f4.doc;cC(gi);var f2,gj,f5=gk.sel;if(f6&&!gi.shiftKey){gj=gk.sel.contains(f3);if(gj>-1){f2=gk.sel.ranges[gj]}else{f2=new dM(f3,f3)}}else{f2=gk.sel.primary()}if(gi.altKey){f1="rect";if(!f6){f2=new dM(f3,f3)}f3=cm(f4,gi,true,true);gj=-1}else{if(f1=="double"){var gg=f4.findWordAt(f3);if(f4.display.shift||gk.extend){f2=fj(gk,f2,gg.anchor,gg.head)}else{f2=gg}}else{if(f1=="triple"){var f9=new dM(X(f3.line,0),fx(gk,X(f3.line+1,0)));if(f4.display.shift||gk.extend){f2=fj(gk,f2,f9.anchor,f9.head)}else{f2=f9}}else{f2=fj(gk,f2,f3)}}}if(!f6){gj=0;bS(gk,new fL([f2],0),N);f5=gk.sel}else{if(gj>-1){e(gk,gj,f2,N)}else{gj=gk.sel.ranges.length;bS(gk,cu(gk.sel.ranges.concat([f2]),gj),{scroll:false,origin:"*mouse"})}}var ge=f3;function gd(gv){if(cd(ge,gv)==0){return}ge=gv;if(f1=="rect"){var gm=[],gs=f4.options.tabSize;var gl=bR(e2(gk,f3.line).text,f3.ch,gs);var gy=bR(e2(gk,gv.line).text,gv.ch,gs);var gn=Math.min(gl,gy),gw=Math.max(gl,gy);for(var gz=Math.min(f3.line,gv.line),gp=Math.min(f4.lastLine(),Math.max(f3.line,gv.line));gz<=gp;gz++){var gx=e2(gk,gz).text,go=ed(gx,gn,gs);if(gn==gw){gm.push(new dM(X(gz,go),X(gz,go)))}else{if(gx.length>go){gm.push(new dM(X(gz,go),X(gz,ed(gx,gw,gs))))}}}if(!gm.length){gm.push(new dM(f3,f3))}bS(gk,cu(f5.ranges.slice(0,gj).concat(gm),gj),{origin:"*mouse",scroll:false});f4.scrollIntoView(gv)}else{var gt=f2;var gq=gt.anchor,gu=gv;if(f1!="single"){if(f1=="double"){var gr=f4.findWordAt(gv)}else{var gr=new dM(X(gv.line,0),fx(gk,X(gv.line+1,0)))}if(cd(gr.anchor,gq)>0){gu=gr.head;gq=aq(gt.from(),gr.anchor)}else{gu=gr.anchor;gq=bv(gt.to(),gr.head)}}var gm=f5.ranges.slice(0);gm[gj]=new dM(fx(gk,gq),gu);bS(gk,cu(gm,gj),N)}}var gb=gf.wrapper.getBoundingClientRect();var f7=0;function gh(gn){var gl=++f7;var gp=cm(f4,gn,true,f1=="rect");if(!gp){return}if(cd(gp,ge)!=0){s(f4);gd(gp);var go=b4(gf,gk);if(gp.line>=go.to||gp.linegb.bottom?20:0;if(gm){setTimeout(cW(f4,function(){if(f7!=gl){return}gf.scroller.scrollTop+=gm;gh(gn)}),50)}}}function ga(gl){f7=Infinity;cC(gl);en(f4);d0(document,"mousemove",gc);d0(document,"mouseup",f8);gk.history.lastSelOrigin=null}var gc=cW(f4,function(gl){if(!fB(gl)){ga(gl)}else{gh(gl)}});var f8=cW(f4,ga);bV(document,"mousemove",gc);bV(document,"mouseup",f8)}function fZ(gc,f8,ga,gb,f4){try{var f2=f8.clientX,f1=f8.clientY}catch(f8){return false}if(f2>=Math.floor(gc.display.gutters.getBoundingClientRect().right)){return false}if(gb){cC(f8)}var f9=gc.display;var f7=f9.lineDiv.getBoundingClientRect();if(f1>f7.bottom||!e5(gc,ga)){return bJ(f8)}f1-=f7.top-f9.viewOffset;for(var f5=0;f5=f2){var gd=bE(gc.doc,f1);var f3=gc.options.gutters[f5];f4(gc,ga,gc,gd,f3,f8);return bJ(f8)}}}function m(f1,f2){return fZ(f1,f2,"gutterClick",true,ad)}var af=0;function bf(f7){var f9=this;if(aO(f9,f7)||a6(f9.display,f7)){return}cC(f7);if(dz){af=+new Date}var f8=cm(f9,f7,true),f1=f7.dataTransfer.files;if(!f8||ai(f9)){return}if(f1&&f1.length&&window.FileReader&&window.File){var f3=f1.length,ga=Array(f3),f2=0;var f5=function(gd,gc){var gb=new FileReader;gb.onload=cW(f9,function(){ga[gc]=gb.result;if(++f2==f3){f8=fx(f9.doc,f8);var ge={from:f8,to:f8,text:aW(ga.join("\n")),origin:"paste"};bb(f9.doc,ge);eU(f9.doc,eG(f8,cR(ge)))}});gb.readAsText(gd)};for(var f6=0;f6-1){f9.state.draggingText(f7);setTimeout(ct(en,f9),20);return}try{var ga=f7.dataTransfer.getData("Text");if(ga){if(f9.state.draggingText&&!(b5?f7.metaKey:f7.ctrlKey)){var f4=f9.listSelections()}ec(f9.doc,eG(f8,f8));if(f4){for(var f6=0;f6f8.clientWidth||gb&&f8.scrollHeight>f8.clientHeight)){return}if(gb&&b5&&cU){outer:for(var ga=f3.target,f7=f5.view;ga!=f8;ga=ga.parentNode){for(var f2=0;f2=9){f1.display.inputHasSelection=null}C(f1)}function cy(f1){if(f1.options.readOnly=="nocursor"){return}if(!f1.state.focused){aC(f1,"focus",f1);f1.state.focused=true;fo(f1.display.wrapper,"CodeMirror-focused");if(!f1.curOp&&f1.display.selForContextMenu!=f1.doc.sel){fc(f1);if(cU){setTimeout(ct(fc,f1,true),0)}}}bk(f1);p(f1)}function aR(f1){if(f1.state.focused){aC(f1,"blur",f1);f1.state.focused=false;f(f1.display.wrapper,"CodeMirror-focused")}clearInterval(f1.display.blinker);setTimeout(function(){if(!f1.state.focused){f1.display.shift=false}},150)}function ay(ga,f5){if(aO(ga,f5,"contextmenu")){return}var f7=ga.display;if(a6(f7,f5)||da(ga,f5)){return}var f9=cm(ga,f5),f1=f7.scroller.scrollTop;if(!f9||dQ){return}var f4=ga.options.resetSelectionOnContextMenu;if(f4&&ga.doc.sel.contains(f9)==-1){cW(ga,bS)(ga.doc,eG(f9),Z)}var f6=f7.input.style.cssText;f7.inputDiv.style.position="absolute";f7.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(f5.clientY-5)+"px; left: "+(f5.clientX-5)+"px; z-index: 1000; background: "+(dz?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(cU){var gb=window.scrollY}en(ga);if(cU){window.scrollTo(null,gb)}fc(ga);if(!ga.somethingSelected()){f7.input.value=f7.prevInput=" "}f7.selForContextMenu=ga.doc.sel;clearTimeout(f7.detectingSelectAll);function f3(){if(f7.input.selectionStart!=null){var gc=ga.somethingSelected();var gd=f7.input.value="\u200b"+(gc?f7.input.value:"");f7.prevInput=gc?"":"\u200b";f7.input.selectionStart=1;f7.input.selectionEnd=gd.length;f7.selForContextMenu=ga.doc.sel}}function f8(){f7.inputDiv.style.position="relative";f7.input.style.cssText=f6;if(dz&&l<9){f7.scrollbarV.scrollTop=f7.scroller.scrollTop=f1}bk(ga);if(f7.input.selectionStart!=null){if(!dz||(dz&&l<9)){f3()}var gc=0,gd=function(){if(f7.selForContextMenu==ga.doc.sel&&f7.input.selectionStart==0){cW(ga,er.selectAll)(ga)}else{if(gc++<10){f7.detectingSelectAll=setTimeout(gd,500)}else{fc(ga)}}};f7.detectingSelectAll=setTimeout(gd,200)}}if(dz&&l>=9){f3()}if(fS){ee(f5);var f2=function(){d0(window,"mouseup",f2);setTimeout(f8,20)};bV(window,"mouseup",f2)}else{setTimeout(f8,50)}}function da(f1,f2){if(!e5(f1,"gutterContextMenu")){return false}return fZ(f1,f2,"gutterContextMenu",false,aC)}var cR=J.changeEnd=function(f1){if(!f1.text){return f1.to}return X(f1.from.line+f1.text.length-1,fv(f1.text).length+(f1.text.length==1?f1.from.ch:0))};function bX(f4,f3){if(cd(f4,f3.from)<0){return f4}if(cd(f4,f3.to)<=0){return cR(f3)}var f1=f4.line+f3.text.length-(f3.to.line-f3.from.line)-1,f2=f4.ch;if(f4.line==f3.to.line){f2+=cR(f3).ch-f3.to.ch}return X(f1,f2)}function e7(f4,f5){var f2=[];for(var f3=0;f3=0;--f1){L(f4,{from:f2[f1].from,to:f2[f1].to,text:f1?[""]:f5.text})}}else{L(f4,f5)}}function L(f3,f4){if(f4.text.length==1&&f4.text[0]==""&&cd(f4.from,f4.to)==0){return}var f2=e7(f3,f4);fA(f3,f4,f2,f3.cm?f3.cm.curOp.id:NaN);d1(f3,f4,f2,d7(f3,f4));var f1=[];dV(f3,function(f6,f5){if(!f5&&db(f1,f6.history)==-1){du(f6.history,f4);f1.push(f6.history)}d1(f6,f4,null,d7(f6,f4))})}function b6(gc,ga,ge){if(gc.cm&&gc.cm.state.suppressEdits){return}var f9=gc.history,f3,f5=gc.sel;var f1=ga=="undo"?f9.done:f9.undone,gd=ga=="undo"?f9.undone:f9.done;for(var f6=0;f6=0;--f6){var gb=f3.changes[f6];gb.origin=ga;if(f4&&!dF(gc,gb,false)){f1.length=0;return}f8.push(dk(gc,gb));var f2=f6?e7(gc,gb):fv(f1);d1(gc,gb,f2,dX(gc,gb));if(!f6&&gc.cm){gc.cm.scrollIntoView({from:gb.from,to:cR(gb)})}var f7=[];dV(gc,function(gg,gf){if(!gf&&db(f7,gg.history)==-1){du(gg.history,gb);f7.push(gg.history)}d1(gg,gb,null,dX(gg,gb))})}}function fa(f2,f4){if(f4==0){return}f2.first+=f4;f2.sel=new fL(bQ(f2.sel.ranges,function(f5){return new dM(X(f5.anchor.line+f4,f5.anchor.ch),X(f5.head.line+f4,f5.head.ch))}),f2.sel.primIndex);if(f2.cm){ag(f2.cm,f2.first,f2.first-f4,f4);for(var f3=f2.cm.display,f1=f3.viewFrom;f1f5.lastLine()){return}if(f6.from.linef3){f6={from:f6.from,to:X(f3,e2(f5,f3).text.length),text:[f6.text[0]],origin:f6.origin}}f6.removed=fM(f5,f6.from,f6.to);if(!f4){f4=e7(f5,f6)}if(f5.cm){aH(f5.cm,f6,f2)}else{fm(f5,f6,f2)}ec(f5,f4,Z)}function aH(gc,f8,f6){var gb=gc.doc,f7=gc.display,f9=f8.from,ga=f8.to;var f1=false,f5=f9.line;if(!gc.options.lineWrapping){f5=bL(z(e2(gb,f9.line)));gb.iter(f5,ga.line+1,function(ge){if(ge==f7.maxLine){f1=true;return true}})}if(gb.sel.contains(f8.from,f8.to)>-1){W(gc)}fm(gb,f8,f6,a9(gc));if(!gc.options.lineWrapping){gb.iter(f5,f9.line+f8.text.length,function(gf){var ge=d9(gf);if(ge>f7.maxLineLength){f7.maxLine=gf;f7.maxLineLength=ge;f7.maxLineChanged=true;f1=false}});if(f1){gc.curOp.updateMaxLine=true}}gb.frontier=Math.min(gb.frontier,f9.line);d2(gc,400);var gd=f8.text.length-(ga.line-f9.line)-1;if(f9.line==ga.line&&f8.text.length==1&&!dG(gc.doc,f8)){S(gc,f9.line,"text")}else{ag(gc,f9.line,ga.line+1,gd)}var f3=e5(gc,"changes"),f4=e5(gc,"change");if(f4||f3){var f2={from:f9,to:ga,text:f8.text,removed:f8.removed,origin:f8.origin};if(f4){ad(gc,"change",gc,f2)}if(f3){(gc.curOp.changeObjs||(gc.curOp.changeObjs=[])).push(f2)}}gc.display.selForContextMenu=null}function aX(f4,f3,f6,f5,f1){if(!f5){f5=f6}if(cd(f5,f6)<0){var f2=f5;f5=f6;f6=f2}if(typeof f3=="string"){f3=aW(f3)}bb(f4,{from:f6,to:f5,text:f3,origin:f1})}function dU(f2,f5){var f6=f2.display,f3=f6.sizer.getBoundingClientRect(),f1=null;if(f5.top+f3.top<0){f1=true}else{if(f5.bottom+f3.top>(window.innerHeight||document.documentElement.clientHeight)){f1=false}}if(f1!=null&&!fi){var f4=fK("div","\u200b",null,"position: absolute; top: "+(f5.top-f6.viewOffset-eV(f2.display))+"px; height: "+(f5.bottom-f5.top+bg)+"px; left: "+f5.left+"px; width: 2px;");f2.display.lineSpace.appendChild(f4);f4.scrollIntoView(f1);f2.display.lineSpace.removeChild(f4)}}function F(gb,f9,f5,f4){if(f4==null){f4=0}for(var f6=0;f6<5;f6++){var f7=false,ga=dI(gb,f9);var f1=!f5||f5==f9?ga:dI(gb,f5);var f3=I(gb,Math.min(ga.left,f1.left),Math.min(ga.top,f1.top)-f4,Math.max(ga.left,f1.left),Math.max(ga.bottom,f1.bottom)+f4);var f8=gb.doc.scrollTop,f2=gb.doc.scrollLeft;if(f3.scrollTop!=null){O(gb,f3.scrollTop);if(Math.abs(gb.doc.scrollTop-f8)>1){f7=true}}if(f3.scrollLeft!=null){bC(gb,f3.scrollLeft);if(Math.abs(gb.doc.scrollLeft-f2)>1){f7=true}}if(!f7){return ga}}}function G(f1,f3,f5,f2,f4){var f6=I(f1,f3,f5,f2,f4);if(f6.scrollTop!=null){O(f1,f6.scrollTop)}if(f6.scrollLeft!=null){bC(f1,f6.scrollLeft)}}function I(gd,f4,gc,f2,gb){var f9=gd.display,f7=aT(gd.display);if(gc<0){gc=0}var f5=gd.curOp&&gd.curOp.scrollTop!=null?gd.curOp.scrollTop:f9.scroller.scrollTop;var gf=f9.scroller.clientHeight-bg,gh={};if(gb-gc>gf){gb=gc+gf}var f3=gd.doc.height+bG(f9);var f1=gcf3-f7;if(gcf5+gf){var ga=Math.min(gc,(f8?f3:gb)-gf);if(ga!=f5){gh.scrollTop=ga}}}var gg=gd.curOp&&gd.curOp.scrollLeft!=null?gd.curOp.scrollLeft:f9.scroller.scrollLeft;var ge=f9.scroller.clientWidth-bg-f9.gutters.offsetWidth;var f6=f2-f4>ge;if(f6){f2=f4+ge}if(f4<10){gh.scrollLeft=0}else{if(f4ge+gg-3){gh.scrollLeft=f2+(f6?0:10)-ge}}}return gh}function cH(f1,f3,f2){if(f3!=null||f2!=null){fq(f1)}if(f3!=null){f1.curOp.scrollLeft=(f1.curOp.scrollLeft==null?f1.doc.scrollLeft:f1.curOp.scrollLeft)+f3}if(f2!=null){f1.curOp.scrollTop=(f1.curOp.scrollTop==null?f1.doc.scrollTop:f1.curOp.scrollTop)+f2}}function fu(f1){fq(f1);var f2=f1.getCursor(),f4=f2,f3=f2;if(!f1.options.lineWrapping){f4=f2.ch?X(f2.line,f2.ch-1):f2;f3=X(f2.line,f2.ch+1)}f1.curOp.scrollToPos={from:f4,to:f3,margin:f1.options.cursorScrollMargin,isCursor:true}}function fq(f1){var f3=f1.curOp.scrollToPos;if(f3){f1.curOp.scrollToPos=null;var f5=dx(f1,f3.from),f4=dx(f1,f3.to);var f2=I(f1,Math.min(f5.left,f4.left),Math.min(f5.top,f4.top)-f3.margin,Math.max(f5.right,f4.right),Math.max(f5.bottom,f4.bottom)+f3.margin);f1.scrollTo(f2.scrollLeft,f2.scrollTop)}}function ac(ge,f4,gd,f3){var gc=ge.doc,f2;if(gd==null){gd="add"}if(gd=="smart"){if(!gc.mode.indent){gd="prev"}else{f2=dr(ge,f4)}}var f8=ge.options.tabSize;var gf=e2(gc,f4),f7=bR(gf.text,null,f8);if(gf.stateAfter){gf.stateAfter=null}var f1=gf.text.match(/^\s*/)[0],ga;if(!f3&&!/\S/.test(gf.text)){ga=0;gd="not"}else{if(gd=="smart"){ga=gc.mode.indent(f2,gf.text.slice(f1.length),gf.text);if(ga==b8||ga>150){if(!f3){return}gd="prev"}}}if(gd=="prev"){if(f4>gc.first){ga=bR(e2(gc,f4-1).text,null,f8)}else{ga=0}}else{if(gd=="add"){ga=f7+ge.options.indentUnit}else{if(gd=="subtract"){ga=f7-ge.options.indentUnit}else{if(typeof gd=="number"){ga=f7+gd}}}}ga=Math.max(0,ga);var gb="",f9=0;if(ge.options.indentWithTabs){for(var f5=Math.floor(ga/f8);f5;--f5){f9+=f8;gb+="\t"}}if(f9=0;f8--){aX(f1.doc,"",f5[f8].from,f5[f8].to,"+delete")}fu(f1)})}function bu(gj,f5,gd,gc,f7){var ga=f5.line,gb=f5.ch,gi=gd;var f2=e2(gj,ga);var gg=true;function gh(){var gk=ga+gd;if(gk=gj.first+gj.size){return(gg=false)}ga=gk;return f2=e2(gj,gk)}function gf(gl){var gk=(f7?v:ah)(f2,gb,gd,true);if(gk==null){if(!gl&&gh()){if(f7){gb=(gd<0?cO:cB)(f2)}else{gb=gd<0?f2.text.length:0}}else{return(gg=false)}}else{gb=gk}return true}if(gc=="char"){gf()}else{if(gc=="column"){gf(true)}else{if(gc=="word"||gc=="group"){var ge=null,f8=gc=="group";var f1=gj.cm&&gj.cm.getHelper(f5,"wordChars");for(var f6=true;;f6=false){if(gd<0&&!gf(!f6)){break}var f3=f2.text.charAt(gb)||"\n";var f4=cx(f3,f1)?"w":f8&&f3=="\n"?"n":!f8||/\s/.test(f3)?null:"p";if(f8&&!f6&&!f4){f4="s"}if(ge&&ge!=f4){if(gd<0){gd=1;gf()}break}if(f4){ge=f4}if(gd>0&&!gf(!f6)){break}}}}}var f9=bT(gj,X(ga,gb),gi,true);if(!gg){f9.hitSide=true}return f9}function bo(f9,f4,f1,f8){var f7=f9.doc,f6=f4.left,f5;if(f8=="page"){var f3=Math.min(f9.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);f5=f4.top+f1*(f3-(f1<0?1.5:0.5)*aT(f9.display))}else{if(f8=="line"){f5=f1>0?f4.bottom+3:f4.top-3}}for(;;){var f2=fC(f9,f6,f5);if(!f2.outside){break}if(f1<0?f5<=0:f5>=f7.height){f2.hitSide=true;break}f5+=f1*5}return f2}J.prototype={constructor:J,focus:function(){window.focus();en(this);C(this)},setOption:function(f3,f4){var f2=this.options,f1=f2[f3];if(f2[f3]==f4&&f3!="mode"){return}f2[f3]=f4;if(ba.hasOwnProperty(f3)){cW(this,ba[f3])(this,f4,f1)}},getOption:function(f1){return this.options[f1]},getDoc:function(){return this.doc},addKeyMap:function(f2,f1){this.state.keyMaps[f1?"push":"unshift"](f2)},removeKeyMap:function(f2){var f3=this.state.keyMaps;for(var f1=0;f10){e(this.doc,f6,new dM(f8,f3[f6].to()),Z)}}else{if(f7.head.line>f4){ac(this,f7.head.line,ga,true);f4=f7.head.line;if(f6==this.doc.sel.primIndex){fu(this)}}}}}),getTokenAt:function(f8,f2){var f5=this.doc;f8=fx(f5,f8);var f4=dr(this,f8.line,f2),f7=this.doc.mode;var f1=e2(f5,f8.line);var f6=new eH(f1.text,this.options.tabSize);while(f6.pos>1;if((f1?f4[f1*2-1]:0)>=f3){f7=f1}else{if(f4[f1*2+1]f4){f2=f4;f1=true}}var f3=e2(this.doc,f2);return eE(this,f3,{top:0,left:0},f5||"page").top+(f1?this.doc.height-bK(f3):0)},defaultTextHeight:function(){return aT(this.display)},defaultCharWidth:function(){return dt(this.display)},setGutterMarker:c2(function(f1,f2,f3){return em(this.doc,f1,"gutter",function(f4){var f5=f4.gutterMarkers||(f4.gutterMarkers={});f5[f2]=f3;if(!f3&&eI(f5)){f4.gutterMarkers=null}return true})}),clearGutter:c2(function(f3){var f1=this,f4=f1.doc,f2=f4.first;f4.iter(function(f5){if(f5.gutterMarkers&&f5.gutterMarkers[f3]){f5.gutterMarkers[f3]=null;S(f1,f2,"gutter");if(eI(f5.gutterMarkers)){f5.gutterMarkers=null}}++f2})}),addLineWidget:c2(function(f3,f2,f1){return bF(this,f3,f2,f1)}),removeLineWidget:function(f1){f1.clear()},lineInfo:function(f1){if(typeof f1=="number"){if(!b7(this.doc,f1)){return null}var f2=f1;f1=e2(this.doc,f1);if(!f1){return null}}else{var f2=bL(f1);if(f2==null){return null}}return{line:f2,handle:f1,text:f1.text,gutterMarkers:f1.gutterMarkers,textClass:f1.textClass,bgClass:f1.bgClass,wrapClass:f1.wrapClass,widgets:f1.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(f6,f3,f8,f4,ga){var f5=this.display;f6=dI(this,fx(this.doc,f6));var f7=f6.bottom,f2=f6.left;f3.style.position="absolute";f5.sizer.appendChild(f3);if(f4=="over"){f7=f6.top}else{if(f4=="above"||f4=="near"){var f1=Math.max(f5.wrapper.clientHeight,this.doc.height),f9=Math.max(f5.sizer.clientWidth,f5.lineSpace.clientWidth);if((f4=="above"||f6.bottom+f3.offsetHeight>f1)&&f6.top>f3.offsetHeight){f7=f6.top-f3.offsetHeight}else{if(f6.bottom+f3.offsetHeight<=f1){f7=f6.bottom}}if(f2+f3.offsetWidth>f9){f2=f9-f3.offsetWidth}}}f3.style.top=f7+"px";f3.style.left=f3.style.right="";if(ga=="right"){f2=f5.sizer.clientWidth-f3.offsetWidth;f3.style.right="0px"}else{if(ga=="left"){f2=0}else{if(ga=="middle"){f2=(f5.sizer.clientWidth-f3.offsetWidth)/2}}f3.style.left=f2+"px"}if(f8){G(this,f2,f7,f2+f3.offsetWidth,f7+f3.offsetHeight)}},triggerOnKeyDown:c2(q),triggerOnKeyPress:c2(cv),triggerOnKeyUp:bd,execCommand:function(f1){if(er.hasOwnProperty(f1)){return er[f1](this)}},findPosH:function(f7,f4,f5,f2){var f1=1;if(f4<0){f1=-1;f4=-f4}for(var f3=0,f6=fx(this.doc,f7);f30&&f1(f4.charAt(f7-1))){--f7}while(f30.5){Y(this)}aC(this,"refresh",this)}),swapDoc:c2(function(f2){var f1=this.doc;f1.cm=null;dY(this,f2);aj(this);fc(this);this.scrollTo(f2.scrollLeft,f2.scrollTop);this.curOp.forceScroll=true;ad(this,"swapDoc",this,f1);return f1}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};bw(J);var eR=J.defaults={};var ba=J.optionHandlers={};function t(f1,f4,f3,f2){J.defaults[f1]=f4;if(f3){ba[f1]=f2?function(f5,f7,f6){if(f6!=ca){f3(f5,f7,f6)}}:f3}}var ca=J.Init={toString:function(){return"CodeMirror.Init"}};t("value","",function(f1,f2){f1.setValue(f2)},true);t("mode",null,function(f1,f2){f1.doc.modeOption=f2;bp(f1)},true);t("indentUnit",2,bp,true);t("indentWithTabs",false);t("smartIndent",true);t("tabSize",4,function(f1){d8(f1);aj(f1);ag(f1)},true);t("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(f1,f2){f1.options.specialChars=new RegExp(f2.source+(f2.test("\t")?"":"|\t"),"g");f1.refresh()},true);t("specialCharPlaceholder",eZ,function(f1){f1.refresh()},true);t("electricChars",true);t("rtlMoveVisually",!aM);t("wholeLineUpdateBefore",true);t("theme","default",function(f1){cK(f1);dl(f1)},true);t("keyMap","default",fY);t("extraKeys",null);t("lineWrapping",false,eu,true);t("gutters",[],function(f1){cc(f1.options);dl(f1)},true);t("fixedGutter",true,function(f1,f2){f1.display.gutters.style.left=f2?dL(f1.display)+"px":"0";f1.refresh()},true);t("coverGutterNextToScrollbar",false,eM,true);t("lineNumbers",false,function(f1){cc(f1.options);dl(f1)},true);t("firstLineNumber",1,dl,true);t("lineNumberFormatter",function(f1){return f1},dl,true);t("showCursorWhenSelecting",false,bA,true);t("resetSelectionOnContextMenu",true);t("readOnly",false,function(f1,f2){if(f2=="nocursor"){aR(f1);f1.display.input.blur();f1.display.disabled=true}else{f1.display.disabled=false;if(!f2){fc(f1)}}});t("disableInput",false,function(f1,f2){if(!f2){fc(f1)}},true);t("dragDrop",true);t("cursorBlinkRate",530);t("cursorScrollMargin",0);t("cursorHeight",1,bA,true);t("singleCursorHeightPerLine",true,bA,true);t("workTime",100);t("workDelay",100);t("flattenSpans",true,d8,true);t("addModeClass",false,d8,true);t("pollInterval",100);t("undoDepth",200,function(f1,f2){f1.doc.history.undoDepth=f2});t("historyEventDelay",1250);t("viewportMargin",10,function(f1){f1.refresh()},true);t("maxHighlightLength",10000,d8,true);t("moveInputWithCursor",true,function(f1,f2){if(!f2){f1.display.inputDiv.style.top=f1.display.inputDiv.style.left=0}});t("tabindex",null,function(f1,f2){f1.display.input.tabIndex=f2||""});t("autofocus",null);var di=J.modes={},aP=J.mimeModes={};J.defineMode=function(f1,f2){if(!J.defaults.mode&&f1!="null"){J.defaults.mode=f1}if(arguments.length>2){f2.dependencies=Array.prototype.slice.call(arguments,2)}di[f1]=f2};J.defineMIME=function(f2,f1){aP[f2]=f1};J.resolveMode=function(f1){if(typeof f1=="string"&&aP.hasOwnProperty(f1)){f1=aP[f1]}else{if(f1&&typeof f1.name=="string"&&aP.hasOwnProperty(f1.name)){var f2=aP[f1.name];if(typeof f2=="string"){f2={name:f2}}f1=cj(f2,f1);f1.name=f2.name}else{if(typeof f1=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(f1)){return J.resolveMode("application/xml")}}}if(typeof f1=="string"){return{name:f1}}else{return f1||{name:"null"}}};J.getMode=function(f2,f1){var f1=J.resolveMode(f1);var f4=di[f1.name];if(!f4){return J.getMode(f2,"text/plain")}var f5=f4(f2,f1);if(df.hasOwnProperty(f1.name)){var f3=df[f1.name];for(var f6 in f3){if(!f3.hasOwnProperty(f6)){continue}if(f5.hasOwnProperty(f6)){f5["_"+f6]=f5[f6]}f5[f6]=f3[f6]}}f5.name=f1.name;if(f1.helperType){f5.helperType=f1.helperType}if(f1.modeProps){for(var f6 in f1.modeProps){f5[f6]=f1.modeProps[f6]}}return f5};J.defineMode("null",function(){return{token:function(f1){f1.skipToEnd()}}});J.defineMIME("text/plain","null");var df=J.modeExtensions={};J.extendMode=function(f3,f2){var f1=df.hasOwnProperty(f3)?df[f3]:(df[f3]={});aK(f2,f1)};J.defineExtension=function(f1,f2){J.prototype[f1]=f2};J.defineDocExtension=function(f1,f2){at.prototype[f1]=f2};J.defineOption=t;var a4=[];J.defineInitHook=function(f1){a4.push(f1)};var fb=J.helpers={};J.registerHelper=function(f2,f1,f3){if(!fb.hasOwnProperty(f2)){fb[f2]=J[f2]={_global:[]}}fb[f2][f1]=f3};J.registerGlobalHelper=function(f3,f2,f1,f4){J.registerHelper(f3,f2,f4);fb[f3]._global.push({pred:f1,val:f4})};var b1=J.copyState=function(f4,f1){if(f1===true){return f1}if(f4.copyState){return f4.copyState(f1)}var f3={};for(var f5 in f1){var f2=f1[f5];if(f2 instanceof Array){f2=f2.concat([])}f3[f5]=f2}return f3};var bY=J.startState=function(f3,f2,f1){return f3.startState?f3.startState(f2,f1):true};J.innerMode=function(f3,f1){while(f3.innerMode){var f2=f3.innerMode(f1);if(!f2||f2.mode==f3){break}f1=f2.state;f3=f2.mode}return f2||{mode:f3,state:f1}};var er=J.commands={selectAll:function(f1){f1.setSelection(X(f1.firstLine(),0),X(f1.lastLine()),Z)},singleSelection:function(f1){f1.setSelection(f1.getCursor("anchor"),f1.getCursor("head"),Z)},killLine:function(f1){eL(f1,function(f3){if(f3.empty()){var f2=e2(f1.doc,f3.head.line).text.length;if(f3.head.ch==f2&&f3.head.line0){f7=new X(f7.line,f7.ch+1);f1.replaceRange(f2.charAt(f7.ch-1)+f2.charAt(f7.ch-2),X(f7.line,f7.ch-2),f7,"+transpose")}else{if(f7.line>f1.doc.first){var f6=e2(f1.doc,f7.line-1).text;if(f6){f1.replaceRange(f2.charAt(0)+"\n"+f6.charAt(f6.length-1),X(f7.line-1,f6.length-1),X(f7.line,1),"+transpose")}}}}f3.push(new dM(f7,f7))}f1.setSelections(f3)})},newlineAndIndent:function(f1){cI(f1,function(){var f2=f1.listSelections().length;for(var f4=0;f4=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.posf2},eatSpace:function(){var f1=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this.pos}return this.pos>f1},skipToEnd:function(){this.pos=this.string.length},skipTo:function(f1){var f2=this.string.indexOf(f1,this.pos);if(f2>-1){this.pos=f2;return true}},backUp:function(f1){this.pos-=f1},column:function(){if(this.lastColumnPos0){return null}if(f3&&f2!==false){this.pos+=f3[0].length}return f3}},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(f2,f1){this.lineStart+=f2;try{return f1()}finally{this.lineStart-=f2}}};var Q=J.TextMarker=function(f2,f1){this.lines=[];this.type=f1;this.doc=f2};bw(Q);Q.prototype.clear=function(){if(this.explicitlyCleared){return}var f8=this.doc.cm,f2=f8&&!f8.curOp;if(f2){cE(f8)}if(e5(this,"clear")){var f9=this.find();if(f9){ad(this,"clear",f9.from,f9.to)}}var f3=null,f6=null;for(var f4=0;f4f8.display.maxLineLength){f8.display.maxLine=f1;f8.display.maxLineLength=f5;f8.display.maxLineChanged=true}}}if(f3!=null&&f8&&this.collapsed){ag(f8,f3,f6+1)}this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=false;if(f8){el(f8.doc)}}if(f8){ad(f8,"markerCleared",f8,this)}if(f2){al(f8)}if(this.parent){this.parent.clear()}};Q.prototype.find=function(f4,f2){if(f4==null&&this.type=="bookmark"){f4=1}var f7,f6;for(var f3=0;f30||ga==0&&f4.clearWhenEmpty!==false){return f4}if(f4.replacedWith){f4.collapsed=true;f4.widgetNode=fK("span",[f4.replacedWith],"CodeMirror-widget");if(!gb.handleMouseEvents){f4.widgetNode.ignoreEvents=true}if(gb.insertLeft){f4.widgetNode.insertLeft=true}}if(f4.collapsed){if(A(f9,f7.line,f7,f8,f4)||f7.line!=f8.line&&A(f9,f8.line,f7,f8,f4)){throw new Error("Inserting collapsed marker partially overlapping an existing one")}a3=true}if(f4.addToHistory){fA(f9,{from:f7,to:f8,origin:"markText"},f9.sel,NaN)}var f2=f7.line,f6=f9.cm,f1;f9.iter(f2,f8.line+1,function(gc){if(f6&&f4.collapsed&&!f6.options.lineWrapping&&z(gc)==f6.display.maxLine){f1=true}if(f4.collapsed&&f2!=f7.line){fO(gc,0)}cb(gc,new d5(f4,f2==f7.line?f7.ch:null,f2==f8.line?f8.ch:null));++f2});if(f4.collapsed){f9.iter(f7.line,f8.line+1,function(gc){if(fk(f9,gc)){fO(gc,0)}})}if(f4.clearOnEnter){bV(f4,"beforeCursorEnter",function(){f4.clear()})}if(f4.readOnly){fV=true;if(f9.history.done.length||f9.history.undone.length){f9.clearHistory()}}if(f4.collapsed){f4.id=++a1;f4.atomic=true}if(f6){if(f1){f6.curOp.updateMaxLine=true}if(f4.collapsed){ag(f6,f7.line,f8.line+1)}else{if(f4.className||f4.title||f4.startStyle||f4.endStyle){for(var f3=f7.line;f3<=f8.line;f3++){S(f6,f3,"text")}}}if(f4.atomic){el(f6.doc)}ad(f6,"markerAdded",f6,f4)}return f4}var y=J.SharedTextMarker=function(f3,f2){this.markers=f3;this.primary=f2;for(var f1=0;f1=f3:f9.to>f3);(f8||(f8=[])).push(new d5(f6,f9.from,f4?null:f9.to))}}}return f8}function aA(f2,f4,f7){if(f2){for(var f5=0,f8;f5=f4:f9.to>f4);if(f3||f9.from==f4&&f6.type=="bookmark"&&(!f7||f9.marker.insertLeft)){var f1=f9.from==null||(f6.inclusiveLeft?f9.from<=f4:f9.from0&&f7){for(var f4=0;f40){continue}var ga=[f4,1],f1=cd(f2.from,f3.from),f9=cd(f2.to,f3.to);if(f1<0||!f8.inclusiveLeft&&!f1){ga.push({from:f2.from,to:f3.from})}if(f9>0||!f8.inclusiveRight&&!f9){ga.push({from:f3.to,to:f2.to})}f6.splice.apply(f6,ga);f4+=ga.length-1}}return f6}function fR(f1){var f3=f1.markedSpans;if(!f3){return}for(var f2=0;f2=0&&f6<=0||ga<=0&&f6>=0){continue}if(ga<=0&&(cd(gb.to,f7)>0||(f2.marker.inclusiveRight&&f5.inclusiveLeft))||ga>=0&&(cd(gb.from,f8)<0||(f2.marker.inclusiveLeft&&f5.inclusiveRight))){return true}}}}function z(f2){var f1;while(f1=eC(f2)){f2=f1.find(-1,true).line}return f2}function h(f3){var f1,f2;while(f1=ei(f3)){f3=f1.find(1,true).line;(f2||(f2=[])).push(f3)}return f2}function aS(f4,f2){var f1=e2(f4,f2),f3=z(f1);if(f1==f3){return f2}return bL(f3)}function dR(f4,f3){if(f3>f4.lastLine()){return f3}var f2=e2(f4,f3),f1;if(!fk(f4,f2)){return f3}while(f1=ei(f2)){f2=f1.find(1,true).line}return bL(f2)+1}function fk(f5,f2){var f1=a3&&f2.markedSpans;if(f1){for(var f4,f3=0;f3f4.start){return f2}}throw new Error("Mode "+f5.name+" failed to advance stream.")}function x(gb,gd,f6,f2,f7,f4,f5){var f3=f6.flattenSpans;if(f3==null){f3=gb.options.flattenSpans}var f9=0,f8=null;var gc=new eH(gd,gb.options.tabSize),f1;if(gd==""){dc(fe(f6,f2),f4)}while(!gc.eol()){if(gc.pos>gb.options.maxHighlightLength){f3=false;if(f5){dm(gb,gd,f2,gc.pos)}gc.pos=gd.length;f1=null}else{f1=dc(ep(f6,gc,f2),f4)}if(gb.options.addModeClass){var ge=J.innerMode(f6,f2).mode.name;if(ge){f1="m-"+(f1?ge+" "+f1:ge)}}if(!f3||f8!=f1){if(f9gb){f9.splice(f7,1,gb,f9[f7+1],gc)}f7+=2;f3=Math.min(gb,gc)}if(!gd){return}if(f6.opaque){f9.splice(gf,f7-gf,gb,"cm-overlay "+gd);f7=gf+2}else{for(;gff4&&f5.from<=f4){break}}if(f5.to>=f6){return f2(f9,gb,f3,f7,gc,ga)}f2(f9,gb.slice(0,f5.to-f4),f3,f7,null,ga);f7=null;gb=gb.slice(f5.to-f4);f4=f5.to}}}function ab(f2,f4,f1,f3){var f5=!f3&&f1.widgetNode;if(f5){f2.map.push(f2.pos,f2.pos+f4,f5);f2.content.appendChild(f5)}f2.pos+=f4}function bm(ga,gg,f9){var f6=ga.markedSpans,f8=ga.text,ge=0;if(!f6){for(var gj=1;gjf5)){if(gi.to!=null&&gn>gi.to){gn=gi.to;gm=""}if(gf.className){f1+=" "+gf.className}if(gf.startStyle&&gi.from==f5){gd+=" "+gf.startStyle}if(gf.endStyle&&gi.to==gn){gm+=" "+gf.endStyle}if(gf.title&&!go){go=gf.title}if(gf.collapsed&&(!f3||dE(f3.marker,gf)<0)){f3=gi}}else{if(gi.from>f5&&gn>gi.from){gn=gi.from}}if(gf.type=="bookmark"&&gi.from==f5&&gf.widgetNode){f7.push(gf)}}if(f3&&(f3.from||0)==f5){ab(gg,(f3.to==null?gk+1:f3.to)-f5,f3.marker,f3.from==null);if(f3.to==null){return}}if(!f3&&f7.length){for(var gh=0;gh=gk){break}var gb=Math.min(gk,gn);while(true){if(gc){var f2=f5+gc.length;if(!f3){var f4=f2>gb?gc.slice(0,gb-f5):gc;gg.addToken(gg,f4,gl?gl+f1:f1,gd,f5+f4.length==gn?gm:"",go)}if(f2>=gb){gc=gc.slice(gb-f5);f5=gb;break}f5=f2;gd=""}gc=f8.slice(ge,ge=f9[gj++]);gl=eK(f9[gj++],gg.cm.options)}}}function dG(f1,f2){return f2.from.ch==0&&f2.to.ch==0&&fv(f2.text)==""&&(!f1.cm||f1.cm.options.wholeLineUpdateBefore)}function fm(ge,f9,f1,f5){function gf(gh){return f1?f1[gh]:null}function f2(gh,gj,gi){ea(gh,gj,gi,f5);ad(gh,"change",gh,f9)}var gc=f9.from,gd=f9.to,gg=f9.text;var ga=e2(ge,gc.line),gb=e2(ge,gd.line);var f8=fv(gg),f4=gf(gg.length-1),f7=gd.line-gc.line;if(dG(ge,f9)){for(var f3=0,f6=[];f31){ge.remove(gc.line+1,f7-1)}ge.insert(gc.line+1,f6)}}}ad(ge,"change",ge,f9)}function eN(f2){this.lines=f2;this.parent=null;for(var f3=0,f1=0;f31||!(this.children[0] instanceof eN))){var f2=[];this.collapse(f2);this.children=[new eN(f2)];this.children[0].parent=this}},collapse:function(f1){for(var f2=0;f250){while(f8.lines.length>50){var f5=f8.lines.splice(f8.lines.length-25,25);var f4=new eN(f5);f8.height-=f4.height;this.children.splice(f6+1,0,f4);f4.parent=this}this.maybeSpill()}break}f2-=f7}},maybeSpill:function(){if(this.children.length<=10){return}var f4=this;do{var f2=f4.children.splice(f4.children.length-5,5);var f3=new fl(f2);if(!f4.parent){var f5=new fl(f4.children);f5.parent=f4;f4.children=[f5,f3];f4=f5}else{f4.size-=f3.size;f4.height-=f3.height;var f1=db(f4.parent.children,f4);f4.parent.children.splice(f1+1,0,f3)}f3.parent=f4.parent}while(f4.children.length>10);f4.parent.maybeSpill()},iterN:function(f1,f7,f6){for(var f2=0;f2=0;f4--){bb(this,f5[f4])}if(f1){eU(this,f1)}else{if(this.cm){fu(this.cm)}}}),undo:cA(function(){b6(this,"undo")}),redo:cA(function(){b6(this,"redo")}),undoSelection:cA(function(){b6(this,"undo",true)}),redoSelection:cA(function(){b6(this,"redo",true)}),setExtending:function(f1){this.extend=f1},getExtending:function(){return this.extend},historySize:function(){var f4=this.history,f1=0,f3=0;for(var f2=0;f2=f5.ch)){f4.push(f3.marker.parent||f3.marker)}}}return f4},findMarks:function(f5,f4,f1){f5=fx(this,f5);f4=fx(this,f4);var f2=[],f3=f5.line;this.iter(f5.line,f4.line+1,function(f6){var f8=f6.markedSpans;if(f8){for(var f7=0;f7f9.to||f9.from==null&&f3!=f5.line||f3==f4.line&&f9.from>f4.ch)&&(!f1||f1(f9.marker))){f2.push(f9.marker.parent||f9.marker)}}}++f3});return f2},getAllMarks:function(){var f1=[];this.iter(function(f3){var f2=f3.markedSpans;if(f2){for(var f4=0;f4f2){f1=f2;return true}f2-=f5;++f3});return fx(this,X(f3,f1))},indexFromPos:function(f2){f2=fx(this,f2);var f1=f2.ch;if(f2.linef4){f4=f1.from}if(f1.to!=null&&f1.to=f4.size){throw new Error("There is no line "+(f6+f4.first)+" in the document.")}for(var f1=f4;!f1.lines;){for(var f2=0;;++f2){var f5=f1.children[f2],f3=f5.chunkSize();if(f61&&!f2.done[f2.done.length-2].ranges){f2.done.pop();return fv(f2.done)}}}}function fA(f7,f5,f1,f4){var f3=f7.history;f3.undone.length=0;var f2=+new Date,f8;if((f3.lastOp==f4||f3.lastOrigin==f5.origin&&f5.origin&&((f5.origin.charAt(0)=="+"&&f7.cm&&f3.lastModTime>f2-f7.cm.options.historyEventDelay)||f5.origin.charAt(0)=="*"))&&(f8=eA(f3,f3.lastOp==f4))){var f9=fv(f8.changes);if(cd(f5.from,f5.to)==0&&cd(f5.from,f9.to)==0){f9.to=cR(f5)}else{f8.changes.push(dk(f7,f5))}}else{var f6=fv(f3.done);if(!f6||!f6.ranges){cJ(f7.sel,f3.done)}f8={changes:[dk(f7,f5)],generation:f3.generation};f3.done.push(f8);while(f3.done.length>f3.undoDepth){f3.done.shift();if(!f3.done[0].ranges){f3.done.shift()}}}f3.done.push(f1);f3.generation=++f3.maxGeneration;f3.lastModTime=f3.lastSelTime=f2;f3.lastOp=f3.lastSelOp=f4;f3.lastOrigin=f3.lastSelOrigin=f5.origin;if(!f9){aC(f7,"historyAdded")}}function by(f5,f1,f3,f4){var f2=f1.charAt(0);return f2=="*"||f2=="+"&&f3.ranges.length==f4.ranges.length&&f3.somethingSelected()==f4.somethingSelected()&&new Date-f5.history.lastSelTime<=(f5.cm?f5.cm.options.historyEventDelay:500)}function fU(f6,f4,f1,f3){var f5=f6.history,f2=f3&&f3.origin;if(f1==f5.lastSelOp||(f2&&f5.lastSelOrigin==f2&&(f5.lastModTime==f5.lastSelTime&&f5.lastOrigin==f2||by(f6,f2,fv(f5.done),f4)))){f5.done[f5.done.length-1]=f4}else{cJ(f4,f5.done)}f5.lastSelTime=+new Date;f5.lastSelOrigin=f2;f5.lastSelOp=f1;if(f3&&f3.clearRedo!==false){fp(f5.undone)}}function cJ(f2,f1){var f3=fv(f1);if(!(f3&&f3.ranges&&f3.equals(f2))){f1.push(f2)}}function bW(f2,f6,f5,f4){var f1=f6["spans_"+f2.id],f3=0;f2.iter(Math.max(f2.first,f5),Math.min(f2.first+f2.size,f4),function(f7){if(f7.markedSpans){(f1||(f1=f6["spans_"+f2.id]={}))[f3]=f7.markedSpans}++f3})}function bh(f3){if(!f3){return null}for(var f2=0,f1;f2-1){fv(ga)[f1]=f8[f1];delete f8[f1]}}}}}}return f2}function K(f4,f3,f2,f1){if(f20}function bw(f1){f1.prototype.on=function(f2,f3){bV(this,f2,f3)};f1.prototype.off=function(f2,f3){d0(this,f2,f3)}}var bg=30;var b8=J.Pass={toString:function(){return"CodeMirror.Pass"}};var Z={scroll:false},N={origin:"*mouse"},cQ={origin:"+move"};function f0(){this.id=null}f0.prototype.set=function(f1,f2){clearTimeout(this.id);this.id=setTimeout(f2,f1)};var bR=J.countColumn=function(f4,f2,f6,f7,f3){if(f2==null){f2=f4.search(/[^\s\u00a0]/);if(f2==-1){f2=f4.length}}for(var f5=f7||0,f8=f3||0;;){var f1=f4.indexOf("\t",f5);if(f1<0||f1>=f2){return f8+(f2-f5)}f8+=f1-f5;f8+=f6-(f8%f6);f5=f1+1}};function ed(f5,f4,f6){for(var f7=0,f3=0;;){var f2=f5.indexOf("\t",f7);if(f2==-1){f2=f5.length}var f1=f2-f7;if(f2==f5.length||f3+f1>=f4){return f7+Math.min(f1,f4-f3)}f3+=f2-f7;f3+=f6-(f3%f6);f7=f2+1;if(f3>=f4){return f7}}}var aV=[""];function co(f1){while(aV.length<=f1){aV.push(fv(aV)+" ")}return aV[f1]}function fv(f1){return f1[f1.length-1]}var dA=function(f1){f1.select()};if(eP){dA=function(f1){f1.selectionStart=0;f1.selectionEnd=f1.value.length}}else{if(dz){dA=function(f2){try{f2.select()}catch(f1){}}}}function db(f3,f1){for(var f2=0;f2"\x80"&&(f1.toUpperCase()!=f1.toLowerCase()||a8.test(f1))};function cx(f1,f2){if(!f2){return fr(f1)}if(f2.source.indexOf("\\w")>-1&&fr(f1)){return true}return f2.test(f1)}function eI(f1){for(var f2 in f1){if(f1.hasOwnProperty(f2)&&f1[f2]){return false}}return true}var ex=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function fd(f1){return f1.charCodeAt(0)>=768&&ex.test(f1)}function fK(f1,f5,f4,f3){var f6=document.createElement(f1);if(f4){f6.className=f4}if(f3){f6.style.cssText=f3}if(typeof f5=="string"){f6.appendChild(document.createTextNode(f5))}else{if(f5){for(var f2=0;f20;--f1){f2.removeChild(f2.firstChild)}return f2}function bP(f1,f2){return dP(f1).appendChild(f2)}function fT(f1,f2){if(f1.contains){return f1.contains(f2)}while(f2=f2.parentNode){if(f2==f1){return true}}}function dC(){return document.activeElement}if(dz&&l<11){dC=function(){try{return document.activeElement}catch(f1){return document.body}}}function T(f1){return new RegExp("\\b"+f1+"\\b\\s*")}function f(f2,f1){var f3=T(f1);if(f3.test(f2.className)){f2.className=f2.className.replace(f3,"")}}function fo(f2,f1){if(!T(f1).test(f2.className)){f2.className+=" "+f1}}function fF(f3,f1){var f2=f3.split(" ");for(var f4=0;f42&&!(dz&&l<8)}}if(fz){return fK("span","\u200b")}else{return fK("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px")}}var fy;function bM(f4){if(fy!=null){return fy}var f1=bP(f4,document.createTextNode("A\u062eA"));var f3=ck(f1,0,1).getBoundingClientRect();if(!f3||f3.left==f3.right){return false}var f2=ck(f1,1,2).getBoundingClientRect();return fy=(f2.right-f3.right<3)}var aW=J.splitLines="\n\nb".split(/\n/).length!=3?function(f6){var f7=0,f1=[],f5=f6.length;while(f7<=f5){var f4=f6.indexOf("\n",f7);if(f4==-1){f4=f6.length}var f3=f6.slice(f7,f6.charAt(f4-1)=="\r"?f4-1:f4);var f2=f3.indexOf("\r");if(f2!=-1){f1.push(f3.slice(0,f2));f7+=f2+1}else{f1.push(f3);f7=f4+1}}return f1}:function(f1){return f1.split(/\r\n?|\n/)};var bq=window.getSelection?function(f2){try{return f2.selectionStart!=f2.selectionEnd}catch(f1){return false}}:function(f3){try{var f1=f3.ownerDocument.selection.createRange()}catch(f2){}if(!f1||f1.parentElement()!=f3){return false}return f1.compareEndPoints("StartToEnd",f1)!=0};var c4=(function(){var f1=fK("div");if("oncopy" in f1){return true}f1.setAttribute("oncopy","return;");return typeof f1.oncopy=="function"})();var eT=null;function aI(f2){if(eT!=null){return eT}var f3=bP(f2,fK("span","x"));var f4=f3.getBoundingClientRect();var f1=ck(f3,0,1).getBoundingClientRect();return eT=Math.abs(f4.left-f1.left)>1}var e3={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};J.keyNames=e3;(function(){for(var f1=0;f1<10;f1++){e3[f1+48]=e3[f1+96]=String(f1)}for(var f1=65;f1<=90;f1++){e3[f1]=String.fromCharCode(f1)}for(var f1=1;f1<=12;f1++){e3[f1+111]=e3[f1+63235]="F"+f1}})();function dS(f1,f7,f6,f5){if(!f1){return f5(f7,f6,"ltr")}var f4=false;for(var f3=0;f3f7||f7==f6&&f2.to==f7){f5(Math.max(f2.from,f7),Math.min(f2.to,f6),f2.level==1?"rtl":"ltr");f4=true}}if(!f4){f5(f7,f6,"ltr")}}function dn(f1){return f1.level%2?f1.to:f1.from}function fW(f1){return f1.level%2?f1.from:f1.to}function cB(f2){var f1=a(f2);return f1?dn(f1[0]):0}function cO(f2){var f1=a(f2);if(!f1){return f2.text.length}return fW(fv(f1))}function br(f2,f5){var f3=e2(f2.doc,f5);var f6=z(f3);if(f6!=f3){f5=bL(f6)}var f1=a(f6);var f4=!f1?0:f1[0].level%2?cO(f6):cB(f6);return X(f5,f4)}function dD(f3,f6){var f2,f4=e2(f3.doc,f6);while(f2=ei(f4)){f4=f2.find(1,true).line;f6=null}var f1=a(f4);var f5=!f1?f4.text.length:f1[0].level%2?cB(f4):cO(f4);return X(f6==null?bL(f4):f6,f5)}function dy(f2,f7){var f6=br(f2,f7.line);var f3=e2(f2.doc,f6.line);var f1=a(f3);if(!f1||f1[0].level==0){var f5=Math.max(0,f3.text.search(/\S/));var f4=f7.line==f6.line&&f7.ch<=f5&&f7.ch;return X(f6.line,f4?0:f5)}return f6}function am(f2,f3,f1){var f4=f2[0].level;if(f3==f4){return true}if(f1==f4){return false}return f3f5){return f2}if((f4.from==f5||f4.to==f5)){if(f3==null){f3=f2}else{if(am(f1,f4.level,f1[f3].level)){if(f4.from!=f4.to){eQ=f3}return f2}else{if(f4.from!=f4.to){eQ=f2}return f3}}}}return f3}function e1(f1,f4,f2,f3){if(!f3){return f4+f2}do{f4+=f2}while(f4>0&&fd(f1.text.charAt(f4)));return f4}function v(f1,f8,f3,f4){var f5=a(f1);if(!f5){return ah(f1,f8,f3,f4)}var f7=aE(f5,f8),f2=f5[f7];var f6=e1(f1,f8,f2.level%2?-f3:f3,f4);for(;;){if(f6>f2.from&&f60)==f2.level%2?f2.to:f2.from}else{f2=f5[f7+=f3];if(!f2){return null}if((f3>0)==f2.level%2){f6=e1(f1,f2.to,-1,f4)}else{f6=e1(f1,f2.from,1,f4)}}}}function ah(f1,f5,f2,f3){var f4=f5+f2;if(f3){while(f4>0&&fd(f1.text.charAt(f4))){f4+=f2}}return f4<0||f4>f1.text.length?null:f4}var bc=(function(){var f7="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";var f5="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";function f4(gb){if(gb<=247){return f7.charAt(gb)}else{if(1424<=gb&&gb<=1524){return"R"}else{if(1536<=gb&&gb<=1773){return f5.charAt(gb-1536)}else{if(1774<=gb&&gb<=2220){return"r"}else{if(8192<=gb&&gb<=8203){return"w"}else{if(gb==8204){return"b"}else{return"L"}}}}}}}var f1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;var ga=/[stwN]/,f3=/[LRr]/,f2=/[Lb1n]/,f6=/[1n]/;var f9="L";function f8(gd,gc,gb){this.level=gd;this.from=gc;this.to=gb}return function(gl){if(!f1.test(gl)){return false}var gr=gl.length,gh=[];for(var gq=0,gd;gq