/** * Jim v0.2.0 * https://github.com/misfo/jim * * Copyright 2011, Trent Ogren * Released under the MIT License */ this.Jim=function(){function a(b){return b[0]==="."?a[b]:window.require(b)}return a["./helpers"]=function(){var a={},b={};return a.Command=function(){function a(a){this.count=a!=null?a:1}return a.prototype.isRepeatable=!0,a.prototype.isComplete=function(){return this.constructor.followedBy?this.followedBy:!0},a}(),a.repeatCountTimes=function(a){return function(b){var c,d;c=this.count,d=[];while(c--)d.push(a.call(this,b));return d}},b.exports||a}(),a["./motions"]=function(){var b={},c={},d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q=Object.prototype.hasOwnProperty,R=function(a,b){function d(){this.constructor=a}for(var c in b)Q.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};return P=a("./helpers"),d=P.Command,N=P.repeatCountTimes,J={},M=function(a,b){return J[a]=b},o=function(){function a(a){this.count=a!=null?a:1}return R(a,d),a.prototype.isRepeatable=!1,a.prototype.linewise=!1,a.prototype.exclusive=!1,a.prototype.visualExec=function(a){return this.exec(a)},a}(),n=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.linewise=!0,a.prototype.exec=function(a){var b;if(b=this.count-1)return(new r(b)).exec(a)},a}(),M("h",s=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exclusive=!0,a.prototype.exec=N(function(a){return a.adaptor.moveLeft()}),a}()),M("j",r=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.linewise=!0,a.prototype.exec=N(function(a){return a.adaptor.moveDown()}),a}()),M("k",B=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.linewise=!0,a.prototype.exec=N(function(a){return a.adaptor.moveUp()}),a}()),M("l",t=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exclusive=!0,a.prototype.exec=N(function(a){return a.adaptor.moveRight(this.operation!=null)}),a}()),I=function(){return/\S+/g},O=function(){return/(\w+)|([^\w\s]+)/g},M("e",A=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exec=N(function(a){var b,c,d,e,f,g,h,i;f=this.bigWord?I():O(),d=a.adaptor.lineText(),i=a.adaptor.position(),h=i[0],b=i[1],g=d.substring(b),e=f.exec(g),(e!=null?e[0].length:void 0)<=1&&(e=f.exec(g));if(e)b+=e[0].length+e.index-1;else for(;;){d=a.adaptor.lineText(++h),c=f.exec(d);if(c){b=c[0].length+c.index-1;break}if(h===a.adaptor.lastRow())return}return a.adaptor.moveTo(h,b)}),a}()),M("E",v=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,A),a.prototype.bigWord=!0,a}()),M("w",z=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exclusive=!0,a.prototype.exec=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;j=this.count,m=[];while(j--){g=this.bigWord?I():O(),d=a.adaptor.lineText(),k=a.adaptor.position(),i=k[0],b=k[1],h=d.substring(b),e=g.exec(h),(e!=null?e.index:void 0)===0&&(e=g.exec(h));if(!e)j===0&&this.operation?b=d.length:(d=a.adaptor.lineText(++i),f=g.exec(d),b=(f!=null?f.index:void 0)||0);else{if(j===0&&((l=this.operation)!=null?l.switchToMode:void 0)==="insert"){c=new A,c.bigWord=this.bigWord,c.exec(a),this.exclusive=!1;return}b+=e.index}m.push(a.adaptor.moveTo(i,b))}return m},a}()),M("W",y=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,z),a.prototype.bigWord=!0,a}()),K=RegExp(""+I().source+"\\s*$"),L=RegExp("("+O().source+")\\s*$"),M("b",q=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exclusive=!0,a.prototype.exec=N(function(a){var b,c,d,e,f,g,h;f=this.bigWord?K:L,d=a.adaptor.lineText(),h=a.adaptor.position(),g=h[0],b=h[1],c=d.substring(0,b),e=f.exec(c);if(e)b=e.index;else{g--;while(/^\s+$/.test(d=a.adaptor.lineText(g)))g--;e=f.exec(d),b=(e!=null?e.index:void 0)||0}return a.adaptor.moveTo(g,b)}),a}()),M("B",p=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,q),a.prototype.bigWord=!0,a}()),M("0",u=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exclusive=!0,a.prototype.exec=function(a){return a.adaptor.moveTo(a.adaptor.row(),0)},a}()),M("^",x=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exec=function(a){var b,c,d,e;return d=a.adaptor.row(),c=a.adaptor.lineText(d),b=((e=/\S/.exec(c))!=null?e.index:void 0)||0,a.adaptor.moveTo(d,b)},a}()),M("$",w=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exec=function(a){var b;return b=this.count-1,b&&(new r(b)).exec(a),a.adaptor.moveToLineEnd()},a}()),M("gg",g=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.linewise=!0,a.prototype.exec=function(a){var b,c;return c=this.count-1,b=a.adaptor.lineText(c),a.adaptor.moveTo(c,0),(new x).exec(a)},a}()),M("G",h=function(){function a(a){this.count=a}return R(a,g),a.prototype.exec=function(b){return this.count||(this.count=b.adaptor.lastRow()+1),a.__super__.exec.apply(this,arguments)},a}()),M("H",e=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.linewise=!0,a.prototype.exec=function(a){var b;return b=a.adaptor.firstFullyVisibleRow()+this.count,(new h(b)).exec(a)},a}()),M("M",i=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.linewise=!0,a.prototype.exec=function(a){var b,c,d;return d=a.adaptor.firstFullyVisibleRow(),b=a.adaptor.lastFullyVisibleRow()-d,c=Math.floor(b/2),(new h(d+1+c)).exec(a)},a}()),M("L",f=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.linewise=!0,a.prototype.exec=function(a){var b;return b=a.adaptor.lastFullyVisibleRow()+2-this.count,(new h(b)).exec(a)},a}()),M("/",E=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.runSearch=function(a,b,c){var d,e,f,g,h;if(!a.search)return;g=a.search,d=g.backwards,e=g.searchString,f=g.wholeWord,c&&(d=!d),h=[];while(b--)h.push(a.adaptor.search(d,e,f));return h},a.prototype.exclusive=!0,a.prototype.getSearch=function(){return{searchString:prompt("Find:"),backwards:this.backwards}},a.prototype.exec=function(b){return b.search=this.getSearch(b),a.runSearch(b,this.count)},a}()),M("?",H=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,E),a.prototype.backwards=!0,a}()),M("*",C=function(){function b(){b.__super__.constructor.apply(this,arguments)}var a;return R(b,E),b.prototype.getSearch=function(b){var c,d,e,f;return f=a(b),d=f[0],c=f[1],c&&(new t(c)).exec(b),e=/^\w/.test(d),{searchString:d,wholeWord:e,backwards:this.backwards}},a=function(a){var b,c,d,e,f,g,h,i;return f=a.adaptor.lineText(),c=a.adaptor.column(),e=f.substring(0,c),i=f.substring(c),b=null,/\W/.test(f[c])?(d=[""],g=/\w+/.exec(i),h=g?g:/[^\w\s]+/.exec(i),b=h.index):(d=/\w*$/.exec(e),h=/^\w*/.exec(i)),[d[0]+h[0],b]},b}()),M("#",D=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,C),a.prototype.backwards=!0,a}()),M("n",F=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exclusive=!0,a.prototype.exec=function(a){return E.runSearch(a,this.count)},a}()),M("N",G=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.prototype.exclusive=!0,a.prototype.exec=function(a){return E.runSearch(a,this.count,!0)},a}()),M("f",j=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.followedBy=/./,a.prototype.exec=function(a){var b,c,d,e,f,g,h;f=(g=this.count)!=null?g:1,h=a.adaptor.position(),e=h[0],b=h[1],d=a.adaptor.lineText().substring(b+1),c=0;while(f--)c=d.indexOf(this.followedBy,c)+1;if(c)return this.beforeChar&&c--,a.adaptor.moveTo(e,b+c)},a}()),M("t",l=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,j),a.prototype.beforeChar=!0,a}()),M("F",k=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,o),a.followedBy=/./,a.prototype.exec=function(a){var b,c,d,e,f,g,h;f=(g=this.count)!=null?g:1,h=a.adaptor.position(),d=h[0],b=h[1],c=a.adaptor.lineText().substring(0,b),e=b;while(f--)e=c.lastIndexOf(this.followedBy,e-1);if(0<=e&&e<b)return this.beforeChar&&e++,a.adaptor.moveTo(d,e)},a}()),M("T",m=function(){function a(){a.__super__.constructor.apply(this,arguments)}return R(a,k),a.prototype.beforeChar=!0,a}()),c.exports={GoToLine:g,MoveDown:r,MoveLeft:s,MoveRight:t,MoveToEndOfLine:w,MoveToFirstNonBlank:x,LinewiseCommandMotion:n,MoveToNextBigWord:y,MoveToNextWord:z,MoveToBigWordEnd:v,MoveToWordEnd:A,defaultMappings:J},c.exports||b}(),a["./operators"]=function(){var b={},c={},d,e,f,g,h,i,j,k,l,m,n,o,p=Object.prototype.hasOwnProperty,q=function(a,b){function d(){this.constructor=a}for(var c in b)p.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};return e=a("./helpers").Command,o=a("./motions"),g=o.GoToLine,i=o.MoveToFirstNonBlank,m={},n=function(a,b){return m[a]=b},j=function(){function a(a,b){this.count=a!=null?a:1,this.motion=b,this.motion&&(this.motion.operation=this)}return q(a,e),a.prototype.isOperation=!0,a.prototype.isComplete=function(){var a;return(a=this.motion)!=null?a.isComplete():void 0},a.prototype.switchToMode="normal",a.prototype.visualExec=function(a){var b;return this.linewise?a.adaptor.makeLinewise():((b=this.motion)!=null?!b.exclusive:!void 0)&&a.adaptor.includeCursorInSelection(),this.operate(a),a.setMode(this.switchToMode)},a.prototype.exec=function(a){var b;return this.startingPosition=a.adaptor.position(),a.adaptor.setSelectionAnchor(),this.count!==1&&(this.motion.count*=this.count,this.count=1),(b=this.linewise)==null&&(this.linewise=this.motion.linewise),this.motion.exec(a),this.visualExec(a)},a}(),n("c",d=function(){function a(){a.__super__.constructor.apply(this,arguments)}return q(a,j),a.prototype.visualExec=function(b){return a.__super__.visualExec.apply(this,arguments),this.repeatableInsert?(b.adaptor.insert(this.repeatableInsert.string),b.setMode("normal")):b.afterInsertSwitch=!0},a.prototype.operate=function(a){var b;return this.linewise&&a.adaptor.moveToEndOfPreviousLine(),a.deleteSelection((b=this.motion)!=null?b.exclusive:void 0,this.linewise)},a.prototype.switchToMode="insert",a}()),n("d",f=function(){function a(){a.__super__.constructor.apply(this,arguments)}return q(a,j),a.prototype.operate=function(a){var b;a.deleteSelection((b=this.motion)!=null?b.exclusive:void 0,this.linewise);if(this.linewise)return(new i).exec(a)},a}()),n("y",l=function(){function a(){a.__super__.constructor.apply(this,arguments)}return q(a,j),a.prototype.operate=function(a){var b,c;a.yankSelection((b=this.motion)!=null?b.exclusive:void 0,this.linewise);if(this.startingPosition)return(c=a.adaptor).moveTo.apply(c,this.startingPosition)},a}()),n(">",h=function(){function a(){a.__super__.constructor.apply(this,arguments)}return q(a,j),a.prototype.operate=function(a){var b,c,d;return d=a.adaptor.selectionRowRange(),c=d[0],b=d[1],a.adaptor.indentSelection(),(new g(c+1)).exec(a)},a}()),n("<",k=function(){function a(){a.__super__.constructor.apply(this,arguments)}return q(a,j),a.prototype.operate=function(a){var b,c,d;return d=a.adaptor.selectionRowRange(),c=d[0],b=d[1],a.adaptor.outdentSelection(),(new g(c+1)).exec(a)},a}()),c.exports={Change:d,Delete:f,defaultMappings:m},c.exports||b}(),a["./commands"]=function(){var b={},c={},d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K=Object.prototype.hasOwnProperty,L=function(a,b){function d(){this.constructor=a}for(var c in b)K.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};return I=a("./helpers"),g=I.Command,H=I.repeatCountTimes,h=a("./operators").Delete,J=a("./motions"),r=J.MoveLeft,s=J.MoveRight,t=J.MoveToEndOfLine,u=J.MoveToFirstNonBlank,F={},G=function(a,b){return F[a]=b},q=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.exec=function(a){return typeof this.beforeSwitch=="function"&&this.beforeSwitch(a),a.setMode(this.switchToMode)},a}(),G("v",E=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.isRepeatable=!1,a.prototype.exec=function(a){var b;return b=a.adaptor.position(),a.adaptor.setSelectionAnchor(),a.setMode("visual",{anchor:b})},a.prototype.visualExec=function(a){var b;return a.mode.linewise?(a.setMode("visual",{linewise:!1}),(b=a.adaptor.editor.selection).setSelectionAnchor.apply(b,a.mode.anchor)):a.onEscape()},a}()),G("V",D=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.isRepeatable=!1,a.prototype.exec=function(a){var b;return b=a.adaptor.setLinewiseSelectionAnchor(),a.setMode("visual",{linewise:!0,anchor:b})},a.prototype.visualExec=function(a){var b,c;return a.mode.linewise?a.onEscape():(c={linewise:!0},b=a.adaptor.setLinewiseSelectionAnchor(),a.mode.anchor||(c.anchor=b),a.setMode("visual",c))},a}()),G("i",k=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,q),a.prototype.switchToMode="insert",a.prototype.exec=function(a){return typeof this.beforeSwitch=="function"&&this.beforeSwitch(a),this.repeatableInsert?a.adaptor.insert(this.repeatableInsert.string):(a.afterInsertSwitch=!0,a.setMode(this.switchToMode))},a}()),G("a",l=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,k),a.prototype.beforeSwitch=function(a){return a.adaptor.moveRight(!0)},a}()),G("A",m=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,k),a.prototype.beforeSwitch=function(a){return(new t).exec(a),a.adaptor.moveRight(!0)},a}()),G("C",f=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,k),a.prototype.beforeSwitch=function(a){return(new j(this.count)).exec(a)},a}()),G("I",n=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,k),a.prototype.beforeSwitch=function(a){return(new u).exec(a)},a}()),G("o",v=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,k),a.prototype.beforeSwitch=function(a){var b;return b=a.adaptor.row()+(this.above?0:1),a.adaptor.insertNewLine(b),a.adaptor.moveTo(b,0)},a}()),G("O",w=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,v),a.prototype.above=!0,a}()),G("s",e=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,k),a.prototype.beforeSwitch=function(a){return(new i(this.count)).exec(a)},a}()),G("R",B=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,q),a.prototype.beforeSwitch=function(a){return a.adaptor.setOverwriteMode(!0)},a.prototype.switchToMode="replace",a}()),G("gJ",o=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.exec=function(a){var b,c;b=Math.max(this.count,2)-1,c=[];while(b--)a.adaptor.selectLineEnding(this.normalize),a.adaptor.deleteSelection(),c.push(this.normalize?(a.adaptor.insert(" "),a.adaptor.moveLeft()):void 0);return c},a.prototype.visualExec=function(a){var b,c,d;return d=a.adaptor.selectionRowRange(),c=d[0],b=d[1],a.adaptor.clearSelection(),a.adaptor.moveTo(c,0),this.count=b-c+1,this.exec(a),a.setMode("normal")},a}()),G("J",p=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,o),a.prototype.normalize=!0,a}()),G("D",j=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.exec=function(a){return(new h(1,new t(this.count))).exec(a)},a}()),G("p",x=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.exec=function(a){var b,c,d,e,f,g,h,i,j,k;if(!(g=a.registers['"']))return;return i=(new Array(this.count+1)).join(g),f=/\n$/.test(g),f?(h=a.adaptor.row()+(this.before?0:1),d=a.adaptor.lastRow(),h>d?(k=/^([\s\S]*)(\r?\n)$/.exec(i),j=k[0],b=k[1],e=k[2],i=e+b,c=a.adaptor.lineText(d).length-1,a.adaptor.moveTo(h,c)):a.adaptor.moveTo(h,0),a.adaptor.insert(i),a.adaptor.moveTo(h,0)):a.adaptor.insert(i,!this.before)},a.prototype.visualExec=function(a){var b;return a.mode.linewise?a.adaptor.makeLinewise():a.adaptor.includeCursorInSelection(),b=a.adaptor.deleteSelection(),this.before=!0,this.exec(a),a.registers['"']=b,a.setMode("normal")},a}()),G("P",y=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,x),a.prototype.before=!0,a}()),G("r",A=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.followedBy=/[\s\S]+/,a.prototype.exec=function(a){var b;return a.adaptor.setSelectionAnchor(),(new s(this.count)).exec(a),a.adaptor.deleteSelection(),b=/^\r?\n$/.test(this.followedBy)?this.followedBy:(new Array(this.count+1)).join(this.followedBy),a.adaptor.insert(b),(new r).exec(a)},a}()),G(".",z=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.isRepeatable=!1,a.prototype.exec=function(a){var b,c,d,e;b=a.lastCommand;if(!b)return;return b.switchToMode==="insert"&&(console.log("command.repeatableInsert",b.repeatableInsert),b.repeatableInsert.contiguous||(e=b.repeatableInsert.string,b=new k,b.repeatableInsert={string:e})),(d=b.selectionSize)?(d.lines?a.adaptor.makeLinewise(d.lines-1):d.chars?(a.adaptor.setSelectionAnchor(),(new s(d.chars)).exec(a)):(a.adaptor.setSelectionAnchor(),c=a.adaptor.row()+d.lineEndings,a.adaptor.moveTo(c,d.trailingChars-1)),b.visualExec(a)):b.exec(a)},a}()),G("u",C=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.isRepeatable=!1,a.prototype.exec=H(function(a){return a.adaptor.undo()}),a}()),G("x",i=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.exec=function(a){return(new h(1,new s(this.count))).exec(a)},a}()),G("X",d=function(){function a(){a.__super__.constructor.apply(this,arguments)}return L(a,g),a.prototype.exec=function(a){return(new h(1,new r(this.count))).exec(a)},a}()),c.exports={defaultMappings:F},c.exports||b}(),a["./keymap"]=function(){var b={},c={},d,e=Object.prototype.hasOwnProperty;return d=function(){function c(){this.commands={},this.motions={},this.visualCommands={},this.partialCommands={},this.partialMotions={},this.partialVisualCommands={}}var b;return c.getDefault=function(){var b,d,f,g,h,i,j,k;d=new c,i=a("./commands").defaultMappings;for(f in i){if(!e.call(i,f))continue;b=i[f],d.mapCommand(f,b)}j=a("./operators").defaultMappings;for(f in j){if(!e.call(j,f))continue;h=j[f],d.mapOperator(f,h)}k=a("./motions").defaultMappings;for(f in k){if(!e.call(k,f))continue;g=k[f],d.mapMotion(f,g)}return d},c.prototype.mapCommand=function(a,b){b.prototype.exec&&(this.commands[a]=b,a.length===2&&(this.partialCommands[a[0]]=!0));if(b.prototype.visualExec){this.visualCommands[a]=b;if(a.length===2)return this.partialVisualCommands[a[0]]=!0}},c.prototype.mapMotion=function(a,b){this.commands[a]=b,this.motions[a]=b,this.visualCommands[a]=b;if(a.length===2)return this.partialMotions[a[0]]=!0,this.partialCommands[a[0]]=!0,this.partialVisualCommands[a[0]]=!0},c.prototype.mapOperator=function(a,b){this.commands[a]=b,this.visualCommands[a]=b;if(a.length===2)return this.partialCommands[a[0]]=!0,this.partialVisualCommands[a[0]]=!0},b=function(a){var b,c;return RegExp("^([1-9]\\d*)?(["+function(){var d;d=[];for(b in a){if(!e.call(a,b))continue;c=a[b],d.push(b)}return d}().join("")+"]?([\\s\\S]*))?$")},c.prototype.commandFor=function(a){var c,d,e,f,g;return this.partialCommandRegex||(this.partialCommandRegex=b(this.partialCommands)),g=a.match(this.partialCommandRegex),a=g[0],f=g[1],d=g[2],c=g[3],c?(e=this.commands[d])?new e(parseInt(f)||null):!1:!0},c.prototype.motionFor=function(c,d){var e,f,g,h,i,j;return this.partialMotionRegex||(this.partialMotionRegex=b(this.partialMotions)),j=c.match(this.partialCommandRegex),c=j[0],g=j[1],h=j[2],f=j[3],f?h===d?(e=a("./motions").LinewiseCommandMotion,new e(parseInt(g)||null)):(i=this.motions[h])?new i(parseInt(g)||null):!1:!0},c.prototype.visualCommandFor=function(a){var c,d,e,f,g;return this.partialVisualCommandRegex||(this.partialVisualCommandRegex=b(this.partialVisualCommands)),g=a.match(this.partialVisualCommandRegex),a=g[0],f=g[1],d=g[2],c=g[3],c?(e=this.visualCommands[d])?new e(parseInt(f)||null):!1:!0},c}(),c.exports=d,c.exports||b}(),a["./modes"]=function(){var a={},b={},c;return c=function(a){return a==null&&(a="command"),console.log("invalid "+a+": "+this.commandPart),this.onEscape()},a.normal={onKeypress:function(a){var b,d,e,f,g;this.commandPart=(this.commandPart||"")+a,this.command?this.command.constructor.followedBy?(this.command.constructor.followedBy.test(this.commandPart)?this.command.followedBy=this.commandPart:console.log(""+this.command+" didn't expect to be followed by \""+this.commandPart+'"'),this.commandPart=""):this.command.isOperation&&((e=(f=this.command.motion)!=null?f.constructor.followedBy:void 0)?e.test(this.commandPart)?this.command.motion.followedBy=this.commandPart:console.log(""+this.command+" didn't expect to be followed by \""+this.commandPart+'"'):(d=this.keymap.motionFor(this.commandPart,this.operatorPending),d===!1?c.call(this,"motion"):d!==!0&&(d.operation=this.command,this.command.motion=d,this.operatorPending=null,this.commandPart=""))):(b=this.keymap.commandFor(this.commandPart),b===!1?c.call(this):b!==!0&&(b.isOperation&&(this.operatorPending=this.commandPart.match(/[^\d]+$/)[0]),this.command=b,this.commandPart=""));if((g=this.command)!=null?g.isComplete():void 0)return this.command.exec(this),this.command.isRepeatable&&(this.lastCommand=this.command),this.command=null}},a.visual={onKeypress:function(a){var b,d,e,f,g,h,i;this.commandPart=(this.commandPart||"")+a,this.command?this.command.constructor.followedBy&&(this.command.constructor.followedBy.test(this.commandPart)?this.command.followedBy=this.commandPart:console.log(""+this.command+" didn't expect to be followed by \""+this.commandPart+'"'),this.commandPart=""):(b=this.keymap.visualCommandFor(this.commandPart),b===!1?c.call(this):b!==!0&&(this.command=b,this.commandPart="")),f=this.adaptor.isSelectionBackwards();if(((g=this.command)!=null?g.isOperation:void 0)||((h=this.command)!=null?h.isComplete():void 0))this.command.isRepeatable&&(this.command.selectionSize=this.mode.name==="visual"&&this.mode.linewise?(i=this.adaptor.selectionRowRange(),e=i[0],d=i[1],i,{lines:d-e+1}):this.adaptor.characterwiseSelectionSize(),this.command.linewise=this.mode.linewise,this.lastCommand=this.command),this.command.visualExec(this),this.command=null;if(this.mode.name==="visual"&&!this.mode.linewise)if(f){if(!this.adaptor.isSelectionBackwards())return this.adaptor.adjustAnchor(-1)}else if(this.adaptor.isSelectionBackwards())return this.adaptor.adjustAnchor(1)}},a.insert={onKeypress:function(){return!0}},a.replace={onKeypress:function(){return!0}},b.exports||a}(),a["./jim"]=function(){var b={},c={},d,e,f=Object.prototype.hasOwnProperty;return e=a("./keymap"),d=function(){function b(a){this.adaptor=a,this.command=null,this.registers={},this.keymap=e.getDefault(),this.setMode("normal")}return b.VERSION="0.2.0",b.prototype.modes=a("./modes"),b.prototype.setMode=function(a,b){var c,d,e,g;this.debugMode&&console.log("setMode",a,b),d=this.mode;if(a===(d!=null?d.name:void 0)){if(!b)return;for(c in b){if(!f.call(b,c))continue;e=b[c],this.mode[c]=e}}else this.mode=b||{},this.mode.name=a;typeof (g=this.adaptor).onModeChange=="function"&&g.onModeChange(d,this.mode);switch(d!=null?d.name:void 0){case"insert":return this.adaptor.moveLeft(),this.lastCommand.repeatableInsert=this.adaptor.lastInsert();case"replace":return this.adaptor.setOverwriteMode(!1)}},b.prototype.onEscape=function(){return this.setMode("normal"),this.command=null,this.commandPart="",this.adaptor.clearSelection()},b.prototype.onKeypress=function(a){return this.modes[this.mode.name].onKeypress.call(this,a)},b.prototype.deleteSelection=function(a,b){return this.registers['"']=this.adaptor.deleteSelection(a,b)},b.prototype.yankSelection=function(a,b){return this.registers['"']=this.adaptor.selectionText(a,b),this.adaptor.clearSelection(!0)},b}(),c.exports=d,c.exports||b}(),a["./ace"]=function(){var b={},c={},d,e,f,g,h,i=Object.prototype.hasOwnProperty,j=function(a,b){function d(){this.constructor=a}for(var c in b)i.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};return g=a("ace/undomanager").UndoManager,e=a("./jim"),d=function(){function c(a){this.editor=a}var a,b;return a=function(a,b){var c,d;return d=a.selection.getSelectionLead(),c=a.selection.doc.getLine(d.row).length,d.column>=c-(b?0:1)},b=function(b){return a(b,!0)},c.prototype.onModeChange=function(a,b){var c,d,e,f;f=["insert","normal","visual"];for(d=0,e=f.length;d<e;d++)c=f[d],this.editor[c===b.name?"setStyle":"unsetStyle"]("jim-"+c+"-mode");this.editor[b.name==="visual"&&b.linewise?"setStyle":"unsetStyle"]("jim-visual-linewise-mode"),b.name==="insert"?this.markUndoPoint("jim:insert:start"):(a!=null?a.name:void 0)==="insert"&&this.markUndoPoint("jim:insert:end");if(b.name==="replace")return this.markUndoPoint("jim:replace:start");if((a!=null?a.name:void 0)==="replace")return this.markUndoPoint("jim:replace:end")},c.prototype.markUndoPoint=function(a){return this.editor.session.getUndoManager().execute({args:[a,this.editor.session]})},c.prototype.setOverwriteMode=function(a){return this.editor.setOverwrite(a)},c.prototype.clearSelection=function(a){var b,c,d;return a&&!this.editor.selection.isBackwards()?(d=this.editor.selection.getSelectionAnchor(),c=d.row,b=d.column,this.editor.navigateTo(c,b)):this.editor.clearSelection()},c.prototype.undo=function(){var a;return a=this.editor.session.getUndoManager(),a.jimUndo(),this.editor.clearSelection()},c.prototype.lastInsert=function(){return this.editor.session.getUndoManager().lastInsert()},c.prototype.column=function(){return this.editor.selection.selectionLead.column},c.prototype.row=function(){return this.editor.selection.selectionLead.row},c.prototype.position=function(){return[this.row(),this.column()]},c.prototype.firstFullyVisibleRow=function(){return this.editor.renderer.getFirstFullyVisibleRow()},c.prototype.lastFullyVisibleRow=function(){var a;return a=this.editor.renderer.getLastFullyVisibleRow(),Math.min(this.lastRow(),a)},c.prototype.includeCursorInSelection=function(){if(!this.editor.selection.isBackwards()&&!b(this.editor))return this.editor.selection.selectRight()},c.prototype.insertNewLine=function(a){return this.editor.session.doc.insertNewLine({row:a,column:0})},c.prototype.adjustAnchor=function(a){var b,c,d;return d=this.editor.selection.getSelectionAnchor(),c=d.row,b=d.column,this.editor.selection.setSelectionAnchor(c,b+a)},c.prototype.isSelectionBackwards=function(){return this.editor.selection.isBackwards()},c.prototype.lastRow=function(){return this.editor.session.getDocument().getLength()-1},c.prototype.lineText=function(a){return this.editor.selection.doc.getLine(a!=null?a:this.row())},c.prototype.makeLinewise=function(a){var b,c,d,e,f,g;return f=this.editor.selection,b=f.selectionAnchor.row,e=f.selectionLead.row,g=a!=null?[e,e+(a-1)]:[Math.min(b,e),Math.max(b,e)],c=g[0],d=g[1],this.editor.selection.setSelectionAnchor(c,0),this.editor.selection.moveCursorTo(d+1,0)},c.prototype.moveUp=function(){return this.editor.selection.moveCursorBy(-1,0)},c.prototype.moveDown=function(){return this.editor.selection.moveCursorBy(1,0)},c.prototype.moveLeft=function(){if(this.editor.selection.selectionLead.getPosition().column>0)return this.editor.selection.moveCursorLeft()},c.prototype.moveRight=function(c){var d;d=c?b(this.editor):a(this.editor);if(!d)return this.editor.selection.moveCursorRight()},c.prototype.moveTo=function(a,b){return this.editor.moveCursorTo(a,b)},c.prototype.moveToLineEnd=function(){var a,b,c,d;return d=this.editor.selection.selectionLead,c=d.row,a=d.column,b=this.editor.session.getDocumentLastRowColumnPosition(c,a),this.moveTo(b.row,b.column-1)},c.prototype.moveToEndOfPreviousLine=function(){var a,b;return a=this.row()-1,b=this.editor.session.doc.getLine(a).length,this.editor.selection.moveCursorTo(a,b)},c.prototype.navigateFileEnd=function(){return this.editor.navigateFileEnd()},c.prototype.navigateLineStart=function(){return this.editor.navigateLineStart()},c.prototype.search=function(a,b,c){var d;this.editor.$search.set({backwards:a,needle:b,wholeWord:c}),a||this.editor.selection.moveCursorRight();if(d=this.editor.$search.find(this.editor.session))return this.moveTo(d.start.row,d.start.column);if(!a)return this.editor.selection.moveCursorLeft()},c.prototype.deleteSelection=function(){var a;return a=this.editor.getCopyText(),this.editor.session.remove(this.editor.getSelectionRange()),this.editor.clearSelection(),a},c.prototype.indentSelection=function(){return this.editor.indent(),this.clearSelection()},c.prototype.outdentSelection=function(){return this.editor.blockOutdent(),this.clearSelection()},c.prototype.insert=function(a,c){c&&!b(this.editor)&&this.editor.selection.moveCursorRight();if(a)return this.editor.insert(a)},c.prototype.emptySelection=function(){return this.editor.selection.isEmpty()},c.prototype.selectionText=function(){return this.editor.getCopyText()},c.prototype.setSelectionAnchor=function(){var a;return a=this.editor.selection.selectionLead,this.editor.selection.setSelectionAnchor(a.row,a.column)},c.prototype.setLinewiseSelectionAnchor=function(){var a,b,c,d,e;return d=this.editor.selection,e=d[d.isEmpty()?"selectionLead":"selectionAnchor"],c=e.row,a=e.column,b=this.editor.session.getDocumentLastRowColumnPosition(c,a),d.setSelectionAnchor(c,b),[c,a]},c.prototype.selectLineEnding=function(a){var b,c;this.editor.selection.moveCursorLineEnd(),this.editor.selection.selectRight();if(a)return b=((c=/\S/.exec(this.lineText()))!=null?c.index:void 0)||0,this.moveTo(this.row(),b)},c.prototype.selectionRowRange=function(){var a,b,c,d;return d=this.position(),c=d[0],b=d[1],a=this.editor.selection.getSelectionAnchor().row,[Math.min(c,a),Math.max(c,a)]},c.prototype.characterwiseSelectionSize=function(){var a,b,c,d;return d=this.editor.selection,b=d.selectionAnchor,c=d.selectionLead,a=c.row-b.row,a===0?{chars:Math.abs(b.column-c.column)}:{lineEndings:Math.abs(a),trailingChars:(a>0?c:b).column+1}},c}(),f=function(){function a(){a.__super__.constructor.apply(this,arguments)}return j(a,g),a.prototype.undo=function(){return this.isJimMark(this.lastOnUndoStack())&&this.silentUndo(),a.__super__.undo.apply(this,arguments)},a.prototype.isJimMark=function(a){return typeof a=="string"&&/^jim:/.test(a)},a.prototype.lastOnUndoStack=function(){return this.$undoStack[this.$undoStack.length-1]},a.prototype.silentUndo=function(){var a;a=this.$undoStack.pop();if(a)return this.$redoStack.push(a)},a.prototype.matchingMark={"jim:insert:end":"jim:insert:start","jim:replace:end":"jim:replace:start"},a.prototype.jimUndo=function(){var a,b,c,d,e;b=this.lastOnUndoStack();if(typeof b=="string"&&(d=this.matchingMark[b])){c=null;for(a=e=this.$undoStack.length-1;e<=0?a<=0:a>=0;e<=0?a++:a--)if(this.$undoStack[a]===d){c=a;break}if(c==null){console.log('found a "'+b+'" on the undoStack, but no "'+d+'"');return}this.silentUndo();while(this.$undoStack.length>c+1)this.isJimMark(this.lastOnUndoStack())?this.silentUndo():this.undo();return this.silentUndo()}return this.undo()},a.prototype.lastInsert=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(this.lastOnUndoStack()!=="jim:insert:end")return"";b=null,c=null,a=null,j=[],i=[],f=function(d){var e,f;return/(insert|remove)/.test(d.action)?!a||a===d.action?d.action==="insertText"?!b||(e=d.range).isEnd.apply(e,b):!c||(f=d.range).isStart.apply(f,c):d.action==="insertText"&&b!=null?d.range.end.row===b[0]:d.action==="removeText"&&c!=null?d.range.end.row===c[0]:!0:!1};for(e=n=this.$undoStack.length-2;n<=0?e<=0:e>=0;n<=0?e++:e--){if(typeof this.$undoStack[e]=="string")break;for(g=o=this.$undoStack[e].length-1;o<=0?g<=0:g>=0;o<=0?g++:g--)for(h=p=this.$undoStack[e][g].deltas.length-1;p<=0?h<=0:h>=0;p<=0?h++:h--){d=this.$undoStack[e][g].deltas[h];if(!f(d))return{string:j.join(""),contiguous:!1};a=d.action;if(a==="removeText"){c=[d.range.end.row,d.range.end.column],q=d.text.split("");for(l=0,m=q.length;l<m;l++)k=q[l],i.push(k)}if(a==="insertText"){b=[d.range.start.row,d.range.start.column];if(i.length&&d.text===i.pop())continue;for(k=r=d.text.length-1;r<=0?k<=0:k>=0;r<=0?k++:k--)j.unshift(d.text[k])}}}return{string:j.join(""),contiguous:!0}},a}(),a("pilot/dom").importCssString(".jim-normal-mode div.ace_cursor\n, .jim-visual-mode div.ace_cursor {\n border: 0;\n background-color: #91FF00;\n opacity: 0.5;\n}\n.jim-visual-linewise-mode .ace_marker-layer .ace_selection {\n left: 0 !important;\n width: 100% !important;\n}"),h=function(a,b){return a===0&&!b},e.aceInit=function(a){var b,c,g;return a.setKeyboardHandler({handleKeyboard:function(a,b,d,e){var f;if(e===27)return c.onEscape();if(h(b,e)){c.afterInsertSwitch&&(c.mode.name==="insert"&&c.adaptor.markUndoPoint("jim:insert:afterSwitch"),c.afterInsertSwitch=!1),c.mode.name==="normal"&&!c.adaptor.emptySelection()&&c.setMode("visual"),d.length>1&&(d=d.charAt(0)),f=c.onKeypress(d);if(!f)return{command:{exec:function(){}}}}}}),g=new f,a.session.setUndoManager(g),b=new d(a),c=new e(b),b.onModeChange(null,{name:"normal"}),c},c.exports||b}(),a["./jim"]}()