mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
www/codemirror/fhem_codemirror.js: New codemirrorParam 'keyMap', Added vim.js for VIM-KeyMap. Forum #54112
git-svn-id: https://svn.fhem.de/fhem/trunk@11602 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
019e51fbfc
commit
85402e1511
@ -1,5 +1,7 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: fhem_codemirror: Added new codemirrorParams:
|
||||
keyMap, jumpToLine, jumpToLine_extraKey
|
||||
- feature: 10_pilight_ctrl: NEW: protocol oregon_21 for temperature
|
||||
- deleted: 52_I2C_GY30_BH1750FVI: Arno Augustin hatte fast zeitgleich
|
||||
eine technisch bessere Variante entwickelt. Diese ist
|
||||
|
@ -16,6 +16,7 @@ var cm_attr = {
|
||||
indentWithTabs: true,
|
||||
autofocus: true,
|
||||
lineNumbers: true,
|
||||
keyMap: false,
|
||||
jumpToLine: false,
|
||||
jumpToLine_extraKey: false,
|
||||
smartIndent: false,
|
||||
@ -103,6 +104,9 @@ function AddCodeMirror(e, cb) {
|
||||
cm_attr.extraKeys[cm_attr.jumpToLine_extraKey] = 'jumpToLine';
|
||||
}
|
||||
}
|
||||
if (cm_attr.keyMap) {
|
||||
cm_active++; loadScript("codemirror/"+cm_attr.keyMap+".js", function(){cm_loaded++;} );
|
||||
}
|
||||
|
||||
// editor user preferences
|
||||
if (cm_attr.height) {
|
||||
|
139
fhem/www/codemirror/vim.js
Normal file
139
fhem/www/codemirror/vim.js
Normal file
@ -0,0 +1,139 @@
|
||||
(function(q){"object"==typeof exports&&"object"==typeof module?q(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"],q):q(CodeMirror)})(function(q){var D=[{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:"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:"<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:"moveToEol",motionArgs:{inclusive:!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:"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"}],wa=[{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"}],m=q.Pos;q.Vim=
|
||||
function(){function ka(a,b){this==q.keyMap.vim&&q.rmClass(a.getWrapperElement(),"cm-fat-cursor");b&&b.attach==S||(a.setOption("disableInput",!1),a.off("cursorActivity",xa),q.off(a.getInputField(),"paste",ya(a)),a.state.vim=null)}function S(a,b){this==q.keyMap.vim&&q.addClass(a.getWrapperElement(),"cm-fat-cursor");b&&b.attach==S||(a.setOption("disableInput",!0),a.setOption("showCursorWhenSelecting",!1),q.signal(a,"vim-mode-change",{mode:"normal"}),a.on("cursorActivity",xa),aa(a),q.on(a.getInputField(),
|
||||
"paste",ya(a)))}function la(a,b){if(b){var c=fb(a);if(!c)return!1;var d=q.Vim.findKey(b,c);"function"==typeof d&&q.signal(b,"vim-keypress",c);return d}}function fb(a){if("'"==a.charAt(0))return a.charAt(1);a=a.split(/-(?!$)/);var b=a[a.length-1];if(1==a.length&&1==a[0].length||2==a.length&&"Shift"==a[0]&&1==b.length)return!1;for(var c=!1,d=0;d<a.length;d++){var f=a[d];f in za?a[d]=za[f]:c=!0;f in Aa&&(a[d]=Aa[f])}if(!c)return!1;T(b)&&(a[a.length-1]=b.toLowerCase());return"<"+a.join("-")+">"}function ya(a){var b=
|
||||
a.state.vim;b.onPasteFn||(b.onPasteFn=function(){b.insertMode||(a.setCursor(y(a.getCursor(),0,1)),ba.enterInsertMode(a,{},b))});return b.onPasteFn}function ma(a,b){for(var c=[],d=a;d<a+b;d++)c.push(String.fromCharCode(d));return c}function Ba(a,b){return b>=a.firstLine()&&b<=a.lastLine()}function T(a){return/^[A-Z]$/.test(a)}function na(a,b){for(var c=0;c<b.length;c++)if(b[c]==a)return!0;return!1}function ca(a,b,c,d,f){if(void 0===b&&!f)throw Error("defaultValue is required unless callback is provided");
|
||||
c||(c="string");J[a]={type:c,defaultValue:b,callback:f};if(d)for(c=0;c<d.length;c++)J[d[c]]=J[a];b&&oa(a,b)}function oa(a,b,c,d){var f=J[a];d=d||{};d=d.scope;if(!f)throw Error("Unknown option: "+a);if("boolean"==f.type){if(b&&!0!==b)throw Error("Invalid argument: "+a+"="+b);!1!==b&&(b=!0)}f.callback?("local"!==d&&f.callback(b,void 0),"global"!==d&&c&&f.callback(b,c)):("local"!==d&&(f.value="boolean"==f.type?!!b:b),"global"!==d&&c&&(c.state.vim.options[a]={value:b}))}function U(a,b,c){var d=J[a];c=
|
||||
c||{};c=c.scope;if(!d)throw Error("Unknown option: "+a);if(d.callback){a=b&&d.callback(void 0,b);if("global"!==c&&void 0!==a)return a;if("local"!==c)return d.callback()}else return a="global"!==c&&b&&b.state.vim.options[a],(a||"local"!==c&&d||{}).value}function Ca(){this.latestRegister=void 0;this.isRecording=this.isPlaying=!1;this.replaySearchQueries=[];this.onRecordingDone=void 0;this.lastInsertModeChanges=Da()}function aa(a){a.state.vim||(a.state.vim={inputState:new da,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:{}});return a.state.vim}function Ea(){r={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:gb(),macroModeState:new Ca,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Fa({}),searchHistoryController:new pa({}),
|
||||
exCommandHistoryController:new pa({})};for(var a in J){var b=J[a];b.value=b.defaultValue}}function da(){this.prefixRepeat=[];this.motionRepeat=[];this.motionArgs=this.motion=this.operatorArgs=this.operator=null;this.keyBuffer=[];this.registerName=null}function z(a,b){a.state.vim.inputState=new da;q.signal(a,"vim-command-done",b)}function E(a,b,c){this.clear();this.keyBuffer=[a||""];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!!b;this.blockwise=!!c}function Fa(a){this.registers=a;
|
||||
this.unnamedRegister=a['"']=new E;a["."]=new E;a[":"]=new E;a["/"]=new E}function pa(){this.historyBuffer=[];this.iterator=0;this.initialPrefix=null}function Ga(a,b){for(var c=[],d=0;d<b;d++)c.push(a);return c}function A(a,b,c){var d=Math.min(Math.max(a.firstLine(),b.line),a.lastLine());a=B(a,d)-1;return m(d,Math.min(Math.max(0,b.ch),c?a+1:a))}function ea(a){var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function y(a,b,c){"object"===typeof b&&(c=b.ch,b=b.line);return m(a.line+b,a.ch+
|
||||
c)}function hb(a,b){return{line:b.line-a.line,ch:b.line-a.line}}function Ha(a,b,c){return function(){for(var d=0;d<c;d++)b(a)}}function x(a){return m(a.line,a.ch)}function F(a,b){return a.ch==b.ch&&a.line==b.line}function w(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch?!0:!1}function C(a,b){2<arguments.length&&(b=C.apply(void 0,Array.prototype.slice.call(arguments,1)));return w(a,b)?a:b}function P(a,b){2<arguments.length&&(b=P.apply(void 0,Array.prototype.slice.call(arguments,1)));return w(a,
|
||||
b)?b:a}function Ia(a,b,c){a=w(a,b);b=w(b,c);return a&&b}function B(a,b){return a.getLine(b).length}function qa(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function ib(a,b,c){var d=B(a,b);c=Array(c-d+1).join(" ");a.setCursor(m(b,d));a.replaceRange(c,a.getCursor())}function Ja(a,b){var c=[],d=a.listSelections(),f=x(a.clipPos(b)),e=!F(b,f),g;a:{var k=a.getCursor("head");for(g=0;g<d.length;g++){var h=F(d[g].anchor,k),l=F(d[g].head,k);if(h||l)break a}g=-1}var k=F(d[g].head,d[g].anchor),h=d.length-
|
||||
1,n=h-g>g?h:0;g=d[n].anchor;var q=Math.min(g.line,f.line),h=Math.max(g.line,f.line),l=g.ch,f=f.ch,d=d[n].head.ch-l,n=f-l;0<d&&0>=n?(l++,e||f--):0>d&&0<=n?(l--,k||f++):0>d&&-1==n&&(l--,f++);for(e=q;e<=h;e++)d={anchor:new m(e,l),head:new m(e,f)},c.push(d);a.setSelections(c);b.ch=f;g.ch=l;return g}function Ka(a,b,c){for(var d=[],f=0;f<c;f++){var e=y(b,f,0);d.push({anchor:e,head:e})}a.setSelections(d,0)}function jb(a,b){var c=b.lastSelection,d=function(){var b=a.getCursor(),d=a.getCursor(),g=c.visualBlock;
|
||||
if(g){for(var d=m(b.line+g.height,b.ch+g.width),g=[],k=b.line;k<d.line;k++){var h=m(k,b.ch),l=m(k,d.ch);g.push({anchor:h,head:l})}a.setSelections(g)}else k=c.anchorMark.find(),h=c.headMark.find(),g=h.line-k.line,k=h.ch-k.ch,d={line:d.line+g,ch:g?d.ch:k+d.ch},c.visualLine&&(b=m(b.line,0),d=m(d.line,B(a,d.line))),a.setSelection(b,d);return[b,d]};return b.visualMode?function(){var b=a.listSelections(),c=b[0],b=b[b.length-1],c=w(c.anchor,c.head)?c.anchor:c.head,b=w(b.anchor,b.head)?b.head:b.anchor;return[c,
|
||||
b]}():d()}function La(a,b){var c=b.sel.anchor,d=b.sel.head;b.lastPastedText&&(d=a.posFromIndex(a.indexFromPos(c)+b.lastPastedText.length),b.lastPastedText=null);b.lastSelection={anchorMark:a.setBookmark(c),headMark:a.setBookmark(d),anchor:x(c),head:x(d),visualMode:b.visualMode,visualLine:b.visualLine,visualBlock:b.visualBlock}}function V(a,b,c){var d=a.state.vim;b=b||d.sel;c=c||d.visualLine?"line":d.visualBlock?"block":"char";b=ra(a,b,c);a.setSelections(b.ranges,b.primary);Ma(a)}function ra(a,b,c,
|
||||
d){var f=x(b.head),e=x(b.anchor);if("char"==c)return f=d||w(b.head,b.anchor)?0:1,e=w(b.head,b.anchor)?1:0,f=y(b.head,0,f),e=y(b.anchor,0,e),{ranges:[{anchor:e,head:f}],primary:0};if("line"==c)return w(b.head,b.anchor)?(f.ch=0,e.ch=B(a,e.line)):(e.ch=0,b=a.lastLine(),f.line>b&&(f.line=b),f.ch=B(a,f.line)),{ranges:[{anchor:e,head:f}],primary:0};if("block"==c){b=Math.min(e.line,f.line);a=Math.min(e.ch,f.ch);c=Math.max(e.ch,f.ch)+1;e=Math.max(e.line,f.line)-b+1;f=f.line==b?0:e-1;d=[];for(var g=0;g<e;g++)d.push({anchor:m(b+
|
||||
g,a),head:m(b+g,c)});return{ranges:d,primary:f}}}function G(a,b){var c=a.state.vim;!1!==b&&a.setCursor(A(a,c.sel.head));La(a,c);c.visualMode=!1;c.visualLine=!1;c.visualBlock=!1;q.signal(a,"vim-mode-change",{mode:"normal"});c.fakeCursor&&c.fakeCursor.clear()}function H(a){if(!a)return 0;var b=a.search(/\S/);return-1==b?a.length:b}function fa(a,b,c,d,f){c=a.getCursor("head");1==a.getSelection().length&&(c=C(c,a.getCursor("anchor")));a=a.getLine(c.line);var e=c.ch;for(f=f?ga[0]:sa[0];!f(a.charAt(e));)if(e++,
|
||||
e>=a.length)return null;d?f=sa[0]:(f=ga[0],f(a.charAt(e))||(f=ga[1]));for(d=e;f(a.charAt(d))&&d<a.length;)d++;for(;f(a.charAt(e))&&0<=e;)e--;e++;if(b){for(b=d;/\s/.test(a.charAt(d))&&d<a.length;)d++;if(b==d){for(b=e;/\s/.test(a.charAt(e-1))&&0<e;)e--;e||(e=b)}}return{start:m(c.line,e),end:m(c.line,d)}}function Na(a,b){r.lastCharacterSearch.increment=a;r.lastCharacterSearch.forward=b.forward;r.lastCharacterSearch.selectedCharacter=b.selectedCharacter}function ta(a,b,c,d){for(var f=a.getCursor(),e=
|
||||
f.ch,g,k=0;k<b;k++){g=a.getLine(f.line);var h=d;g=c?g.indexOf(h,e+1):g.lastIndexOf(h,e-1);if(-1==g)return null;e=g}return m(a.getCursor().line,g)}function K(a,b,c,d){na(c,kb)&&(b.marks[c]&&b.marks[c].clear(),b.marks[c]=a.setBookmark(d))}function Oa(a,b,c,d,f){function e(b,c,d){return d?!a.getLine(b)!=!a.getLine(b+c):!!a.getLine(b)&&!a.getLine(b+c)}b=b.line;var g=a.firstLine(),k=a.lastLine(),h=b;if(d){for(;g<=h&&h<=k&&0<c;)e(h,d)&&c--,h+=d;return new m(h,0)}h=a.state.vim;h.visualLine&&e(b,1,!0)&&(h=
|
||||
h.sel.anchor,e(h.line,-1,!0)&&(f&&h.line==b||(b+=1)));d=!a.getLine(b);for(h=b;h<=k&&c;h++)e(h,1,!0)&&(f&&!a.getLine(h)==d||c--);c=new m(h,0);h>k&&!d?d=!0:f=!1;for(h=b;h>g&&(f&&!a.getLine(h)!=d&&h!=b||!e(h,-1,!0));h--);return{start:new m(h,0),end:c}}function Pa(){}function L(a){a=a.state.vim;return a.searchState_||(a.searchState_=new Pa)}function Qa(a){var b=Ra(a)||[];if(!b.length)return[];var c=[];if(0===b[0]){for(var d=0;d<b.length;d++)"number"==typeof b[d]&&c.push(a.substring(b[d]+1,b[d+1]));return c}}
|
||||
function Ra(a){for(var b=!1,c=[],d=0;d<a.length;d++){var f=a.charAt(d);b||"/"!=f||c.push(d);b=!b&&"\\"==f}return c}function u(a,b){a.openNotification?a.openNotification('<span style="color: red">'+b+"</span>",{bottom:!0,duration:5E3}):alert(b)}function ha(a,b){var c=(b.prefix||"")+" "+(b.desc||""),d=b.desc,f='<span style="font-family: monospace; white-space: pre">'+(b.prefix||"")+'<input type="text"></span>';d&&(f+=' <span style="color: #888">'+d+"</span>");d=b.onClose;a.openDialog?a.openDialog(f,
|
||||
d,{bottom:!0,value:b.value,onKeyDown:b.onKeyDown,onKeyUp:b.onKeyUp,selectValueOnOpen:!1}):d(prompt(c,""))}function W(a,b,c,d){if(b){var f=L(a),e;c=!!c;d=!!d;r.registerController.getRegister("/").setText(b);if(b instanceof RegExp)e=b;else{var g=Ra(b),k;g.length?(k=b.substring(0,g[0]),e=-1!=b.substring(g[0]).indexOf("i")):k=b;if(k){if(!U("pcre")){b=k;g=!1;k=[];for(var h=-1;h<b.length;h++){var l=b.charAt(h)||"",n=b.charAt(h+1)||"",m=n&&-1!="|(){".indexOf(n);g?("\\"===l&&m||k.push(l),g=!1):"\\"===l?(g=
|
||||
!0,n&&-1!="}".indexOf(n)&&(m=!0),m&&"\\"!==n||k.push(l)):(k.push(l),m&&"\\"!==n&&k.push("\\"))}k=k.join("")}d&&(c=/^[^A-Z]*$/.test(k));e=new RegExp(k,c||e?"i":void 0)}else e=null}if(e){Sa(a,e);a:if(a=f.getQuery(),e instanceof RegExp&&a instanceof RegExp){c=["global","multiline","ignoreCase","source"];for(d=0;d<c.length;d++)if(b=c[d],e[b]!==a[b]){a=!1;break a}a=!0}else a=!1;if(a)return e;f.setQuery(e);return e}}}function lb(a){if("^"==a.source.charAt(0))var b=!0;return{token:function(c){if(b&&!c.sol())c.skipToEnd();
|
||||
else{var d=c.match(a,!1);if(d){if(0==d[0].length)return c.next(),"searching";if(!c.sol()&&(c.backUp(1),!a.exec(c.next()+d[0])))return c.next(),null;c.match(a);return"searching"}for(;!c.eol()&&(c.next(),!c.match(a,!1)););}},query:a}}function Sa(a,b){var c=L(a),d=c.getOverlay();d&&b==d.query||(d&&a.removeOverlay(d),d=lb(b),a.addOverlay(d),a.showMatchesOnScrollbar&&(c.getScrollbarAnnotate()&&c.getScrollbarAnnotate().clear(),c.setScrollbarAnnotate(a.showMatchesOnScrollbar(b))),c.setOverlay(d))}function Ta(a,
|
||||
b,c,d){void 0===d&&(d=1);return a.operation(function(){for(var f=a.getCursor(),e=a.getSearchCursor(c,f),g=0;g<d;g++){var k=e.find(b);0==g&&k&&F(e.from(),f)&&(k=e.find(b));if(!k&&(e=a.getSearchCursor(c,b?m(a.lastLine()):m(a.firstLine(),0)),!e.find(b)))return}return e.from()})}function ua(a){var b=L(a);a.removeOverlay(L(a).getOverlay());b.setOverlay(null);b.getScrollbarAnnotate()&&(b.getScrollbarAnnotate().clear(),b.setScrollbarAnnotate(null))}function mb(a,b,c){"number"!=typeof a&&(a=a.line);return b instanceof
|
||||
Array?na(a,b):c?a>=b&&a<=c:a==b}function va(a){var b=a.getScrollInfo(),c=a.coordsChar({left:0,top:6+b.top},"local");a=a.coordsChar({left:0,top:b.clientHeight-10+b.top},"local");return{top:c.line,bottom:a.line}}function nb(a,b,c,d,f,e,g,k,h){function l(){a.operation(function(){for(;!v;)n(),m();p()})}function n(){var b=a.getRange(e.from(),e.to()).replace(g,k);e.replace(b)}function m(){for(;e.findNext()&&mb(e.from(),d,f);)if(c||!R||e.from().line!=R.line){a.scrollIntoView(e.from(),30);a.setSelection(e.from(),
|
||||
e.to());R=e.from();v=!1;return}v=!0}function p(b){b&&b();a.focus();R&&(a.setCursor(R),b=a.state.vim,b.exMode=!1,b.lastHPos=b.lastHSPos=R.ch);h&&h()}function r(b,c,d){q.e_stop(b);switch(q.keyName(b)){case "Y":n();m();break;case "N":m();break;case "A":b=h;h=void 0;a.operation(l);h=b;break;case "L":n();case "Q":case "Esc":case "Ctrl-C":case "Ctrl-[":p(d)}v&&p(d);return!0}a.state.vim.exMode=!0;var v=!1,R=e.from();m();v?u(a,"No matches for "+g.source):b?ha(a,{prefix:"replace with <strong>"+k+"</strong> (y/n/a/q/l)",
|
||||
onKeyDown:r}):(l(),h&&h())}function X(a){var b=a.state.vim,c=r.macroModeState,d=r.registerController.getRegister("."),f=c.isPlaying,e=c.lastInsertModeChanges,g;if(!f){var k=e.inVisualBlock?b.lastSelection.visualBlock.height:1,h=e.changes;g=[];for(var l=0;l<h.length;)g.push(h[l]),h[l]instanceof ia?l++:l+=k;e.changes=g;a.off("change",Ua);q.off(a.getInputField(),"keydown",Va)}!f&&1<b.insertModeRepeat&&(Wa(a,b,b.insertModeRepeat-1,!0),b.lastEditInputState.repeatOverride=b.insertModeRepeat);delete b.insertModeRepeat;
|
||||
b.insertMode=!1;a.setCursor(a.getCursor().line,a.getCursor().ch-1);a.setOption("keyMap","vim");a.setOption("disableInput",!0);a.toggleOverwrite(!1);d.setText(e.changes.join(""));q.signal(a,"vim-mode-change",{mode:"normal"});c.isRecording&&(c.isPlaying||(a=r.registerController.getRegister(c.latestRegister))&&a.pushInsertModeChanges&&a.pushInsertModeChanges(c.lastInsertModeChanges))}function Xa(a){D.unshift(a)}function Ua(a,b){var c=r.macroModeState,d=c.lastInsertModeChanges;if(!c.isPlaying)for(;b;){d.expectCursorActivityForChange=
|
||||
!0;if("+input"==b.origin||"paste"==b.origin||void 0===b.origin)c=b.text.join("\n"),d.changes.push(c);b=b.next}}function xa(a){var b=a.state.vim;if(b.insertMode){var c=r.macroModeState;if(c.isPlaying)return;c=c.lastInsertModeChanges;c.expectCursorActivityForChange?c.expectCursorActivityForChange=!1:c.changes=[]}else if(!a.curOp.isVimOp){var c=a.getCursor("anchor"),d=a.getCursor("head");b.visualMode&&!a.somethingSelected()?G(a,!1):b.visualMode||b.insertMode||!a.somethingSelected()||(b.visualMode=!0,
|
||||
b.visualLine=!1,q.signal(a,"vim-mode-change",{mode:"visual"}));if(b.visualMode){var f=w(d,c)?0:-1,e=w(d,c)?-1:0,d=y(d,0,f),c=y(c,0,e);b.sel={anchor:c,head:d};K(a,b,"<",C(d,c));K(a,b,">",P(d,c))}else b.insertMode||(b.lastHPos=a.getCursor().ch)}b.visualMode&&Ma(a)}function Ma(a){var b=a.state.vim,c=A(a,x(b.sel.head)),d=y(c,0,1);b.fakeCursor&&b.fakeCursor.clear();b.fakeCursor=a.markText(c,d,{className:"cm-animate-fat-cursor"})}function ia(a){this.keyName=a}function Va(a){function b(){c.changes.push(new ia(d));
|
||||
return!0}var c=r.macroModeState.lastInsertModeChanges,d=q.keyName(a);d&&(-1==d.indexOf("Delete")&&-1==d.indexOf("Backspace")||q.lookupKey(d,"vim-insert",b))}function Wa(a,b,c,d){function f(){k?N.processAction(a,b,b.lastEditActionCommand):N.evalInput(a,b)}function e(c){0<g.lastInsertModeChanges.changes.length&&(c=b.lastEditActionCommand?c:1,Ya(a,g.lastInsertModeChanges.changes,c))}var g=r.macroModeState;g.isPlaying=!0;var k=!!b.lastEditActionCommand,h=b.inputState;b.inputState=b.lastEditInputState;
|
||||
if(k&&b.lastEditActionCommand.interlaceInsertRepeat)for(var l=0;l<c;l++)f(),e(1);else d||f(),e(c);b.inputState=h;b.insertMode&&!d&&X(a);g.isPlaying=!1}function Ya(a,b,c){function d(b){if("string"==typeof b)q.commands[b](a);else b(a);return!0}var f=a.getCursor("head"),e=r.macroModeState.lastInsertModeChanges.inVisualBlock;e&&(c=a.state.vim.lastSelection,c=hb(c.anchor,c.head),Ka(a,f,c.line+1),c=a.listSelections().length,a.setCursor(f));for(var g=0;g<c;g++){e&&a.setCursor(y(f,g,0));for(var k=0;k<b.length;k++){var h=
|
||||
b[k];if(h instanceof ia)q.lookupKey(h.keyName,"vim-insert",d);else{var l=a.getCursor();a.replaceRange(h,l,l)}}}e&&a.setCursor(y(f,0,1))}q.defineOption("vimMode",!1,function(a,b,c){b&&"vim"!=a.getOption("keyMap")?a.setOption("keyMap","vim"):!b&&c!=q.Init&&/^vim/.test(a.getOption("keyMap"))&&a.setOption("keyMap","default")});var za={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},Aa={Enter:"CR",Backspace:"BS",Delete:"Del"},ob=/[\d]/,ga=[q.isWordChar,function(a){return a&&!q.isWordChar(a)&&!/\s/.test(a)}],
|
||||
sa=[function(a){return/\S/.test(a)}],ja=ma(65,26),Y=ma(97,26),Za=ma(48,10),kb=[].concat(ja,Y,Za,["<",">"]),$a=[].concat(ja,Y,Za,["-",'"',".",":","/"]),J={};ca("filetype",void 0,"string",["ft"],function(a,b){if(void 0!==b){if(void 0===a){var c=b.getOption("mode");return"null"==c?"":c}b.setOption("mode",""==a?"null":a)}});var gb=function(){var a=-1,b=0,c=0,d=Array(100);return{cachedCursor:void 0,add:function(f,e,g){function k(b){var c=++a%100,e=d[c];e&&e.clear();d[c]=f.setBookmark(b)}var h=d[a%100];
|
||||
h?(h=h.find())&&!F(h,e)&&k(e):k(e);k(g);b=a;c=a-100+1;0>c&&(c=0)},move:function(f,e){a+=e;a>b?a=b:a<c&&(a=c);var g=d[(100+a)%100];if(g&&!g.find()){var k=0<e?1:-1,h,l=f.getCursor();do if(a+=k,(g=d[(100+a)%100])&&(h=g.find())&&!F(l,h))break;while(a<b&&a>c)}return g}}},Da=function(a){return a?{changes:a.changes,expectCursorActivityForChange:a.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};Ca.prototype={exitMacroRecordMode:function(){var a=r.macroModeState;if(a.onRecordingDone)a.onRecordingDone();
|
||||
a.onRecordingDone=void 0;a.isRecording=!1},enterMacroRecordMode:function(a,b){var c=r.registerController.getRegister(b);c&&(c.clear(),this.latestRegister=b,a.openDialog&&(this.onRecordingDone=a.openDialog("(recording)["+b+"]",null,{bottom:!0})),this.isRecording=!0)}};var r,Z,ja={buildKeyMap:function(){},getRegisterController:function(){return r.registerController},resetVimGlobalState_:Ea,getVimGlobalState_:function(){return r},maybeInitVimState_:aa,suppressErrorLogging:!1,InsertModeKey:ia,map:function(a,
|
||||
b,c){I.map(a,b,c)},unmap:function(a,b){I.unmap(a,b)},setOption:oa,getOption:U,defineOption:ca,defineEx:function(a,b,c){if(!b)b=a;else if(0!==a.indexOf(b))throw Error('(Vim.defineEx) "'+b+'" is not a prefix of "'+a+'", command not registered');ab[a]=c;I.commandMap_[b]={name:a,shortName:b,type:"api"}},handleKey:function(a,b,c){a=this.findKey(a,b,c);if("function"===typeof a)return a()},findKey:function(a,b,c){function d(){if("<Esc>"==b)return z(a),g.visualMode?G(a):g.insertMode&&X(a),!0}function f(){if(d())return!0;
|
||||
for(var c=g.inputState.keyBuffer+=b,e=1==b.length,f=N.matchCommand(c,D,g.inputState,"insert");1<c.length&&"full"!=f.type;){var c=g.inputState.keyBuffer=c.slice(1),k=N.matchCommand(c,D,g.inputState,"insert");"none"!=k.type&&(f=k)}if("none"==f.type)return z(a),!1;if("partial"==f.type)return Z&&window.clearTimeout(Z),Z=window.setTimeout(function(){g.insertMode&&g.inputState.keyBuffer&&z(a)},U("insertModeEscKeysTimeout")),!e;Z&&window.clearTimeout(Z);e&&(e=a.getCursor(),a.replaceRange("",y(e,0,-(c.length-
|
||||
1)),e,"+input"));z(a);return f.command}function e(){var e;a:{var f=r.macroModeState;if(f.isRecording){if("q"==b){f.exitMacroRecordMode();z(a);e=!0;break a}"mapping"!=c&&(e=b,f.isPlaying||(f=r.registerController.getRegister(f.latestRegister))&&f.pushText(e))}e=void 0}if(e||d())return!0;e=g.inputState.keyBuffer+=b;if(/^[1-9]\d*$/.test(e))return!0;f=/^(\d*)(.*)$/.exec(e);if(!f)return z(a),!1;var k=N.matchCommand(f[2]||f[1],D,g.inputState,g.visualMode?"visual":"normal");if("none"==k.type)return z(a),
|
||||
!1;if("partial"==k.type)return!0;g.inputState.keyBuffer="";f=/^(\d*)(.*)$/.exec(e);f[1]&&"0"!=f[1]&&g.inputState.pushRepeatDigit(f[1]);return k.command}var g=aa(a),k;k=g.insertMode?f():e();return!1===k?void 0:!0===k?function(){}:function(){return a.operation(function(){a.curOp.isVimOp=!0;try{if("keyToKey"==k.type)for(var c=k.toKeys,d;c;)d=/<\w+-.+?>|<\w+>|./.exec(c),b=d[0],c=c.substring(d.index+b.length),q.Vim.handleKey(a,b,"mapping");else N.processCommand(a,g,k)}catch(e){throw a.state.vim=void 0,
|
||||
aa(a),q.Vim.suppressErrorLogging||console.log(e),e;}return!0})}},handleEx:function(a,b){I.processCommand(a,b)},defineMotion:function(a,b){O[a]=b},defineAction:function(a,b){ba[a]=b},defineOperator:function(a,b){bb[a]=b},mapCommand:function(a,b,c,d,f){a={keys:a,type:b};a[b]=c;a[b+"Args"]=d;for(var e in f)a[e]=f[e];Xa(a)},_mapCommand:Xa,defineRegister:function(a,b){var c=r.registerController.registers[a];if(!a||1!=a.length)throw Error("Register name must be 1 character");if(c[a])throw Error("Register already defined "+
|
||||
a);c[a]=b;$a.push(a)},exitVisualMode:G,exitInsertMode:X};da.prototype.pushRepeatDigit=function(a){this.operator?this.motionRepeat=this.motionRepeat.concat(a):this.prefixRepeat=this.prefixRepeat.concat(a)};da.prototype.getRepeat=function(){var a=0;if(0<this.prefixRepeat.length||0<this.motionRepeat.length)a=1,0<this.prefixRepeat.length&&(a*=parseInt(this.prefixRepeat.join(""),10)),0<this.motionRepeat.length&&(a*=parseInt(this.motionRepeat.join(""),10));return a};E.prototype={setText:function(a,b,c){this.keyBuffer=
|
||||
[a||""];this.linewise=!!b;this.blockwise=!!c},pushText:function(a,b){b&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0);this.keyBuffer.push(a)},pushInsertModeChanges:function(a){this.insertModeChanges.push(Da(a))},pushSearchQuery:function(a){this.searchQueries.push(a)},clear:function(){this.keyBuffer=[];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!1},toString:function(){return this.keyBuffer.join("")}};Fa.prototype={pushText:function(a,b,c,d,f){d&&"\n"==c.charAt(0)&&
|
||||
(c=c.slice(1)+"\n");d&&"\n"!==c.charAt(c.length-1)&&(c+="\n");var e=this.isValidRegister(a)?this.getRegister(a):null;if(e)T(a)?e.pushText(c,d):e.setText(c,d,f),this.unnamedRegister.setText(e.toString(),d);else{switch(b){case "yank":this.registers["0"]=new E(c,d,f);break;case "delete":case "change":-1==c.indexOf("\n")?this.registers["-"]=new E(c,d):(this.shiftNumericRegisters_(),this.registers["1"]=new E(c,d))}this.unnamedRegister.setText(c,d,f)}},getRegister:function(a){if(!this.isValidRegister(a))return this.unnamedRegister;
|
||||
a=a.toLowerCase();this.registers[a]||(this.registers[a]=new E);return this.registers[a]},isValidRegister:function(a){return a&&na(a,$a)},shiftNumericRegisters_:function(){for(var a=9;2<=a;a--)this.registers[a]=this.getRegister(""+(a-1))}};pa.prototype={nextMatch:function(a,b){var c=this.historyBuffer,d=b?-1:1;null===this.initialPrefix&&(this.initialPrefix=a);for(var f=this.iterator+d;b?0<=f:f<c.length;f+=d)for(var e=c[f],g=0;g<=e.length;g++)if(this.initialPrefix==e.substring(0,g))return this.iterator=
|
||||
f,e;if(f>=c.length)return this.iterator=c.length,this.initialPrefix;if(0>f)return a},pushInput:function(a){var b=this.historyBuffer.indexOf(a);-1<b&&this.historyBuffer.splice(b,1);a.length&&this.historyBuffer.push(a)},reset:function(){this.initialPrefix=null;this.iterator=this.historyBuffer.length}};var N={matchCommand:function(a,b,c,d){var f,e,g=[];f=[];for(var k=0;k<b.length;k++){var h=b[k],l;if(l=!("insert"==d&&"insert"!=h.context||h.context&&h.context!=d||c.operator&&"action"==h.type)){e=a;var n=
|
||||
h.keys;if("<character>"==n.slice(-11)){l=n.length-11;var m=e.slice(0,l),n=n.slice(0,l);e=m==n&&e.length>l?"full":0==n.indexOf(m)?"partial":!1}else e=e==n?"full":0==n.indexOf(e)?"partial":!1;l=e}l&&("partial"==e&&g.push(h),"full"==e&&f.push(h))}b=g.length&&g;f=f.length&&f;if(!f&&!b)return{type:"none"};if(!f&&b)return{type:"partial"};var p;for(b=0;b<f.length;b++)d=f[b],p||(p=d);if("<character>"==p.keys.slice(-11)){a=(f=/^.*(<[\w\-]+>)$/.exec(a))?f[1]:a.slice(-1);if(1<a.length)switch(a){case "<CR>":a=
|
||||
"\n";break;case "<Space>":a=" "}c.selectedCharacter=a}return{type:"full",command:p}},processCommand:function(a,b,c){b.inputState.repeatOverride=c.repeatOverride;switch(c.type){case "motion":this.processMotion(a,b,c);break;case "operator":this.processOperator(a,b,c);break;case "operatorMotion":this.processOperatorMotion(a,b,c);break;case "action":this.processAction(a,b,c);break;case "search":this.processSearch(a,b,c);break;case "ex":case "keyToEx":this.processEx(a,b,c)}},processMotion:function(a,b,
|
||||
c){b.inputState.motion=c.motion;b.inputState.motionArgs=ea(c.motionArgs);this.evalInput(a,b)},processOperator:function(a,b,c){var d=b.inputState;if(d.operator){if(d.operator==c.operator){d.motion="expandToLine";d.motionArgs={linewise:!0};this.evalInput(a,b);return}z(a)}d.operator=c.operator;d.operatorArgs=ea(c.operatorArgs);b.visualMode&&this.evalInput(a,b)},processOperatorMotion:function(a,b,c){var d=b.visualMode,f=ea(c.operatorMotionArgs);f&&d&&f.visualLine&&(b.visualLine=!0);this.processOperator(a,
|
||||
b,c);d||this.processMotion(a,b,c)},processAction:function(a,b,c){var d=b.inputState,f=d.getRepeat(),e=!!f,g=ea(c.actionArgs)||{};d.selectedCharacter&&(g.selectedCharacter=d.selectedCharacter);c.operator&&this.processOperator(a,b,c);c.motion&&this.processMotion(a,b,c);(c.motion||c.operator)&&this.evalInput(a,b);g.repeat=f||1;g.repeatIsExplicit=e;g.registerName=d.registerName;z(a);b.lastMotion=null;c.isEdit&&this.recordLastEdit(b,d,c);ba[c.action](a,g,b)},processSearch:function(a,b,c){function d(d,
|
||||
e,f){r.searchHistoryController.pushInput(d);r.searchHistoryController.reset();try{W(a,d,e,f)}catch(g){u(a,"Invalid regex: "+d);z(a);return}N.processMotion(a,b,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:c.searchArgs.toJumplist}})}function f(b){a.scrollTo(m.left,m.top);d(b,!0,!0);var c=r.macroModeState;c.isRecording&&(c.isPlaying||(c=r.registerController.getRegister(c.latestRegister))&&c.pushSearchQuery&&c.pushSearchQuery(b))}function e(b,c,d){b=q.keyName(b);"Up"==b||"Down"==
|
||||
b?(c=r.searchHistoryController.nextMatch(c,"Up"==b?!0:!1)||"",d(c)):"Left"!=b&&"Right"!=b&&"Ctrl"!=b&&"Alt"!=b&&"Shift"!=b&&r.searchHistoryController.reset();var e;try{e=W(a,c,!0,!0)}catch(f){}e?a.scrollIntoView(Ta(a,!k,e),30):(ua(a),a.scrollTo(m.left,m.top))}function g(b,c,d){var e=q.keyName(b);"Esc"==e||"Ctrl-C"==e||"Ctrl-["==e||"Backspace"==e&&""==c?(r.searchHistoryController.pushInput(c),r.searchHistoryController.reset(),W(a,n),ua(a),a.scrollTo(m.left,m.top),q.e_stop(b),z(a),d(),a.focus()):"Ctrl-U"==
|
||||
e&&(q.e_stop(b),d(""))}if(a.getSearchCursor){var k=c.searchArgs.forward,h=c.searchArgs.wholeWordOnly;L(a).setReversed(!k);var l=k?"/":"?",n=L(a).getQuery(),m=a.getScrollInfo();switch(c.searchArgs.querySrc){case "prompt":h=r.macroModeState;h.isPlaying?(l=h.replaySearchQueries.shift(),d(l,!0,!1)):ha(a,{onClose:f,prefix:l,desc:pb,onKeyUp:e,onKeyDown:g});break;case "wordUnderCursor":var p=fa(a,!1,!0,!1,!0),t=!0;p||(p=fa(a,!1,!0,!1,!1),t=!1);p&&(l=a.getLine(p.start.line).substring(p.start.ch,p.end.ch),
|
||||
l=t&&h?"\\b"+l+"\\b":l.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1"),r.jumpList.cachedCursor=a.getCursor(),a.setCursor(p.start),d(l,!0,!1))}}},processEx:function(a,b,c){function d(b){r.exCommandHistoryController.pushInput(b);r.exCommandHistoryController.reset();I.processCommand(a,b)}function f(b,c,d){var f=q.keyName(b);if("Esc"==f||"Ctrl-C"==f||"Ctrl-["==f||"Backspace"==f&&""==c)r.exCommandHistoryController.pushInput(c),r.exCommandHistoryController.reset(),q.e_stop(b),z(a),d(),a.focus();"Up"==f||"Down"==
|
||||
f?(c=r.exCommandHistoryController.nextMatch(c,"Up"==f?!0:!1)||"",d(c)):"Ctrl-U"==f?(q.e_stop(b),d("")):"Left"!=f&&"Right"!=f&&"Ctrl"!=f&&"Alt"!=f&&"Shift"!=f&&r.exCommandHistoryController.reset()}"keyToEx"==c.type?I.processCommand(a,c.exArgs.input):b.visualMode?ha(a,{onClose:d,prefix:":",value:"'<,'>",onKeyDown:f}):ha(a,{onClose:d,prefix:":",onKeyDown:f})},evalInput:function(a,b){var c=b.inputState,d=c.motion,f=c.motionArgs||{},e=c.operator,g=c.operatorArgs||{},k=c.registerName,h=b.sel,l=x(b.visualMode?
|
||||
A(a,h.head):a.getCursor("head")),n=x(b.visualMode?A(a,h.anchor):a.getCursor("anchor")),q=x(l),n=x(n),p,t,v;e&&this.recordLastEdit(b,c);v=void 0!==c.repeatOverride?c.repeatOverride:c.getRepeat();if(0<v&&f.explicitRepeat)f.repeatIsExplicit=!0;else if(f.noRepeat||!f.explicitRepeat&&0===v)v=1,f.repeatIsExplicit=!1;c.selectedCharacter&&(f.selectedCharacter=g.selectedCharacter=c.selectedCharacter);f.repeat=v;z(a);if(d){p=O[d](a,l,f,b);b.lastMotion=O[d];if(!p)return;f.toJumplist&&(d=r.jumpList,(c=d.cachedCursor)?
|
||||
(F(c,p)||r.jumpList.add(a,c,p),delete d.cachedCursor):F(l,p)||r.jumpList.add(a,l,p));p instanceof Array&&(t=p[0],p=p[1]);p||(p=x(l));b.visualMode?(b.visualBlock&&Infinity===p.ch||(p=A(a,p,b.visualBlock)),t&&(t=A(a,t,!0)),t=t||n,h.anchor=t,h.head=p,V(a),K(a,b,"<",w(t,p)?t:p),K(a,b,">",w(t,p)?p:t)):e||(p=A(a,p),a.setCursor(p.line,p.ch))}if(e){g.lastSel?(t=n,h=g.lastSel,p=Math.abs(h.head.line-h.anchor.line),l=Math.abs(h.head.ch-h.anchor.ch),p=h.visualLine?m(n.line+p,n.ch):h.visualBlock?m(n.line+p,n.ch+
|
||||
l):h.head.line==h.anchor.line?m(n.line,n.ch+l):m(n.line+p,n.ch),b.visualMode=!0,b.visualLine=h.visualLine,b.visualBlock=h.visualBlock,h=b.sel={anchor:t,head:p},V(a)):b.visualMode&&(g.lastSel={anchor:x(h.anchor),head:x(h.head),visualBlock:b.visualBlock,visualLine:b.visualLine});if(b.visualMode){if(t=C(h.head,h.anchor),h=P(h.head,h.anchor),q=b.visualLine||g.linewise,f=b.visualBlock?"block":q?"line":"char",t=ra(a,{anchor:t,head:h},f),q)if(h=t.ranges,"block"==f)for(f=0;f<h.length;f++)h[f].head.ch=B(a,
|
||||
h[f].head.line);else"line"==f&&(h[0].head=m(h[0].head.line+1,0))}else{t=x(t||n);h=x(p||q);w(h,t)&&(q=t,t=h,h=q);if(q=f.linewise||g.linewise)l=h,t.ch=0,l.ch=0,l.line++;else if(f.forward&&(l=h,d=a.getRange(t,l),/\n\s*$/.test(d))){d=d.split("\n");d.pop();for(c=d.pop();0<d.length&&c&&/^\s*$/.test(c);c=d.pop())l.line--,l.ch=0;c?(l.line--,l.ch=B(a,l.line)):l.ch=0}t=ra(a,{anchor:t,head:h},"char",!f.inclusive||q)}a.setSelections(t.ranges,t.primary);b.lastMotion=null;g.repeat=v;g.registerName=k;g.linewise=
|
||||
q;e=bb[e](a,g,t.ranges,n,p);b.visualMode&&G(a,null!=e);e&&a.setCursor(e)}},recordLastEdit:function(a,b,c){var d=r.macroModeState;d.isPlaying||(a.lastEditInputState=b,a.lastEditActionCommand=c,d.lastInsertModeChanges.changes=[],d.lastInsertModeChanges.expectCursorActivityForChange=!1)}},O={moveToTopLine:function(a,b,c){b=va(a).top+c.repeat-1;return m(b,H(a.getLine(b)))},moveToMiddleLine:function(a){var b=va(a),b=Math.floor(.5*(b.top+b.bottom));return m(b,H(a.getLine(b)))},moveToBottomLine:function(a,
|
||||
b,c){b=va(a).bottom-c.repeat+1;return m(b,H(a.getLine(b)))},expandToLine:function(a,b,c){return m(b.line+c.repeat-1,Infinity)},findNext:function(a,b,c){b=L(a);var d=b.getQuery();if(d){var f=!c.forward,f=b.isReversed()?!f:f;Sa(a,d);return Ta(a,f,d,c.repeat)}},goToMark:function(a,b,c,d){return(b=d.marks[c.selectedCharacter])?(b=b.find(),c.linewise?{line:b.line,ch:H(a.getLine(b.line))}:b):null},moveToOtherHighlightedEnd:function(a,b,c,d){return d.visualBlock&&c.sameLine?(b=d.sel,[A(a,m(b.anchor.line,
|
||||
b.head.ch)),A(a,m(b.head.line,b.anchor.ch))]):[d.sel.head,d.sel.anchor]},jumpToMark:function(a,b,c,d){for(var f=0;f<c.repeat;f++){var e=b,g;for(g in d.marks)if(/^[a-z]$/.test(g)){var k=d.marks[g].find();if(c.forward?!w(k,e):!w(e,k))if(!c.linewise||k.line!=e.line){var h=F(e,b),l=c.forward?Ia(e,k,b):Ia(b,k,e);if(h||l)b=k}}}c.linewise&&(b=m(b.line,H(a.getLine(b.line))));return b},moveByCharacters:function(a,b,c){a=c.repeat;return m(b.line,c.forward?b.ch+a:b.ch-a)},moveByLines:function(a,b,c,d){var f=
|
||||
b.ch;switch(d.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:f=d.lastHPos;break;default:d.lastHPos=f}var e=c.repeat+(c.repeatOffset||0),e=c.forward?b.line+e:b.line-e,g=a.firstLine(),k=a.lastLine();if(e<g&&b.line==g)return this.moveToStartOfLine(a,b,c,d);if(e>k&&b.line==k)return this.moveToEol(a,b,c,d);c.toFirstChar&&(f=H(a.getLine(e)),d.lastHPos=f);d.lastHSPos=a.charCoords(m(e,f),"div").left;return m(e,f)},moveByDisplayLines:function(a,
|
||||
b,c,d){switch(d.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:d.lastHSPos=a.charCoords(b,"div").left}var f=c.repeat;b=a.findPosV(b,c.forward?f:-f,"line",d.lastHSPos);b.hitSide&&(c.forward?c={top:a.charCoords(b,"div").top+8,left:d.lastHSPos}:(c=a.charCoords(m(a.firstLine(),0),"div"),c.left=d.lastHSPos),b=a.coordsChar(c,"div"));d.lastHPos=b.ch;return b},moveByPage:function(a,b,c){var d=c.repeat;return a.findPosV(b,
|
||||
c.forward?d:-d,"page")},moveByParagraph:function(a,b,c){return Oa(a,b,c.repeat,c.forward?1:-1)},moveByScroll:function(a,b,c,d){var f=a.getScrollInfo(),e=c.repeat;e||(e=f.clientHeight/(2*a.defaultTextHeight()));var g=a.charCoords(b,"local");c.repeat=e;b=O.moveByDisplayLines(a,b,c,d);if(!b)return null;c=a.charCoords(b,"local");a.scrollTo(null,f.top+c.top-g.top);return b},moveByWords:function(a,b,c){var d=b,f=c.repeat;b=!!c.forward;var e=!!c.wordEnd,g=!!c.bigWord;c=x(d);var k=[];(b&&!e||!b&&e)&&f++;
|
||||
for(var h=!(b&&e),l=0;l<f;l++){var n;b:{n=a;var q=b,p=g,r=h,v=d.line,u=d.ch,M=n.getLine(v),Q=q?1:-1,p=p?sa:ga;if(r&&""==M){v+=Q;M=n.getLine(v);if(!Ba(n,v)){n=null;break b}u=q?0:M.length}for(;;){if(r&&""==M){n={from:0,to:0,line:v};break b}for(var q=0<Q?M.length:-1,w,y;u!=q;){for(var A=!1,z=0;z<p.length&&!A;++z)if(p[z](M.charAt(u))){for(w=u;u!=q&&p[z](M.charAt(u));)u+=Q;y=u;A=w!=y;if(w!=d.ch||v!=d.line||y!=w+Q){n={from:Math.min(w,y+1),to:Math.max(w,y),line:v};break b}}A||(u+=Q)}v+=Q;if(!Ba(n,v)){n=
|
||||
null;break b}M=n.getLine(v);u=0<Q?0:M.length}}if(!n){g=B(a,a.lastLine());k.push(b?{line:a.lastLine(),from:g,to:g}:{line:0,from:0,to:0});break}k.push(n);d=m(n.line,b?n.to-1:n.from)}a=k.length!=f;f=k[0];g=k.pop();b&&!e?(a||f.from==c.ch&&f.line==c.line||(g=k.pop()),b=m(g.line,g.from)):b&&e?b=m(g.line,g.to-1):!b&&e?(a||f.to==c.ch&&f.line==c.line||(g=k.pop()),b=m(g.line,g.to)):b=m(g.line,g.from);return b},moveTillCharacter:function(a,b,c){a=ta(a,c.repeat,c.forward,c.selectedCharacter);b=c.forward?-1:1;
|
||||
Na(b,c);if(!a)return null;a.ch+=b;return a},moveToCharacter:function(a,b,c){var d=c.repeat;Na(0,c);return ta(a,d,c.forward,c.selectedCharacter)||b},moveToSymbol:function(a,b,c){var d=c.repeat,f=c.forward,e=c.selectedCharacter;c=x(a.getCursor());var g=f?1:-1,k=f?a.lineCount():-1,h=c.ch,l=c.line,n=a.getLine(l),f={lineText:n,nextCh:n.charAt(h),lastCh:null,index:h,symb:e,reverseSymb:(f?{")":"(","}":"{"}:{"(":")","{":"}"})[e],forward:f,depth:0,curMoveThrough:!1};if(h=qb[e]){e=cb[h].init;h=cb[h].isComplete;
|
||||
for(e&&e(f);l!==k&&d;)f.index+=g,f.nextCh=f.lineText.charAt(f.index),f.nextCh||(l+=g,f.lineText=a.getLine(l)||"",0<g?f.index=0:(e=f.lineText.length,f.index=0<e?e-1:0),f.nextCh=f.lineText.charAt(f.index)),h(f)&&(c.line=l,c.ch=f.index,d--);a=f.nextCh||f.curMoveThrough?m(l,f.index):c}else a=c;return a||b},moveToColumn:function(a,b,c,d){c=c.repeat;d.lastHPos=c-1;d.lastHSPos=a.charCoords(b,"div").left;b=a.getCursor().line;return A(a,m(b,c-1))},moveToEol:function(a,b,c,d){d.lastHPos=Infinity;b=m(b.line+
|
||||
c.repeat-1,Infinity);c=a.clipPos(b);c.ch--;d.lastHSPos=a.charCoords(c,"div").left;return b},moveToFirstNonWhiteSpaceCharacter:function(a,b){return m(b.line,H(a.getLine(b.line)))},moveToMatchedSymbol:function(a,b){var c=b.line,d=b.ch,f=a.getLine(c),e;do if((e=f.charAt(d++))&&-1!="()[]{}".indexOf(e)){var g=a.getTokenTypeAt(m(c,d));if("string"!==g&&"comment"!==g)break}while(e);return e?a.findMatchingBracket(m(c,d)).to:b},moveToStartOfLine:function(a,b){return m(b.line,0)},moveToLineOrEdgeOfDocument:function(a,
|
||||
b,c){b=c.forward?a.lastLine():a.firstLine();c.repeatIsExplicit&&(b=c.repeat-a.getOption("firstLineNumber"));return m(b,H(a.getLine(b)))},textObjectManipulation:function(a,b,c,d){var f={"'":!0,'"':!0},e=c.selectedCharacter;"b"==e?e="(":"B"==e&&(e="{");var g=!c.textObjectInner;if({"(":")",")":"(","{":"}","}":"{","[":"]","]":"["}[e]){var k,h;h={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[e];k={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[e];c=a.getLine(b.line).charAt(b.ch)===
|
||||
k?1:0;k=a.scanForBracket(m(b.line,b.ch+c),-1,null,{bracketRegex:h});h=a.scanForBracket(m(b.line,b.ch+c),1,null,{bracketRegex:h});if(k&&h){k=k.pos;h=h.pos;if(k.line==h.line&&k.ch>h.ch||k.line>h.line)b=k,k=h,h=b;g?h.ch+=1:k.ch+=1;b={start:k,end:h}}else b={start:b,end:b}}else if(f[e]){c=e;b=x(b);d=a.getLine(b.line).split("");e=d.indexOf(c);b.ch<e?b.ch=e:e<b.ch&&d[b.ch]==c&&(h=b.ch,--b.ch);if(d[b.ch]!=c||h)for(e=b.ch;-1<e&&!k;e--)d[e]==c&&(k=e+1);else k=b.ch+1;if(k&&!h)for(e=k,f=d.length;e<f&&!h;e++)d[e]==
|
||||
c&&(h=e);k&&h?(g&&(--k,++h),b={start:m(b.line,k),end:m(b.line,h)}):b={start:b,end:b}}else if("W"===e)b=fa(a,g,!0,!0);else if("w"===e)b=fa(a,g,!0,!1);else if("p"===e)if(b=Oa(a,b,c.repeat,0,g),c.linewise=!0,d.visualMode)d.visualLine||(d.visualLine=!0);else{if(g=d.inputState.operatorArgs)g.linewise=!0;b.end.line--}else return null;return a.state.vim.visualMode?(g=b.start,b=b.end,h=a.state.vim.sel,k=h.head,h=h.anchor,w(b,g)&&(c=b,b=g,g=c),w(k,h)?(k=C(g,k),h=P(h,b)):(h=C(g,h),k=P(k,b),k=y(k,0,-1),-1==
|
||||
k.ch&&k.line!=a.firstLine()&&(k=m(k.line-1,B(a,k.line-1)))),[h,k]):[b.start,b.end]},repeatLastCharacterSearch:function(a,b,c){var d=r.lastCharacterSearch,f=c.repeat,e=c.forward===d.forward,g=(d.increment?1:0)*(e?-1:1);a.moveH(-g,"char");c.inclusive=e?!0:!1;c=ta(a,f,e,d.selectedCharacter);if(!c)return a.moveH(g,"char"),b;c.ch+=g;return c}},bb={change:function(a,b,c){var d,f,e=a.state.vim;r.macroModeState.lastInsertModeChanges.inVisualBlock=e.visualBlock;if(e.visualMode)f=a.getSelection(),d=Ga("",c.length),
|
||||
a.replaceSelections(d),d=C(c[0].head,c[0].anchor);else{d=c[0].anchor;var g=c[0].head;f=a.getRange(d,g);e=e.lastEditInputState||{};if("moveByWords"==e.motion&&!/^\s*$/.test(f)){var k=/\s+$/.exec(f);k&&e.motionArgs&&e.motionArgs.forward&&(g=y(g,0,-k[0].length),f=f.slice(0,-k[0].length))}e=new m(d.line-1,Number.MAX_VALUE);k=a.firstLine()==a.lastLine();g.line>a.lastLine()&&b.linewise&&!k?a.replaceRange("",e,g):a.replaceRange("",d,g);b.linewise&&(k||(a.setCursor(e),q.commands.newlineAndIndent(a)),d.ch=
|
||||
Number.MAX_VALUE)}r.registerController.pushText(b.registerName,"change",f,b.linewise,1<c.length);ba.enterInsertMode(a,{head:d},a.state.vim)},"delete":function(a,b,c){var d,f=a.state.vim;if(f.visualBlock){d=a.getSelection();var e=Ga("",c.length);a.replaceSelections(e);c=c[0].anchor}else e=c[0].anchor,c=c[0].head,b.linewise&&c.line!=a.firstLine()&&e.line==a.lastLine()&&e.line==c.line-1&&(e.line==a.firstLine()?e.ch=0:e=m(e.line-1,B(a,e.line-1))),d=a.getRange(e,c),a.replaceRange("",e,c),c=e,b.linewise&&
|
||||
(c=O.moveToFirstNonWhiteSpaceCharacter(a,e));r.registerController.pushText(b.registerName,"delete",d,b.linewise,f.visualBlock);return A(a,c)},indent:function(a,b,c){var d=a.state.vim,f=c[0].anchor.line,e=d.visualBlock?c[c.length-1].anchor.line:c[0].head.line,d=d.visualMode?b.repeat:1;for(b.linewise&&e--;f<=e;f++)for(var g=0;g<d;g++)a.indentLine(f,b.indentRight);return O.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},changeCase:function(a,b,c,d,f){for(var e=a.getSelections(),g=[],k=b.toLower,h=
|
||||
0;h<e.length;h++){var l=e[h],n="";if(!0===k)n=l.toLowerCase();else if(!1===k)n=l.toUpperCase();else for(var m=0;m<l.length;m++)var p=l.charAt(m),n=n+(T(p)?p.toLowerCase():p.toUpperCase());g.push(n)}a.replaceSelections(g);return b.shouldMoveCursor?f:!a.state.vim.visualMode&&b.linewise&&c[0].anchor.line+1==c[0].head.line?O.moveToFirstNonWhiteSpaceCharacter(a,d):b.linewise?d:C(c[0].anchor,c[0].head)},yank:function(a,b,c,d){var f=a.state.vim;a=a.getSelection();c=f.visualMode?C(f.sel.anchor,f.sel.head,
|
||||
c[0].head,c[0].anchor):d;r.registerController.pushText(b.registerName,"yank",a,b.linewise,f.visualBlock);return c}},ba={jumpListWalk:function(a,b,c){c.visualMode||(c=b.repeat,b=(b=(b=r.jumpList.move(a,b.forward?c:-c))?b.find():void 0)?b:a.getCursor(),a.setCursor(b))},scroll:function(a,b,c){if(!c.visualMode){var d=b.repeat||1;c=a.defaultTextHeight();var f=a.getScrollInfo().top,d=c*d,f=b.forward?f+d:f-d,d=x(a.getCursor()),e=a.charCoords(d,"local");b.forward?f>e.top?(d.line+=(f-e.top)/c,d.line=Math.ceil(d.line),
|
||||
a.setCursor(d),e=a.charCoords(d,"local"),a.scrollTo(null,e.top)):a.scrollTo(null,f):(b=f+a.getScrollInfo().clientHeight,b<e.bottom?(d.line-=(e.bottom-b)/c,d.line=Math.floor(d.line),a.setCursor(d),e=a.charCoords(d,"local"),a.scrollTo(null,e.bottom-a.getScrollInfo().clientHeight)):a.scrollTo(null,f))}},scrollToCursor:function(a,b){var c=a.getCursor().line,d=a.charCoords(m(c,0),"local"),c=a.getScrollInfo().clientHeight,f=d.top,d=d.bottom-f;switch(b.position){case "center":f=f-c/2+d;break;case "bottom":f=
|
||||
f-c+d}a.scrollTo(null,f)},replayMacro:function(a,b,c){var d=b.selectedCharacter;b=b.repeat;var f=r.macroModeState;"@"==d&&(d=f.latestRegister);for(;b--;){var e=a,g=c,k=f,h=d,l=r.registerController.getRegister(h);if(":"==h)l.keyBuffer[0]&&I.processCommand(e,l.keyBuffer[0]);else{var h=l.keyBuffer,m=0;k.isPlaying=!0;k.replaySearchQueries=l.searchQueries.slice(0);for(var u=0;u<h.length;u++)for(var p=h[u],t,v;p;)t=/<\w+-.+?>|<\w+>|./.exec(p),v=t[0],p=p.substring(t.index+v.length),q.Vim.handleKey(e,v,"macro"),
|
||||
g.insertMode&&(t=l.insertModeChanges[m++].changes,r.macroModeState.lastInsertModeChanges.changes=t,Ya(e,t,1),X(e))}k.isPlaying=!1}},enterMacroRecordMode:function(a,b){r.macroModeState.enterMacroRecordMode(a,b.selectedCharacter)},enterInsertMode:function(a,b,c){if(!a.getOption("readOnly")){c.insertMode=!0;c.insertModeRepeat=b&&b.repeat||1;var d=b?b.insertAt:null,f=c.sel,e=b.head||a.getCursor("head"),g=a.listSelections().length;if("eol"==d)e=m(e.line,B(a,e.line));else if("charAfter"==d)e=y(e,0,1);else if("firstNonBlank"==
|
||||
d)e=O.moveToFirstNonWhiteSpaceCharacter(a,e);else if("startOfSelectedArea"==d)c.visualBlock?(e=m(Math.min(f.head.line,f.anchor.line),Math.min(f.head.ch,f.anchor.ch)),g=Math.abs(f.head.line-f.anchor.line)+1):e=f.head.line<f.anchor.line?f.head:m(f.anchor.line,0);else if("endOfSelectedArea"==d)c.visualBlock?(e=m(Math.min(f.head.line,f.anchor.line),Math.max(f.head.ch+1,f.anchor.ch)),g=Math.abs(f.head.line-f.anchor.line)+1):e=f.head.line>=f.anchor.line?y(f.head,0,1):m(f.anchor.line,0);else if("inplace"==
|
||||
d&&c.visualMode)return;a.setOption("keyMap","vim-insert");a.setOption("disableInput",!1);b&&b.replace?(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),q.signal(a,"vim-mode-change",{mode:"replace"})):(a.setOption("keyMap","vim-insert"),q.signal(a,"vim-mode-change",{mode:"insert"}));r.macroModeState.isPlaying||(a.on("change",Ua),q.on(a.getInputField(),"keydown",Va));c.visualMode&&G(a);Ka(a,e,g)}},toggleVisualMode:function(a,b,c){var d=b.repeat,f=a.getCursor();c.visualMode?c.visualLine^b.linewise||
|
||||
c.visualBlock^b.blockwise?(c.visualLine=!!b.linewise,c.visualBlock=!!b.blockwise,q.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),V(a)):G(a):(c.visualMode=!0,c.visualLine=!!b.linewise,c.visualBlock=!!b.blockwise,b=A(a,m(f.line,f.ch+d-1),!0),c.sel={anchor:f,head:b},q.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),V(a),K(a,c,"<",C(f,b)),K(a,c,">",P(f,b)))},reselectLastSelection:function(a,
|
||||
b,c){b=c.lastSelection;c.visualMode&&La(a,c);if(b){var d=b.anchorMark.find(),f=b.headMark.find();d&&f&&(c.sel={anchor:d,head:f},c.visualMode=!0,c.visualLine=b.visualLine,c.visualBlock=b.visualBlock,V(a),K(a,c,"<",C(d,f)),K(a,c,">",P(d,f)),q.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}))}},joinLines:function(a,b,c){var d;if(c.visualMode){b=a.getCursor("anchor");d=a.getCursor("head");if(w(d,b)){var f=d;d=b;b=f}d.ch=B(a,d.line)-1}else d=Math.max(b.repeat,
|
||||
2),b=a.getCursor(),d=A(a,m(b.line+d-1,Infinity));for(var e=0,g=b.line;g<d.line;g++){var e=B(a,b.line),f=m(b.line+1,B(a,b.line+1)),k=a.getRange(b,f),k=k.replace(/\n\s*/g," ");a.replaceRange(k,b,f)}b=m(b.line,e);c.visualMode&&G(a,!1);a.setCursor(b)},newLineAndEnterInsertMode:function(a,b,c){c.insertMode=!0;var d=x(a.getCursor());d.line!==a.firstLine()||b.after?(d.line=b.after?d.line:d.line-1,d.ch=B(a,d.line),a.setCursor(d),(q.commands.newlineAndIndentContinueComment||q.commands.newlineAndIndent)(a)):
|
||||
(a.replaceRange("\n",m(a.firstLine(),0)),a.setCursor(a.firstLine(),0));this.enterInsertMode(a,{repeat:b.repeat},c)},paste:function(a,b,c){var d=x(a.getCursor()),f=r.registerController.getRegister(b.registerName),e=f.toString();if(e){if(b.matchIndent)var g=a.getOption("tabSize"),k=function(a){var b=a.split("\t").length-1;a=a.split(" ").length-1;return b*g+1*a},h=a.getLine(a.getCursor().line),l=k(h.match(/^\s*/)[0]),h=e.replace(/\n$/,""),n=e!==h,q=k(e.match(/^\s*/)[0]),e=h.replace(/^\s*/gm,function(b){b=
|
||||
l+(k(b)-q);return 0>b?"":a.getOption("indentWithTabs")?Array(Math.floor(b/g)+1).join("\t"):Array(b+1).join(" ")}),e=e+(n?"\n":"");1<b.repeat&&(e=Array(b.repeat+1).join(e));h=f.linewise;f=f.blockwise;if(h)c.visualMode?e=c.visualLine?e.slice(0,-1):"\n"+e.slice(0,e.length-1)+"\n":b.after?(e="\n"+e.slice(0,e.length-1),d.ch=B(a,d.line)):d.ch=0;else{if(f)for(e=e.split("\n"),n=0;n<e.length;n++)e[n]=""==e[n]?" ":e[n];d.ch+=b.after?1:0}var p;if(c.visualMode){c.lastPastedText=e;b=jb(a,c);d=b[0];b=b[1];var n=
|
||||
a.getSelection(),t=a.listSelections(),t=Array(t.length).join("1").split("1");c.lastSelection&&(p=c.lastSelection.headMark.find());r.registerController.unnamedRegister.setText(n);f?(a.replaceSelections(t),b=m(d.line+e.length-1,d.ch),a.setCursor(d),Ja(a,b),a.replaceSelections(e),e=d):c.visualBlock?(a.replaceSelections(t),a.setCursor(d),a.replaceRange(e,d,d),e=d):(a.replaceRange(e,d,b),e=a.posFromIndex(a.indexFromPos(d)+e.length-1));p&&(c.lastSelection.headMark=a.setBookmark(p));h&&(e.ch=0)}else if(f){a.setCursor(d);
|
||||
for(n=0;n<e.length;n++)p=d.line+n,p>a.lastLine()&&a.replaceRange("\n",m(p,0)),B(a,p)<d.ch&&ib(a,p,d.ch);a.setCursor(d);Ja(a,m(d.line+e.length-1,d.ch));a.replaceSelections(e);e=d}else a.replaceRange(e,d),h&&b.after?e=m(d.line+1,H(a.getLine(d.line+1))):h&&!b.after?e=m(d.line,H(a.getLine(d.line))):!h&&b.after?(p=a.indexFromPos(d),e=a.posFromIndex(p+e.length-1)):(p=a.indexFromPos(d),e=a.posFromIndex(p+e.length));c.visualMode&&G(a,!1);a.setCursor(e)}},undo:function(a,b){a.operation(function(){Ha(a,q.commands.undo,
|
||||
b.repeat)();a.setCursor(a.getCursor("anchor"))})},redo:function(a,b){Ha(a,q.commands.redo,b.repeat)()},setRegister:function(a,b,c){c.inputState.registerName=b.selectedCharacter},setMark:function(a,b,c){K(a,c,b.selectedCharacter,a.getCursor())},replace:function(a,b,c){var d=b.selectedCharacter,f=a.getCursor(),e,g=a.listSelections();c.visualMode?(f=a.getCursor("start"),e=a.getCursor("end")):(e=a.getLine(f.line),b=f.ch+b.repeat,b>e.length&&(b=e.length),e=m(f.line,b));"\n"==d?(c.visualMode||a.replaceRange("",
|
||||
f,e),(q.commands.newlineAndIndentContinueComment||q.commands.newlineAndIndent)(a)):(b=a.getRange(f,e),b=b.replace(/[^\n]/g,d),c.visualBlock?(f=Array(a.getOption("tabSize")+1).join(" "),b=a.getSelection(),b=b.replace(/\t/g,f).replace(/[^\n]/g,d).split("\n"),a.replaceSelections(b)):a.replaceRange(b,f,e),c.visualMode?(f=w(g[0].anchor,g[0].head)?g[0].anchor:g[0].head,a.setCursor(f),G(a,!1)):a.setCursor(y(e,0,-1)))},incrementNumberToken:function(a,b){for(var c=a.getCursor(),d=a.getLine(c.line),f=/-?\d+/g,
|
||||
e,g,k,h;null!==(e=f.exec(d))&&!(h=e[0],g=e.index,k=g+h.length,c.ch<k););!b.backtrack&&k<=c.ch||!h||(d=b.increase?1:-1,d=parseInt(h)+d*b.repeat,h=m(c.line,g),k=m(c.line,k),d=d.toString(),a.replaceRange(d,h,k),a.setCursor(m(c.line,g+d.length-1)))},repeatLastEdit:function(a,b,c){if(c.lastEditInputState){var d=b.repeat;d&&b.repeatIsExplicit?c.lastEditInputState.repeatOverride=d:d=c.lastEditInputState.repeatOverride||d;Wa(a,c,d,!1)}},exitInsertMode:X},qb={"(":"bracket",")":"bracket","{":"bracket","}":"bracket",
|
||||
"[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},cb={bracket:{isComplete:function(a){if(a.nextCh===a.symb){if(a.depth++,1<=a.depth)return!0}else a.nextCh===a.reverseSymb&&a.depth--;return!1}},section:{init:function(a){a.curMoveThrough=!0;a.symb=(a.forward?"]":"[")===a.symb?"{":"}"},isComplete:function(a){return 0===a.index&&a.nextCh===a.symb}},comment:{isComplete:function(a){var b="*"===a.lastCh&&"/"===a.nextCh;a.lastCh=a.nextCh;return b}},method:{init:function(a){a.symb=
|
||||
"m"===a.symb?"{":"}";a.reverseSymb="{"===a.symb?"}":"{"},isComplete:function(a){return a.nextCh===a.symb?!0:!1}},preprocess:{init:function(a){a.index=0},isComplete:function(a){if("#"===a.nextCh){var b=a.lineText.match(/#(\w+)/)[1];if("endif"===b){if(a.forward&&0===a.depth)return!0;a.depth++}else if("if"===b){if(!a.forward&&0===a.depth)return!0;a.depth--}if("else"===b&&0===a.depth)return!0}return!1}}};ca("pcre",!0,"boolean");Pa.prototype={getQuery:function(){return r.query},setQuery:function(a){r.query=
|
||||
a},getOverlay:function(){return this.searchOverlay},setOverlay:function(a){this.searchOverlay=a},isReversed:function(){return r.isReversed},setReversed:function(a){r.isReversed=a},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(a){this.annotate=a}};var db={"\\n":"\n","\\r":"\r","\\t":"\t"},eb={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":"\t"},pb="(Javascript regexp)",Y=function(){this.buildCommandMap_()};Y.prototype={processCommand:function(a,b,c){var d=this;
|
||||
a.operation(function(){a.curOp.isVimOp=!0;d._processCommand(a,b,c)})},_processCommand:function(a,b,c){var d=a.state.vim,f=r.registerController.getRegister(":"),e=f.toString();d.visualMode&&G(a);d=new q.StringStream(b);f.setText(b);c=c||{};c.input=b;try{this.parseInput_(a,d,c)}catch(h){throw u(a,h),h;}var g,k;if(c.commandName){if(g=this.matchCommand_(c.commandName)){k=g.name;g.excludeFromCommandHistory&&f.setText(e);this.parseCommandArgs_(d,c,g);if("exToKey"==g.type){for(b=0;b<g.toKeys.length;b++)q.Vim.handleKey(a,
|
||||
g.toKeys[b],"mapping");return}if("exToEx"==g.type){this.processCommand(a,g.toInput);return}}}else void 0!==c.line&&(k="move");if(k)try{ab[k](a,c),g&&g.possiblyAsync||!c.callback||c.callback()}catch(h){throw u(a,h),h;}else u(a,'Not an editor command ":'+b+'"')},parseInput_:function(a,b,c){b.eatWhile(":");b.eat("%")?(c.line=a.firstLine(),c.lineEnd=a.lastLine()):(c.line=this.parseLineSpec_(a,b),void 0!==c.line&&b.eat(",")&&(c.lineEnd=this.parseLineSpec_(a,b)));a=b.match(/^(\w+)/);c.commandName=a?a[1]:
|
||||
b.match(/.*/)[0];return c},parseLineSpec_:function(a,b){var c=b.match(/^(\d+)/);if(c)return parseInt(c[1],10)-1;switch(b.next()){case ".":return a.getCursor().line;case "$":return a.lastLine();case "'":if((c=a.state.vim.marks[b.next()])&&c.find())return c.find().line;throw Error("Mark not set");default:b.backUp(1)}},parseCommandArgs_:function(a,b,c){a.eol()||(b.argString=a.match(/.*/)[0],a=c.argDelimiter||/\s+/,a=qa(b.argString).split(a),a.length&&a[0]&&(b.args=a))},matchCommand_:function(a){for(var b=
|
||||
a.length;0<b;b--){var c=a.substring(0,b);if(this.commandMap_[c]&&(c=this.commandMap_[c],0===c.name.indexOf(a)))return c}return null},buildCommandMap_:function(){this.commandMap_={};for(var a=0;a<wa.length;a++){var b=wa[a];this.commandMap_[b.shortName||b.name]=b}},map:function(a,b,c){if(":"!=a&&":"==a.charAt(0)){if(c)throw Error("Mode not supported for ex mappings");c=a.substring(1);":"!=b&&":"==b.charAt(0)?this.commandMap_[c]={name:c,type:"exToEx",toInput:b.substring(1),user:!0}:this.commandMap_[c]=
|
||||
{name:c,type:"exToKey",toKeys:b,user:!0}}else b=":"!=b&&":"==b.charAt(0)?{keys:a,type:"keyToEx",exArgs:{input:b.substring(1)},user:!0}:{keys:a,type:"keyToKey",toKeys:b,user:!0},c&&(b.context=c),D.unshift(b)},unmap:function(a,b){if(":"!=a&&":"==a.charAt(0)){if(b)throw Error("Mode not supported for ex mappings");var c=a.substring(1);if(this.commandMap_[c]&&this.commandMap_[c].user){delete this.commandMap_[c];return}}else for(c=0;c<D.length;c++)if(a==D[c].keys&&D[c].context===b&&D[c].user){D.splice(c,
|
||||
1);return}throw Error("No such mapping.");}};var ab={colorscheme:function(a,b){!b.args||1>b.args.length?u(a,a.getOption("theme")):a.setOption("theme",b.args[0])},map:function(a,b,c){var d=b.args;!d||2>d.length?a&&u(a,"Invalid mapping: "+b.input):I.map(d[0],d[1],c)},imap:function(a,b){this.map(a,b,"insert")},nmap:function(a,b){this.map(a,b,"normal")},vmap:function(a,b){this.map(a,b,"visual")},unmap:function(a,b,c){var d=b.args;!d||1>d.length?a&&u(a,"No such mapping: "+b.input):I.unmap(d[0],c)},move:function(a,
|
||||
b){N.processCommand(a,a.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:b.line+1})},set:function(a,b){var c=b.args,d=b.setCfg||{};if(!c||1>c.length)a&&u(a,"Invalid mapping: "+b.input);else{var f=c[0].split("="),c=f[0],f=f[1],e=!1;if("?"==c.charAt(c.length-1)){if(f)throw Error("Trailing characters: "+b.argString);c=c.substring(0,c.length-1);e=!0}void 0===f&&"no"==c.substring(0,2)&&(c=c.substring(2),f=!1);var g=J[c]&&
|
||||
"boolean"==J[c].type;g&&void 0==f&&(f=!0);!g&&void 0===f||e?(d=U(c,a,d),!0===d||!1===d?u(a," "+(d?"":"no")+c):u(a," "+c+"="+d)):oa(c,f,a,d)}},setlocal:function(a,b){b.setCfg={scope:"local"};this.set(a,b)},setglobal:function(a,b){b.setCfg={scope:"global"};this.set(a,b)},registers:function(a,b){var c=b.args,d=r.registerController.registers,f="----------Registers----------<br><br>";if(c)for(var c=c.join(""),e=0;e<c.length;e++){if(k=c.charAt(e),r.registerController.isValidRegister(k))var g=d[k]||new E,
|
||||
f=f+('"'+k+" "+g.toString()+"<br>")}else for(var k in d)c=d[k].toString(),c.length&&(f+='"'+k+" "+c+"<br>");u(a,f)},sort:function(a,b){function c(a,b){if(d){var c;c=a;a=b;b=c}f&&(a=a.toLowerCase(),b=b.toLowerCase());c=g&&n.exec(a);var e=g&&n.exec(b);if(!c)return a<b?-1:1;c=parseInt((c[1]+c[2]).toLowerCase(),r);e=parseInt((e[1]+e[2]).toLowerCase(),r);return c-e}var d,f,e,g,k=function(){if(b.argString){var a=new q.StringStream(b.argString);a.eat("!")&&(d=!0);if(!a.eol()){if(!a.eatSpace())return"Invalid arguments";
|
||||
var c=a.match(/[a-z]+/);if(c){c=c[0];f=-1!=c.indexOf("i");e=-1!=c.indexOf("u");var h=-1!=c.indexOf("d")&&1,k=-1!=c.indexOf("x")&&1,c=-1!=c.indexOf("o")&&1;if(1<h+k+c)return"Invalid arguments";g=h&&"decimal"||k&&"hex"||c&&"octal"}if(a.match(/\/.*\//))return"patterns not supported"}}}();if(k)u(a,k+": "+b.argString);else{var k=b.line||a.firstLine(),h=b.lineEnd||b.line||a.lastLine();if(k!=h){var k=m(k,0),h=m(h,B(a,h)),l=a.getRange(k,h).split("\n"),n="decimal"==g?/(-?)([\d]+)/:"hex"==g?/(-?)(?:0x)?([0-9a-f]+)/i:
|
||||
"octal"==g?/([0-7]+)/:null,r="decimal"==g?10:"hex"==g?16:"octal"==g?8:null,p=[],t=[];if(g)for(var v=0;v<l.length;v++)n.exec(l[v])?p.push(l[v]):t.push(l[v]);else t=l;p.sort(c);t.sort(c);l=d?p.concat(t):t.concat(p);if(e)for(var p=l,w,l=[],v=0;v<p.length;v++)p[v]!=w&&l.push(p[v]),w=p[v];a.replaceRange(l.join("\n"),k,h)}}},global:function(a,b){var c=b.argString;if(c){var d=void 0!==b.line?b.line:a.firstLine(),f=b.lineEnd||b.line||a.lastLine(),e=Qa(c),g;e.length&&(c=e[0],g=e.slice(1,e.length).join("/"));
|
||||
if(c)try{W(a,c,!0,!0)}catch(m){u(a,"Invalid regex: "+c);return}for(var e=L(a).getQuery(),k=[],c="";d<=f;d++)e.test(a.getLine(d))&&(k.push(d+1),c+=a.getLine(d)+"<br>");if(g){var h=0,l=function(){h<k.length&&I.processCommand(a,k[h]+g,{callback:l});h++};l()}else u(a,c)}else u(a,"Regular Expression missing from global")},substitute:function(a,b){if(!a.getSearchCursor)throw Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var c=b.argString,d=
|
||||
c?Qa(c):[],f,e="",g,k,h=!1,l=!1;if(d.length){f=d[0];e=d[1];if(void 0!==e){if(U("pcre"))for(e=new q.StringStream(e),g=[];!e.eol();){for(;e.peek()&&"\\"!=e.peek();)g.push(e.next());var c=!1,n;for(n in eb)if(e.match(n,!0)){c=!0;g.push(eb[n]);break}c||g.push(e.next())}else for(n=!1,g=[],c=-1;c<e.length;c++){var w=e.charAt(c)||"",p=e.charAt(c+1)||"";db[w+p]?(g.push(db[w+p]),c++):n?(g.push(w),n=!1):"\\"===w?(n=!0,ob.test(p)||"$"===p?g.push("$"):"/"!==p&&"\\"!==p&&g.push("\\")):("$"===w&&g.push("$"),g.push(w),
|
||||
"/"===p&&g.push("\\"))}e=g.join("");r.lastSubstituteReplacePart=e}g=d[2]?d[2].split(" "):[]}else if(c&&c.length){u(a,"Substitutions should be of the form :s/pattern/replace/");return}g&&(d=g[0],k=parseInt(g[1]),d&&(-1!=d.indexOf("c")&&(h=!0,d.replace("c","")),-1!=d.indexOf("g")&&(l=!0,d.replace("g","")),f=f+"/"+d));if(f)try{W(a,f,!0,!0)}catch(t){u(a,"Invalid regex: "+f);return}e=e||r.lastSubstituteReplacePart;void 0===e?u(a,"No previous substitute regular expression"):(f=L(a).getQuery(),d=void 0!==
|
||||
b.line?b.line:a.getCursor().line,n=b.lineEnd||d,d==a.firstLine()&&n==a.lastLine()&&(n=Infinity),k&&(d=n,n=d+k-1),k=A(a,m(d,0)),k=a.getSearchCursor(f,k),nb(a,h,l,d,n,k,f,e,b.callback))},redo:q.commands.redo,undo:q.commands.undo,write:function(a){q.commands.save?q.commands.save(a):a.save&&a.save()},nohlsearch:function(a){ua(a)},yank:function(a){var b=x(a.getCursor()).line;a=a.getLine(b);r.registerController.pushText("0","yank",a,!0,!0)},delmarks:function(a,b){if(b.argString&&qa(b.argString))for(var c=
|
||||
a.state.vim,d=new q.StringStream(qa(b.argString));!d.eol();){d.eatSpace();var f=d.pos;if(!d.match(/[a-zA-Z]/,!1)){u(a,"Invalid argument: "+b.argString.substring(f));break}var e=d.next();if(d.match("-",!0)){if(!d.match(/[a-zA-Z]/,!1)){u(a,"Invalid argument: "+b.argString.substring(f));break}var g=d.next();if(/^[a-z]$/.test(e)&&/^[a-z]$/.test(g)||T(e)&&T(g)){e=e.charCodeAt(0);g=g.charCodeAt(0);if(e>=g){u(a,"Invalid argument: "+b.argString.substring(f));break}for(f=0;f<=g-e;f++){var k=String.fromCharCode(e+
|
||||
f);delete c.marks[k]}}else{u(a,"Invalid argument: "+e+"-");break}}else delete c.marks[e]}else u(a,"Argument required")}},I=new Y;q.keyMap.vim={attach:S,detach:ka,call:la};ca("insertModeEscKeysTimeout",200,"number");q.keyMap["vim-insert"]={"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",Enter:function(a){(q.commands.newlineAndIndentContinueComment||q.commands.newlineAndIndent)(a)},fallthrough:["default"],attach:S,detach:ka,call:la};q.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],
|
||||
attach:S,detach:ka,call:la};Ea();return ja}()});
|
Loading…
Reference in New Issue
Block a user