2015-05-15 00:46:32 +08:00
|
|
|
ace.define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/dom","ace/lib/oop","ace/lib/keys","ace/lib/event","ace/search","ace/lib/useragent","ace/search_highlight","ace/commands/multi_select_commands","ace/mode/text","ace/multi_select"],function(e,t,n){"use strict";function r(){function t(e){return typeof e!="object"?e+"":"line"in e?e.line+":"+e.ch:"anchor"in e?t(e.anchor)+"->"+t(e.head):Array.isArray(e)?"["+e.map(function(e){return t(e)})+"]":JSON.stringify(e)}var e="";for(var n=0;n<arguments.length;n++){var r=arguments[n],i=t(r);e+=i+" "}console.log(e)}function m(e){return{row:e.line,column:e.ch}}function g(e){return new w(e.row,e.column)}function S(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),v.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",Xn),et(e),v.on(e.getInputField(),"paste",O(e))}function x(e){e.setOption("disableInput",!1),e.off("cursorActivity",Xn),v.off(e.getInputField(),"paste",O(e)),e.state.vim=null}function T(e,t){this==v.keyMap.vim&&v.rmClass(e.getWrapperElement(),"cm-fat-cursor"),(!t||t.attach!=N)&&x(e,!1)}function N(e,t){this==v.keyMap.vim&&v.addClass(e.getWrapperElement(),"cm-fat-cursor"),(!t||t.attach!=N)&&S(e)}function C(e,t){if(!t)return undefined;var n=A(e);if(!n)return!1;var r=v.Vim.findKey(t,n);return typeof r=="function"&&v.signal(t,"vim-keypress",n),r}function A(e){if(e.charAt(0)=="'")return e.charAt(1);var t=e.split("-");/-$/.test(e)&&t.splice(-2,2,"-");var n=t[t.length-1];if(t.length==1&&t[0].length==1)return!1;if(t.length==2&&t[0]=="Shift"&&n.length==1)return!1;var r=!1;for(var i=0;i<t.length;i++){var s=t[i];s in k?t[i]=k[s]:r=!0,s in L&&(t[i]=L[s])}return r?(W(n)&&(t[t.length-1]=n.toLowerCase()),"<"+t.join("-")+">"):!1}function O(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(wt(e.getCursor(),0,1)),mt.enterInsertMode(e,{},t))}),t.onPasteFn}function P(e,t){var n=[];for(var r=e;r<e+t;r++)n.push(String.fromCharCode(r));return n}function q(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function R(e){return/^[a-z]$/.test(e)}function U(e){return"()[]{}".indexOf(e)!=-1}function z(e){return M.test(e)}function W(e){return/^[A-Z]$/.test(e)}function X(e){return/^\s*$/.test(e)}function V(e,t){for(var n=0;n<t.length;n++)if(t[n]==e)return!0;return!1}function J(e,t,n,r,i){if(t===undefined&&!i)throw Error("defaultValue is required unless callback is provided");n||(n="string"),$[e]={type:n,defaultValue:t,callback:i};if(r)for(var s=0;s<r.length;s++)$[r[s]]=$[e];t&&K(e,t)}function K(e,t,n,r){var i=$[e];r=r||{};var s=r.scope;if(!i)throw Error("Unknown option: "+e);if(i.type=="boolean"){if(t&&t!==!0)throw Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}i.callback?(s!=="local"&&i.callback(t,undefined),s!=="global"&&n&&i.callback(t,n)):(s!=="local"&&(i.value=i.type=="boolean"?!!t:t),s!=="global"&&n&&(n.state.vim.options[e]={value:t}))}function Q(e,t,n){var r=$[e];n=n||{};var i=n.scope;if(!r)throw Error("Unknown option: "+e);if(r.callback){var s=t&&r.callback(undefined,t);if(i!=="global"&&s!==undefined)return s;if(i!=="local")return r.callback();return}var s=i!=="global"&&t&&t.state.vim.options[e];return(s||i!=="local"&&r||{}).value}function Z(){this.latestRegister=undefined,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=undefined,this.lastInsertModeChanges=Y()}function et(e){return e.state.vim||(e.state.vim={inputState:new st,lastEditInputState:undefined,lastEditActionCommand:undefined,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:undefined,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}}),e.state.vim}function nt(){tt={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:undefined,jumpList:G(),macroModeState:new Z,lastChararacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new at({}),searchHistoryController:new ft({}),exCommandHistoryController:new ft({})};for(var e in $){var t=$[e];t.value=t
|