vim.md

simple vi markdown editor https://github.com/joseamarin/vim.MD joseamarin.github.io/vim.md/
git clone http://git.hanabi.in/repos/vim.md.git
Log | Files | Refs | README

commit 51fddf12c3a514c99657353e1b2759a5b311ebf0
parent 8194e9edc66713a2a4a1fea03958772bac780fa6
Author: jose marin <josemarinemail@gmail.com>
Date:   Mon,  9 Jul 2018 02:33:59 -0400

implemented working vim editor through code mirror markdown renders in realtime

Diffstat:
Mindex.html | 8+++-----
Djavascript/jsvim.js | 1217-------------------------------------------------------------------------------
Mjavascript/main.js | 42++++++++++++++++++++----------------------
Djavascript/vim.min.js | 2--
Alib/the-matrix.css | 30++++++++++++++++++++++++++++++
Mstyles/main.css | 4++++
6 files changed, 57 insertions(+), 1246 deletions(-)

diff --git a/index.html b/index.html @@ -8,10 +8,10 @@ <link rel="stylesheet" href="styles/semantic.min.css"> <link rel="stylesheet" href="styles/xt256.css"> <link rel="stylesheet" href="lib/codemirror.min.css"> + <link rel="stylesheet" href="lib/the-matrix.css"> <link rel="stylesheet" href="styles/main.css"> </head> <body id="book"> - <div class="ui inverted menu" style="margin-bottom: 0;"> <div class="header item"> Home @@ -22,11 +22,10 @@ <a class="item"> Export </a> - </div> <!--/nav --> - + </div> <div class="book-wrapper"> <div class="book-wrapper-inner"> - <div class="book-col--40"> + <div class="book-col--40 js-input"> </div> <div class="book-col--60"> <div class="book-content"> @@ -37,7 +36,6 @@ </div> <script src="javascript/highlight.min.js"></script> <script src="javascript/marked.min.js"></script> - <script src="javascript/jsvim.js"></script> <script src="lib/codemirror.min.js"></script> <script src="lib/vim.min.js"></script> <script src="javascript/main.js"></script> diff --git a/javascript/jsvim.js b/javascript/jsvim.js @@ -1,1217 +0,0 @@ -/* (c) jakub.mikians@gmail.com 2012, 2013 */ - -/* commented parts starting with //ext// should make crossrider extension out - * of this script */ - -//ext//appAPI.ready(function($) { - -/*===================================================================*/ -/* Command tree */ - -function Node(data) { - this.set_choice = function( option, node, data ) { - this.nodes[ option ] = {node: node, data: data} - return this - } - - this.get_choice = function( option ) { - return this.nodes[option] - } - - this.get_choice_node = function( option ) { - var x = this.get_choice( option ) - return (x === undefined) ? undefined : x.node - } - - this.is_leaf = function() { - return is_empty_object( this.nodes ) - } - - this.set_choices = function( choices ) { - for (var key in choices) - if (choices.hasOwnProperty(key)) { - var val = choices[key] - if ( val instanceof Array ) { - this.set_choice( key, val[0], val[1] ) - } else { - this.set_choice( key, val ) - } - } - return this - } - - this.data = data - this.nodes = {} -} - -var merge_dict = function( dict_a, dict_b ) { - var r = {} - - var clone = function( src ) { - for (var p in src) - if (src.hasOwnProperty(p)) - r[p] = src[p] - } - - clone(dict_a) - if (dict_b !== undefined) clone(dict_b) - - return r -} - -var is_empty_object = function(e) { - for (var prop in e) if (e.hasOwnProperty(prop)) return false; - return true; -} - -/*===================================================================*/ -/* VIM class and other */ - -var COMMAND = 'COMMAND' -var INSERT = 'INSERT' -var VISUAL = 'VISUAL' - -var NREPEATS_LIMIT = 100 -var UNDO_DEPTH = 100 - - -var _proxy = function( func, context ) { - return function(){ - return func.apply( context, arguments ) - } -} - -var __special_keys = { - 8:'Backspace', - 9:'Tab', - 13:'Enter', - 27:'Escape', - 33:'PageUp', - 34:'PageDown', - 35:'End', - 36:'Home', - 37:'Left', - 38:'Up', - 39:'Right', - 40:'Down', - 45:'Insert', - 46:'Delete', -} - -function VIM(ctrees) { - this.attach_to = function(m_selector) { - this.m_selector = m_selector - m_selector.onkeydown = _proxy( this.on_keydown, this) - m_selector.onkeypress = _proxy( this.on_keypress, this) - this.reset() -//ext// window.__refocus = true - } - - this.on_keydown = function(event){ - var p - var m = __special_keys[ event.keyCode ] - if (undefined === m ) { - p = true - } else { - p = this.on_key( '<'+m+'>', event ) - } - return p - } - - this.on_keypress = function(event){ - var m = String.fromCharCode( event.keyCode ) - var p = this.on_key( m, event ) - return p - } - - this.on_key = function(c, event) { - this.log('"' + c + '"') - var pass_keys - if ('<Escape>' === c) { - this.reset() - pass_keys = false - } - else if ( this.is_mode(INSERT) ) { - if (c === '<Enter>') { - this.enter_auto_indent() - pass_keys = false - } else { - pass_keys = true - } - } - else if (c !== null) { - this.accept_key( c ) - pass_keys = false - } - - if ( false === pass_keys ) { - event.preventDefault() - event.stopPropagation() - } - return pass_keys - } - - this.enter_auto_indent = function() { - var text = this.get_text() - var pos = this.get_pos() - - var xs = select_line(text, pos) - var n_spaces = count_space_from( text, xs[0] ) - var local_pos = pos - xs[0] - n_spaces = (local_pos < n_spaces) ? local_pos : n_spaces - var t = "\n" + repeat_str(' ', n_spaces) - text = insert_at( text, t, pos ) - - this.set_text( text ) - this.set_pos( pos + t.length ) - } - - this.set_mode = function(mode) { - this.log("set_mode " + mode) - if (this.m_mode === COMMAND && mode === VISUAL) { - // do not change when comming from PENDING - would affect 'viw' - this.m_selection_from = this.get_pos() - } - this.m_mode = mode - if (this.on_set_mode !== undefined) this.on_set_mode(this) - } - - this.insert_to_clipboard = function(text) { - this.log('insert_to_clipboard len: ' + text.length) - if (this.m_allow_clipboard_reset) { - this.m_allow_clipboard_reset = false - this.m_buffer = '' - } - this.m_buffer += text - } - - /* This is used to distinguish between "2daw" and "dawdaw". In first case, - * both lines should be put into the buffer, and in the second case - only - * the line deleted at second "daw", overwriting the line from first "daw" */ - this.allow_clipboard_reset = function(text) { - this.m_allow_clipboard_reset = true - } - - this.get_clipboard = function() { - return this.m_buffer - } - - this.save_undo_state = function() { - var curr_text = this.get_text() - var last_text = last( this.m_undo_stack ) - last_text = (last_text === undefined) ? '' : last_text.text - - if ( curr_text !== last_text ) { - var t = {text: curr_text, pos: this.get_pos()} - this.m_undo_stack.push( t ) - if (this.m_undo_stack.length > UNDO_DEPTH ) { - this.m_undo_stack.shift() - } - this.log('undo depth ' + this.m_undo_stack.length ) - } - } - - this.is_mode = function(mode) { - return this.m_mode === mode - } - - this.reset = function() { - this.reset_mode() - this.reset_commands() - } - - this.reset_mode = function() { - this.set_mode( COMMAND ) - } - - this.reset_commands = function() { - this.m_cnode = this.m_ctrees[ this.m_mode ] - this.m_cdata = {} - this.m_current_sequence = '' - } - - this.get_pos = function() { - return getCaret( document.activeElement ) - } - - this.get_text = function() { - return this.m_selector.value - } - - this.set_text = function(tx) { - this.m_selector.value = tx - } - - this.set_pos = function(k) { - _select_pos( this.m_selector, k ) - if (this.on_set_pos !== undefined) this.on_set_pos(this) - } - - this.select_current_line = function() { - return select_line( this.get_text(), this.get_pos() ) - } - - this.accept_key = function(c) { - this.m_current_sequence += c - var x = this.m_cnode.get_choice(c) - if (x === undefined) { - this.log('(unknown sequence "'+this.m_current_sequence+'"') - this.reset_commands() - } - else { - this.m_cdata = merge_dict( this.m_cdata, x.data ) - this.m_cdata = merge_dict( this.m_cdata, x.node.data ) - this.m_cnode = x.node - - if (this.m_cnode.is_leaf()) { - var nrepeats - if (this.m_cdata.digit === undefined) { - nrepeats = ( (this.m_digit_buffer === '') ? 1 - : parseInt(this.m_digit_buffer)) - nrepeats = (nrepeats > NREPEATS_LIMIT) ? NREPEATS_LIMIT : - ( (nrepeats < 1) ? 1 : nrepeats) - this.m_digit_buffer = '' - } - else { - nrepeats = 1 - } - if (nrepeats !== 1) { this.log('n. repeats: ' + nrepeats) } - - this.allow_clipboard_reset() - if ( ! this.m_cdata.dont_save_undo_state ) { - this.save_undo_state() - } - for (var i = 0; i < nrepeats; i++ ) { - this.execute_leaf() - } - this.reset_commands() - } - } - } - - this.execute_leaf = function() { - var fn = this.m_cdata.action - if ( fn === undefined ) { - this.log('ERROR: could not execute leaf!') - } else { - //fn.apply( this, [this, this.m_cdata] ) - fn( this, this.m_cdata ) - } - } - - this.log = function(message){ - if (this.on_log !== undefined) { - this.on_log(message) - } - } - - this.m_ctrees = build_sequence_trees() // this can be shared among all VIMs - this.m_selector = null - this.m_mode = undefined - this.m_selection_from = undefined - this.m_cnode = undefined - this.m_current_sequence = '' - this.m_digit_buffer = '' - this.m_cdata = {} /* data merged during ctree traversal */ - this.m_undo_stack = [] - this.m_buffer = '' - - // callbacks, for extenal functions; e.g., for nice formatting - this.on_set_mode = undefined - this.on_set_pos = undefined - this.on_log = undefined -} /* VIM END */ - -//============================================================================== - -// http://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea -function getCaret(el) { - if (el.selectionStart) { - return el.selectionStart; - } else if (document.selection) { - el.focus(); - - var r = document.selection.createRange(); - if (r == null) { - return 0; - } - - var re = el.createTextRange(), - rc = re.duplicate(); - re.moveToBookmark(r.getBookmark()); - rc.setEndPoint('EndToStart', re); - - return rc.text.length; - } - return 0; -} - -/* -based on -http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area -*/ -var _select_pos = function(el, pos) { - if (el.setSelectionRange) { - el.focus(); - el.setSelectionRange(pos, pos); - } else if (el.createTextRange) { - var range = el.createTextRange(); - range.collapse(true); - range.moveEnd('character', pos); - range.moveStart('character', pos); - range.select(); - } -}; - - -//============================================================================= - -var node = function(x) { - return new Node(x) -} - -var build_sequence_trees = function() { - var tree_command = build_tree_command_mode() - var tree_visual = build_tree_visual_mode() - return {COMMAND: tree_command, - VISUAL: tree_visual} -} - -var build_tree_command_mode = function() { - var d_inside = function(fn) { - return function(text, pos) { - var xs = fn(text, pos) - return (xs[1] === 0) ? xs : [xs[0] + 1, xs[1] - 2] - } - } - - var d_in_line = function(fn){ - return function(text, pos) { - var iline = select_line(text, pos) - var line_pos = iline[0], line_len = iline[1] - var line = text.substr( line_pos, line_len ) - var xs = fn( line, pos - line_pos ) - return [ xs[0] + line_pos, xs[1] ] - } - } - - var choices_ai = { - 'a': node() - .set_choice('p', node({ select_func: d_with_whitespaces_after(select_paragraph) })) - .set_choice('w', node({ select_func: find_word_with_spaces_after })) - .set_choice('W', node({ select_func: d_with_spaces_after(find_word_plus) })) - .set_choice("'", node({ select_func: d_in_line( select_quotes.partial("'")) })) - .set_choice('"', node({ select_func: d_in_line( select_quotes.partial('"')) })) - .set_choice('(', node({ select_func: select_bounds.partial('()') })) - .set_choice(')', node({ select_func: select_bounds.partial('()') })) - .set_choice('{', node({ select_func: select_bounds.partial('{}') })) - .set_choice('}', node({ select_func: select_bounds.partial('{}') })) - .set_choice('<', node({ select_func: select_bounds.partial('<>') })) - .set_choice('>', node({ select_func: select_bounds.partial('<>') })) - .set_choice('[', node({ select_func: select_bounds.partial('[]') })) - .set_choice(']', node({ select_func: select_bounds.partial('[]') })) , - - 'i': node() - .set_choice('p', node({ select_func: select_paragraph })) - .set_choice('w', node({ select_func: find_word })) - .set_choice('W', node({ select_func: find_word_plus })) - .set_choice("'", node({ select_func: d_inside( d_in_line( select_quotes.partial("'"))) })) - .set_choice('"', node({ select_func: d_inside( d_in_line( select_quotes.partial('"'))) })) - .set_choice('(', node({ select_func: d_inside( select_bounds.partial('()')) })) - .set_choice(')', node({ select_func: d_inside( select_bounds.partial('()')) })) - .set_choice('{', node({ select_func: d_inside( select_bounds.partial('{}')) })) - .set_choice('}', node({ select_func: d_inside( select_bounds.partial('{}')) })) - .set_choice('<', node({ select_func: d_inside( select_bounds.partial('<>')) })) - .set_choice('>', node({ select_func: d_inside( select_bounds.partial('<>')) })) - .set_choice('[', node({ select_func: d_inside( select_bounds.partial('[]')) })) - .set_choice(']', node({ select_func: d_inside( select_bounds.partial('[]')) })) , - } - - var _select_line = node( {select_func: select_line } ) - - var _c = node() - .set_choices( make_choices_for_navigation() ) - .set_choices( choices_ai ) - .set_choice('c', _select_line ) - .set_choice('w', node( {select_func: till_right_word_bound} )) - .set_choice('W', node( {select_func: till_right_word_bound_plus} )) - - var _d = make_node_dy('d') - .set_choices( choices_ai ) - - var _y = make_node_dy('y') - .set_choices( choices_ai ) - - var _indent_inc = make_node_indent('>') - .set_choices( choices_ai ) - - var _indent_dec = make_node_indent('<') - .set_choices( choices_ai ) - - var _r = node() - .set_choices( make_choices_for_navigation({action: act_move})) - .set_choices( make_choices_for_digits() ) - .set_choice('a', node({action: act_append})) - .set_choice('A', node({action: act_append_to_end})) - .set_choice('c', _c, {action: act_delete_range, mode: INSERT}) - .set_choice('C', node({action: act_delete_range, mode: INSERT, - move_func: move_to_line_end})) - .set_choice('d', _d, {action: act_delete_range, mode: COMMAND}) - .set_choice('D', node({action: act_delete_range, mode: COMMAND, - move_func: move_to_line_end})) - .set_choice('i', node({action: act_insert})) - .set_choice('J', node({action: act_merge_lines})) - .set_choice('o', node({action: act_insert_line_after})) - .set_choice('O', node({action: act_insert_line_before})) - .set_choice('p', node({action: act_paste_after})) - .set_choice('P', node({action: act_paste_before})) - .set_choice('s', node({action: act_delete_char, mode: INSERT})) - .set_choice('u', node({action: act_undo, dont_save_undo_state: true})) - .set_choice('v', node({action: act_visual_mode})) - .set_choice('x', node({action: act_delete_char})) - .set_choice('y', _y, {action: act_yank_range}) - .set_choice('>', _indent_inc, {action: act_indent_increase} ) - .set_choice('<', _indent_dec, {action: act_indent_decrease} ) - - return _r -} - -var make_node_dy = function( line_char ) { - var e = node() - .set_choices( make_choices_for_navigation() ) - .set_choice( line_char, node( {select_func: select_line_nl} ) ) - .set_choice('w', node( {select_func: till_next_word} )) - .set_choice('W', node( {select_func: till_next_word_plus} )) - return e -} - -var make_node_indent = function( line_char ) { - var e = node() - .set_choices( make_choices_for_navigation() ) - .set_choice( line_char, node( {select_func: select_line} ) ) - return e -} - - -var build_tree_visual_mode = function() { - var _r = node() - .set_choices( make_choices_for_navigation({action: act_move}) ) - .set_choices( make_choices_for_digits() ) - .set_choice('d', node({action: act_delete_current_selection, mode: COMMAND}) ) - .set_choice('c', node({action: act_delete_current_selection, mode: INSERT}) ) - return _r -} - -var make_choices_for_navigation = function(params) { - params = (params===undefined) ? {} : params - var N = function(d) { return node( merge_dict( params, d) ) } - - var _g = node() - .set_choice('g', N({move_func: move_to_very_beginning})) - - var ch = { - '0': N({move_func: move_to_line_start}), - '$': N({move_func: move_to_line_end}), - '<Left>': N({move_func: move_left}), - '<Down>': N({move_func: move_down}), - '<Up>': N({move_func: move_up}), - '<Right>': N({move_func: move_right}), - 'h': N({move_func: move_left}), - 'j': N({move_func: move_down}), - 'k': N({move_func: move_up}), - 'l': N({move_func: move_right}), - '<Enter>': N({move_func: move_to_word_in_next_line}), - '<Backspace>': N({move_func: move_left}), - - 'w': N({move_func: move_to_next_word}), - 'W': N({move_func: move_to_next_word_plus}), - 'e': N({move_func: move_to_end_of_word}), - 'E': N({move_func: move_to_end_of_word_plus}), - 'b': N({move_func: move_to_prev_word}), - 'B': N({move_func: move_to_prev_word_plus}), - 'g': _g, - 'G': N({move_func: move_to_very_end}), - } - return ch -} - -var make_choices_for_digits = function(){ - var xs = {} - for (var i = 1; i < 10; i++) { - var c = i.toString() - xs[c] = node({action: act_accept_digit, digit: c}) - } - xs['0'] = node({action: act_zero, digit: '0'}) - return xs -} - -//============================================================================= - -/* find_... , till_... and other selection functions return [pos,len] where pos - * is position of the element and len is length of element. len can be 0 */ - -var find_word = function( text, pos ) { - var m = '(\\s(?=\\S))|([^W](?=[W]))|(\\S(?=\\s))|([W](?=[^W]))'.replace(/W/g,'\\u0000-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u00bf') - var p = new RegExp( m,'g' ) - return __find_regex_break( p, text, pos ) -} - -// non ascii unicode -///[\u0000-\u002f\u003a-\u0040\u005b-\u0060\u007b-\u00bf]/ - -var find_word_plus = function(text, pos) { - var p = /(\s(?=\S))|(\S(?=\s))/g - return __find_regex_break(p, text, pos) -} - -var find_word_with_spaces_after = function(text, pos) { - return d_with_spaces_after(find_word)(text, pos) -} - -var d_with_spaces_after = function(fn) { - return d_with_characters_after(fn, ' ') -} - -var d_with_whitespaces_after = function(fn) { - return d_with_characters_after(fn, '\n\s') -} - -var d_with_characters_after = function(fn, characters){ - return function(text, pos) { - var g = fn(text, pos) - var n = count_space_from(text, g[0]+g[1], characters) - return [ g[0], g[1] + n ] - } -} - - -//var find_word_with_spaces_before = function(text, pos) { -// var xs = find_word(text, pos) -// var n = count_space_to(text, xs[0]) -// return [ xs[0]-n, xs[1]+n ] -//} - -var find_word_plus_with_trailing_spaces = function(text, pos) { - var g = find_word_plus(text, pos) - var n = count_space_from(text, g[0]+g[1]) - return [ g[0], g[1] + n ] -} - -var till_right_word_bound = function( text, pos ) { - var xs = find_word( text, pos ) - return [ pos, xs[0] + xs[1] - pos ] -} - - -var till_right_word_bound_plus = function( text, pos ) { - var xs = find_word_plus( text, pos ) - return [ pos, xs[0] + xs[1] - pos ] -} - -//var till_left_word_bound = function( text, pos ) { -// var xs = find_word( text, pos ) -// var len = pos - xs[0] -// return [ xs[0], len ] -//} - -var till_next_word = function(text, pos) { - var g = find_word_with_spaces_after(text,pos) - return [ pos, g[0] + g[1] - pos] -} - -var till_next_word_plus = function(text, pos) { - var g = find_word_plus_with_trailing_spaces(text,pos) - return [ pos, g[0] + g[1] - pos ] -} - - -///* decorator - find a pattern with fn_find and latter find the trailing spaces */ -//var with_trailing_spaces = function( fn_find ) { // todo: refactor, remove? -// return function( text, pos ) { -// var xs = fn_find(text, pos) -// var t = regex_end_pos( /\s*/, text, {from: xs[1]} ) -// xs[1] = t -// return xs -// } -//} - -var regex_end_pos = function( regex, text, opts ) { - opts = (opts === undefined) ? {from:0} : opts - var tx = text.substr( opts.from ) - var m = regex.exec(tx) - var g = 0 // group === undefined ? 0 : group - return m === null ? null : m.index + m[g].length + opts.from -} - -var cut_slice = function( text, i0, i1 ) { - var from, to - if (i0 < i1 ) { from = i0; to = i1 } - else { from = i1; to = i0 } - return { text: text.substr(0, from) + text.substr(to), - cut: text.substr(from, (to-from)), - from: from, to: to } -} - -/* return [start of the line, length] */ -var select_line = function( text, pos ) { - var ileft = trailing_nl( text, pos ) - var iright = leading_nl( text, pos ) - return [ileft, iright - ileft] -} - -var select_line_nl = function( text, pos ) { - var ileft = trailing_nl( text, pos ) - var iright = leading_nl( text, pos ) - return [ileft, iright - ileft + 1 ] -} - -var select_next_line = function( text, pos ) { - var xs = select_line( text, pos ) - var k = xs[0]+xs[1]+1 - return ( k < text.length ) ? select_line( text, k ) : undefined -} - -var select_prev_line = function( text, pos ) { - var xs = select_line( text, pos ) - var k = xs[0] - 1 - return (k >= 0) ? select_line(text, k) : undefined -} - -var select_bounds = function(bounds, text, pos) { - var m_left = bounds.charAt(0) - var m_right = bounds.charAt(1) - var i_left, i_right - - if ( text.charAt(pos) == m_left ) { - i_left = pos - } else { - var k = 1 - for( var i = pos - 1; i >= 0; i-- ) { - var c = text.charAt(i) - k += ((c === m_left) ? -1 : 0) + ((c === m_right) ? 1 : 0) - if (k === 0 ) { - i_left = i - break - } - } - } - - if ( text.charAt(pos) == m_right ) { - i_right = pos - } else { - var k = 1 - for( var i = pos + 1; i < text.length; i++ ) { - var c = text.charAt(i) - k += ((c === m_left) ? 1 : 0) + ((c === m_right) ? -1 : 0) - if (k === 0) { - i_right = i - break - } - } - } - - return ((i_right === undefined) || (i_left === undefined)) ? - [pos,0] : - [i_left, i_right - i_left + 1] -} - -var select_quotes = function(quote, text, pos) { - var xs = __select_quotes(quote, text, pos) - var i_left = xs[0], i_right = xs[1] - return ( (i_left === undefined) || (i_right === undefined) ) ? - [pos,0] : - [i_left, i_right - i_left + 1] -} - -var __select_quotes = function(quote, text, pos) { - var i_left, i_right - for(var i = pos; i >= 0; i--) { - //if (text.charAt(i) === quote) { - if (text.substr(i, quote.length) === quote) { - i_left = i - break - } - } - for(var i = pos + 1; i < text.length; i++) { - //if (text.charAt(i) === quote) { - if (text.substr(i, quote.length) === quote) { - i_right = i - break - } - } - return [i_left, i_right] -} - -var select_paragraph = function(text, pos) { - var regex = /\n\s*\n/g - return __find_regex(regex, text, pos) -} - -var __find_regex = function(regex, text, pos ) { - var m, ileft = 0, iright - while ( (m=regex.exec(text)) !== null ) { - var i = m.index + m[0].length - if ((ileft === undefined) || (i <= pos)) { - ileft = i - } - i = m.index - if ((iright === undefined) && (i > pos)) { - iright = i - } - } - iright = (iright === undefined) ? (text.length) : iright - return [ileft, iright - ileft] -} - -/* todo: merge __find_regex and __find_regex_break */ -var __find_regex_break = function( regex, text, pos ) { - var m, ileft = 0, iright - while ( (m=regex.exec(text)) !== null ) { - var i = m.index + 1 - if ((ileft === undefined) || (i <= pos)) { - ileft = i - } - if ((iright === undefined) && (i > pos)) { - iright = i - } - } - iright = (iright === undefined) ? (text.length) : iright - return [ileft, iright - ileft] -} - -var trailing_nl = function ( text, pos ) { - var i = trailing_char( text, pos, "\n" ) - return (i===undefined) ? 0 : i -} - -var leading_nl = function ( text, pos ) { - var i = leading_char( text, pos, "\n" ) - return (i===undefined) ? text.length : i -} - -var trailing_char = function( text, pos, character ) { - var t - for ( var i = (pos-1); i >= 0; i-- ) { - if ( text.charAt(i) == character ) { - t = i + 1 - break - } - } - return t -} - -var leading_char = function(text, pos, character) { - var t - for (var i = pos; i < text.length; i++ ) { - if (text.charAt(i) == character) { - t = i - break - } - } - return t -} - -/* Decorator, skips spaces at position and starts searching from after the - * spaces */ -var skip_spaces = function(search_func) { - return function(text, pos) { - var k = count_space_from( text, pos ) - var xs = search_func( text, k + pos ) - return xs - } -} - -var count_space_from = function(text, pos, characters) { - characters = (characters===undefined) ? (' ') : characters - var r = new RegExp('^['+characters+']+') - var m = r.exec(text.substr(pos)) - return (m===null) ? 0 : m[0].length -} - -var count_space_to = function(text,pos) { - var k - if (pos > text.length) { - k = 0 - } else { - var m = /[ ]+$/.exec(text.substr(0,pos)) - k = (m===null) ? 0 : m[0].length - } - return k -} - -var insert_at = function( base, chunk, pos ) { - return base.slice(0,pos).concat( chunk ).concat( base.slice(pos) ) -} - -var repeat_str = function( str, n_repeats ) { - return (new Array(n_repeats+1)).join( str ) -} - -var last = function(xs, def) { - return (xs.length > 0) ? ( xs[xs.length-1] ) : def -} - -var insert_line_after_auto_indent = function(text, pos) { - var xs = select_line( text, pos ) - var k = count_space_from( text, xs[0] ) - var t = "\n" + repeat_str(" ", k) - var q = {} - q.text = insert_at( text, t, xs[0] + xs[1] ) - q.pos = xs[0] + xs[1] + k + 1 - return q -} - -Function.prototype.partial = function() { - var base_args = to_array(arguments), - base_fn = this - return function(){ - var next_args = to_array(arguments) - return base_fn.apply(this, base_args.concat(next_args)) - } -} - -var to_array = function( args ) { - return Array.prototype.slice.call(args, 0) -} - -/* ACTIONS -- various commands */ - -var act_insert_line_after = function(vim, cdata) { - var text = vim.get_text() - var pos = vim.get_pos() - var q = insert_line_after_auto_indent( text, pos ) - vim.set_text( q.text ) - vim.set_pos( q.pos ) - vim.set_mode( INSERT ) -} - -var act_insert_line_before = function(vim, cdata) { - var text = vim.get_text() - var pos = vim.get_pos() - var xs = select_line( text, pos ) - var k = count_space_from( text, xs[0] ) - var t = repeat_str(" ", k) + "\n" - text = insert_at( text, t, xs[0] ) - vim.set_text( text ) - vim.set_pos( xs[0] + k ) - vim.set_mode( INSERT ) -} - -var act_move = function(vim, cdata) { - var p = cdata.move_func.apply( vim, [vim.get_text(), vim.get_pos()] ) - vim.set_pos( p ) -} - -var act_accept_digit = function(vim, cdata) { - vim.m_digit_buffer += cdata.digit -} - -/* zero is handled separately, because it can be both "go to start of the - * line" and "insert 0 to digit buffer" */ -var act_zero = function(vim, cdata) { - if (vim.m_digit_buffer === '') { - var s = vim.select_current_line() - vim.set_pos( s[0] ) - } else { - vim.m_digit_buffer += cdata.digit - } -} - -var act_delete_range = function(vim, cdata) { - vim.log('delete range') - var t = __yank(vim, cdata) - vim.set_text( t.text ) - vim.set_pos( t.from ) - vim.set_mode( cdata.mode ) -} - -var act_yank_range = function(vim, cdata) { - vim.log('yank range') - var t = __yank(vim, cdata) - vim.set_pos( t.from ) -} - -var __yank = function(vim, cdata) { - var xs = selection_with.apply( vim, [ cdata, vim.get_text(), vim.get_pos() ] ) // todo, clean - var t = cut_slice( vim.get_text(), xs[0], xs[0] + xs[1] ) - vim.insert_to_clipboard( t.cut ) - return t -} - -/* use either select_func or move_func parameter */ -var selection_with = function( cdata, text, pos ) { - var fn, xs - fn = cdata.select_func - if (fn === undefined) { - fn = cdata.move_func - var k = fn.apply( this, [ text, pos ] ) - var len = k - pos - xs = (len >= 0) ? [pos, len] : [pos + len, -len] - } - else { - xs = fn.apply( this, [ text, pos ] ) - } - return xs -} - -var act_delete_char = function(vim, cdata) { - var p = vim.get_pos() - var t = vim.get_text() - vim.set_text( t.substr(0,p) + t.substr(p+1) ) - vim.set_pos( p ) - vim.insert_to_clipboard( t.substr(p,1) ) - if (cdata.mode !== undefined) { - vim.set_mode(INSERT) - } -} - -var act_append = function(vim, cdata) { - vim.log('append') - var xs = vim.select_current_line() - var p = vim.get_pos() - vim.set_pos( p + (p == (xs[0] + xs[1]) ? 0 : 1) ) /* don't move at the end of line*/ - vim.set_mode(INSERT) -} - -var act_append_to_end = function(vim, cdata) { - vim.log('append to end') - var xs = vim.select_current_line() - vim.set_pos( xs[0] + xs[1] ) - vim.set_mode(INSERT) -} - -var act_insert = function(vim, cdata) { - vim.log('insert') - vim.set_mode(INSERT) -} - -var act_delete_current_selection = function(vim, cdata) { - vim.log('delete current selection') - var t = cut_slice( vim.get_text(), vim.m_selection_from, vim.get_pos() ) - vim.set_text( t.text) - vim.set_pos( t.from ) - vim.set_mode(cdata.mode) - vim.insert_to_clipboard( t.cut ) -} - -var act_visual_mode = function(vim, cdata) { - vim.log('act_visual_mode') - vim.set_mode( VISUAL ) -} - -var act_undo = function(vim, cdata) { - if (vim.m_undo_stack.length > 0) { - vim.log('act_undo') - var u = vim.m_undo_stack.pop() - vim.set_text( u.text ) - vim.set_pos( u.pos ) - } -} - -var act_paste_after = function(vim, cdata) { - var pos = vim.get_pos() - __paste(vim, cdata) - vim.set_pos( pos + vim.get_clipboard().length ) -} - -var act_paste_before = function(vim, cdata){ - var pos = vim.get_pos() - __paste(vim, cdata) - vim.set_pos( pos ) -} - -var __paste = function(vim, cdata) { - var pos = vim.get_pos() - var buff = vim.get_clipboard() - var t = vim.get_text() - vim.log('act_paste, length: ' + buff.length ) - vim.set_text( t.substr(0, pos) + buff + t.substr(pos) ) -} - -var act_merge_lines = function(vim, cdata) { - vim.log('act_merge_lines') - var pos = vim.get_pos() - var t = vim.get_text() - var xs = select_line( t, pos ) - var endl = xs[0] + xs[1] - t = t.substr( 0, endl ) + t.substr( endl + 1 ) - vim.set_text( t ) - vim.set_pos( endl ) -} - -var act_indent_increase = function(vim, cdata) { - vim.log('act_indent_increase') - __alter_selection(vim, cdata, function(t){return t.replace(/^/gm, ' ')} ) -} - -var act_indent_decrease = function(vim, cdata) { - vim.log('act_indent_decrease') - __alter_selection(vim, cdata, function(t){return t.replace(/^ /gm, '')} ) -} - -var __alter_selection = function(vim, cdata, func) { - var xs = selection_with.apply( vim, [ cdata, vim.get_text(), vim.get_pos() ] ) - xs = expand_to_line_start( vim.get_text(), xs ) - var g = cut_with( vim.get_text(), xs ) - g.mid = func( g.mid ) - var new_text = g.left + g.mid + g.right - vim.set_text( new_text ) - vim.set_pos( xs[0] + count_space_from(new_text, xs[0]) ) -} - -var expand_to_line_start = function(text, range) { - var xs = select_line( text, range[0] ) - var off = range[0] - xs[0] - return [xs[0], range[1] + off ] -} - -var cut_with = function(text, range) { - var pos = range[0], len = range[1] - return { left: text.substr(0,pos), - mid: text.substr(pos,len), - right: text.substr(pos+len) } -} - -//ext//var act_unfocus = function(vim, cdata) { -//ext// vim.log('--unfocus--') -//ext// window.__refocus = false -//ext// vim.m_selector.blur() -//ext//} -//ext// -/* MOVE -- move functions, are launched in VIM context */ - -var move_right = function(text, pos) { - return (pos < text.length) ? (pos+1) : (pos) -} - -var move_left = function(text, pos) { - return (pos>0) ? (pos-1) : (pos) -} - -var move_down = function(text, pos) { - var lnext = select_next_line(text, pos) - if (lnext !== undefined ) { - var lcurr = select_line(text, pos) - var offset = pos - lcurr[0] - offset = (offset >= lnext[1]) ? (lnext[1]) : offset - pos = offset + lnext[0] - } - return pos -} - -var move_up = function(text, pos) { - var lprev = select_prev_line(text, pos) - if (lprev !== undefined ) { - var lcurr = select_line(text, pos) - var offset = pos - lcurr[0] - offset = (offset >= lprev[1]) ? (lprev[1]) : offset - pos = offset + lprev[0] - } - return pos -} - -var move_to_next_word = function(text, pos) { - var xs = find_word_with_spaces_after(text, pos) - return xs[0] + xs[1] -} - -var move_to_next_word_plus = function(text, pos) { - var xs = find_word_plus_with_trailing_spaces( text, pos ) - return xs[0] + xs[1] -} - -var move_to_end_of_word = function(text, pos) { - var xs = skip_spaces(find_word)( text, pos ) - return xs[0] + xs[1] -} - -var move_to_end_of_word_plus = function(text, pos) { - var xs = skip_spaces(find_word_plus)( text, pos ) - return xs[0] + xs[1] -} - -var move_to_prev_word = function(text, pos) { - var k = count_space_to(text, pos) + 1 - var xs = find_word(text,pos - k) - return xs[0] -} - -var move_to_prev_word_plus = function(text, pos) { - var k = count_space_to(text, pos) + 1 - var xs = find_word_plus(text,pos - k) - return xs[0] -} - -var move_to_word_in_next_line = function(text, pos) { - var new_pos - var xline = select_next_line(text, pos) - if (undefined === xline) { - new_pos = pos - } else { - var nspaces = count_space_from( text, xline[0] ) - new_pos = xline[0] + nspaces - } - return new_pos -} - -var move_to_very_beginning = function(text, pos) { - return 0 -} - -var move_to_very_end = function(text, pos) { - return text.length -} - -var move_to_line_start = function(text, pos) { - var s = select_line( text, pos ) - return s[0] -} - -var move_to_line_end = function(text, pos) { - var s = select_line( text, pos ) - return s[0] + s[1] -} - -/* === READY === */ - -/* crossrider hook */ - -//ext// /* hook vim on click into textarea */ -//ext// $(document).on('focus', 'textarea', function(event){ -//ext// console.log( 'vim: FOCUS' ) -//ext// $(this).off('keyup keydown keypress') -//ext// //$(this).on('keyup keydown keypress', function(e){ -//ext// // e.stopPropagation() -//ext// // e.preventDefault() -//ext// // return false -//ext// //}) -//ext// -//ext// if ( undefined === this.__vim_is_attached ) { -//ext// var v = new VIM() -//ext// v.on_log = function(m){console.log(m)} -//ext// v.attach_to( this ) -//ext// this.__vim_is_attached = true -//ext// } else { -//ext// console.log('vim: already attached') -//ext// } -//ext// }) -//ext// -//ext// $(document).on('blur', 'textarea', function(event){ -//ext// //$(this).off('vim: keyup keydown keypress') -//ext// if (true === window.__refocus) { -//ext// console.log('blur: refocus') -//ext// $(this).focus() -//ext// } else { -//ext// console.log('blur: don\'t refocus') -//ext// } -//ext// -//ext// return false -//ext// }) -//ext// -//ext// $(document).on('click',function(event){ -//ext// console.log('vim: loose focus on click') -//ext// window.__refocus = false -//ext// $(this).focus() -//ext// }) -//ext// -//ext//}); diff --git a/javascript/main.js b/javascript/main.js @@ -1,44 +1,42 @@ (function() { - - const myCodeMirror = CodeMirror(document.querySelector('.book-col--40'), { - value: window.localStorage.getItem('data'), + + if (!window.localStorage.getItem('markdown') || !window.localStorage.getItem('markdown').replace(/\s/g, '')) { + window.localStorage.setItem('markdown', '# Your markdown _here_') + } + + const myCodeMirror = CodeMirror(document.querySelector('.js-input'), { + value: window.localStorage.getItem('markdown'), mode: "javascript", + lineWrapping: true, //lineNumbers: true, - keyMap: 'vim' + keyMap: 'vim', + theme: 'the-matrix' }); - console.log(myCodeMirror.getValue() ) - - CodeMirror.Vim.map('kj', '<Esc>', 'insert') // comment out if you want to use normal <Esc> key to exit insert mode - if (myCodeMirror) { + CodeMirror.Vim.map('kj', '<Esc>', 'insert') // to use kj as <Esc> also + hljs.initHighlightingOnLoad(); - if (window.localStorage.getItem('data')) { - myCodeMirror.value = window.localStorage.getItem('data'); - document.querySelector('.js-content').innerHTML = marked(window.localStorage.getItem('data')); + + if (window.localStorage.getItem('markdown')) { + myCodeMirror.value = window.localStorage.getItem('markdown'); + document.querySelector('.js-content').innerHTML = marked(window.localStorage.getItem('markdown')); } else { document.querySelector('.js-content').innerHTML = myCodeMirror.getValue(); } - document.querySelector('.CodeMirror-code').addEventListener('keyup', event => { - const val = event.target.value; - const transformed = marked(val); + document.querySelector('.CodeMirror').addEventListener('keyup', event => { + const transformed = marked(myCodeMirror.getValue()); document.querySelector('.js-content').innerHTML = transformed; for (let i = 0; i < document.getElementsByTagName('code').length; i++) { hljs.highlightBlock(document.getElementsByTagName('code')[i]); } setTimeout(() => { - document.querySelector('.js-content').parentElement.scrollTop = 10000000; + document.querySelector('.js-content').parentElement.parentElement.scrollTop = 10000000; }, 250) - window.localStorage.setItem('data', val); + window.localStorage.setItem('markdown', myCodeMirror.getValue()); }); } - // const vim = new VIM(); - - // vim.attach_to(document.querySelector('.js-input')); - // document.querySelector('.CodeMirror-code').focus(); - - })(); diff --git a/javascript/vim.min.js b/javascript/vim.min.js @@ -1 +0,0 @@ -!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(Qe){"use strict";var ze=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},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:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',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<CR>",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:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],Ze=[{name:"colorscheme",shortName:"colo"},{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:"se"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],Ge=Qe.Pos;Qe.Vim=function(){function e(e,t){var r;this==Qe.keyMap.vim&&(Qe.rmClass(e.getWrapperElement(),"cm-fat-cursor"),"contenteditable"==e.getOption("inputStyle")&&null!=document.body.style.caretColor&&(function(e){var t=e.state.fatCursorMarks;if(t)for(var r=0;r<t.length;r++)t[r].clear();e.state.fatCursorMarks=null,e.off("cursorActivity",a)}(e),e.getInputField().style.caretColor="")),t&&t.attach==o||((r=e).setOption("disableInput",!1),r.off("cursorActivity",Ve),Qe.off(r.getInputField(),"paste",c(r)),r.state.vim=null)}function o(e,t){var r,n;this==Qe.keyMap.vim&&(Qe.addClass(e.getWrapperElement(),"cm-fat-cursor"),"contenteditable"==e.getOption("inputStyle")&&null!=document.body.style.caretColor&&((r=e).state.fatCursorMarks=i(r),r.on("cursorActivity",a),e.getInputField().style.caretColor="transparent")),t&&t.attach==o||((n=e).setOption("disableInput",!0),n.setOption("showCursorWhenSelecting",!1),Qe.signal(n,"vim-mode-change",{mode:"normal"}),n.on("cursorActivity",Ve),R(n),Qe.on(n.getInputField(),"paste",c(n)))}function i(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var o=t[n];if(o.empty())if(o.anchor.ch<e.getLine(o.anchor.line).length)r.push(e.markText(o.anchor,Ge(o.anchor.line,o.anchor.ch+1),{className:"cm-fat-cursor-mark"}));else{var i=document.createElement("span");i.textContent=" ",i.className="cm-fat-cursor-mark",r.push(e.setBookmark(o.anchor,{widget:i}))}}return r}function a(e){var t=e.state.fatCursorMarks;if(t)for(var r=0;r<t.length;r++)t[r].clear();e.state.fatCursorMarks=i(e)}function t(e,t){if(t){if(this[e])return this[e];var r=function(e){if("'"==e.charAt(0))return e.charAt(1);var t=e.split(/-(?!$)/),r=t[t.length-1];if(1==t.length&&1==t[0].length)return!1;if(2==t.length&&"Shift"==t[0]&&1==r.length)return!1;for(var n=!1,o=0;o<t.length;o++){var i=t[o];i in s?t[o]=s[i]:n=!0,i in l&&(t[o]=l[i])}return!!n&&(k(r)&&(t[t.length-1]=r.toLowerCase()),"<"+t.join("-")+">")}(e);if(!r)return!1;var n=Qe.Vim.findKey(t,r);return"function"==typeof n&&Qe.signal(t,"vim-keypress",r),n}}Qe.defineOption("vimMode",!1,function(e,t,r){t&&"vim"!=e.getOption("keyMap")?e.setOption("keyMap","vim"):!t&&r!=Qe.Init&&/^vim/.test(e.getOption("keyMap"))&&e.setOption("keyMap","default")});var s={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},l={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"};function c(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor($(e.getCursor(),0,1)),D.enterInsertMode(e,{},t))}),t.onPasteFn}var m=/[\d]/,g=[Qe.isWordChar,function(e){return e&&!Qe.isWordChar(e)&&!/\s/.test(e)}],v=[function(e){return/\S/.test(e)}];function r(e,t){for(var r=[],n=e;n<e+t;n++)r.push(String.fromCharCode(n));return r}var n=r(65,26),u=r(97,26),h=r(48,10),p=[].concat(n,u,h,["<",">"]),f=[].concat(n,u,h,["-",'"',".",":","/"]);function y(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function d(e){return/^[a-z]$/.test(e)}function k(e){return/^[A-Z]$/.test(e)}function B(e){return/^\s*$/.test(e)}function C(e){return-1!=".?!".indexOf(e)}function w(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}var M={};function x(e,t,r,n,o){if(void 0===t&&!o)throw Error("defaultValue is required unless callback is provided");if(r||(r="string"),M[e]={type:r,defaultValue:t,callback:o},n)for(var i=0;i<n.length;i++)M[n[i]]=M[e];t&&S(e,t)}function S(e,t,r,n){var o=M[e],i=(n=n||{}).scope;if(!o)return new Error("Unknown option: "+e);if("boolean"==o.type){if(t&&!0!==t)return new Error("Invalid argument: "+e+"="+t);!1!==t&&(t=!0)}o.callback?("local"!==i&&o.callback(t,void 0),"global"!==i&&r&&o.callback(t,r)):("local"!==i&&(o.value="boolean"==o.type?!!t:t),"global"!==i&&r&&(r.state.vim.options[e]={value:t}))}function A(e,t,r){var n=M[e],o=(r=r||{}).scope;if(!n)return new Error("Unknown option: "+e);if(n.callback){var i=t&&n.callback(void 0,t);return"global"!==o&&void 0!==i?i:"local"!==o?n.callback():void 0}return((i="global"!==o&&t&&t.state.vim.options[e])||"local"!==o&&n||{}).value}x("filetype",void 0,"string",["ft"],function(e,t){if(void 0!==t){if(void 0===e)return"null"==(r=t.getOption("mode"))?"":r;var r=""==e?"null":e;t.setOption("mode",r)}});var _,b,L=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};function T(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=L()}function R(e){return e.state.vim||(e.state.vim={inputState:new I,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}}),e.state.vim}function E(){var a,s,l,c,u;for(var e in _={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:(a=100,s=-1,l=0,c=0,u=new Array(a),{cachedCursor:void 0,add:function(n,e,t){var r=u[s%a];function o(e){var t=++s%a,r=u[t];r&&r.clear(),u[t]=n.setBookmark(e)}if(r){var i=r.find();i&&!Z(i,e)&&o(e)}else o(e);o(t),(c=(l=s)-a+1)<0&&(c=0)},move:function(e,t){l<(s+=t)?s=l:s<c&&(s=c);var r=u[(a+s)%a];if(r&&!r.find()){var n,o=0<t?1:-1,i=e.getCursor();do{if((r=u[(a+(s+=o))%a])&&(n=r.find())&&!Z(i,n))break}while(s<l&&c<s)}return r}}),macroModeState:new T,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new P({}),searchHistoryController:new j,exCommandHistoryController:new j},M){var t=M[e];t.value=t.defaultValue}}var O={buildKeyMap:function(){},getRegisterController:function(){return _.registerController},resetVimGlobalState_:E,getVimGlobalState_:function(){return _},maybeInitVimState_:R,suppressErrorLogging:(T.prototype={exitMacroRecordMode:function(){var e=_.macroModeState;e.onRecordingDone&&e.onRecordingDone(),e.onRecordingDone=void 0,e.isRecording=!1},enterMacroRecordMode:function(e,t){var r=_.registerController.getRegister(t);r&&(r.clear(),this.latestRegister=t,e.openDialog&&(this.onRecordingDone=e.openDialog("(recording)["+t+"]",null,{bottom:!0})),this.isRecording=!0)}},!1),InsertModeKey:Ue,map:function(e,t,r){je.map(e,t,r)},unmap:function(e,t){je.unmap(e,t)},setOption:S,getOption:A,defineOption:x,defineEx:function(e,t,r){if(t){if(0!==e.indexOf(t))throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered')}else t=e;Pe[e]=r,je.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if("function"==typeof n)return n()},findKey:function(s,l,t){var e,c=R(s);function o(){var e=_.macroModeState;if(e.isRecording){if("q"==l)return e.exitMacroRecordMode(),K(s),!0;"mapping"!=t&&function(e,t){if(!e.isPlaying){var r=e.latestRegister,n=_.registerController.getRegister(r);n&&n.pushText(t)}}(e,l)}}function u(){if("<Esc>"==l)return K(s),c.visualMode?le(s):c.insertMode&&He(s),!0}return!1===(e=c.insertMode?function(){if(u())return!0;for(var e=c.inputState.keyBuffer=c.inputState.keyBuffer+l,t=1==l.length,r=H.matchCommand(e,ze,c.inputState,"insert");1<e.length&&"full"!=r.type;){e=c.inputState.keyBuffer=e.slice(1);var n=H.matchCommand(e,ze,c.inputState,"insert");"none"!=n.type&&(r=n)}if("none"==r.type)return K(s),!1;if("partial"==r.type)return b&&window.clearTimeout(b),b=window.setTimeout(function(){c.insertMode&&c.inputState.keyBuffer&&K(s)},A("insertModeEscKeysTimeout")),!t;if(b&&window.clearTimeout(b),t){for(var o=s.listSelections(),i=0;i<o.length;i++){var a=o[i].head;s.replaceRange("",$(a,0,-(e.length-1)),a,"+input")}_.macroModeState.lastInsertModeChanges.changes.pop()}return K(s),r.command}():function(){if(o()||u())return!0;var e=c.inputState.keyBuffer=c.inputState.keyBuffer+l;if(/^[1-9]\d*$/.test(e))return!0;if(!(t=/^(\d*)(.*)$/.exec(e)))return K(s),!1;var t,r=c.visualMode?"visual":"normal",n=H.matchCommand(t[2]||t[1],ze,c.inputState,r);return"none"==n.type?(K(s),!1):"partial"==n.type||(c.inputState.keyBuffer="",(t=/^(\d*)(.*)$/.exec(e))[1]&&"0"!=t[1]&&c.inputState.pushRepeatDigit(t[1]),n.command)}())?c.insertMode||1!==l.length?void 0:function(){return!0}:!0===e?function(){return!0}:function(){return s.operation(function(){s.curOp.isVimOp=!0;try{"keyToKey"==e.type?function(e){for(var t;e;)t=/<\w+-.+?>|<\w+>|./.exec(e),l=t[0],e=e.substring(t.index+l.length),Qe.Vim.handleKey(s,l,"mapping")}(e.toKeys):H.processCommand(s,c,e)}catch(e){throw s.state.vim=void 0,R(s),Qe.Vim.suppressErrorLogging||console.log(e),e}return!0})}},handleEx:function(e,t){je.processCommand(e,t)},defineMotion:function(e,t){F[e]=t},defineAction:function(e,t){D[e]=t},defineOperator:function(e,t){V[e]=t},mapCommand:function(e,t,r,n,o){var i={keys:e,type:t};for(var a in i[t]=r,i[t+"Args"]=n,o)i[a]=o[a];_e(i)},_mapCommand:_e,defineRegister:function(e,t){var r=_.registerController.registers;if(!e||1!=e.length)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,f.push(e)},exitVisualMode:le,exitInsertMode:He};function I(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null}function K(e,t){e.state.vim.inputState=new I,Qe.signal(e,"vim-command-done",t)}function N(e,t,r){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!r}function P(e){this.registers=e,this.unnamedRegister=e['"']=new N,e["."]=new N,e[":"]=new N,e["/"]=new N}function j(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}I.prototype.pushRepeatDigit=function(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)},I.prototype.getRepeat=function(){var e=0;return(0<this.prefixRepeat.length||0<this.motionRepeat.length)&&(e=1,0<this.prefixRepeat.length&&(e*=parseInt(this.prefixRepeat.join(""),10)),0<this.motionRepeat.length&&(e*=parseInt(this.motionRepeat.join(""),10))),e},N.prototype={setText:function(e,t,r){this.keyBuffer=[e||""],this.linewise=!!t,this.blockwise=!!r},pushText:function(e,t){t&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(e)},pushInsertModeChanges:function(e){this.insertModeChanges.push(L(e))},pushSearchQuery:function(e){this.searchQueries.push(e)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},P.prototype={pushText:function(e,t,r,n,o){n&&"\n"!==r.charAt(r.length-1)&&(r+="\n");var i=this.isValidRegister(e)?this.getRegister(e):null;if(i)k(e)?i.pushText(r,n):i.setText(r,n,o),this.unnamedRegister.setText(i.toString(),n);else{switch(t){case"yank":this.registers[0]=new N(r,n,o);break;case"delete":case"change":-1==r.indexOf("\n")?this.registers["-"]=new N(r,n):(this.shiftNumericRegisters_(),this.registers[1]=new N(r,n))}this.unnamedRegister.setText(r,n,o)}},getRegister:function(e){return this.isValidRegister(e)?(e=e.toLowerCase(),this.registers[e]||(this.registers[e]=new N),this.registers[e]):this.unnamedRegister},isValidRegister:function(e){return e&&w(e,f)},shiftNumericRegisters_:function(){for(var e=9;2<=e;e--)this.registers[e]=this.getRegister(""+(e-1))}},j.prototype={nextMatch:function(e,t){var r=this.historyBuffer,n=t?-1:1;null===this.initialPrefix&&(this.initialPrefix=e);for(var o=this.iterator+n;t?0<=o:o<r.length;o+=n)for(var i=r[o],a=0;a<=i.length;a++)if(this.initialPrefix==i.substring(0,a))return this.iterator=o,i;return o>=r.length?(this.iterator=r.length,this.initialPrefix):o<0?e:void 0},pushInput:function(e){var t=this.historyBuffer.indexOf(e);-1<t&&this.historyBuffer.splice(t,1),e.length&&this.historyBuffer.push(e)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var H={matchCommand:function(e,t,r,n){var o,i=function(e,t,r,n){for(var o,i=[],a=[],s=0;s<t.length;s++){var l=t[s];"insert"==r&&"insert"!=l.context||l.context&&l.context!=r||n.operator&&"action"==l.type||!(o=q(e,l.keys))||("partial"==o&&i.push(l),"full"==o&&a.push(l))}return{partial:i.length&&i,full:a.length&&a}}(e,t,n,r);if(!i.full&&!i.partial)return{type:"none"};if(!i.full&&i.partial)return{type:"partial"};for(var a=0;a<i.full.length;a++){var s=i.full[a];o||(o=s)}if("<character>"==o.keys.slice(-11)){var l=function(e){var t=/^.*(<[^>]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(1<r.length)switch(r){case"<CR>":r="\n";break;case"<Space>":r=" ";break;default:r=""}return r}(e);if(!l)return{type:"none"};r.selectedCharacter=l}return{type:"full",command:o}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r)}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=J(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator){if(n.operator==r.operator)return n.motion="expandToLine",n.motionArgs={linewise:!0},void this.evalInput(e,t);K(e)}n.operator=r.operator,n.operatorArgs=J(r.operatorArgs),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,o=J(r.operatorMotionArgs);o&&n&&o.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,o=n.getRepeat(),i=!!o,a=J(r.actionArgs)||{};n.selectedCharacter&&(a.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),a.repeat=o||1,a.repeatIsExplicit=i,a.registerName=n.registerName,K(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),D[r.action](e,a,t)},processSearch:function(s,n,o){if(s.getSearchCursor){var l=o.searchArgs.forward,e=o.searchArgs.wholeWordOnly;Ce(s).setReversed(!l);var t=l?"/":"?",i=Ce(s).getQuery(),c=s.getScrollInfo();switch(o.searchArgs.querySrc){case"prompt":var r=_.macroModeState;r.isPlaying?p(h=r.replaySearchQueries.shift(),!0,!1):Te(s,{onClose:function(e){s.scrollTo(c.left,c.top),p(e,!0,!0);var t=_.macroModeState;t.isRecording&&function(e,t){if(!e.isPlaying){var r=e.latestRegister,n=_.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}(t,e)},prefix:t,desc:Le,onKeyUp:function(e,t,r){var n,o,i,a=Qe.keyName(e);"Up"==a||"Down"==a?(n="Up"==a,o=e.target?e.target.selectionEnd:0,r(t=_.searchHistoryController.nextMatch(t,n)||""),o&&e.target&&(e.target.selectionEnd=e.target.selectionStart=Math.min(o,e.target.value.length))):"Left"!=a&&"Right"!=a&&"Ctrl"!=a&&"Alt"!=a&&"Shift"!=a&&_.searchHistoryController.reset();try{i=Re(s,t,!0,!0)}catch(e){}i?s.scrollIntoView(Oe(s,!l,i),30):(Be(s),s.scrollTo(c.left,c.top))},onKeyDown:function(e,t,r){var n=Qe.keyName(e);"Esc"==n||"Ctrl-C"==n||"Ctrl-["==n||"Backspace"==n&&""==t?(_.searchHistoryController.pushInput(t),_.searchHistoryController.reset(),Re(s,i),Be(s),s.scrollTo(c.left,c.top),Qe.e_stop(e),K(s),r(),s.focus()):"Up"==n||"Down"==n?Qe.e_stop(e):"Ctrl-U"==n&&(Qe.e_stop(e),r(""))}});break;case"wordUnderCursor":var a=ue(s,!1,0,!1,!0),u=!0;if(a||(a=ue(s,!1,0,!1,!1),u=!1),!a)return;var h=s.getLine(a.start.line).substring(a.start.ch,a.end.ch);h=u&&e?"\\b"+h+"\\b":h.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1"),_.jumpList.cachedCursor=s.getCursor(),s.setCursor(a.start),p(h,!0,!1)}}function p(t,e,r){_.searchHistoryController.pushInput(t),_.searchHistoryController.reset();try{Re(s,t,e,r)}catch(e){return be(s,"Invalid regex: "+t),void K(s)}H.processMotion(s,n,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:o.searchArgs.toJumplist}})}},processEx:function(a,e,t){function r(e){_.exCommandHistoryController.pushInput(e),_.exCommandHistoryController.reset(),je.processCommand(a,e)}function n(e,t,r){var n,o,i=Qe.keyName(e);("Esc"==i||"Ctrl-C"==i||"Ctrl-["==i||"Backspace"==i&&""==t)&&(_.exCommandHistoryController.pushInput(t),_.exCommandHistoryController.reset(),Qe.e_stop(e),K(a),r(),a.focus()),"Up"==i||"Down"==i?(Qe.e_stop(e),n="Up"==i,o=e.target?e.target.selectionEnd:0,r(t=_.exCommandHistoryController.nextMatch(t,n)||""),o&&e.target&&(e.target.selectionEnd=e.target.selectionStart=Math.min(o,e.target.value.length))):"Ctrl-U"==i?(Qe.e_stop(e),r("")):"Left"!=i&&"Right"!=i&&"Ctrl"!=i&&"Alt"!=i&&"Shift"!=i&&_.exCommandHistoryController.reset()}"keyToEx"==t.type?je.processCommand(a,t.exArgs.input):e.visualMode?Te(a,{onClose:r,prefix:":",value:"'<,'>",onKeyDown:n,selectValueOnOpen:!1}):Te(a,{onClose:r,prefix:":",onKeyDown:n})},evalInput:function(e,t){var r,n,o,i,a=t.inputState,s=a.motion,l=a.motionArgs||{},c=a.operator,u=a.operatorArgs||{},h=a.registerName,p=t.sel,f=z(t.visualMode?U(e,p.head):e.getCursor("head")),d=z(t.visualMode?U(e,p.anchor):e.getCursor("anchor")),m=z(f),g=z(d);if(c&&this.recordLastEdit(t,a),0<(o=void 0!==a.repeatOverride?a.repeatOverride:a.getRepeat())&&l.explicitRepeat?l.repeatIsExplicit=!0:(l.noRepeat||!l.explicitRepeat&&0===o)&&(o=1,l.repeatIsExplicit=!1),a.selectedCharacter&&(l.selectedCharacter=u.selectedCharacter=a.selectedCharacter),l.repeat=o,K(e),s){var v=F[s](e,f,l,t);if(t.lastMotion=F[s],!v)return;if(l.toJumplist){var y=_.jumpList,k=y.cachedCursor;k?(he(e,k,v),delete y.cachedCursor):he(e,f,v)}v instanceof Array?(n=v[0],r=v[1]):r=v,r||(r=z(f)),t.visualMode?(t.visualBlock&&r.ch===1/0||(r=U(e,r,t.visualBlock)),n&&(n=U(e,n,!0)),n=n||g,p.anchor=n,p.head=r,ae(e),ve(e,t,"<",G(n,r)?n:r),ve(e,t,">",G(n,r)?r:n)):c||(r=U(e,r),e.setCursor(r.line,r.ch))}if(c){if(u.lastSel){n=g;var C=u.lastSel,w=Math.abs(C.head.line-C.anchor.line),M=Math.abs(C.head.ch-C.anchor.ch);r=C.visualLine?Ge(g.line+w,g.ch):C.visualBlock?Ge(g.line+w,g.ch+M):C.head.line==C.anchor.line?Ge(g.line,g.ch+M):Ge(g.line+w,g.ch),t.visualMode=!0,t.visualLine=C.visualLine,t.visualBlock=C.visualBlock,p=t.sel={anchor:n,head:r},ae(e)}else t.visualMode&&(u.lastSel={anchor:z(p.anchor),head:z(p.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var x,S,A,b,L;if(t.visualMode){if(x=X(p.head,p.anchor),S=Y(p.head,p.anchor),A=t.visualLine||u.linewise,L=se(e,{anchor:x,head:S},b=t.visualBlock?"block":A?"line":"char"),A){var T=L.ranges;if("block"==b)for(var R=0;R<T.length;R++)T[R].head.ch=te(e,T[R].head.line);else"line"==b&&(T[0].head=Ge(T[0].head.line+1,0))}}else{if(x=z(n||g),G(S=z(r||m),x)){var E=x;x=S,S=E}(A=l.linewise||u.linewise)?(i=S,x.ch=0,i.ch=0,i.line++):l.forward&&function(e,t,r){var n=e.getRange(t,r);if(/\n\s*$/.test(n)){var o=n.split("\n");o.pop();for(var i=o.pop();0<o.length&&i&&B(i);i=o.pop())r.line--,r.ch=0;i?(r.line--,r.ch=te(e,r.line)):r.ch=0}}(e,x,S),L=se(e,{anchor:x,head:S},b="char",!l.inclusive||A)}e.setSelections(L.ranges,L.primary),t.lastMotion=null,u.repeat=o,u.registerName=h,u.linewise=A;var O=V[c](e,u,L.ranges,g,r);t.visualMode&&le(e,null!=O),O&&e.setCursor(O)}},recordLastEdit:function(e,t,r){var n=_.macroModeState;n.isPlaying||(e.lastEditInputState=t,e.lastEditActionCommand=r,n.lastInsertModeChanges.changes=[],n.lastInsertModeChanges.expectCursorActivityForChange=!1)}},F={moveToTopLine:function(e,t,r){var n=Ie(e).top+r.repeat-1;return Ge(n,ce(e.getLine(n)))},moveToMiddleLine:function(e){var t=Ie(e),r=Math.floor(.5*(t.top+t.bottom));return Ge(r,ce(e.getLine(r)))},moveToBottomLine:function(e,t,r){var n=Ie(e).bottom-r.repeat+1;return Ge(n,ce(e.getLine(n)))},expandToLine:function(e,t,r){return Ge(t.line+r.repeat-1,1/0)},findNext:function(e,t,r){var n=Ce(e),o=n.getQuery();if(o){var i=!r.forward;return i=n.isReversed()?!i:i,Ee(e,o),Oe(e,i,o,r.repeat)}},goToMark:function(e,t,r,n){var o=Ke(e,n,r.selectedCharacter);return o?r.linewise?{line:o.line,ch:ce(e.getLine(o.line))}:o:null},moveToOtherHighlightedEnd:function(e,t,r,n){if(n.visualBlock&&r.sameLine){var o=n.sel;return[U(e,Ge(o.anchor.line,o.head.ch)),U(e,Ge(o.head.line,o.anchor.ch))]}return[n.sel.head,n.sel.anchor]},jumpToMark:function(e,t,r,n){for(var o=t,i=0;i<r.repeat;i++){var a=o;for(var s in n.marks)if(d(s)){var l=n.marks[s].find();if(!((r.forward?G(l,a):G(a,l))||r.linewise&&l.line==a.line)){var c=Z(a,o),u=r.forward?ee(a,l,o):ee(o,l,a);(c||u)&&(o=l)}}}return r.linewise&&(o=Ge(o.line,ce(e.getLine(o.line)))),o},moveByCharacters:function(e,t,r){var n=t,o=r.repeat,i=r.forward?n.ch+o:n.ch-o;return Ge(n.line,i)},moveByLines:function(e,t,r,n){var o=t,i=o.ch;switch(n.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:i=n.lastHPos;break;default:n.lastHPos=i}var a=r.repeat+(r.repeatOffset||0),s=r.forward?o.line+a:o.line-a,l=e.firstLine(),c=e.lastLine();return s<l&&o.line==l?this.moveToStartOfLine(e,t,r,n):c<s&&o.line==c?this.moveToEol(e,t,r,n):(r.toFirstChar&&(i=ce(e.getLine(s)),n.lastHPos=i),n.lastHSPos=e.charCoords(Ge(s,i),"div").left,Ge(s,i))},moveByDisplayLines:function(e,t,r,n){var o=t;switch(n.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:n.lastHSPos=e.charCoords(o,"div").left}var i=r.repeat;if((s=e.findPosV(o,r.forward?i:-i,"line",n.lastHSPos)).hitSide)if(r.forward)var a={top:e.charCoords(s,"div").top+8,left:n.lastHSPos},s=e.coordsChar(a,"div");else{var l=e.charCoords(Ge(e.firstLine(),0),"div");l.left=n.lastHSPos,s=e.coordsChar(l,"div")}return n.lastHPos=s.ch,s},moveByPage:function(e,t,r){var n=t,o=r.repeat;return e.findPosV(n,r.forward?o:-o,"page")},moveByParagraph:function(e,t,r){var n=r.forward?1:-1;return ye(e,t,r.repeat,n)},moveBySentence:function(e,t,r){var n=r.forward?1:-1;return function(e,t,r,n){function u(e,t){if(t.pos+t.dir<0||t.pos+t.dir>=t.line.length){if(t.ln+=t.dir,!y(e,t.ln))return t.line=null,t.ln=null,void(t.pos=null);t.line=e.getLine(t.ln),t.pos=0<t.dir?0:t.line.length-1}else t.pos+=t.dir}function o(e,t,r,n){var o=e.getLine(t),i=""===o,a={line:o,ln:t,pos:r,dir:n},s={ln:a.ln,pos:a.pos},l=""===a.line;for(u(e,a);null!==a.line;){if(s.ln=a.ln,s.pos=a.pos,""===a.line&&!l)return{ln:a.ln,pos:a.pos};if(i&&""!==a.line&&!B(a.line[a.pos]))return{ln:a.ln,pos:a.pos};!C(a.line[a.pos])||i||a.pos!==a.line.length-1&&!B(a.line[a.pos+1])||(i=!0),u(e,a)}var o=e.getLine(s.ln);s.pos=0;for(var c=o.length-1;0<=c;--c)if(!B(o[c])){s.pos=c;break}return s}function i(e,t,r,n){var o=e.getLine(t),i={line:o,ln:t,pos:r,dir:n},a={ln:i.ln,pos:null},s=""===i.line;for(u(e,i);null!==i.line;){if(""===i.line&&!s)return null!==a.pos?a:{ln:i.ln,pos:i.pos};if(C(i.line[i.pos])&&null!==a.pos&&(i.ln!==a.ln||i.pos+1!==a.pos))return a;""===i.line||B(i.line[i.pos])||(s=!1,a={ln:i.ln,pos:i.pos}),u(e,i)}for(var o=e.getLine(a.ln),l=a.pos=0;l<o.length;++l)if(!B(o[l])){a.pos=l;break}return a}for(var a={ln:t.line,pos:t.ch};0<r;)a=n<0?i(e,a.ln,a.pos,n):o(e,a.ln,a.pos,n),r--;return Ge(a.ln,a.pos)}(e,t,r.repeat,n)},moveByScroll:function(e,t,r,n){var o=e.getScrollInfo(),i=null,a=r.repeat;a||(a=o.clientHeight/(2*e.defaultTextHeight()));var s=e.charCoords(t,"local");if(r.repeat=a,!(i=F.moveByDisplayLines(e,t,r,n)))return null;var l=e.charCoords(i,"local");return e.scrollTo(null,o.top+l.top-s.top),i},moveByWords:function(e,t,r){return function(e,t,r,n,o,i){var a=z(t),s=[];(n&&!o||!n&&o)&&r++;for(var l=!(n&&o),c=0;c<r;c++){var u=me(e,t,n,i,l);if(!u){var h=te(e,e.lastLine());s.push(n?{line:e.lastLine(),from:h,to:h}:{line:0,from:0,to:0});break}s.push(u),t=Ge(u.line,n?u.to-1:u.from)}var p=s.length!=r,f=s[0],d=s.pop();return n&&!o?(p||f.from==a.ch&&f.line==a.line||(d=s.pop()),Ge(d.line,d.from)):n&&o?Ge(d.line,d.to-1):!n&&o?(p||f.to==a.ch&&f.line==a.line||(d=s.pop()),Ge(d.line,d.to)):Ge(d.line,d.from)}(e,t,r.repeat,!!r.forward,!!r.wordEnd,!!r.bigWord)},moveTillCharacter:function(e,t,r){var n=ge(e,r.repeat,r.forward,r.selectedCharacter),o=r.forward?-1:1;return pe(o,r),n?(n.ch+=o,n):null},moveToCharacter:function(e,t,r){var n=r.repeat;return pe(0,r),ge(e,n,r.forward,r.selectedCharacter)||t},moveToSymbol:function(e,t,r){return function(e,t,r,n){var o=z(e.getCursor()),i=r?1:-1,a=r?e.lineCount():-1,s=o.ch,l=o.line,c=e.getLine(l),u={lineText:c,nextCh:c.charAt(s),lastCh:null,index:s,symb:n,reverseSymb:(r?{")":"(","}":"{"}:{"(":")","{":"}"})[n],forward:r,depth:0,curMoveThrough:!1},h=fe[n];if(!h)return o;var p=de[h].init,f=de[h].isComplete;for(p&&p(u);l!==a&&t;){if(u.index+=i,u.nextCh=u.lineText.charAt(u.index),!u.nextCh){if(l+=i,u.lineText=e.getLine(l)||"",0<i)u.index=0;else{var d=u.lineText.length;u.index=0<d?d-1:0}u.nextCh=u.lineText.charAt(u.index)}f(u)&&(o.line=l,o.ch=u.index,t--)}return u.nextCh||u.curMoveThrough?Ge(l,u.index):o}(e,r.repeat,r.forward,r.selectedCharacter)||t},moveToColumn:function(e,t,r,n){var o,i,a,s=r.repeat;return n.lastHPos=s-1,n.lastHSPos=e.charCoords(t,"div").left,i=s,a=(o=e).getCursor().line,U(o,Ge(a,i-1))},moveToEol:function(e,t,r,n){var o=t;n.lastHPos=1/0;var i=Ge(o.line+r.repeat-1,1/0),a=e.clipPos(i);return a.ch--,n.lastHSPos=e.charCoords(a,"div").left,i},moveToFirstNonWhiteSpaceCharacter:function(e,t){var r=t;return Ge(r.line,ce(e.getLine(r.line)))},moveToMatchedSymbol:function(e,t){for(var r,n=t,o=n.line,i=n.ch,a=e.getLine(o);i<a.length;i++)if((r=a.charAt(i))&&-1!="()[]{}".indexOf(r)){var s=e.getTokenTypeAt(Ge(o,i+1));if("string"!==s&&"comment"!==s)break}return i<a.length?e.findMatchingBracket(Ge(o,i)).to:n},moveToStartOfLine:function(e,t){return Ge(t.line,0)},moveToLineOrEdgeOfDocument:function(e,t,r){var n=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(n=r.repeat-e.getOption("firstLineNumber")),Ge(n,ce(e.getLine(n)))},textObjectManipulation:function(e,t,r,n){var o=r.selectedCharacter;"b"==o?o="(":"B"==o&&(o="{");var i,a,s,l,c,u,h,p,f=!r.textObjectInner;if({"(":")",")":"(","{":"}","}":"{","[":"]","]":"["}[o])i=function(e,t,r,n){var o,i,a=t,s={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[r],l={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[r],c=e.getLine(a.line).charAt(a.ch)===l?1:0;if(o=e.scanForBracket(Ge(a.line,a.ch+c),-1,void 0,{bracketRegex:s}),i=e.scanForBracket(Ge(a.line,a.ch+c),1,void 0,{bracketRegex:s}),!o||!i)return{start:a,end:a};if(o=o.pos,i=i.pos,o.line==i.line&&o.ch>i.ch||o.line>i.line){var u=o;o=i,i=u}return n?i.ch+=1:o.ch+=1,{start:o,end:i}}(e,t,o,f);else if({"'":!0,'"':!0}[o])i=function(e,t,r,n){var o,i,a,s,l=z(t),c=e.getLine(l.line).split(""),u=c.indexOf(r);if(l.ch<u?l.ch=u:u<l.ch&&c[l.ch]==r&&(i=l.ch,--l.ch),c[l.ch]!=r||i)for(a=l.ch;-1<a&&!o;a--)c[a]==r&&(o=a+1);else o=l.ch+1;if(o&&!i)for(a=o,s=c.length;a<s&&!i;a++)c[a]==r&&(i=a);return o&&i?(n&&(--o,++i),{start:Ge(l.line,o),end:Ge(l.line,i)}):{start:l,end:l}}(e,t,o,f);else if("W"===o)i=ue(e,f,0,!0);else if("w"===o)i=ue(e,f,0,!1);else{if("p"!==o)return null;if(i=ye(e,t,r.repeat,0,f),r.linewise=!0,n.visualMode)n.visualLine||(n.visualLine=!0);else{var d=n.inputState.operatorArgs;d&&(d.linewise=!0),i.end.line--}}return e.state.vim.visualMode?(a=e,s=i.start,l=i.end,u=a.state.vim.sel,h=u.head,p=u.anchor,G(l,s)&&(c=l,l=s,s=c),G(h,p)?(h=X(s,h),p=Y(p,l)):(p=X(s,p),-1==(h=$(h=Y(h,l),0,-1)).ch&&h.line!=a.firstLine()&&(h=Ge(h.line-1,te(a,h.line-1)))),[p,h]):[i.start,i.end]},repeatLastCharacterSearch:function(e,t,r){var n=_.lastCharacterSearch,o=r.repeat,i=r.forward===n.forward,a=(n.increment?1:0)*(i?-1:1);e.moveH(-a,"char"),r.inclusive=!!i;var s=ge(e,o,i,n.selectedCharacter);return s?(s.ch+=a,s):(e.moveH(a,"char"),t)}};function W(e,t){for(var r=[],n=0;n<t;n++)r.push(e);return r}var V={change:function(e,t,r){var n,o,i=e.state.vim;if(_.macroModeState.lastInsertModeChanges.inVisualBlock=i.visualBlock,i.visualMode){o=e.getSelection();var a=W("",r.length);e.replaceSelections(a),n=X(r[0].head,r[0].anchor)}else{var s=r[0].anchor,l=r[0].head;o=e.getRange(s,l);var c=i.lastEditInputState||{};if("moveByWords"==c.motion&&!B(o)){var u=/\s+$/.exec(o);u&&c.motionArgs&&c.motionArgs.forward&&(l=$(l,0,-u[0].length),o=o.slice(0,-u[0].length))}var h=new Ge(s.line-1,Number.MAX_VALUE),p=e.firstLine()==e.lastLine();l.line>e.lastLine()&&t.linewise&&!p?e.replaceRange("",h,l):e.replaceRange("",s,l),t.linewise&&(p||(e.setCursor(h),Qe.commands.newlineAndIndent(e)),s.ch=Number.MAX_VALUE),n=s}_.registerController.pushText(t.registerName,"change",o,t.linewise,1<r.length),D.enterInsertMode(e,{head:n},e.state.vim)},delete:function(e,t,r){var n,o,i=e.state.vim;if(i.visualBlock){o=e.getSelection();var a=W("",r.length);e.replaceSelections(a),n=r[0].anchor}else{var s=r[0].anchor,l=r[0].head;t.linewise&&l.line!=e.firstLine()&&s.line==e.lastLine()&&s.line==l.line-1&&(s.line==e.firstLine()?s.ch=0:s=Ge(s.line-1,te(e,s.line-1))),o=e.getRange(s,l),e.replaceRange("",s,l),n=s,t.linewise&&(n=F.moveToFirstNonWhiteSpaceCharacter(e,s))}return _.registerController.pushText(t.registerName,"delete",o,t.linewise,i.visualBlock),U(e,n,i.insertMode)},indent:function(e,t,r){var n=e.state.vim,o=r[0].anchor.line,i=n.visualBlock?r[r.length-1].anchor.line:r[0].head.line,a=n.visualMode?t.repeat:1;t.linewise&&i--;for(var s=o;s<=i;s++)for(var l=0;l<a;l++)e.indentLine(s,t.indentRight);return F.moveToFirstNonWhiteSpaceCharacter(e,r[0].anchor)},changeCase:function(e,t,r,n,o){for(var i=e.getSelections(),a=[],s=t.toLower,l=0;l<i.length;l++){var c=i[l],u="";if(!0===s)u=c.toLowerCase();else if(!1===s)u=c.toUpperCase();else for(var h=0;h<c.length;h++){var p=c.charAt(h);u+=k(p)?p.toLowerCase():p.toUpperCase()}a.push(u)}return e.replaceSelections(a),t.shouldMoveCursor?o:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?F.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:X(r[0].anchor,r[0].head)},yank:function(e,t,r,n){var o=e.state.vim,i=e.getSelection(),a=o.visualMode?X(o.sel.anchor,o.sel.head,r[0].head,r[0].anchor):n;return _.registerController.pushText(t.registerName,"yank",i,t.linewise,o.visualBlock),a}};var D={jumpListWalk:function(e,t,r){if(!r.visualMode){var n=t.repeat,o=t.forward,i=_.jumpList.move(e,o?n:-n),a=i?i.find():void 0;a=a||e.getCursor(),e.setCursor(a)}},scroll:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,o=e.defaultTextHeight(),i=e.getScrollInfo().top,a=o*n,s=t.forward?i+a:i-a,l=z(e.getCursor()),c=e.charCoords(l,"local");if(t.forward)s>c.top?(l.line+=(s-c.top)/o,l.line=Math.ceil(l.line),e.setCursor(l),c=e.charCoords(l,"local"),e.scrollTo(null,c.top)):e.scrollTo(null,s);else{var u=s+e.getScrollInfo().clientHeight;u<c.bottom?(l.line-=(c.bottom-u)/o,l.line=Math.floor(l.line),e.setCursor(l),c=e.charCoords(l,"local"),e.scrollTo(null,c.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,s)}}},scrollToCursor:function(e,t){var r=e.getCursor().line,n=e.charCoords(Ge(r,0),"local"),o=e.getScrollInfo().clientHeight,i=n.top,a=n.bottom-i;switch(t.position){case"center":i=i-o/2+a;break;case"bottom":i=i-o+a}e.scrollTo(null,i)},replayMacro:function(e,t,r){var n=t.selectedCharacter,o=t.repeat,i=_.macroModeState;for("@"==n&&(n=i.latestRegister);o--;)Fe(e,r,i,n)},enterMacroRecordMode:function(e,t){var r=_.macroModeState,n=t.selectedCharacter;_.registerController.isValidRegister(n)&&r.enterMacroRecordMode(e,n)},toggleOverwrite:function(e){e.state.overwrite?(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),Qe.signal(e,"vim-mode-change",{mode:"insert"})):(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),Qe.signal(e,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(e,t,r){if(!e.getOption("readOnly")){r.insertMode=!0,r.insertModeRepeat=t&&t.repeat||1;var n=t?t.insertAt:null,o=r.sel,i=t.head||e.getCursor("head"),a=e.listSelections().length;if("eol"==n)i=Ge(i.line,te(e,i.line));else if("charAfter"==n)i=$(i,0,1);else if("firstNonBlank"==n)i=F.moveToFirstNonWhiteSpaceCharacter(e,i);else if("startOfSelectedArea"==n)r.visualBlock?(i=Ge(Math.min(o.head.line,o.anchor.line),Math.min(o.head.ch,o.anchor.ch)),a=Math.abs(o.head.line-o.anchor.line)+1):i=o.head.line<o.anchor.line?o.head:Ge(o.anchor.line,0);else if("endOfSelectedArea"==n)r.visualBlock?(i=Ge(Math.min(o.head.line,o.anchor.line),Math.max(o.head.ch+1,o.anchor.ch)),a=Math.abs(o.head.line-o.anchor.line)+1):i=o.head.line>=o.anchor.line?$(o.head,0,1):Ge(o.anchor.line,0);else if("inplace"==n&&r.visualMode)return;e.setOption("disableInput",!1),t&&t.replace?(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),Qe.signal(e,"vim-mode-change",{mode:"replace"})):(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),Qe.signal(e,"vim-mode-change",{mode:"insert"})),_.macroModeState.isPlaying||(e.on("change",We),Qe.on(e.getInputField(),"keydown",Je)),r.visualMode&&le(e),oe(e,i,a)}},toggleVisualMode:function(e,t,r){var n,o=t.repeat,i=e.getCursor();r.visualMode?r.visualLine^t.linewise||r.visualBlock^t.blockwise?(r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,Qe.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),ae(e)):le(e):(r.visualMode=!0,r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,n=U(e,Ge(i.line,i.ch+o-1),!0),r.sel={anchor:i,head:n},Qe.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),ae(e),ve(e,r,"<",X(i,n)),ve(e,r,">",Y(i,n)))},reselectLastSelection:function(e,t,r){var n=r.lastSelection;if(r.visualMode&&ie(e,r),n){var o=n.anchorMark.find(),i=n.headMark.find();if(!o||!i)return;r.sel={anchor:o,head:i},r.visualMode=!0,r.visualLine=n.visualLine,r.visualBlock=n.visualBlock,ae(e),ve(e,r,"<",X(o,i)),ve(e,r,">",Y(o,i)),Qe.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var n,o;if(r.visualMode){if(n=e.getCursor("anchor"),G(o=e.getCursor("head"),n)){var i=o;o=n,n=i}o.ch=te(e,o.line)-1}else{var a=Math.max(t.repeat,2);n=e.getCursor(),o=U(e,Ge(n.line+a-1,1/0))}for(var s=0,l=n.line;l<o.line;l++){s=te(e,n.line),i=Ge(n.line+1,te(e,n.line+1));var c=e.getRange(n,i);c=c.replace(/\n\s*/g," "),e.replaceRange(c,n,i)}var u=Ge(n.line,s);r.visualMode&&le(e,!1),e.setCursor(u)},newLineAndEnterInsertMode:function(e,t,r){r.insertMode=!0;var n=z(e.getCursor());n.line!==e.firstLine()||t.after?(n.line=t.after?n.line:n.line-1,n.ch=te(e,n.line),e.setCursor(n),(Qe.commands.newlineAndIndentContinueComment||Qe.commands.newlineAndIndent)(e)):(e.replaceRange("\n",Ge(e.firstLine(),0)),e.setCursor(e.firstLine(),0)),this.enterInsertMode(e,{repeat:t.repeat},r)},paste:function(n,e,t){var r,o,i,a,s,l=z(n.getCursor()),c=_.registerController.getRegister(e.registerName);if(v=c.toString()){if(e.matchIndent){var u=n.getOption("tabSize"),h=function(e){var t=e.split("\t").length-1,r=e.split(" ").length-1;return t*u+1*r},p=n.getLine(n.getCursor().line),f=h(p.match(/^\s*/)[0]),d=v.replace(/\n$/,""),m=v!==d,g=h(v.match(/^\s*/)[0]),v=d.replace(/^\s*/gm,function(e){var t=f+(h(e)-g);if(t<0)return"";if(n.getOption("indentWithTabs")){var r=Math.floor(t/u);return Array(r+1).join("\t")}return Array(t+1).join(" ")});v+=m?"\n":""}1<e.repeat&&(v=Array(e.repeat+1).join(v));var y,k,C,w,M,x,S,A,b,L,T=c.linewise,R=c.blockwise;if(T)t.visualMode?v=t.visualLine?v.slice(0,-1):"\n"+v.slice(0,v.length-1)+"\n":e.after?(v="\n"+v.slice(0,v.length-1),l.ch=te(n,l.line)):l.ch=0;else{if(R){v=v.split("\n");for(var E=0;E<v.length;E++)v[E]=""==v[E]?" ":v[E]}l.ch+=e.after?1:0}if(t.visualMode){var O;t.lastPastedText=v;var B=(C=n,M=(w=t).lastSelection,w.visualMode?(x=C.listSelections(),S=x[0],A=x[x.length-1],b=G(S.anchor,S.head)?S.anchor:S.head,L=G(A.anchor,A.head)?A.head:A.anchor,[b,L]):function(){var e=C.getCursor(),t=C.getCursor(),r=M.visualBlock;if(r){var n=r.width,o=r.height;t=Ge(e.line+o,e.ch+n);for(var i=[],a=e.line;a<t.line;a++){var s=Ge(a,e.ch),l=Ge(a,t.ch),c={anchor:s,head:l};i.push(c)}C.setSelections(i)}else{var u=M.anchorMark.find(),h=M.headMark.find(),p=h.line-u.line,f=h.ch-u.ch;t={line:t.line+p,ch:p?t.ch:f+t.ch},M.visualLine&&(e=Ge(e.line,0),t=Ge(t.line,te(C,t.line))),C.setSelection(e,t)}return[e,t]}()),I=B[0],K=B[1],N=n.getSelection(),P=n.listSelections(),j=new Array(P.length).join("1").split("1");t.lastSelection&&(O=t.lastSelection.headMark.find()),_.registerController.unnamedRegister.setText(N),R?(n.replaceSelections(j),K=Ge(I.line+v.length-1,I.ch),n.setCursor(I),ne(n,K),n.replaceSelections(v),y=I):t.visualBlock?(n.replaceSelections(j),n.setCursor(I),n.replaceRange(v,I,I),y=I):(n.replaceRange(v,I,K),y=n.posFromIndex(n.indexFromPos(I)+v.length-1)),O&&(t.lastSelection.headMark=n.setBookmark(O)),T&&(y.ch=0)}else if(R){for(n.setCursor(l),E=0;E<v.length;E++){var H=l.line+E;H>n.lastLine()&&n.replaceRange("\n",Ge(H,0)),te(n,H)<l.ch&&(r=n,o=H,i=l.ch,void 0,a=te(r,o),s=new Array(i-a+1).join(" "),r.setCursor(Ge(o,a)),r.replaceRange(s,r.getCursor()))}n.setCursor(l),ne(n,Ge(l.line+v.length-1,l.ch)),n.replaceSelections(v),y=l}else n.replaceRange(v,l),T&&e.after?y=Ge(l.line+1,ce(n.getLine(l.line+1))):T&&!e.after?y=Ge(l.line,ce(n.getLine(l.line))):!T&&e.after?(k=n.indexFromPos(l),y=n.posFromIndex(k+v.length-1)):(k=n.indexFromPos(l),y=n.posFromIndex(k+v.length));t.visualMode&&le(n,!1),n.setCursor(y)}},undo:function(e,t){e.operation(function(){Q(e,Qe.commands.undo,t.repeat)(),e.setCursor(e.getCursor("anchor"))})},redo:function(e,t){Q(e,Qe.commands.redo,t.repeat)()},setRegister:function(e,t,r){r.inputState.registerName=t.selectedCharacter},setMark:function(e,t,r){ve(e,r,t.selectedCharacter,e.getCursor())},replace:function(e,t,r){var n,o,i=t.selectedCharacter,a=e.getCursor(),s=e.listSelections();if(r.visualMode)a=e.getCursor("start"),o=e.getCursor("end");else{var l=e.getLine(a.line);(n=a.ch+t.repeat)>l.length&&(n=l.length),o=Ge(a.line,n)}if("\n"==i)r.visualMode||e.replaceRange("",a,o),(Qe.commands.newlineAndIndentContinueComment||Qe.commands.newlineAndIndent)(e);else{var c=e.getRange(a,o);if(c=c.replace(/[^\n]/g,i),r.visualBlock){var u=new Array(e.getOption("tabSize")+1).join(" ");c=(c=e.getSelection()).replace(/\t/g,u).replace(/[^\n]/g,i).split("\n"),e.replaceSelections(c)}else e.replaceRange(c,a,o);r.visualMode?(a=G(s[0].anchor,s[0].head)?s[0].anchor:s[0].head,e.setCursor(a),le(e,!1)):e.setCursor($(o,0,-1))}},incrementNumberToken:function(e,t){for(var r,n,o,i,a=e.getCursor(),s=e.getLine(a.line),l=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi;null!==(r=l.exec(s))&&(o=(n=r.index)+r[0].length,!(a.ch<o)););if((t.backtrack||!(o<=a.ch))&&r){var c=r[2]||r[4],u=r[3]||r[5],h=t.increase?1:-1,p={"0b":2,0:8,"":10,"0x":16}[c.toLowerCase()];i=(parseInt(r[1]+u,p)+h*t.repeat).toString(p);var f=c?new Array(u.length-i.length+1+r[1].length).join("0"):"";i="-"===i.charAt(0)?"-"+c+f+i.substr(1):c+f+i;var d=Ge(a.line,n),m=Ge(a.line,o);e.replaceRange(i,d,m),e.setCursor(Ge(a.line,n+i.length-1))}},repeatLastEdit:function(e,t,r){if(r.lastEditInputState){var n=t.repeat;n&&t.repeatIsExplicit?r.lastEditInputState.repeatOverride=n:n=r.lastEditInputState.repeatOverride||n,$e(e,r,n,!1)}},indent:function(e,t){e.indentLine(e.getCursor().line,t.indentRight)},exitInsertMode:He};function U(e,t,r){var n=Math.min(Math.max(e.firstLine(),t.line),e.lastLine()),o=te(e,n)-1;o=r?o+1:o;var i=Math.min(Math.max(0,t.ch),o);return Ge(n,i)}function J(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function $(e,t,r){return"object"==typeof t&&(r=t.ch,t=t.line),Ge(e.line+t,e.ch+r)}function q(e,t){if("<character>"==t.slice(-11)){var r=t.length-11,n=e.slice(0,r),o=t.slice(0,r);return n==o&&e.length>r?"full":0==o.indexOf(n)&&"partial"}return e==t?"full":0==t.indexOf(e)&&"partial"}function Q(t,r,n){return function(){for(var e=0;e<n;e++)r(t)}}function z(e){return Ge(e.line,e.ch)}function Z(e,t){return e.ch==t.ch&&e.line==t.line}function G(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function X(e,t){return 2<arguments.length&&(t=X.apply(void 0,Array.prototype.slice.call(arguments,1))),G(e,t)?e:t}function Y(e,t){return 2<arguments.length&&(t=Y.apply(void 0,Array.prototype.slice.call(arguments,1))),G(e,t)?t:e}function ee(e,t,r){var n=G(e,t),o=G(t,r);return n&&o}function te(e,t){return e.getLine(t).length}function re(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function ne(e,t){var r=[],n=e.listSelections(),o=z(e.clipPos(t)),i=!Z(t,o),a=function(e,t,r){for(var n=0;n<e.length;n++){var o="head"!=r&&Z(e[n].anchor,t),i="anchor"!=r&&Z(e[n].head,t);if(o||i)return n}return-1}(n,e.getCursor("head")),s=Z(n[a].head,n[a].anchor),l=n.length-1,c=a<l-a?l:0,u=n[c].anchor,h=Math.min(u.line,o.line),p=Math.max(u.line,o.line),f=u.ch,d=o.ch,m=n[c].head.ch-f,g=d-f;0<m&&g<=0?(f++,i||d--):m<0&&0<=g?(f--,s||d++):m<0&&-1==g&&(f--,d++);for(var v=h;v<=p;v++){var y={anchor:new Ge(v,f),head:new Ge(v,d)};r.push(y)}return e.setSelections(r),t.ch=d,u.ch=f,u}function oe(e,t,r){for(var n=[],o=0;o<r;o++){var i=$(t,o,0);n.push({anchor:i,head:i})}e.setSelections(n,0)}function ie(e,t){var r=t.sel.anchor,n=t.sel.head;t.lastPastedText&&(n=e.posFromIndex(e.indexFromPos(r)+t.lastPastedText.length),t.lastPastedText=null),t.lastSelection={anchorMark:e.setBookmark(r),headMark:e.setBookmark(n),anchor:z(r),head:z(n),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function ae(e,t,r){var n=e.state.vim,o=se(e,t=t||n.sel,r=r||n.visualLine?"line":n.visualBlock?"block":"char");e.setSelections(o.ranges,o.primary),De(e)}function se(e,t,r,n){var o=z(t.head),i=z(t.anchor);if("char"==r){var a=n||G(t.head,t.anchor)?0:1,s=G(t.head,t.anchor)?1:0;return o=$(t.head,0,a),{ranges:[{anchor:i=$(t.anchor,0,s),head:o}],primary:0}}if("line"==r){if(G(t.head,t.anchor))o.ch=0,i.ch=te(e,i.line);else{i.ch=0;var l=e.lastLine();o.line>l&&(o.line=l),o.ch=te(e,o.line)}return{ranges:[{anchor:i,head:o}],primary:0}}if("block"==r){for(var c=Math.min(i.line,o.line),u=Math.min(i.ch,o.ch),h=Math.max(i.line,o.line),p=Math.max(i.ch,o.ch)+1,f=h-c+1,d=o.line==c?0:f-1,m=[],g=0;g<f;g++)m.push({anchor:Ge(c+g,u),head:Ge(c+g,p)});return{ranges:m,primary:d}}}function le(e,t){var r=e.state.vim;!1!==t&&e.setCursor(U(e,r.sel.head)),ie(e,r),r.visualMode=!1,r.visualLine=!1,r.visualBlock=!1,Qe.signal(e,"vim-mode-change",{mode:"normal"}),r.fakeCursor&&r.fakeCursor.clear()}function ce(e){if(!e)return 0;var t=e.search(/\S/);return-1==t?e.length:t}function ue(e,t,r,n,o){for(var i,a,s=(a=(i=e).getCursor("head"),1==i.getSelection().length&&(a=X(a,i.getCursor("anchor"))),a),l=e.getLine(s.line),c=s.ch,u=o?g[0]:v[0];!u(l.charAt(c));)if(++c>=l.length)return null;n?u=v[0]:(u=g[0])(l.charAt(c))||(u=g[1]);for(var h=c,p=c;u(l.charAt(h))&&h<l.length;)h++;for(;u(l.charAt(p))&&0<=p;)p--;if(p++,t){for(var f=h;/\s/.test(l.charAt(h))&&h<l.length;)h++;if(f==h){for(var d=p;/\s/.test(l.charAt(p-1))&&0<p;)p--;p||(p=d)}}return{start:Ge(s.line,p),end:Ge(s.line,h)}}function he(e,t,r){Z(t,r)||_.jumpList.add(e,t,r)}function pe(e,t){_.lastCharacterSearch.increment=e,_.lastCharacterSearch.forward=t.forward,_.lastCharacterSearch.selectedCharacter=t.selectedCharacter}var fe={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},de={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(e.depth++,1<=e.depth)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?"]":"[")===e.symb?"{":"}"},isComplete:function(e){return 0===e.index&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t="*"===e.lastCh&&"/"===e.nextCh;return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb="m"===e.symb?"{":"}",e.reverseSymb="{"===e.symb?"}":"{"},isComplete:function(e){return e.nextCh===e.symb}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if("#"===e.nextCh){var t=e.lineText.match(/#(\w+)/)[1];if("endif"===t){if(e.forward&&0===e.depth)return!0;e.depth++}else if("if"===t){if(!e.forward&&0===e.depth)return!0;e.depth--}if("else"===t&&0===e.depth)return!0}return!1}}};function me(e,t,r,n,o){var i=t.line,a=t.ch,s=e.getLine(i),l=r?1:-1,c=n?v:g;if(o&&""==s){if(i+=l,s=e.getLine(i),!y(e,i))return null;a=r?0:s.length}for(;;){if(o&&""==s)return{from:0,to:0,line:i};for(var u=0<l?s.length:-1,h=u,p=u;a!=u;){for(var f=!1,d=0;d<c.length&&!f;++d)if(c[d](s.charAt(a))){for(h=a;a!=u&&c[d](s.charAt(a));)a+=l;if(f=h!=(p=a),h==t.ch&&i==t.line&&p==h+l)continue;return{from:Math.min(h,p+1),to:Math.max(h,p),line:i}}f||(a+=l)}if(!y(e,i+=l))return null;s=e.getLine(i),a=0<l?0:s.length}}function ge(e,t,r,n){for(var o,i=e.getCursor(),a=i.ch,s=0;s<t;s++){if(-1==(l=a,c=e.getLine(i.line),u=n,h=!0,p=void 0,r?-1==(p=c.indexOf(u,l+1))||h||(p-=1):-1==(p=c.lastIndexOf(u,l-1))||h||(p+=1),o=p))return null;a=o}var l,c,u,h,p;return Ge(e.getCursor().line,o)}function ve(e,t,r,n){w(r,p)&&(t.marks[r]&&t.marks[r].clear(),t.marks[r]=e.setBookmark(n))}function ye(t,e,r,n,o){var i,a=e.line,s=t.firstLine(),l=t.lastLine(),c=a;function u(e){return!t.getLine(e)}function h(e,t,r){return r?u(e)!=u(e+t):!u(e)&&u(e+t)}if(n){for(;s<=c&&c<=l&&0<r;)h(c,n)&&r--,c+=n;return new Ge(c,0)}var p=t.state.vim;if(p.visualLine&&h(a,1,!0)){var f=p.sel.anchor;h(f.line,-1,!0)&&(o&&f.line==a||(a+=1))}var d=u(a);for(c=a;c<=l&&r;c++)h(c,1,!0)&&(o&&u(c)==d||r--);for(i=new Ge(c,0),l<c&&!d?d=!0:o=!1,c=a;s<c&&(o&&u(c)!=d&&c!=a||!h(c,-1,!0));c--);return{start:new Ge(c,0),end:i}}function ke(){}function Ce(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new ke)}function we(e,t){var r=Me(e,t)||[];if(!r.length)return[];var n=[];if(0===r[0]){for(var o=0;o<r.length;o++)"number"==typeof r[o]&&n.push(e.substring(r[o]+1,r[o+1]));return n}}function Me(e,t){t||(t="/");for(var r=!1,n=[],o=0;o<e.length;o++){var i=e.charAt(o);r||i!=t||n.push(o),r=!r&&"\\"==i}return n}x("pcre",!0,"boolean"),ke.prototype={getQuery:function(){return _.query},setQuery:function(e){_.query=e},getOverlay:function(){return this.searchOverlay},setOverlay:function(e){this.searchOverlay=e},isReversed:function(){return _.isReversed},setReversed:function(e){_.isReversed=e},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(e){this.annotate=e}};var xe={"\\n":"\n","\\r":"\r","\\t":"\t"};var Se={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":"\t"};function Ae(e,t,r){if(_.registerController.getRegister("/").setText(e),e instanceof RegExp)return e;var n,o,i=Me(e,"/");return i.length?(n=e.substring(0,i[0]),o=-1!=e.substring(i[0]).indexOf("i")):n=e,n?(A("pcre")||(n=function(e){for(var t=!1,r=[],n=-1;n<e.length;n++){var o=e.charAt(n)||"",i=e.charAt(n+1)||"",a=i&&-1!="|(){".indexOf(i);t?("\\"===o&&a||r.push(o),t=!1):"\\"===o?(t=!0,i&&-1!="}".indexOf(i)&&(a=!0),a&&"\\"!==i||r.push(o)):(r.push(o),a&&"\\"!==i&&r.push("\\"))}return r.join("")}(n)),r&&(t=/^[^A-Z]*$/.test(n)),new RegExp(n,t||o?"i":void 0)):null}function be(e,t){e.openNotification?e.openNotification('<span style="color: red">'+t+"</span>",{bottom:!0,duration:5e3}):alert(t)}var Le="(Javascript regexp)";function Te(e,t){var r,n,o,i,a,s,l,c,u=(t.prefix||"")+" "+(t.desc||""),h=(r=t.prefix,n=t.desc,o='<span style="font-family: monospace; white-space: pre">'+(r||"")+'<input type="text"></span>',n&&(o+=' <span style="color: #888">'+n+"</span>"),o);i=e,a=h,s=u,l=t.onClose,c=t,i.openDialog?i.openDialog(a,l,{bottom:!0,value:c.value,onKeyDown:c.onKeyDown,onKeyUp:c.onKeyUp,selectValueOnOpen:!1}):l(prompt(s,""))}function Re(e,t,r,n){if(t){var o=Ce(e),i=Ae(t,!!r,!!n);if(i)return Ee(e,i),function(e,t){if(e instanceof RegExp&&t instanceof RegExp){for(var r=["global","multiline","ignoreCase","source"],n=0;n<r.length;n++){var o=r[n];if(e[o]!==t[o])return!1}return!0}return!1}(i,o.getQuery())||o.setQuery(i),i}}function Ee(e,t){var r=Ce(e),n=r.getOverlay();n&&t==n.query||(n&&e.removeOverlay(n),n=function(r){if("^"==r.source.charAt(0))var n=!0;return{token:function(e){if(!n||e.sol()){var t=e.match(r,!1);if(t)return 0==t[0].length?(e.next(),"searching"):e.sol()||(e.backUp(1),r.exec(e.next()+t[0]))?(e.match(r),"searching"):(e.next(),null);for(;!e.eol()&&(e.next(),!e.match(r,!1)););}else e.skipToEnd()},query:r}}(t),e.addOverlay(n),e.showMatchesOnScrollbar&&(r.getScrollbarAnnotate()&&r.getScrollbarAnnotate().clear(),r.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))),r.setOverlay(n))}function Oe(o,i,a,s){return void 0===s&&(s=1),o.operation(function(){for(var e=o.getCursor(),t=o.getSearchCursor(a,e),r=0;r<s;r++){var n=t.find(i);if(0==r&&n&&Z(t.from(),e)&&(n=t.find(i)),!n&&!(t=o.getSearchCursor(a,i?Ge(o.lastLine()):Ge(o.firstLine(),0))).find(i))return}return t.from()})}function Be(e){var t=Ce(e);e.removeOverlay(Ce(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function Ie(e){var t=e.getScrollInfo(),r=e.coordsChar({left:0,top:6+t.top},"local"),n=t.clientHeight-10+t.top,o=e.coordsChar({left:0,top:n},"local");return{top:r.line,bottom:o.line}}function Ke(e,t,r){if("'"==r){var n=e.doc.history.done,o=n[n.length-2];return o&&o.ranges&&o.ranges[0].head}if("."==r){if(0==e.doc.history.lastModTime)return;var i=e.doc.history.done.filter(function(e){if(void 0!==e.changes)return e});return i.reverse(),i[0].changes[0].to}var a=t.marks[r];return a&&a.find()}var Ne=function(){this.buildCommandMap_()};Ne.prototype={processCommand:function(e,t,r){var n=this;e.operation(function(){e.curOp.isVimOp=!0,n._processCommand(e,t,r)})},_processCommand:function(t,e,r){var n=t.state.vim,o=_.registerController.getRegister(":"),i=o.toString();n.visualMode&&le(t);var a=new Qe.StringStream(e);o.setText(e);var s,l,c=r||{};c.input=e;try{this.parseInput_(t,a,c)}catch(e){throw be(t,e),e}if(c.commandName){if(s=this.matchCommand_(c.commandName)){if(l=s.name,s.excludeFromCommandHistory&&o.setText(i),this.parseCommandArgs_(a,c,s),"exToKey"==s.type){for(var u=0;u<s.toKeys.length;u++)Qe.Vim.handleKey(t,s.toKeys[u],"mapping");return}if("exToEx"==s.type)return void this.processCommand(t,s.toInput)}}else void 0!==c.line&&(l="move");if(l)try{Pe[l](t,c),s&&s.possiblyAsync||!c.callback||c.callback()}catch(e){throw be(t,e),e}else be(t,'Not an editor command ":'+e+'"')},parseInput_:function(e,t,r){t.eatWhile(":"),t.eat("%")?(r.line=e.firstLine(),r.lineEnd=e.lastLine()):(r.line=this.parseLineSpec_(e,t),void 0!==r.line&&t.eat(",")&&(r.lineEnd=this.parseLineSpec_(e,t)));var n=t.match(/^(\w+)/);return r.commandName=n?n[1]:t.match(/.*/)[0],r},parseLineSpec_:function(e,t){var r=t.match(/^(\d+)/);if(r)return parseInt(r[1],10)-1;switch(t.next()){case".":return this.parseLineSpecOffset_(t,e.getCursor().line);case"$":return this.parseLineSpecOffset_(t,e.lastLine());case"'":var n=t.next(),o=Ke(e,e.state.vim,n);if(!o)throw new Error("Mark not set");return this.parseLineSpecOffset_(t,o.line);case"-":case"+":return t.backUp(1),this.parseLineSpecOffset_(t,e.getCursor().line);default:return void t.backUp(1)}},parseLineSpecOffset_:function(e,t){var r=e.match(/^([+-])?(\d+)/);if(r){var n=parseInt(r[2],10);"-"==r[1]?t-=n:t+=n}return t},parseCommandArgs_:function(e,t,r){if(!e.eol()){t.argString=e.match(/.*/)[0];var n=r.argDelimiter||/\s+/,o=re(t.argString).split(n);o.length&&o[0]&&(t.args=o)}},matchCommand_:function(e){for(var t=e.length;0<t;t--){var r=e.substring(0,t);if(this.commandMap_[r]){var n=this.commandMap_[r];if(0===n.name.indexOf(e))return n}}return null},buildCommandMap_:function(){this.commandMap_={};for(var e=0;e<Ze.length;e++){var t=Ze[e],r=t.shortName||t.name;this.commandMap_[r]=t}},map:function(e,t,r){if(":"!=e&&":"==e.charAt(0)){if(r)throw Error("Mode not supported for ex mappings");var n=e.substring(1);":"!=t&&":"==t.charAt(0)?this.commandMap_[n]={name:n,type:"exToEx",toInput:t.substring(1),user:!0}:this.commandMap_[n]={name:n,type:"exToKey",toKeys:t,user:!0}}else if(":"!=t&&":"==t.charAt(0)){var o={keys:e,type:"keyToEx",exArgs:{input:t.substring(1)}};r&&(o.context=r),ze.unshift(o)}else o={keys:e,type:"keyToKey",toKeys:t},r&&(o.context=r),ze.unshift(o)},unmap:function(e,t){if(":"!=e&&":"==e.charAt(0)){if(t)throw Error("Mode not supported for ex mappings");var r=e.substring(1);if(this.commandMap_[r]&&this.commandMap_[r].user)return void delete this.commandMap_[r]}else for(var n=e,o=0;o<ze.length;o++)if(n==ze[o].keys&&ze[o].context===t)return void ze.splice(o,1);throw Error("No such mapping.")}};var Pe={colorscheme:function(e,t){!t.args||t.args.length<1?be(e,e.getOption("theme")):e.setOption("theme",t.args[0])},map:function(e,t,r){var n=t.args;!n||n.length<2?e&&be(e,"Invalid mapping: "+t.input):je.map(n[0],n[1],r)},imap:function(e,t){this.map(e,t,"insert")},nmap:function(e,t){this.map(e,t,"normal")},vmap:function(e,t){this.map(e,t,"visual")},unmap:function(e,t,r){var n=t.args;!n||n.length<1?e&&be(e,"No such mapping: "+t.input):je.unmap(n[0],r)},move:function(e,t){H.processCommand(e,e.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:t.line+1})},set:function(e,t){var r=t.args,n=t.setCfg||{};if(!r||r.length<1)e&&be(e,"Invalid mapping: "+t.input);else{var o=r[0].split("="),i=o[0],a=o[1],s=!1;if("?"==i.charAt(i.length-1)){if(a)throw Error("Trailing characters: "+t.argString);i=i.substring(0,i.length-1),s=!0}void 0===a&&"no"==i.substring(0,2)&&(i=i.substring(2),a=!1);var l=M[i]&&"boolean"==M[i].type;if(l&&null==a&&(a=!0),!l&&void 0===a||s){var c=A(i,e,n);c instanceof Error?be(e,c.message):be(e,!0===c||!1===c?" "+(c?"":"no")+i:" "+i+"="+c)}else{var u=S(i,a,e,n);u instanceof Error&&be(e,u.message)}}},setlocal:function(e,t){t.setCfg={scope:"local"},this.set(e,t)},setglobal:function(e,t){t.setCfg={scope:"global"},this.set(e,t)},registers:function(e,t){var r=t.args,n=_.registerController.registers,o="----------Registers----------<br><br>";if(r){r=r.join("");for(var i=0;i<r.length;i++)a=r.charAt(i),_.registerController.isValidRegister(a)&&(o+='"'+a+" "+(n[a]||new N).toString()+"<br>")}else for(var a in n){var s=n[a].toString();s.length&&(o+='"'+a+" "+s+"<br>")}be(e,o)},sort:function(e,i){var a,s,l,c,u,t=function(){if(i.argString){var e=new Qe.StringStream(i.argString);if(e.eat("!")&&(a=!0),e.eol())return;if(!e.eatSpace())return"Invalid arguments";var t=e.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!t&&!e.eol())return"Invalid arguments";if(t[1]){s=-1!=t[1].indexOf("i"),l=-1!=t[1].indexOf("u");var r=-1!=t[1].indexOf("d")||-1!=t[1].indexOf("n")&&1,n=-1!=t[1].indexOf("x")&&1,o=-1!=t[1].indexOf("o")&&1;if(1<r+n+o)return"Invalid arguments";c=(r?"decimal":n&&"hex")||o&&"octal"}t[2]&&(u=new RegExp(t[2].substr(1,t[2].length-2),s?"i":""))}}();if(t)be(e,t+": "+i.argString);else{var r=i.line||e.firstLine(),n=i.lineEnd||i.line||e.lastLine();if(r!=n){var o=Ge(r,0),h=Ge(n,te(e,n)),p=e.getRange(o,h).split("\n"),f=u||("decimal"==c?/(-?)([\d]+)/:"hex"==c?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==c?/([0-7]+)/:null),d="decimal"==c?10:"hex"==c?16:"octal"==c?8:null,m=[],g=[];if(c||u)for(var v=0;v<p.length;v++){var y=u?p[v].match(u):null;y&&""!=y[0]?m.push(y):!u&&f.exec(p[v])?m.push(p[v]):g.push(p[v])}else g=p;if(m.sort(u?function(e,t){var r;return a&&(r=e,e=t,t=r),s&&(e[0]=e[0].toLowerCase(),t[0]=t[0].toLowerCase()),e[0]<t[0]?-1:1}:w),u)for(v=0;v<m.length;v++)m[v]=m[v].input;else c||g.sort(w);if(p=a?m.concat(g):g.concat(m),l){var k,C=p;for(p=[],v=0;v<C.length;v++)C[v]!=k&&p.push(C[v]),k=C[v]}e.replaceRange(p.join("\n"),o,h)}}function w(e,t){var r;a&&(r=e,e=t,t=r),s&&(e=e.toLowerCase(),t=t.toLowerCase());var n=c&&f.exec(e),o=c&&f.exec(t);return n?(n=parseInt((n[1]+n[2]).toLowerCase(),d))-(o=parseInt((o[1]+o[2]).toLowerCase(),d)):e<t?-1:1}},global:function(t,e){var r=e.argString;if(r){var n,o=void 0!==e.line?e.line:t.firstLine(),i=e.lineEnd||e.line||t.lastLine(),a=we(r,"/"),s=r;if(a.length&&(s=a[0],n=a.slice(1,a.length).join("/")),s)try{Re(t,s,!0,!0)}catch(e){return void be(t,"Invalid regex: "+s)}for(var l=Ce(t).getQuery(),c=[],u="",h=o;h<=i;h++)l.test(t.getLine(h))&&(c.push(h+1),u+=t.getLine(h)+"<br>");if(n){var p=0,f=function(){if(p<c.length){var e=c[p]+n;je.processCommand(t,e,{callback:f})}p++};f()}else be(t,u)}else be(t,"Regular Expression missing from global")},substitute:function(t,e){if(!t.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var r,n,o,i,a=e.argString,s=a?we(a,a[0]):[],l="",c=!1,u=!1;if(s.length)r=s[0],l=s[1],r&&"$"===r[r.length-1]&&(r=r.slice(0,r.length-1)+"\\n",l=l?l+"\n":"\n"),void 0!==l&&(l=A("pcre")?function(e){for(var t=new Qe.StringStream(e),r=[];!t.eol();){for(;t.peek()&&"\\"!=t.peek();)r.push(t.next());var n=!1;for(var o in Se)if(t.match(o,!0)){n=!0,r.push(Se[o]);break}n||r.push(t.next())}return r.join("")}(l):function(e){for(var t,r=!1,n=[],o=-1;o<e.length;o++){var i=e.charAt(o)||"",a=e.charAt(o+1)||"";xe[i+a]?(n.push(xe[i+a]),o++):r?(n.push(i),r=!1):"\\"===i?(r=!0,t=a,m.test(t)||"$"===a?n.push("$"):"/"!==a&&"\\"!==a&&n.push("\\")):("$"===i&&n.push("$"),n.push(i),"/"===a&&n.push("\\"))}return n.join("")}(l),_.lastSubstituteReplacePart=l),n=s[2]?s[2].split(" "):[];else if(a&&a.length)return void be(t,"Substitutions should be of the form :s/pattern/replace/");if(n&&(o=n[0],i=parseInt(n[1]),o&&(-1!=o.indexOf("c")&&(c=!0,o.replace("c","")),-1!=o.indexOf("g")&&(u=!0,o.replace("g","")),r=r.replace(/\//g,"\\/")+"/"+o)),r)try{Re(t,r,!0,!0)}catch(e){return void be(t,"Invalid regex: "+r)}if(void 0!==(l=l||_.lastSubstituteReplacePart)){var h=Ce(t).getQuery(),p=void 0!==e.line?e.line:t.getCursor().line,f=e.lineEnd||p;p==t.firstLine()&&f==t.lastLine()&&(f=1/0),i&&(f=(p=f)+i-1);var d=U(t,Ge(p,0));!function(o,e,n,i,a,s,r,l,c){var u=!(o.state.vim.exMode=!0),h=s.from();function p(){o.operation(function(){for(;!u;)f(),d();m()})}function f(){var e=o.getRange(s.from(),s.to()),t=e.replace(r,l);s.replace(t)}function d(){for(;s.findNext()&&(e=s.from(),t=i,r=a,"number"!=typeof e&&(e=e.line),t instanceof Array?w(e,t):r?t<=e&&e<=r:e==t);)if(n||!h||s.from().line!=h.line)return o.scrollIntoView(s.from(),30),o.setSelection(s.from(),s.to()),h=s.from(),void(u=!1);var e,t,r;u=!0}function m(e){if(e&&e(),o.focus(),h){o.setCursor(h);var t=o.state.vim;t.exMode=!1,t.lastHPos=t.lastHSPos=h.ch}c&&c()}d(),u?be(o,"No matches for "+r.source):e?Te(o,{prefix:"replace with <strong>"+l+"</strong> (y/n/a/q/l)",onKeyDown:function(e,t,r){switch(Qe.e_stop(e),Qe.keyName(e)){case"Y":f(),d();break;case"N":d();break;case"A":var n=c;c=void 0,o.operation(p),c=n;break;case"L":f();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":m(r)}return u&&m(r),!0}}):(p(),c&&c())}(t,c,u,p,f,t.getSearchCursor(h,d),h,l,e.callback)}else be(t,"No previous substitute regular expression")},redo:Qe.commands.redo,undo:Qe.commands.undo,write:function(e){Qe.commands.save?Qe.commands.save(e):e.save&&e.save()},nohlsearch:function(e){Be(e)},yank:function(e){var t=z(e.getCursor()).line,r=e.getLine(t);_.registerController.pushText("0","yank",r,!0,!0)},delmarks:function(e,t){if(t.argString&&re(t.argString))for(var r=e.state.vim,n=new Qe.StringStream(re(t.argString));!n.eol();){n.eatSpace();var o=n.pos;if(!n.match(/[a-zA-Z]/,!1))return void be(e,"Invalid argument: "+t.argString.substring(o));var i=n.next();if(n.match("-",!0)){if(!n.match(/[a-zA-Z]/,!1))return void be(e,"Invalid argument: "+t.argString.substring(o));var a=i,s=n.next();if(!(d(a)&&d(s)||k(a)&&k(s)))return void be(e,"Invalid argument: "+a+"-");var l=a.charCodeAt(0),c=s.charCodeAt(0);if(c<=l)return void be(e,"Invalid argument: "+t.argString.substring(o));for(var u=0;u<=c-l;u++){var h=String.fromCharCode(l+u);delete r.marks[h]}}else delete r.marks[i]}else be(e,"Argument required")}},je=new Ne;function He(e){var t=e.state.vim,r=_.macroModeState,n=_.registerController.getRegister("."),o=r.isPlaying,i=r.lastInsertModeChanges,a=[];if(!o){for(var s=i.inVisualBlock&&t.lastSelection?t.lastSelection.visualBlock.height:1,l=i.changes,c=(a=[],0);c<l.length;)a.push(l[c]),l[c]instanceof Ue?c++:c+=s;i.changes=a,e.off("change",We),Qe.off(e.getInputField(),"keydown",Je)}!o&&1<t.insertModeRepeat&&($e(e,t,t.insertModeRepeat-1,!0),t.lastEditInputState.repeatOverride=t.insertModeRepeat),delete t.insertModeRepeat,t.insertMode=!1,e.setCursor(e.getCursor().line,e.getCursor().ch-1),e.setOption("keyMap","vim"),e.setOption("disableInput",!0),e.toggleOverwrite(!1),n.setText(i.changes.join("")),Qe.signal(e,"vim-mode-change",{mode:"normal"}),r.isRecording&&function(e){if(!e.isPlaying){var t=e.latestRegister,r=_.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}(r)}function _e(e){ze.unshift(e)}function Fe(e,t,r,n){var o=_.registerController.getRegister(n);if(":"==n)return o.keyBuffer[0]&&je.processCommand(e,o.keyBuffer[0]),void(r.isPlaying=!1);var i=o.keyBuffer,a=0;r.isPlaying=!0,r.replaySearchQueries=o.searchQueries.slice(0);for(var s=0;s<i.length;s++)for(var l,c,u=i[s];u;)if(c=(l=/<\w+-.+?>|<\w+>|./.exec(u))[0],u=u.substring(l.index+c.length),Qe.Vim.handleKey(e,c,"macro"),t.insertMode){var h=o.insertModeChanges[a++].changes;qe(e,_.macroModeState.lastInsertModeChanges.changes=h,1),He(e)}r.isPlaying=!1}function We(e,t){var r=_.macroModeState,n=r.lastInsertModeChanges;if(!r.isPlaying)for(;t;){if(n.expectCursorActivityForChange=!0,"+input"==t.origin||"paste"==t.origin||void 0===t.origin){var o=t.text.join("\n");n.maybeReset&&(n.changes=[],n.maybeReset=!1),e.state.overwrite&&!/\n/.test(o)?n.changes.push([o]):n.changes.push(o)}t=t.next}}function Ve(e){var t=e.state.vim;if(t.insertMode){var r=_.macroModeState;if(r.isPlaying)return;var n=r.lastInsertModeChanges;n.expectCursorActivityForChange?n.expectCursorActivityForChange=!1:n.maybeReset=!0}else e.curOp.isVimOp||function(e,t){var r=e.getCursor("anchor"),n=e.getCursor("head");if(t.visualMode&&!e.somethingSelected()?le(e,!1):t.visualMode||t.insertMode||!e.somethingSelected()||(t.visualMode=!0,t.visualLine=!1,Qe.signal(e,"vim-mode-change",{mode:"visual"})),t.visualMode){var o=G(n,r)?0:-1,i=G(n,r)?-1:0;n=$(n,0,o),r=$(r,0,i),t.sel={anchor:r,head:n},ve(e,t,"<",X(n,r)),ve(e,t,">",Y(n,r))}else t.insertMode||(t.lastHPos=e.getCursor().ch)}(e,t);t.visualMode&&De(e)}function De(e){var t=e.state.vim,r=U(e,z(t.sel.head)),n=$(r,0,1);t.fakeCursor&&t.fakeCursor.clear(),t.fakeCursor=e.markText(r,n,{className:"cm-animate-fat-cursor"})}function Ue(e){this.keyName=e}function Je(e){var t=_.macroModeState.lastInsertModeChanges,r=Qe.keyName(e);r&&(-1==r.indexOf("Delete")&&-1==r.indexOf("Backspace")||Qe.lookupKey(r,"vim-insert",function(){return t.maybeReset&&(t.changes=[],t.maybeReset=!1),t.changes.push(new Ue(r)),!0}))}function $e(r,n,e,t){var o=_.macroModeState;o.isPlaying=!0;var i=!!n.lastEditActionCommand,a=n.inputState;function s(){i?H.processAction(r,n,n.lastEditActionCommand):H.evalInput(r,n)}function l(e){if(0<o.lastInsertModeChanges.changes.length){e=n.lastEditActionCommand?e:1;var t=o.lastInsertModeChanges;qe(r,t.changes,e)}}if(n.inputState=n.lastEditInputState,i&&n.lastEditActionCommand.interlaceInsertRepeat)for(var c=0;c<e;c++)s(),l(1);else t||s(),l(e);n.inputState=a,n.insertMode&&!t&&He(r),o.isPlaying=!1}function qe(t,e,r){function n(e){return"string"==typeof e?Qe.commands[e](t):e(t),!0}var o,i,a=t.getCursor("head"),s=_.macroModeState.lastInsertModeChanges.inVisualBlock;if(s){var l=t.state.vim.lastSelection,c=(o=l.anchor,{line:(i=l.head).line-o.line,ch:i.line-o.line});oe(t,a,c.line+1),r=t.listSelections().length,t.setCursor(a)}for(var u=0;u<r;u++){s&&t.setCursor($(a,u,0));for(var h=0;h<e.length;h++){var p=e[h];if(p instanceof Ue)Qe.lookupKey(p.keyName,"vim-insert",n);else if("string"==typeof p){var f=t.getCursor();t.replaceRange(p,f,f)}else{var d=t.getCursor(),m=$(d,0,p[0].length);t.replaceRange(p[0],d,m)}}}s&&t.setCursor($(a,0,1))}return Qe.keyMap.vim={attach:o,detach:e,call:t},x("insertModeEscKeysTimeout",200,"number"),Qe.keyMap["vim-insert"]={fallthrough:["default"],attach:o,detach:e,call:t},Qe.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:o,detach:e,call:t},E(),O}()}); -\ No newline at end of file diff --git a/lib/the-matrix.css b/lib/the-matrix.css @@ -0,0 +1,30 @@ +.cm-s-the-matrix.CodeMirror { background: #000000; color: #00FF00; } +.cm-s-the-matrix div.CodeMirror-selected { background: #2D2D2D; } +.cm-s-the-matrix .CodeMirror-line::selection, .cm-s-the-matrix .CodeMirror-line > span::selection, .cm-s-the-matrix .CodeMirror-line > span > span::selection { background: rgba(45, 45, 45, 0.99); } +.cm-s-the-matrix .CodeMirror-line::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span::-moz-selection, .cm-s-the-matrix .CodeMirror-line > span > span::-moz-selection { background: rgba(45, 45, 45, 0.99); } +.cm-s-the-matrix .CodeMirror-gutters { background: #060; border-right: 2px solid #00FF00; } +.cm-s-the-matrix .CodeMirror-guttermarker { color: #0f0; } +.cm-s-the-matrix .CodeMirror-guttermarker-subtle { color: white; } +.cm-s-the-matrix .CodeMirror-linenumber { color: #FFFFFF; } +.cm-s-the-matrix .CodeMirror-cursor { border-left: 1px solid #00FF00; } + +.cm-s-the-matrix span.cm-keyword { color: #008803; font-weight: bold; } +.cm-s-the-matrix span.cm-atom { color: #3FF; } +.cm-s-the-matrix span.cm-number { color: #FFB94F; } +.cm-s-the-matrix span.cm-def { color: #99C; } +.cm-s-the-matrix span.cm-variable { color: #F6C; } +.cm-s-the-matrix span.cm-variable-2 { color: #C6F; } +.cm-s-the-matrix span.cm-variable-3, .cm-s-the-matrix span.cm-type { color: #96F; } +.cm-s-the-matrix span.cm-property { color: #62FFA0; } +.cm-s-the-matrix span.cm-operator { color: #999; } +.cm-s-the-matrix span.cm-comment { color: #CCCCCC; } +.cm-s-the-matrix span.cm-string { color: #39C; } +.cm-s-the-matrix span.cm-meta { color: #C9F; } +.cm-s-the-matrix span.cm-qualifier { color: #FFF700; } +.cm-s-the-matrix span.cm-builtin { color: #30a; } +.cm-s-the-matrix span.cm-bracket { color: #cc7; } +.cm-s-the-matrix span.cm-tag { color: #FFBD40; } +.cm-s-the-matrix span.cm-attribute { color: #FFF700; } +.cm-s-the-matrix span.cm-error { color: #FF0000; } + +.cm-s-the-matrix .CodeMirror-activeline-background { background: #040; } diff --git a/styles/main.css b/styles/main.css @@ -135,3 +135,7 @@ html, body { #book .CodeMirror { height: 100%; } + +#book .CodeMirror-cursor { + width: 10px; +}