Version Description
- fixed bug: editor was not stopping when switching between visual editor and text editor
Download this release
Release Info
Developer | arniebradfo |
Plugin | HTML Editor Syntax Highlighter |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2.0 to 2.2.1
- dist/hesh.css +1 -1
- dist/hesh.js +9 -12
- dist/hesh.min.js +1 -1
- html-editor-syntax-highlighter.php +3 -3
- readme.txt +4 -1
dist/hesh.css
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Author URI: http://arniebradfo.com/
|
5 |
* Author: Peter Mukhortov
|
6 |
* Author URI: http://mukhortov.com/
|
7 |
-
* Version: 2.2.
|
8 |
**//* BASICS */.CodeMirror {
|
9 |
/* Set height, width, borders, and global font properties here */
|
10 |
font-family: monospace;
|
4 |
* Author URI: http://arniebradfo.com/
|
5 |
* Author: Peter Mukhortov
|
6 |
* Author URI: http://mukhortov.com/
|
7 |
+
* Version: 2.2.1
|
8 |
**//* BASICS */.CodeMirror {
|
9 |
/* Set height, width, borders, and global font properties here */
|
10 |
font-family: monospace;
|
dist/hesh.js
CHANGED
@@ -21385,7 +21385,7 @@ CodeMirror.registerHelper("fold", "indent", function(cm, start) {
|
|
21385 |
* @link http://arniebradfo.com/
|
21386 |
* @author Petr Mukhortov
|
21387 |
* @link http://mukhortov.com/
|
21388 |
-
* @since 2.2.
|
21389 |
*/
|
21390 |
|
21391 |
console.log(window.heshOptions); // from wordpress php
|
@@ -21410,21 +21410,21 @@ console.log(window.heshOptions); // from wordpress php
|
|
21410 |
var toolbar = document.getElementById('ed_toolbar');
|
21411 |
var target = document.getElementById('content') || document.getElementById('newcontent');
|
21412 |
var tabText = document.getElementById('content-html');
|
21413 |
-
var
|
21414 |
var publishButton = document.getElementById('save-post') || document.getElementById('publish');
|
21415 |
var postID = document.getElementById('post_ID') != null ? document.getElementById('post_ID').value : 0;
|
21416 |
var fullHeightToggle = document.getElementById('editor-expand-toggle');
|
21417 |
|
21418 |
var state = {
|
21419 |
-
|
21420 |
isThemeOrPlugin: document.getElementById('newcontent') != null,
|
21421 |
|
21422 |
isActive: function () {
|
21423 |
return document.getElementsByClassName('CodeMirror')[0] != null;
|
21424 |
},
|
21425 |
|
21426 |
-
|
21427 |
-
return document.getElementsByClassName('
|
21428 |
},
|
21429 |
|
21430 |
isFullHeight: function () {
|
@@ -22090,18 +22090,15 @@ console.log(window.heshOptions); // from wordpress php
|
|
22090 |
function initialise() {
|
22091 |
if (state.isThemeOrPlugin) {
|
22092 |
startEditor();
|
22093 |
-
} else if (state.
|
22094 |
tabText.addEventListener('click', function () {
|
22095 |
window.setTimeout(startEditor, 0);
|
22096 |
});
|
22097 |
-
|
22098 |
-
|
22099 |
-
if (tab.id === 'content-html') continue; // its the "Text" tab
|
22100 |
-
tab.addEventListener('click', stopEditor);
|
22101 |
-
}
|
22102 |
-
if (state.isTextTabSelected()) startEditor();
|
22103 |
} else {
|
22104 |
startEditor();
|
|
|
22105 |
}
|
22106 |
}
|
22107 |
|
21385 |
* @link http://arniebradfo.com/
|
21386 |
* @author Petr Mukhortov
|
21387 |
* @link http://mukhortov.com/
|
21388 |
+
* @since 2.2.1
|
21389 |
*/
|
21390 |
|
21391 |
console.log(window.heshOptions); // from wordpress php
|
21410 |
var toolbar = document.getElementById('ed_toolbar');
|
21411 |
var target = document.getElementById('content') || document.getElementById('newcontent');
|
21412 |
var tabText = document.getElementById('content-html');
|
21413 |
+
var tabVisual = document.getElementById('content-tmce');
|
21414 |
var publishButton = document.getElementById('save-post') || document.getElementById('publish');
|
21415 |
var postID = document.getElementById('post_ID') != null ? document.getElementById('post_ID').value : 0;
|
21416 |
var fullHeightToggle = document.getElementById('editor-expand-toggle');
|
21417 |
|
21418 |
var state = {
|
21419 |
+
isVisualEnabled: document.getElementById('content-tmce') != null,
|
21420 |
isThemeOrPlugin: document.getElementById('newcontent') != null,
|
21421 |
|
21422 |
isActive: function () {
|
21423 |
return document.getElementsByClassName('CodeMirror')[0] != null;
|
21424 |
},
|
21425 |
|
21426 |
+
isVisualActive: function () {
|
21427 |
+
return document.getElementsByClassName('tmce-active')[0] != null;
|
21428 |
},
|
21429 |
|
21430 |
isFullHeight: function () {
|
22090 |
function initialise() {
|
22091 |
if (state.isThemeOrPlugin) {
|
22092 |
startEditor();
|
22093 |
+
} else if (state.isVisualEnabled) {
|
22094 |
tabText.addEventListener('click', function () {
|
22095 |
window.setTimeout(startEditor, 0);
|
22096 |
});
|
22097 |
+
tabVisual.addEventListener('click', stopEditor);
|
22098 |
+
if (!state.isVisualActive()) startEditor();
|
|
|
|
|
|
|
|
|
22099 |
} else {
|
22100 |
startEditor();
|
22101 |
+
document.body.className += ' visual-editor-is-disabled';
|
22102 |
}
|
22103 |
}
|
22104 |
|
dist/hesh.min.js
CHANGED
@@ -10,4 +10,4 @@ this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}functio
|
|
10 |
;var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return r(e)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:f[t]}function r(e){var t=e.state.closeBrackets;return!t||t.override?t:e.getModeAt(e.getCursor()).closeBrackets||t}function n(n){var i=r(n);if(!i||n.getOption("disableInput"))return e.Pass;for(var o=t(i,"pairs"),a=n.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return e.Pass;var c=s(n,a[l].head);if(!c||o.indexOf(c)%2!=0)return e.Pass}for(var l=a.length-1;l>=0;l--){var u=a[l].head;n.replaceRange("",d(u.line,u.ch-1),d(u.line,u.ch+1),"+delete")}}function i(n){var i=r(n),o=i&&t(i,"explode");if(!o||n.getOption("disableInput"))return e.Pass;for(var a=n.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return e.Pass;var c=s(n,a[l].head);if(!c||o.indexOf(c)%2!=0)return e.Pass}n.operation(function(){n.replaceSelection("\n\n",null),n.execCommand("goCharLeft"),a=n.listSelections();for(var e=0;e<a.length;e++){var t=a[e].head.line;n.indentLine(t,null,!0),n.indentLine(t+1,null,!0)}})}function o(t){var r=e.cmpPos(t.anchor,t.head)>0;return{anchor:new d(t.anchor.line,t.anchor.ch+(r?-1:1)),head:new d(t.head.line,t.head.ch+(r?1:-1))}}function a(n,i){var a=r(n);if(!a||n.getOption("disableInput"))return e.Pass;var s=t(a,"pairs"),f=s.indexOf(i);if(f==-1)return e.Pass;for(var h,p=t(a,"triples"),m=s.charAt(f+1)==i,g=n.listSelections(),v=f%2==0,y=0;y<g.length;y++){var b,x=g[y],w=x.head,k=n.getRange(w,d(w.line,w.ch+1));if(v&&!x.empty())b="surround";else if(!m&&v||k!=i)if(m&&w.ch>1&&p.indexOf(i)>=0&&n.getRange(d(w.line,w.ch-2),w)==i+i&&(w.ch<=2||n.getRange(d(w.line,w.ch-3),d(w.line,w.ch-2))!=i))b="addFour";else if(m){if(e.isWordChar(k)||!c(n,w,i))return e.Pass;b="both"}else{if(!v||n.getLine(w.line).length!=w.ch&&!l(k,s)&&!/\s/.test(k))return e.Pass;b="both"}else b=m&&u(n,w)?"both":p.indexOf(i)>=0&&n.getRange(w,d(w.line,w.ch+3))==i+i+i?"skipThree":"skip";if(h){if(h!=b)return e.Pass}else h=b}var C=f%2?s.charAt(f-1):i,S=f%2?i:s.charAt(f+1);n.operation(function(){if("skip"==h)n.execCommand("goCharRight");else if("skipThree"==h)for(var e=0;e<3;e++)n.execCommand("goCharRight");else if("surround"==h){for(var t=n.getSelections(),e=0;e<t.length;e++)t[e]=C+t[e]+S;n.replaceSelections(t,"around"),t=n.listSelections().slice();for(var e=0;e<t.length;e++)t[e]=o(t[e]);n.setSelections(t)}else"both"==h?(n.replaceSelection(C+S,null),n.triggerElectric(C+S),n.execCommand("goCharLeft")):"addFour"==h&&(n.replaceSelection(C+C+C+C,"before"),n.execCommand("goCharRight"))})}function l(e,t){var r=t.lastIndexOf(e);return r>-1&&r%2==1}function s(e,t){var r=e.getRange(d(t.line,t.ch-1),d(t.line,t.ch+1));return 2==r.length?r:null}function c(t,r,n){var i=t.getLine(r.line),o=t.getTokenAt(r);if(/\bstring2?\b/.test(o.type)||u(t,r))return!1;var a=new e.StringStream(i.slice(0,r.ch)+n+i.slice(r.ch),4);for(a.pos=a.start=o.start;;){var l=t.getMode().token(a,o.state);if(a.pos>=r.ch+1)return/\bstring2?\b/.test(l);a.start=a.pos}}function u(e,t){var r=e.getTokenAt(d(t.line,t.ch+1));return/\bstring/.test(r.type)&&r.start==t.ch}var f={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"},d=e.Pos;e.defineOption("autoCloseBrackets",!1,function(t,r,n){n&&n!=e.Init&&(t.removeKeyMap(p),t.state.closeBrackets=null),r&&(t.state.closeBrackets=r,t.addKeyMap(p))});for(var h=f.pairs+"`",p={Backspace:n,Enter:i},m=0;m<h.length;m++)p["'"+h.charAt(m)+"'"]=function(e){return function(t){return a(t,e)}}(h.charAt(m))}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/edit/matchbrackets")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(e){"use strict";function t(t,r,n){if(n<0&&0==r.ch)return t.clipPos(h(r.line-1));var i=t.getLine(r.line);if(n>0&&r.ch>=i.length)return t.clipPos(h(r.line+1,0));for(var o,a="start",l=r.ch,s=n<0?0:i.length,c=0;l!=s;l+=n,c++){var u=i.charAt(n<0?l-1:l),f="_"!=u&&e.isWordChar(u)?"w":"o";if("w"==f&&u.toUpperCase()==u&&(f="W"),"start"==a)"o"!=f&&(a="in",o=f);else if("in"==a&&o!=f){if("w"==o&&"W"==f&&n<0&&l--,"W"==o&&"w"==f&&n>0){o="w";continue}break}}return h(r.line,l)}function r(e,r){e.extendSelectionsBy(function(n){return e.display.shift||e.doc.extend||n.empty()?t(e.doc,n.head,r):r<0?n.from():n.to()})}function n(t,r){if(t.isReadOnly())return e.Pass;t.operation(function(){for(var e=t.listSelections().length,n=[],i=-1,o=0;o<e;o++){var a=t.listSelections()[o].head;if(!(a.line<=i)){var l=h(a.line+(r?0:1),0);t.replaceRange("\n",l,null,"+insertLine"),t.indentLine(l.line,null,!0),n.push({head:l,anchor:l}),i=a.line+1}}t.setSelections(n)}),t.execCommand("indentAuto")}function i(t,r){for(var n=r.ch,i=n,o=t.getLine(r.line);n&&e.isWordChar(o.charAt(n-1));)--n;for(;i<o.length&&e.isWordChar(o.charAt(i));)++i;return{from:h(r.line,n),to:h(r.line,i),word:o.slice(n,i)}}function o(e,t,r){for(var n=0;n<e.length;n++)if(e[n].from()==t&&e[n].to()==r)return!0;return!1}function a(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n],o=i.head,a=e.scanForBracket(o,-1);if(!a)return!1;for(;;){var l=e.scanForBracket(o,1);if(!l)return!1;if(l.ch==y.charAt(y.indexOf(a.ch)+1)){r.push({anchor:h(a.pos.line,a.pos.ch+1),head:l.pos});break}o=h(l.pos.line,l.pos.ch+1)}}return e.setSelections(r),!0}function l(t,r){if(t.isReadOnly())return e.Pass;for(var n,i=t.listSelections(),o=[],a=0;a<i.length;a++){var l=i[a];if(!l.empty()){for(var s=l.from().line,c=l.to().line;a<i.length-1&&i[a+1].from().line==c;)c=i[++a].to().line;i[a].to().ch||c--,o.push(s,c)}}o.length?n=!0:o.push(t.firstLine(),t.lastLine()),t.operation(function(){for(var e=[],i=0;i<o.length;i+=2){var a=o[i],l=o[i+1],s=h(a,0),c=h(l),u=t.getRange(s,c,!1);r?u.sort():u.sort(function(e,t){var r=e.toUpperCase(),n=t.toUpperCase();return r!=n&&(e=r,t=n),e<t?-1:e==t?0:1}),t.replaceRange(u,s,c),n&&e.push({anchor:s,head:h(l+1,0)})}n&&t.setSelections(e,0)})}function s(t,r){t.operation(function(){for(var n=t.listSelections(),o=[],a=[],l=0;l<n.length;l++){var s=n[l];s.empty()?(o.push(l),a.push("")):a.push(r(t.getRange(s.from(),s.to())))}t.replaceSelections(a,"around","case");for(var c,l=o.length-1;l>=0;l--){var s=n[o[l]];if(!(c&&e.cmpPos(s.head,c)>0)){var u=i(t,s.head);c=u.from,t.replaceRange(r(u.word),u.from,u.to)}}})}function c(t){var r=t.getCursor("from"),n=t.getCursor("to");if(0==e.cmpPos(r,n)){var o=i(t,r);if(!o.word)return;r=o.from,n=o.to}return{from:r,to:n,query:t.getRange(r,n),word:o}}function u(e,t){var r=c(e);if(r){var n=r.query,i=e.getSearchCursor(n,t?r.to:r.from);(t?i.findNext():i.findPrevious())?e.setSelection(i.from(),i.to()):(i=e.getSearchCursor(n,t?h(e.firstLine(),0):e.clipPos(h(e.lastLine()))),(t?i.findNext():i.findPrevious())?e.setSelection(i.from(),i.to()):r.word&&e.setSelection(r.from,r.to))}}var f=e.keyMap.sublime={fallthrough:"default"},d=e.commands,h=e.Pos,p=e.keyMap.default==e.keyMap.macDefault,m=p?"Cmd-":"Ctrl-",g=p?"Ctrl-":"Alt-";d[f[g+"Left"]="goSubwordLeft"]=function(e){r(e,-1)},d[f[g+"Right"]="goSubwordRight"]=function(e){r(e,1)},p&&(f["Cmd-Left"]="goLineStartSmart");var v=p?"Ctrl-Alt-":"Ctrl-";d[f[v+"Up"]="scrollLineUp"]=function(e){var t=e.getScrollInfo();if(!e.somethingSelected()){var r=e.lineAtHeight(t.top+t.clientHeight,"local");e.getCursor().line>=r&&e.execCommand("goLineUp")}e.scrollTo(null,t.top-e.defaultTextHeight())},d[f[v+"Down"]="scrollLineDown"]=function(e){var t=e.getScrollInfo();if(!e.somethingSelected()){var r=e.lineAtHeight(t.top,"local")+1;e.getCursor().line<=r&&e.execCommand("goLineDown")}e.scrollTo(null,t.top+e.defaultTextHeight())},d[f["Shift-"+m+"L"]="splitSelectionByLine"]=function(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++)for(var i=t[n].from(),o=t[n].to(),a=i.line;a<=o.line;++a)o.line>i.line&&a==o.line&&0==o.ch||r.push({anchor:a==i.line?i:h(a,0),head:a==o.line?o:h(a)});e.setSelections(r,0)},f["Shift-Tab"]="indentLess",d[f.Esc="singleSelectionTop"]=function(e){var t=e.listSelections()[0];e.setSelection(t.anchor,t.head,{scroll:!1})},d[f[m+"L"]="selectLine"]=function(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n];r.push({anchor:h(i.from().line,0),head:h(i.to().line+1,0)})}e.setSelections(r)},f["Shift-Ctrl-K"]="deleteLine",d[f[m+"Enter"]="insertLineAfter"]=function(e){return n(e,!1)},d[f["Shift-"+m+"Enter"]="insertLineBefore"]=function(e){return n(e,!0)},d[f[m+"D"]="selectNextOccurrence"]=function(t){var r=t.getCursor("from"),n=t.getCursor("to"),a=t.state.sublimeFindFullWord==t.doc.sel;if(0==e.cmpPos(r,n)){var l=i(t,r);if(!l.word)return;t.setSelection(l.from,l.to),a=!0}else{var s=t.getRange(r,n),c=a?new RegExp("\\b"+s+"\\b"):s,u=t.getSearchCursor(c,n),f=u.findNext();if(f||(u=t.getSearchCursor(c,h(t.firstLine(),0)),f=u.findNext()),!f||o(t.listSelections(),u.from(),u.to()))return e.Pass;t.addSelection(u.from(),u.to())}a&&(t.state.sublimeFindFullWord=t.doc.sel)};var y="(){}[]";d[f["Shift-"+m+"Space"]="selectScope"]=function(e){a(e)||e.execCommand("selectAll")},d[f["Shift-"+m+"M"]="selectBetweenBrackets"]=function(t){if(!a(t))return e.Pass},d[f[m+"M"]="goToBracket"]=function(t){t.extendSelectionsBy(function(r){var n=t.scanForBracket(r.head,1);if(n&&0!=e.cmpPos(n.pos,r.head))return n.pos;var i=t.scanForBracket(r.head,-1);return i&&h(i.pos.line,i.pos.ch+1)||r.head})};var b=p?"Cmd-Ctrl-":"Shift-Ctrl-";d[f[b+"Up"]="swapLineUp"]=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),n=[],i=t.firstLine()-1,o=[],a=0;a<r.length;a++){var l=r[a],s=l.from().line-1,c=l.to().line;o.push({anchor:h(l.anchor.line-1,l.anchor.ch),head:h(l.head.line-1,l.head.ch)}),0!=l.to().ch||l.empty()||--c,s>i?n.push(s,c):n.length&&(n[n.length-1]=c),i=c}t.operation(function(){for(var e=0;e<n.length;e+=2){var r=n[e],i=n[e+1],a=t.getLine(r);t.replaceRange("",h(r,0),h(r+1,0),"+swapLine"),i>t.lastLine()?t.replaceRange("\n"+a,h(t.lastLine()),null,"+swapLine"):t.replaceRange(a+"\n",h(i,0),null,"+swapLine")}t.setSelections(o),t.scrollIntoView()})},d[f[b+"Down"]="swapLineDown"]=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),n=[],i=t.lastLine()+1,o=r.length-1;o>=0;o--){var a=r[o],l=a.to().line+1,s=a.from().line;0!=a.to().ch||a.empty()||l--,l<i?n.push(l,s):n.length&&(n[n.length-1]=s),i=s}t.operation(function(){for(var e=n.length-2;e>=0;e-=2){var r=n[e],i=n[e+1],o=t.getLine(r);r==t.lastLine()?t.replaceRange("",h(r-1),h(r),"+swapLine"):t.replaceRange("",h(r,0),h(r+1,0),"+swapLine"),t.replaceRange(o+"\n",h(i,0),null,"+swapLine")}t.scrollIntoView()})},d[f[m+"/"]="toggleCommentIndented"]=function(e){e.toggleComment({indent:!0})},d[f[m+"J"]="joinLines"]=function(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){for(var i=t[n],o=i.from(),a=o.line,l=i.to().line;n<t.length-1&&t[n+1].from().line==l;)l=t[++n].to().line;r.push({start:a,end:l,anchor:!i.empty()&&o})}e.operation(function(){for(var t=0,n=[],i=0;i<r.length;i++){for(var o,a=r[i],l=a.anchor&&h(a.anchor.line-t,a.anchor.ch),s=a.start;s<=a.end;s++){var c=s-t;s==a.end&&(o=h(c,e.getLine(c).length+1)),c<e.lastLine()&&(e.replaceRange(" ",h(c),h(c+1,/^\s*/.exec(e.getLine(c+1))[0].length)),++t)}n.push({anchor:l||o,head:o})}e.setSelections(n,0)})},d[f["Shift-"+m+"D"]="duplicateLine"]=function(e){e.operation(function(){for(var t=e.listSelections().length,r=0;r<t;r++){var n=e.listSelections()[r];n.empty()?e.replaceRange(e.getLine(n.head.line)+"\n",h(n.head.line,0)):e.replaceRange(e.getRange(n.from(),n.to()),n.from())}e.scrollIntoView()})},p||(f[m+"T"]="transposeChars"),d[f.F9="sortLines"]=function(e){l(e,!0)},d[f[m+"F9"]="sortLinesInsensitive"]=function(e){l(e,!1)},d[f.F2="nextBookmark"]=function(e){var t=e.state.sublimeBookmarks;if(t)for(;t.length;){var r=t.shift(),n=r.find();if(n)return t.push(r),e.setSelection(n.from,n.to)}},d[f["Shift-F2"]="prevBookmark"]=function(e){var t=e.state.sublimeBookmarks;if(t)for(;t.length;){t.unshift(t.pop());var r=t[t.length-1].find();if(r)return e.setSelection(r.from,r.to);t.pop()}},d[f[m+"F2"]="toggleBookmark"]=function(e){for(var t=e.listSelections(),r=e.state.sublimeBookmarks||(e.state.sublimeBookmarks=[]),n=0;n<t.length;n++){for(var i=t[n].from(),o=t[n].to(),a=e.findMarks(i,o),l=0;l<a.length;l++)if(a[l].sublimeBookmark){a[l].clear();for(var s=0;s<r.length;s++)r[s]==a[l]&&r.splice(s--,1);break}l==a.length&&r.push(e.markText(i,o,{sublimeBookmark:!0,clearWhenEmpty:!1}))}},d[f["Shift-"+m+"F2"]="clearBookmarks"]=function(e){var t=e.state.sublimeBookmarks;if(t)for(var r=0;r<t.length;r++)t[r].clear();t.length=0},d[f["Alt-F2"]="selectBookmarks"]=function(e){var t=e.state.sublimeBookmarks,r=[];if(t)for(var n=0;n<t.length;n++){var i=t[n].find();i?r.push({anchor:i.from,head:i.to}):t.splice(n--,0)}r.length&&e.setSelections(r,0)},f["Alt-Q"]="wrapLines";var x=m+"K ";f[x+m+"Backspace"]="delLineLeft",d[f.Backspace="smartBackspace"]=function(t){if(t.somethingSelected())return e.Pass;t.operation(function(){for(var r=t.listSelections(),n=t.getOption("indentUnit"),i=r.length-1;i>=0;i--){var o=r[i].head,a=t.getRange({line:o.line,ch:0},o),l=e.countColumn(a,null,t.getOption("tabSize")),s=t.findPosH(o,-1,"char",!1);if(a&&!/\S/.test(a)&&l%n==0){var c=new h(o.line,e.findColumn(a,l-n,n));c.ch!=o.ch&&(s=c)}t.replaceRange("",s,o,"+delete")}})},d[f[x+m+"K"]="delLineRight"]=function(e){e.operation(function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange("",t[r].anchor,h(t[r].to().line),"+delete");e.scrollIntoView()})},d[f[x+m+"U"]="upcaseAtCursor"]=function(e){s(e,function(e){return e.toUpperCase()})},d[f[x+m+"L"]="downcaseAtCursor"]=function(e){s(e,function(e){return e.toLowerCase()})},d[f[x+m+"Space"]="setSublimeMark"]=function(e){e.state.sublimeMark&&e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor())},d[f[x+m+"A"]="selectToSublimeMark"]=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&e.setSelection(e.getCursor(),t)},d[f[x+m+"W"]="deleteToSublimeMark"]=function(t){var r=t.state.sublimeMark&&t.state.sublimeMark.find();if(r){var n=t.getCursor(),i=r;if(e.cmpPos(n,i)>0){var o=i;i=n,n=o}t.state.sublimeKilled=t.getRange(n,i),t.replaceRange("",n,i)}},d[f[x+m+"X"]="swapWithSublimeMark"]=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&(e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor()),e.setCursor(t))},d[f[x+m+"Y"]="sublimeYank"]=function(e){null!=e.state.sublimeKilled&&e.replaceSelection(e.state.sublimeKilled,null,"paste")},f[x+m+"G"]="clearBookmarks",d[f[x+m+"C"]="showInCenter"]=function(e){var t=e.cursorCoords(null,"local");e.scrollTo(null,(t.top+t.bottom)/2-e.getScrollInfo().clientHeight/2)};var w=p?"Ctrl-Shift-":"Ctrl-Alt-";d[f[w+"Up"]="selectLinesUpward"]=function(e){e.operation(function(){for(var t=e.listSelections(),r=0;r<t.length;r++){var n=t[r];n.head.line>e.firstLine()&&e.addSelection(h(n.head.line-1,n.head.ch))}})},d[f[w+"Down"]="selectLinesDownward"]=function(e){e.operation(function(){for(var t=e.listSelections(),r=0;r<t.length;r++){var n=t[r];n.head.line<e.lastLine()&&e.addSelection(h(n.head.line+1,n.head.ch))}})},d[f[m+"F3"]="findUnder"]=function(e){u(e,!0)},d[f["Shift-"+m+"F3"]="findUnderPrevious"]=function(e){u(e,!1)},d[f["Alt-F3"]="findAllUnder"]=function(e){var t=c(e);if(t){for(var r=e.getSearchCursor(t.query),n=[],i=-1;r.findNext();)n.push({anchor:r.from(),head:r.to()}),r.from().line<=t.from.line&&r.from().ch<=t.from.ch&&i++;e.setSelections(n,i)}},f["Shift-"+m+"["]="fold",f["Shift-"+m+"]"]="unfold",f[x+m+"0"]=f[x+m+"J"]="unfoldAll",f[m+"I"]="findIncremental",f["Shift-"+m+"I"]="findIncrementalReverse",f[m+"H"]="replace",f.F3="findNext",f["Shift-F3"]="findPrev",e.normalizeKeyMap(f)}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror")):"function"==typeof define&&define.amd?define(["../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return e.line==t.line&&e.ch==t.ch}function r(e){P.push(e),P.length>50&&P.shift()}function n(e){if(!P.length)return r(e);P[P.length-1]+=e}function i(e){return P[P.length-(e?Math.min(e,1):1)]||""}function o(){return P.length>1&&P.pop(),i()}function a(e,i,o,a,l){null==l&&(l=e.getRange(i,o)),a&&R&&R.cm==e&&t(i,R.pos)&&e.isClean(R.gen)?n(l):r(l),e.replaceRange("",i,o,"+delete"),R=a?{cm:e,pos:i,gen:e.changeGeneration()}:null}function l(e,t,r){return e.findPosH(t,r,"char",!0)}function s(e,t,r){return e.findPosH(t,r,"word",!0)}function c(e,t,r){return e.findPosV(t,r,"line",e.doc.sel.goalColumn)}function u(e,t,r){return e.findPosV(t,r,"page",e.doc.sel.goalColumn)}function f(e,t,r){for(var n=t.line,i=e.getLine(n),o=/\S/.test(r<0?i.slice(0,t.ch):i.slice(t.ch)),a=e.firstLine(),l=e.lastLine();;){if((n+=r)<a||n>l)return e.clipPos(N(n-r,r<0?0:null));i=e.getLine(n);if(/\S/.test(i))o=!0;else if(o)return N(n,0)}}function d(e,t,r){for(var n=t.line,i=t.ch,o=e.getLine(t.line),a=!1;;){var l=o.charAt(i+(r<0?-1:0));if(l){if(a&&/[!?.]/.test(l))return N(n,i+(r>0?1:0));a||(a=/\w/.test(l)),i+=r}else{if(n==(r<0?e.firstLine():e.lastLine()))return N(n,i);if(o=e.getLine(n+r),!/\S/.test(o))return N(n,i);n+=r,i=r<0?o.length:0}}}function h(e,r,n){var i;if(e.findMatchingBracket&&(i=e.findMatchingBracket(r,!0))&&i.match&&(i.forward?1:-1)==n)return n>0?N(i.to.line,i.to.ch+1):i.to;for(var o=!0;;o=!1){var a=e.getTokenAt(r),l=N(r.line,n<0?a.start:a.end);if(!(o&&n>0&&a.end==r.ch)&&/\w/.test(a.string))return l;var s=e.findPosH(l,n,"char");if(t(l,s))return r;r=s}}function p(e,t){var r=e.state.emacsPrefix;return r?(k(e),"-"==r?-1:Number(r)):t?null:1}function m(e){var t="string"==typeof e?function(t){t.execCommand(e)}:e;return function(e){var r=p(e);t(e);for(var n=1;n<r;++n)t(e)}}function g(e,r,n,i){var o=p(e);o<0&&(i=-i,o=-o);for(var a=0;a<o;++a){var l=n(e,r,i);if(t(l,r))break;r=l}return r}function v(e,t){var r=function(r){r.extendSelection(g(r,r.getCursor(),e,t))};return r.motion=!0,r}function y(e,t,r){for(var n,i=e.listSelections(),o=i.length;o--;)n=i[o].head,a(e,n,g(e,n,t,r),!0)}function b(e){if(e.somethingSelected()){for(var t,r=e.listSelections(),n=r.length;n--;)t=r[n],a(e,t.anchor,t.head);return!0}}function x(e,t){if(e.state.emacsPrefix)return void("-"!=t&&(e.state.emacsPrefix+=t));e.state.emacsPrefix=t,e.on("keyHandled",w),e.on("inputRead",C)}function w(e,t){e.state.emacsPrefixMap||B.hasOwnProperty(t)||k(e)}function k(e){e.state.emacsPrefix=null,e.off("keyHandled",w),e.off("inputRead",C)}function C(e,t){var r=p(e);if(r>1&&"+input"==t.origin){for(var n=t.text.join("\n"),i="",o=1;o<r;++o)i+=n;e.replaceSelection(i)}}function S(e){e.state.emacsPrefixMap=!0,e.addKeyMap(D),e.on("keyHandled",_),e.on("inputRead",_)}function _(e,t){("string"!=typeof t||!/^\d$/.test(t)&&"Ctrl-U"!=t)&&(e.removeKeyMap(D),e.state.emacsPrefixMap=!1,e.off("keyHandled",_),e.off("inputRead",_))}function M(e){e.setCursor(e.getCursor()),e.setExtending(!e.getExtending()),e.on("change",function(){e.setExtending(!1)})}function L(e){e.setExtending(!1),e.setCursor(e.getCursor())}function T(e,t,r){e.openDialog?e.openDialog(t+': <input type="text" style="width: 10em"/>',r,{bottom:!0}):r(prompt(t,""))}function A(e,t){var r=e.getCursor(),n=e.findPosH(r,1,"word");e.replaceRange(t(e.getRange(r,n)),r,n),e.setCursor(n)}function O(e){for(var t=e.getCursor(),r=t.line,n=t.ch,i=[];r>=e.firstLine();){for(var o=e.getLine(r),a=null==n?o.length:n;a>0;){var n=o.charAt(--a);if(")"==n)i.push("(");else if("]"==n)i.push("[");else if("}"==n)i.push("{");else if(/[\(\{\[]/.test(n)&&(!i.length||i.pop()!=n))return e.extendSelection(N(r,a))}--r,n=null}}function E(e){e.execCommand("clearSearch"),L(e)}function I(e){D[e]=function(t){x(t,e)},z["Ctrl-"+e]=function(t){x(t,e)},B["Ctrl-"+e]=!0}var N=e.Pos,P=[],R=null,B={"Alt-G":!0,"Ctrl-X":!0,"Ctrl-Q":!0,"Ctrl-U":!0};e.emacs={kill:a,killRegion:b,repeated:m};for(var z=e.keyMap.emacs=e.normalizeKeyMap({"Ctrl-W":function(e){a(e,e.getCursor("start"),e.getCursor("end"))},"Ctrl-K":m(function(e){var t=e.getCursor(),r=e.clipPos(N(t.line)),n=e.getRange(t,r);/\S/.test(n)||(n+="\n",r=N(t.line+1,0)),a(e,t,r,!0,n)}),"Alt-W":function(e){r(e.getSelection()),L(e)},"Ctrl-Y":function(e){var t=e.getCursor();e.replaceRange(i(p(e)),t,t,"paste"),e.setSelection(t,e.getCursor())},"Alt-Y":function(e){e.replaceSelection(o(),"around","paste")},"Ctrl-Space":M,"Ctrl-Shift-2":M,"Ctrl-F":v(l,1),"Ctrl-B":v(l,-1),Right:v(l,1),Left:v(l,-1),"Ctrl-D":function(e){y(e,l,1)},Delete:function(e){b(e)||y(e,l,1)},"Ctrl-H":function(e){y(e,l,-1)},Backspace:function(e){b(e)||y(e,l,-1)},"Alt-F":v(s,1),"Alt-B":v(s,-1),"Alt-D":function(e){y(e,s,1)},"Alt-Backspace":function(e){y(e,s,-1)},"Ctrl-N":v(c,1),"Ctrl-P":v(c,-1),Down:v(c,1),Up:v(c,-1),"Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd",End:"goLineEnd",Home:"goLineStart","Alt-V":v(u,-1),"Ctrl-V":v(u,1),PageUp:v(u,-1),PageDown:v(u,1),"Ctrl-Up":v(f,-1),"Ctrl-Down":v(f,1),"Alt-A":v(d,-1),"Alt-E":v(d,1),"Alt-K":function(e){y(e,d,1)},"Ctrl-Alt-K":function(e){y(e,h,1)},"Ctrl-Alt-Backspace":function(e){y(e,h,-1)},"Ctrl-Alt-F":v(h,1),"Ctrl-Alt-B":v(h,-1),"Shift-Ctrl-Alt-2":function(e){var t=e.getCursor();e.setSelection(g(e,t,h,1),t)},"Ctrl-Alt-T":function(e){var t=h(e,e.getCursor(),-1),r=h(e,t,1),n=h(e,r,1),i=h(e,n,-1);e.replaceRange(e.getRange(i,n)+e.getRange(r,i)+e.getRange(t,r),t,n)},"Ctrl-Alt-U":m(O),"Alt-Space":function(e){for(var t=e.getCursor(),r=t.ch,n=t.ch,i=e.getLine(t.line);r&&/\s/.test(i.charAt(r-1));)--r;for(;n<i.length&&/\s/.test(i.charAt(n));)++n;e.replaceRange(" ",N(t.line,r),N(t.line,n))},"Ctrl-O":m(function(e){e.replaceSelection("\n","start")}),"Ctrl-T":m(function(e){e.execCommand("transposeChars")}),"Alt-C":m(function(e){A(e,function(e){var t=e.search(/\w/);return t==-1?e:e.slice(0,t)+e.charAt(t).toUpperCase()+e.slice(t+1).toLowerCase()})}),"Alt-U":m(function(e){A(e,function(e){return e.toUpperCase()})}),"Alt-L":m(function(e){A(e,function(e){return e.toLowerCase()})}),"Alt-;":"toggleComment","Ctrl-/":m("undo"),"Shift-Ctrl--":m("undo"),"Ctrl-Z":m("undo"),"Cmd-Z":m("undo"),"Shift-Alt-,":"goDocStart","Shift-Alt-.":"goDocEnd","Ctrl-S":"findNext","Ctrl-R":"findPrev","Ctrl-G":E,"Shift-Alt-5":"replace","Alt-/":"autocomplete",Enter:"newlineAndIndent","Ctrl-J":m(function(e){e.replaceSelection("\n","end")}),Tab:"indentAuto","Alt-G G":function(e){var t=p(e,!0);if(null!=t&&t>0)return e.setCursor(t-1);T(e,"Goto line",function(t){var r;t&&!isNaN(r=Number(t))&&r==(0|r)&&r>0&&e.setCursor(r-1)})},"Ctrl-X Tab":function(e){e.indentSelection(p(e,!0)||e.getOption("indentUnit"))},"Ctrl-X Ctrl-X":function(e){e.setSelection(e.getCursor("head"),e.getCursor("anchor"))},"Ctrl-X Ctrl-S":"save","Ctrl-X Ctrl-W":"save","Ctrl-X S":"saveAll","Ctrl-X F":"open","Ctrl-X U":m("undo"),"Ctrl-X K":"close","Ctrl-X Delete":function(e){a(e,e.getCursor(),d(e,e.getCursor(),1),!0)},"Ctrl-X H":"selectAll","Ctrl-Q Tab":m("insertTab"),"Ctrl-U":S}),D={"Ctrl-G":k},W=0;W<10;++W)I(String(W));I("-")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(e){"use strict";var t=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},
|
11 |
context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],r=[{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"}],n=e.Pos;e.Vim=function(){function i(t){t.setOption("disableInput",!0),t.setOption("showCursorWhenSelecting",!1),e.signal(t,"vim-mode-change",{mode:"normal"}),t.on("cursorActivity",tt),C(t),e.on(t.getInputField(),"paste",u(t))}function o(t){t.setOption("disableInput",!1),t.off("cursorActivity",tt),e.off(t.getInputField(),"paste",u(t)),t.state.vim=null}function a(t,r){this==e.keyMap.vim&&e.rmClass(t.getWrapperElement(),"cm-fat-cursor"),r&&r.attach==l||o(t,!1)}function l(t,r){this==e.keyMap.vim&&e.addClass(t.getWrapperElement(),"cm-fat-cursor"),r&&r.attach==l||i(t)}function s(t,r){if(r){if(this[t])return this[t];var n=c(t);if(!n)return!1;var i=e.Vim.findKey(r,n);return"function"==typeof i&&e.signal(r,"vim-keypress",n),i}}function c(e){if("'"==e.charAt(0))return e.charAt(1);var t=e.split(/-(?!$)/),r=t[t.length-1];if(1==t.length&&1==t[0].length)return!1;if(2==t.length&&"Shift"==t[0]&&1==r.length)return!1;for(var n=!1,i=0;i<t.length;i++){var o=t[i];o in st?t[i]=st[o]:n=!0,o in ct&&(t[i]=ct[o])}return!!n&&(g(r)&&(t[t.length-1]=r.toLowerCase()),"<"+t.join("-")+">")}function u(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(z(e.getCursor(),0,1)),Lt.enterInsertMode(e,{},t))}),t.onPasteFn}function f(e,t){for(var r=[],n=e;n<e+t;n++)r.push(String.fromCharCode(n));return r}function d(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function h(e){return/^[a-z]$/.test(e)}function p(e){return"()[]{}".indexOf(e)!=-1}function m(e){return ut.test(e)}function g(e){return/^[A-Z]$/.test(e)}function v(e){return/^\s*$/.test(e)}function y(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}function b(e,t,r,n,i){if(void 0===t&&!i)throw Error("defaultValue is required unless callback is provided");if(r||(r="string"),yt[e]={type:r,defaultValue:t,callback:i},n)for(var o=0;o<n.length;o++)yt[n[o]]=yt[e];t&&x(e,t)}function x(e,t,r,n){var i=yt[e];n=n||{};var o=n.scope;if(!i)throw Error("Unknown option: "+e);if("boolean"==i.type){if(t&&t!==!0)throw Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}i.callback?("local"!==o&&i.callback(t,void 0),"global"!==o&&r&&i.callback(t,r)):("local"!==o&&(i.value="boolean"==i.type?!!t:t),"global"!==o&&r&&(r.state.vim.options[e]={value:t}))}function w(e,t,r){var n=yt[e];r=r||{};var i=r.scope;if(!n)throw Error("Unknown option: "+e);{if(!n.callback){var o="global"!==i&&t&&t.state.vim.options[e];return(o||"local"!==i&&n||{}).value}var o=t&&n.callback(void 0,t);if("global"!==i&&void 0!==o)return o;if("local"!==i)return n.callback()}}function k(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=xt()}function C(e){return e.state.vim||(e.state.vim={inputState:new _,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}}),e.state.vim}function S(){wt={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:bt(),macroModeState:new k,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new A({}),searchHistoryController:new O({}),exCommandHistoryController:new O({})};for(var e in yt){var t=yt[e];t.value=t.defaultValue}}function _(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null}function M(t,r){t.state.vim.inputState=new _,e.signal(t,"vim-command-done",r)}function L(e,t,r){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!r}function T(e,t){var r=wt.registerController.registers[e];if(!e||1!=e.length)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,vt.push(e)}function A(e){this.registers=e,this.unnamedRegister=e['"']=new L,e["."]=new L,e[":"]=new L,e["/"]=new L}function O(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}function E(e,t){_t[e]=t}function I(e,t){for(var r=[],n=0;n<t;n++)r.push(e);return r}function N(e,t){Mt[e]=t}function P(e,t){Lt[e]=t}function R(e,t,r){var i=Math.min(Math.max(e.firstLine(),t.line),e.lastLine()),o=X(e,i)-1;o=r?o+1:o;var a=Math.min(Math.max(0,t.ch),o);return n(i,a)}function B(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function z(e,t,r){return"object"==typeof t&&(r=t.ch,t=t.line),n(e.line+t,e.ch+r)}function D(e,t){return{line:t.line-e.line,ch:t.line-e.line}}function W(e,t,r,n){for(var i,o=[],a=[],l=0;l<t.length;l++){var s=t[l];"insert"==r&&"insert"!=s.context||s.context&&s.context!=r||n.operator&&"action"==s.type||!(i=q(e,s.keys))||("partial"==i&&o.push(s),"full"==i&&a.push(s))}return{partial:o.length&&o,full:a.length&&a}}function q(e,t){if("<character>"==t.slice(-11)){var r=t.length-11,n=e.slice(0,r),i=t.slice(0,r);return n==i&&e.length>r?"full":0==i.indexOf(n)&&"partial"}return e==t?"full":0==t.indexOf(e)&&"partial"}function F(e){var t=/^.*(<[\w\-]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(r.length>1)switch(r){case"<CR>":r="\n";break;case"<Space>":r=" "}return r}function H(e,t,r){return function(){for(var n=0;n<r;n++)t(e)}}function j(e){return n(e.line,e.ch)}function K(e,t){return e.ch==t.ch&&e.line==t.line}function U(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function V(e,t){return arguments.length>2&&(t=V.apply(void 0,Array.prototype.slice.call(arguments,1))),U(e,t)?e:t}function $(e,t){return arguments.length>2&&(t=$.apply(void 0,Array.prototype.slice.call(arguments,1))),U(e,t)?t:e}function G(e,t,r){var n=U(e,t),i=U(t,r);return n&&i}function X(e,t){return e.getLine(t).length}function Y(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Q(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function J(e,t,r){var i=X(e,t),o=new Array(r-i+1).join(" ");e.setCursor(n(t,i)),e.replaceRange(o,e.getCursor())}function Z(e,t){var r=[],i=e.listSelections(),o=j(e.clipPos(t)),a=!K(t,o),l=e.getCursor("head"),s=te(i,l),c=K(i[s].head,i[s].anchor),u=i.length-1,f=u-s>s?u:0,d=i[f].anchor,h=Math.min(d.line,o.line),p=Math.max(d.line,o.line),m=d.ch,g=o.ch,v=i[f].head.ch-m,y=g-m;v>0&&y<=0?(m++,a||g--):v<0&&y>=0?(m--,c||g++):v<0&&y==-1&&(m--,g++);for(var b=h;b<=p;b++){var x={anchor:new n(b,m),head:new n(b,g)};r.push(x)}return s=o.line==p?r.length-1:0,e.setSelections(r),t.ch=g,d.ch=m,d}function ee(e,t,r){for(var n=[],i=0;i<r;i++){var o=z(t,i,0);n.push({anchor:o,head:o})}e.setSelections(n,0)}function te(e,t,r){for(var n=0;n<e.length;n++){var i="head"!=r&&K(e[n].anchor,t),o="anchor"!=r&&K(e[n].head,t);if(i||o)return n}return-1}function re(e,t){var r=t.lastSelection;return t.visualMode?function(){var t=e.listSelections(),r=t[0],n=t[t.length-1];return[U(r.anchor,r.head)?r.anchor:r.head,U(n.anchor,n.head)?n.head:n.anchor]}():function(){var t=e.getCursor(),i=e.getCursor(),o=r.visualBlock;if(o){var a=o.width,l=o.height;i=n(t.line+l,t.ch+a);for(var s=[],c=t.line;c<i.line;c++){var u=n(c,t.ch),f=n(c,i.ch),d={anchor:u,head:f};s.push(d)}e.setSelections(s)}else{var h=r.anchorMark.find(),p=r.headMark.find(),m=p.line-h.line,g=p.ch-h.ch;i={line:i.line+m,ch:m?i.ch:g+i.ch},r.visualLine&&(t=n(t.line,0),i=n(i.line,X(e,i.line))),e.setSelection(t,i)}return[t,i]}()}function ne(e,t){var r=t.sel.anchor,n=t.sel.head;t.lastPastedText&&(n=e.posFromIndex(e.indexFromPos(r)+t.lastPastedText.length),t.lastPastedText=null),t.lastSelection={anchorMark:e.setBookmark(r),headMark:e.setBookmark(n),anchor:j(r),head:j(n),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function ie(e,t,r){var i,o=e.state.vim.sel,a=o.head,l=o.anchor;return U(r,t)&&(i=r,r=t,t=i),U(a,l)?(a=V(t,a),l=$(l,r)):(l=V(t,l),a=$(a,r),a=z(a,0,-1),a.ch==-1&&a.line!=e.firstLine()&&(a=n(a.line-1,X(e,a.line-1)))),[l,a]}function oe(e,t,r){var n=e.state.vim;t=t||n.sel;var r=r||n.visualLine?"line":n.visualBlock?"block":"char",i=ae(e,t,r);e.setSelections(i.ranges,i.primary),rt(e)}function ae(e,t,r,i){var o=j(t.head),a=j(t.anchor);if("char"==r){var l=i||U(t.head,t.anchor)?0:1,s=U(t.head,t.anchor)?1:0;return o=z(t.head,0,l),a=z(t.anchor,0,s),{ranges:[{anchor:a,head:o}],primary:0}}if("line"==r){if(U(t.head,t.anchor))o.ch=0,a.ch=X(e,a.line);else{a.ch=0;var c=e.lastLine();o.line>c&&(o.line=c),o.ch=X(e,o.line)}return{ranges:[{anchor:a,head:o}],primary:0}}if("block"==r){for(var u=Math.min(a.line,o.line),f=Math.min(a.ch,o.ch),d=Math.max(a.line,o.line),h=Math.max(a.ch,o.ch)+1,p=d-u+1,m=o.line==u?0:p-1,g=[],v=0;v<p;v++)g.push({anchor:n(u+v,f),head:n(u+v,h)});return{ranges:g,primary:m}}}function le(e){var t=e.getCursor("head");return 1==e.getSelection().length&&(t=V(t,e.getCursor("anchor"))),t}function se(t,r){var n=t.state.vim;r!==!1&&t.setCursor(R(t,n.sel.head)),ne(t,n),n.visualMode=!1,n.visualLine=!1,n.visualBlock=!1,e.signal(t,"vim-mode-change",{mode:"normal"}),n.fakeCursor&&n.fakeCursor.clear()}function ce(e,t,r){var n=e.getRange(t,r);if(/\n\s*$/.test(n)){var i=n.split("\n");i.pop();for(var o,o=i.pop();i.length>0&&o&&v(o);o=i.pop())r.line--,r.ch=0;o?(r.line--,r.ch=X(e,r.line)):r.ch=0}}function ue(e,t,r){t.ch=0,r.ch=0,r.line++}function fe(e){if(!e)return 0;var t=e.search(/\S/);return t==-1?e.length:t}function de(e,t,r,i,o){for(var a=le(e),l=e.getLine(a.line),s=a.ch,c=o?ft[0]:dt[0];!c(l.charAt(s));)if(++s>=l.length)return null;i?c=dt[0]:(c=ft[0])(l.charAt(s))||(c=ft[1]);for(var u=s,f=s;c(l.charAt(u))&&u<l.length;)u++;for(;c(l.charAt(f))&&f>=0;)f--;if(f++,t){for(var d=u;/\s/.test(l.charAt(u))&&u<l.length;)u++;if(d==u){for(var h=f;/\s/.test(l.charAt(f-1))&&f>0;)f--;f||(f=h)}}return{start:n(a.line,f),end:n(a.line,u)}}function he(e,t,r){K(t,r)||wt.jumpList.add(e,t,r)}function pe(e,t){wt.lastCharacterSearch.increment=e,wt.lastCharacterSearch.forward=t.forward,wt.lastCharacterSearch.selectedCharacter=t.selectedCharacter}function me(e,t,r,i){var o=j(e.getCursor()),a=r?1:-1,l=r?e.lineCount():-1,s=o.ch,c=o.line,u=e.getLine(c),f={lineText:u,nextCh:u.charAt(s),lastCh:null,index:s,symb:i,reverseSymb:(r?{")":"(","}":"{"}:{"(":")","{":"}"})[i],forward:r,depth:0,curMoveThrough:!1},d=Tt[i];if(!d)return o;var h=At[d].init,p=At[d].isComplete;for(h&&h(f);c!==l&&t;){if(f.index+=a,f.nextCh=f.lineText.charAt(f.index),!f.nextCh){if(c+=a,f.lineText=e.getLine(c)||"",a>0)f.index=0;else{var m=f.lineText.length;f.index=m>0?m-1:0}f.nextCh=f.lineText.charAt(f.index)}p(f)&&(o.line=c,o.ch=f.index,t--)}return f.nextCh||f.curMoveThrough?n(c,f.index):o}function ge(e,t,r,n,i){var o=t.line,a=t.ch,l=e.getLine(o),s=r?1:-1,c=n?dt:ft;if(i&&""==l){if(o+=s,l=e.getLine(o),!d(e,o))return null;a=r?0:l.length}for(;;){if(i&&""==l)return{from:0,to:0,line:o};for(var u=s>0?l.length:-1,f=u,h=u;a!=u;){for(var p=!1,m=0;m<c.length&&!p;++m)if(c[m](l.charAt(a))){for(f=a;a!=u&&c[m](l.charAt(a));)a+=s;if(h=a,p=f!=h,f==t.ch&&o==t.line&&h==f+s)continue;return{from:Math.min(f,h+1),to:Math.max(f,h),line:o}}p||(a+=s)}if(o+=s,!d(e,o))return null;l=e.getLine(o),a=s>0?0:l.length}}function ve(e,t,r,i,o,a){var l=j(t),s=[];(i&&!o||!i&&o)&&r++;for(var c=!(i&&o),u=0;u<r;u++){var f=ge(e,t,i,a,c);if(!f){var d=X(e,e.lastLine());s.push(i?{line:e.lastLine(),from:d,to:d}:{line:0,from:0,to:0});break}s.push(f),t=n(f.line,i?f.to-1:f.from)}var h=s.length!=r,p=s[0],m=s.pop();return i&&!o?(h||p.from==l.ch&&p.line==l.line||(m=s.pop()),n(m.line,m.from)):i&&o?n(m.line,m.to-1):!i&&o?(h||p.to==l.ch&&p.line==l.line||(m=s.pop()),n(m.line,m.to)):n(m.line,m.from)}function ye(e,t,r,i){for(var o,a=e.getCursor(),l=a.ch,s=0;s<t;s++){if((o=we(l,e.getLine(a.line),i,r,!0))==-1)return null;l=o}return n(e.getCursor().line,o)}function be(e,t){var r=e.getCursor().line;return R(e,n(r,t-1))}function xe(e,t,r,n){y(r,gt)&&(t.marks[r]&&t.marks[r].clear(),t.marks[r]=e.setBookmark(n))}function we(e,t,r,n,i){var o;return n?(o=t.indexOf(r,e+1))==-1||i||(o-=1):(o=t.lastIndexOf(r,e-1))==-1||i||(o+=1),o}function ke(e,t,r,i,o){function a(t){return!e.getLine(t)}function l(e,t,r){return r?a(e)!=a(e+t):!a(e)&&a(e+t)}var s,c,u=t.line,f=e.firstLine(),d=e.lastLine(),h=u;if(i){for(;f<=h&&h<=d&&r>0;)l(h,i)&&r--,h+=i;return new n(h,0)}var p=e.state.vim;if(p.visualLine&&l(u,1,!0)){var m=p.sel.anchor;l(m.line,-1,!0)&&(o&&m.line==u||(u+=1))}var g=a(u);for(h=u;h<=d&&r;h++)l(h,1,!0)&&(o&&a(h)==g||r--);for(c=new n(h,0),h>d&&!g?g=!0:o=!1,h=u;h>f&&(o&&a(h)!=g&&h!=u||!l(h,-1,!0));h--);return s=new n(h,0),{start:s,end:c}}function Ce(e,t,r,i){var o,a,l=t,s={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[r],c={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[r],u=e.getLine(l.line).charAt(l.ch),f=u===c?1:0;if(o=e.scanForBracket(n(l.line,l.ch+f),-1,null,{bracketRegex:s}),a=e.scanForBracket(n(l.line,l.ch+f),1,null,{bracketRegex:s}),!o||!a)return{start:l,end:l};if(o=o.pos,a=a.pos,o.line==a.line&&o.ch>a.ch||o.line>a.line){var d=o;o=a,a=d}return i?a.ch+=1:o.ch+=1,{start:o,end:a}}function Se(e,t,r,i){var o,a,l,s,c=j(t),u=e.getLine(c.line),f=u.split(""),d=f.indexOf(r);if(c.ch<d?c.ch=d:d<c.ch&&f[c.ch]==r&&(a=c.ch,--c.ch),f[c.ch]!=r||a)for(l=c.ch;l>-1&&!o;l--)f[l]==r&&(o=l+1);else o=c.ch+1;if(o&&!a)for(l=o,s=f.length;l<s&&!a;l++)f[l]==r&&(a=l);return o&&a?(i&&(--o,++a),{start:n(c.line,o),end:n(c.line,a)}):{start:c,end:c}}function _e(){}function Me(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new _e)}function Le(e,t,r,n,i){e.openDialog?e.openDialog(t,n,{bottom:!0,value:i.value,onKeyDown:i.onKeyDown,onKeyUp:i.onKeyUp,selectValueOnOpen:!1}):n(prompt(r,""))}function Te(e){var t=Ae(e)||[];if(!t.length)return[];var r=[];if(0===t[0]){for(var n=0;n<t.length;n++)"number"==typeof t[n]&&r.push(e.substring(t[n]+1,t[n+1]));return r}}function Ae(e){for(var t=!1,r=[],n=0;n<e.length;n++){var i=e.charAt(n);t||"/"!=i||r.push(n),t=!t&&"\\"==i}return r}function Oe(e){for(var t="|(){",r="}",n=!1,i=[],o=-1;o<e.length;o++){var a=e.charAt(o)||"",l=e.charAt(o+1)||"",s=l&&t.indexOf(l)!=-1;n?("\\"===a&&s||i.push(a),n=!1):"\\"===a?(n=!0,l&&r.indexOf(l)!=-1&&(s=!0),s&&"\\"!==l||i.push(a)):(i.push(a),s&&"\\"!==l&&i.push("\\"))}return i.join("")}function Ee(e){for(var t=!1,r=[],n=-1;n<e.length;n++){var i=e.charAt(n)||"",o=e.charAt(n+1)||"";Ot[i+o]?(r.push(Ot[i+o]),n++):t?(r.push(i),t=!1):"\\"===i?(t=!0,m(o)||"$"===o?r.push("$"):"/"!==o&&"\\"!==o&&r.push("\\")):("$"===i&&r.push("$"),r.push(i),"/"===o&&r.push("\\"))}return r.join("")}function Ie(t){for(var r=new e.StringStream(t),n=[];!r.eol();){for(;r.peek()&&"\\"!=r.peek();)n.push(r.next());var i=!1;for(var o in Et)if(r.match(o,!0)){i=!0,n.push(Et[o]);break}i||n.push(r.next())}return n.join("")}function Ne(e,t,r){if(wt.registerController.getRegister("/").setText(e),e instanceof RegExp)return e;var n,i,o=Ae(e);if(o.length){n=e.substring(0,o[0]);i=e.substring(o[0]).indexOf("i")!=-1}else n=e;return n?(w("pcre")||(n=Oe(n)),r&&(t=/^[^A-Z]*$/.test(n)),new RegExp(n,t||i?"i":void 0)):null}function Pe(e,t){e.openNotification?e.openNotification('<span style="color: red">'+t+"</span>",{bottom:!0,duration:5e3}):alert(t)}function Re(e,t){var r='<span style="font-family: monospace; white-space: pre">'+(e||"")+'<input type="text"></span>';return t&&(r+=' <span style="color: #888">'+t+"</span>"),r}function Be(e,t){var r=(t.prefix||"")+" "+(t.desc||"");Le(e,Re(t.prefix,t.desc),r,t.onClose,t)}function ze(e,t){if(e instanceof RegExp&&t instanceof RegExp){for(var r=["global","multiline","ignoreCase","source"],n=0;n<r.length;n++){var i=r[n];if(e[i]!==t[i])return!1}return!0}return!1}function De(e,t,r,n){if(t){var i=Me(e),o=Ne(t,!!r,!!n);if(o)return qe(e,o),ze(o,i.getQuery())?o:(i.setQuery(o),o)}}function We(e){if("^"==e.source.charAt(0))var t=!0;return{token:function(r){if(t&&!r.sol())return void r.skipToEnd();var n=r.match(e,!1);if(n)return 0==n[0].length?(r.next(),"searching"):r.sol()||(r.backUp(1),e.exec(r.next()+n[0]))?(r.match(e),"searching"):(r.next(),null);for(;!r.eol()&&(r.next(),!r.match(e,!1)););},query:e}}function qe(e,t){var r=Me(e),n=r.getOverlay();n&&t==n.query||(n&&e.removeOverlay(n),n=We(t),e.addOverlay(n),e.showMatchesOnScrollbar&&(r.getScrollbarAnnotate()&&r.getScrollbarAnnotate().clear(),r.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))),r.setOverlay(n))}function Fe(e,t,r,i){return void 0===i&&(i=1),e.operation(function(){for(var o=e.getCursor(),a=e.getSearchCursor(r,o),l=0;l<i;l++){var s=a.find(t);if(0==l&&s&&K(a.from(),o)&&(s=a.find(t)),!s&&(a=e.getSearchCursor(r,t?n(e.lastLine()):n(e.firstLine(),0)),!a.find(t)))return}return a.from()})}function He(e){var t=Me(e);e.removeOverlay(Me(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function je(e,t,r){return"number"!=typeof e&&(e=e.line),t instanceof Array?y(e,t):r?e>=t&&e<=r:e==t}function Ke(e){var t=e.getScrollInfo(),r=e.coordsChar({left:0,top:6+t.top},"local"),n=t.clientHeight-10+t.top,i=e.coordsChar({left:0,top:n},"local");return{top:r.line,bottom:i.line}}function Ue(e,t,r){if("'"==r){var n=e.doc.history.done,i=n[n.length-2];return i&&i.ranges&&i.ranges[0].head}var o=t.marks[r];return o&&o.find()}function Ve(t,r,n,i,o,a,l,s,c){function u(){t.operation(function(){for(;!m;)f(),d();h()})}function f(){var e=t.getRange(a.from(),a.to()),r=e.replace(l,s);a.replace(r)}function d(){for(;a.findNext()&&je(a.from(),i,o);)if(n||!g||a.from().line!=g.line)return t.scrollIntoView(a.from(),30),t.setSelection(a.from(),a.to()),g=a.from(),void(m=!1);m=!0}function h(e){if(e&&e(),t.focus(),g){t.setCursor(g);var r=t.state.vim;r.exMode=!1,r.lastHPos=r.lastHSPos=g.ch}c&&c()}function p(r,n,i){switch(e.e_stop(r),e.keyName(r)){case"Y":f(),d();break;case"N":d();break;case"A":var o=c;c=void 0,t.operation(u),c=o;break;case"L":f();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":h(i)}return m&&h(i),!0}t.state.vim.exMode=!0;var m=!1,g=a.from();return d(),m?void Pe(t,"No matches for "+l.source):r?void Be(t,{prefix:"replace with <strong>"+s+"</strong> (y/n/a/q/l)",onKeyDown:p}):(u(),void(c&&c()))}function $e(t){var r=t.state.vim,n=wt.macroModeState,i=wt.registerController.getRegister("."),o=n.isPlaying,a=n.lastInsertModeChanges,l=[];if(!o){for(var s=a.inVisualBlock?r.lastSelection.visualBlock.height:1,c=a.changes,l=[],u=0;u<c.length;)l.push(c[u]),c[u]instanceof it?u++:u+=s;a.changes=l,t.off("change",et),e.off(t.getInputField(),"keydown",ot)}!o&&r.insertModeRepeat>1&&(at(t,r,r.insertModeRepeat-1,!0),r.lastEditInputState.repeatOverride=r.insertModeRepeat),delete r.insertModeRepeat,r.insertMode=!1,t.setCursor(t.getCursor().line,t.getCursor().ch-1),t.setOption("keyMap","vim"),t.setOption("disableInput",!0),t.toggleOverwrite(!1),i.setText(a.changes.join("")),e.signal(t,"vim-mode-change",{mode:"normal"}),n.isRecording&&Je(n)}function Ge(e){t.unshift(e)}function Xe(e,t,r,n,i){var o={keys:e,type:t};o[t]=r,o[t+"Args"]=n;for(var a in i)o[a]=i[a];Ge(o)}function Ye(t,r,n,i){var o=wt.registerController.getRegister(i);if(":"==i)return o.keyBuffer[0]&&Rt.processCommand(t,o.keyBuffer[0]),void(n.isPlaying=!1);var a=o.keyBuffer,l=0;n.isPlaying=!0,n.replaySearchQueries=o.searchQueries.slice(0);for(var s=0;s<a.length;s++)for(var c,u,f=a[s];f;)if(c=/<\w+-.+?>|<\w+>|./.exec(f),u=c[0],f=f.substring(c.index+u.length),e.Vim.handleKey(t,u,"macro"),r.insertMode){var d=o.insertModeChanges[l++].changes;wt.macroModeState.lastInsertModeChanges.changes=d,lt(t,d,1),$e(t)}n.isPlaying=!1}function Qe(e,t){if(!e.isPlaying){var r=e.latestRegister,n=wt.registerController.getRegister(r);n&&n.pushText(t)}}function Je(e){if(!e.isPlaying){var t=e.latestRegister,r=wt.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}function Ze(e,t){if(!e.isPlaying){var r=e.latestRegister,n=wt.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}function et(e,t){var r=wt.macroModeState,n=r.lastInsertModeChanges;if(!r.isPlaying)for(;t;){if(n.expectCursorActivityForChange=!0,"+input"==t.origin||"paste"==t.origin||void 0===t.origin){var i=t.text.join("\n");n.maybeReset&&(n.changes=[],n.maybeReset=!1),n.changes.push(i)}t=t.next}}function tt(e){var t=e.state.vim;if(t.insertMode){var r=wt.macroModeState;if(r.isPlaying)return;var n=r.lastInsertModeChanges;n.expectCursorActivityForChange?n.expectCursorActivityForChange=!1:n.maybeReset=!0}else e.curOp.isVimOp||nt(e,t);t.visualMode&&rt(e)}function rt(e){var t=e.state.vim,r=R(e,j(t.sel.head)),n=z(r,0,1);t.fakeCursor&&t.fakeCursor.clear(),t.fakeCursor=e.markText(r,n,{className:"cm-animate-fat-cursor"})}function nt(t,r){var n=t.getCursor("anchor"),i=t.getCursor("head");if(r.visualMode&&!t.somethingSelected()?se(t,!1):r.visualMode||r.insertMode||!t.somethingSelected()||(r.visualMode=!0,r.visualLine=!1,e.signal(t,"vim-mode-change",{mode:"visual"})),r.visualMode){var o=U(i,n)?0:-1,a=U(i,n)?-1:0;i=z(i,0,o),n=z(n,0,a),r.sel={anchor:n,head:i},xe(t,r,"<",V(i,n)),xe(t,r,">",$(i,n))}else r.insertMode||(r.lastHPos=t.getCursor().ch)}function it(e){this.keyName=e}function ot(t){function r(){return i.maybeReset&&(i.changes=[],i.maybeReset=!1),i.changes.push(new it(o)),!0}var n=wt.macroModeState,i=n.lastInsertModeChanges,o=e.keyName(t);o&&(o.indexOf("Delete")==-1&&o.indexOf("Backspace")==-1||e.lookupKey(o,"vim-insert",r))}function at(e,t,r,n){function i(){l?St.processAction(e,t,t.lastEditActionCommand):St.evalInput(e,t)}function o(r){if(a.lastInsertModeChanges.changes.length>0){r=t.lastEditActionCommand?r:1;var n=a.lastInsertModeChanges;lt(e,n.changes,r)}}var a=wt.macroModeState;a.isPlaying=!0;var l=!!t.lastEditActionCommand,s=t.inputState;if(t.inputState=t.lastEditInputState,l&&t.lastEditActionCommand.interlaceInsertRepeat)for(var c=0;c<r;c++)i(),o(1);else n||i(),o(r);t.inputState=s,t.insertMode&&!n&&$e(e),a.isPlaying=!1}function lt(t,r,n){function i(r){return"string"==typeof r?e.commands[r](t):r(t),!0}var o=t.getCursor("head"),a=wt.macroModeState.lastInsertModeChanges.inVisualBlock;if(a){var l=t.state.vim,s=l.lastSelection,c=D(s.anchor,s.head);ee(t,o,c.line+1),n=t.listSelections().length,t.setCursor(o)}for(var u=0;u<n;u++){a&&t.setCursor(z(o,u,0));for(var f=0;f<r.length;f++){var d=r[f];if(d instanceof it)e.lookupKey(d.keyName,"vim-insert",i);else{var h=t.getCursor();t.replaceRange(d,h,h)}}}a&&t.setCursor(z(o,0,1))}e.defineOption("vimMode",!1,function(t,r,n){r&&"vim"!=t.getOption("keyMap")?t.setOption("keyMap","vim"):!r&&n!=e.Init&&/^vim/.test(t.getOption("keyMap"))&&t.setOption("keyMap","default")});var st={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},ct={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"},ut=/[\d]/,ft=[e.isWordChar,function(t){return t&&!e.isWordChar(t)&&!/\s/.test(t)}],dt=[function(e){return/\S/.test(e)}],ht=f(65,26),pt=f(97,26),mt=f(48,10),gt=[].concat(ht,pt,mt,["<",">"]),vt=[].concat(ht,pt,mt,["-",'"',".",":","/"]),yt={};b("filetype",void 0,"string",["ft"],function(e,t){if(void 0!==t){if(void 0===e){var r=t.getOption("mode");return"null"==r?"":r}var r=""==e?"null":e;t.setOption("mode",r)}});var bt=function(){function e(e,t,l){function s(t){var i=++n%r,o=a[i];o&&o.clear(),a[i]=e.setBookmark(t)}var c=n%r,u=a[c];if(u){var f=u.find();f&&!K(f,t)&&s(t)}else s(t);s(l),i=n,(o=n-r+1)<0&&(o=0)}function t(e,t){n+=t,n>i?n=i:n<o&&(n=o);var l=a[(r+n)%r];if(l&&!l.find()){var s,c=t>0?1:-1,u=e.getCursor();do{if(n+=c,(l=a[(r+n)%r])&&(s=l.find())&&!K(u,s))break}while(n<i&&n>o)}return l}var r=100,n=-1,i=0,o=0,a=new Array(r);return{cachedCursor:void 0,add:e,move:t}},xt=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};k.prototype={exitMacroRecordMode:function(){var e=wt.macroModeState;e.onRecordingDone&&e.onRecordingDone(),e.onRecordingDone=void 0,e.isRecording=!1},enterMacroRecordMode:function(e,t){var r=wt.registerController.getRegister(t);r&&(r.clear(),this.latestRegister=t,e.openDialog&&(this.onRecordingDone=e.openDialog("(recording)["+t+"]",null,{bottom:!0})),this.isRecording=!0)}};var wt,kt,Ct={buildKeyMap:function(){},getRegisterController:function(){return wt.registerController},resetVimGlobalState_:S,getVimGlobalState_:function(){return wt},maybeInitVimState_:C,suppressErrorLogging:!1,InsertModeKey:it,map:function(e,t,r){Rt.map(e,t,r)},unmap:function(e,t){Rt.unmap(e,t)},setOption:x,getOption:w,defineOption:b,defineEx:function(e,t,r){if(t){if(0!==e.indexOf(t))throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered')}else t=e;Pt[e]=r,Rt.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if("function"==typeof n)return n()},findKey:function(r,n,i){function o(){var e=wt.macroModeState;if(e.isRecording){if("q"==n)return e.exitMacroRecordMode(),M(r),!0;"mapping"!=i&&Qe(e,n)}}function a(){if("<Esc>"==n)return M(r),c.visualMode?se(r):c.insertMode&&$e(r),!0}function l(t){for(var i;t;)i=/<\w+-.+?>|<\w+>|./.exec(t),n=i[0],t=t.substring(i.index+n.length),e.Vim.handleKey(r,n,"mapping")}var s,c=C(r);return s=c.insertMode?function(){if(a())return!0;for(var e=c.inputState.keyBuffer=c.inputState.keyBuffer+n,i=1==n.length,o=St.matchCommand(e,t,c.inputState,"insert");e.length>1&&"full"!=o.type;){var e=c.inputState.keyBuffer=e.slice(1),l=St.matchCommand(e,t,c.inputState,"insert");"none"!=l.type&&(o=l)}if("none"==o.type)return M(r),!1;if("partial"==o.type)return kt&&window.clearTimeout(kt),kt=window.setTimeout(function(){c.insertMode&&c.inputState.keyBuffer&&M(r)},w("insertModeEscKeysTimeout")),!i;if(kt&&window.clearTimeout(kt),i){for(var s=r.listSelections(),u=0;u<s.length;u++){var f=s[u].head;r.replaceRange("",z(f,0,-(e.length-1)),f,"+input")}wt.macroModeState.lastInsertModeChanges.changes.pop()}return M(r),o.command}():function(){if(o()||a())return!0;var e=c.inputState.keyBuffer=c.inputState.keyBuffer+n;if(/^[1-9]\d*$/.test(e))return!0;var i=/^(\d*)(.*)$/.exec(e);if(!i)return M(r),!1;var l=c.visualMode?"visual":"normal",s=St.matchCommand(i[2]||i[1],t,c.inputState,l);if("none"==s.type)return M(r),!1;if("partial"==s.type)return!0;c.inputState.keyBuffer="";var i=/^(\d*)(.*)$/.exec(e);return i[1]&&"0"!=i[1]&&c.inputState.pushRepeatDigit(i[1]),s.command}(),s===!1?void 0:s===!0?function(){return!0}:function(){return r.operation(function(){r.curOp.isVimOp=!0;try{"keyToKey"==s.type?l(s.toKeys):St.processCommand(r,c,s)}catch(t){throw r.state.vim=void 0,C(r),e.Vim.suppressErrorLogging||console.log(t),t}return!0})}},handleEx:function(e,t){Rt.processCommand(e,t)},defineMotion:E,defineAction:P,defineOperator:N,mapCommand:Xe,_mapCommand:Ge,defineRegister:T,exitVisualMode:se,exitInsertMode:$e};_.prototype.pushRepeatDigit=function(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)},_.prototype.getRepeat=function(){var e=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(e=1,this.prefixRepeat.length>0&&(e*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(e*=parseInt(this.motionRepeat.join(""),10))),e},L.prototype={setText:function(e,t,r){this.keyBuffer=[e||""],this.linewise=!!t,this.blockwise=!!r},pushText:function(e,t){t&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(e)},pushInsertModeChanges:function(e){this.insertModeChanges.push(xt(e))},pushSearchQuery:function(e){this.searchQueries.push(e)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},A.prototype={pushText:function(e,t,r,n,i){n&&"\n"==r.charAt(0)&&(r=r.slice(1)+"\n"),n&&"\n"!==r.charAt(r.length-1)&&(r+="\n");var o=this.isValidRegister(e)?this.getRegister(e):null;if(!o){switch(t){case"yank":
|
12 |
this.registers[0]=new L(r,n,i);break;case"delete":case"change":r.indexOf("\n")==-1?this.registers["-"]=new L(r,n):(this.shiftNumericRegisters_(),this.registers[1]=new L(r,n))}return void this.unnamedRegister.setText(r,n,i)}g(e)?o.pushText(r,n):o.setText(r,n,i),this.unnamedRegister.setText(o.toString(),n)},getRegister:function(e){return this.isValidRegister(e)?(e=e.toLowerCase(),this.registers[e]||(this.registers[e]=new L),this.registers[e]):this.unnamedRegister},isValidRegister:function(e){return e&&y(e,vt)},shiftNumericRegisters_:function(){for(var e=9;e>=2;e--)this.registers[e]=this.getRegister(""+(e-1))}},O.prototype={nextMatch:function(e,t){var r=this.historyBuffer,n=t?-1:1;null===this.initialPrefix&&(this.initialPrefix=e);for(var i=this.iterator+n;t?i>=0:i<r.length;i+=n)for(var o=r[i],a=0;a<=o.length;a++)if(this.initialPrefix==o.substring(0,a))return this.iterator=i,o;return i>=r.length?(this.iterator=r.length,this.initialPrefix):i<0?e:void 0},pushInput:function(e){var t=this.historyBuffer.indexOf(e);t>-1&&this.historyBuffer.splice(t,1),e.length&&this.historyBuffer.push(e)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var St={matchCommand:function(e,t,r,n){var i=W(e,t,n,r);if(!i.full&&!i.partial)return{type:"none"};if(!i.full&&i.partial)return{type:"partial"};for(var o,a=0;a<i.full.length;a++){var l=i.full[a];o||(o=l)}return"<character>"==o.keys.slice(-11)&&(r.selectedCharacter=F(e)),{type:"full",command:o}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r)}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=B(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator){if(n.operator==r.operator)return n.motion="expandToLine",n.motionArgs={linewise:!0},void this.evalInput(e,t);M(e)}n.operator=r.operator,n.operatorArgs=B(r.operatorArgs),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,i=B(r.operatorMotionArgs);i&&n&&i.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,i=n.getRepeat(),o=!!i,a=B(r.actionArgs)||{};n.selectedCharacter&&(a.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),a.repeat=i||1,a.repeatIsExplicit=o,a.registerName=n.registerName,M(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),Lt[r.action](e,a,t)},processSearch:function(t,r,n){function i(e,i,o){wt.searchHistoryController.pushInput(e),wt.searchHistoryController.reset();try{De(t,e,i,o)}catch(r){return Pe(t,"Invalid regex: "+e),void M(t)}St.processMotion(t,r,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:n.searchArgs.toJumplist}})}function o(e){t.scrollTo(d.left,d.top),i(e,!0,!0);var r=wt.macroModeState;r.isRecording&&Ze(r,e)}function a(r,n,i){var o,a,l=e.keyName(r);"Up"==l||"Down"==l?(o="Up"==l,a=r.target?r.target.selectionEnd:0,n=wt.searchHistoryController.nextMatch(n,o)||"",i(n),a&&r.target&&(r.target.selectionEnd=r.target.selectionStart=Math.min(a,r.target.value.length))):"Left"!=l&&"Right"!=l&&"Ctrl"!=l&&"Alt"!=l&&"Shift"!=l&&wt.searchHistoryController.reset();var c;try{c=De(t,n,!0,!0)}catch(e){}c?t.scrollIntoView(Fe(t,!s,c),30):(He(t),t.scrollTo(d.left,d.top))}function l(r,n,i){var o=e.keyName(r);"Esc"==o||"Ctrl-C"==o||"Ctrl-["==o||"Backspace"==o&&""==n?(wt.searchHistoryController.pushInput(n),wt.searchHistoryController.reset(),De(t,f),He(t),t.scrollTo(d.left,d.top),e.e_stop(r),M(t),i(),t.focus()):"Up"==o||"Down"==o?e.e_stop(r):"Ctrl-U"==o&&(e.e_stop(r),i(""))}if(t.getSearchCursor){var s=n.searchArgs.forward,c=n.searchArgs.wholeWordOnly;Me(t).setReversed(!s);var u=s?"/":"?",f=Me(t).getQuery(),d=t.getScrollInfo();switch(n.searchArgs.querySrc){case"prompt":var h=wt.macroModeState;if(h.isPlaying){var p=h.replaySearchQueries.shift();i(p,!0,!1)}else Be(t,{onClose:o,prefix:u,desc:It,onKeyUp:a,onKeyDown:l});break;case"wordUnderCursor":var m=de(t,!1,!0,!1,!0),g=!0;if(m||(m=de(t,!1,!0,!1,!1),g=!1),!m)return;var p=t.getLine(m.start.line).substring(m.start.ch,m.end.ch);p=g&&c?"\\b"+p+"\\b":Q(p),wt.jumpList.cachedCursor=t.getCursor(),t.setCursor(m.start),i(p,!0,!1)}}},processEx:function(t,r,n){function i(e){wt.exCommandHistoryController.pushInput(e),wt.exCommandHistoryController.reset(),Rt.processCommand(t,e)}function o(r,n,i){var o,a,l=e.keyName(r);("Esc"==l||"Ctrl-C"==l||"Ctrl-["==l||"Backspace"==l&&""==n)&&(wt.exCommandHistoryController.pushInput(n),wt.exCommandHistoryController.reset(),e.e_stop(r),M(t),i(),t.focus()),"Up"==l||"Down"==l?(e.e_stop(r),o="Up"==l,a=r.target?r.target.selectionEnd:0,n=wt.exCommandHistoryController.nextMatch(n,o)||"",i(n),a&&r.target&&(r.target.selectionEnd=r.target.selectionStart=Math.min(a,r.target.value.length))):"Ctrl-U"==l?(e.e_stop(r),i("")):"Left"!=l&&"Right"!=l&&"Ctrl"!=l&&"Alt"!=l&&"Shift"!=l&&wt.exCommandHistoryController.reset()}"keyToEx"==n.type?Rt.processCommand(t,n.exArgs.input):r.visualMode?Be(t,{onClose:i,prefix:":",value:"'<,'>",onKeyDown:o}):Be(t,{onClose:i,prefix:":",onKeyDown:o})},evalInput:function(e,t){var r,i,o,a=t.inputState,l=a.motion,s=a.motionArgs||{},c=a.operator,u=a.operatorArgs||{},f=a.registerName,d=t.sel,h=j(t.visualMode?R(e,d.head):e.getCursor("head")),p=j(t.visualMode?R(e,d.anchor):e.getCursor("anchor")),m=j(h),g=j(p);if(c&&this.recordLastEdit(t,a),o=void 0!==a.repeatOverride?a.repeatOverride:a.getRepeat(),o>0&&s.explicitRepeat?s.repeatIsExplicit=!0:(s.noRepeat||!s.explicitRepeat&&0===o)&&(o=1,s.repeatIsExplicit=!1),a.selectedCharacter&&(s.selectedCharacter=u.selectedCharacter=a.selectedCharacter),s.repeat=o,M(e),l){var v=_t[l](e,h,s,t);if(t.lastMotion=_t[l],!v)return;if(s.toJumplist){var y=wt.jumpList,b=y.cachedCursor;b?(he(e,b,v),delete y.cachedCursor):he(e,h,v)}v instanceof Array?(i=v[0],r=v[1]):r=v,r||(r=j(h)),t.visualMode?(t.visualBlock&&r.ch===1/0||(r=R(e,r,t.visualBlock)),i&&(i=R(e,i,!0)),i=i||g,d.anchor=i,d.head=r,oe(e),xe(e,t,"<",U(i,r)?i:r),xe(e,t,">",U(i,r)?r:i)):c||(r=R(e,r),e.setCursor(r.line,r.ch))}if(c){if(u.lastSel){i=g;var x=u.lastSel,w=Math.abs(x.head.line-x.anchor.line),k=Math.abs(x.head.ch-x.anchor.ch);r=x.visualLine?n(g.line+w,g.ch):x.visualBlock?n(g.line+w,g.ch+k):x.head.line==x.anchor.line?n(g.line,g.ch+k):n(g.line+w,g.ch),t.visualMode=!0,t.visualLine=x.visualLine,t.visualBlock=x.visualBlock,d=t.sel={anchor:i,head:r},oe(e)}else t.visualMode&&(u.lastSel={anchor:j(d.anchor),head:j(d.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var C,S,_,L,T;if(t.visualMode){if(C=V(d.head,d.anchor),S=$(d.head,d.anchor),_=t.visualLine||u.linewise,L=t.visualBlock?"block":_?"line":"char",T=ae(e,{anchor:C,head:S},L),_){var A=T.ranges;if("block"==L)for(var O=0;O<A.length;O++)A[O].head.ch=X(e,A[O].head.line);else"line"==L&&(A[0].head=n(A[0].head.line+1,0))}}else{if(C=j(i||g),S=j(r||m),U(S,C)){var E=C;C=S,S=E}_=s.linewise||u.linewise,_?ue(e,C,S):s.forward&&ce(e,C,S),L="char";T=ae(e,{anchor:C,head:S},L,!s.inclusive||_)}e.setSelections(T.ranges,T.primary),t.lastMotion=null,u.repeat=o,u.registerName=f,u.linewise=_;var I=Mt[c](e,u,T.ranges,g,r);t.visualMode&&se(e,null!=I),I&&e.setCursor(I)}},recordLastEdit:function(e,t,r){var n=wt.macroModeState;n.isPlaying||(e.lastEditInputState=t,e.lastEditActionCommand=r,n.lastInsertModeChanges.changes=[],n.lastInsertModeChanges.expectCursorActivityForChange=!1)}},_t={moveToTopLine:function(e,t,r){var i=Ke(e).top+r.repeat-1;return n(i,fe(e.getLine(i)))},moveToMiddleLine:function(e){var t=Ke(e),r=Math.floor(.5*(t.top+t.bottom));return n(r,fe(e.getLine(r)))},moveToBottomLine:function(e,t,r){var i=Ke(e).bottom-r.repeat+1;return n(i,fe(e.getLine(i)))},expandToLine:function(e,t,r){return n(t.line+r.repeat-1,1/0)},findNext:function(e,t,r){var n=Me(e),i=n.getQuery();if(i){var o=!r.forward;return o=n.isReversed()?!o:o,qe(e,i),Fe(e,o,i,r.repeat)}},goToMark:function(e,t,r,n){var i=Ue(e,n,r.selectedCharacter);return i?r.linewise?{line:i.line,ch:fe(e.getLine(i.line))}:i:null},moveToOtherHighlightedEnd:function(e,t,r,i){if(i.visualBlock&&r.sameLine){var o=i.sel;return[R(e,n(o.anchor.line,o.head.ch)),R(e,n(o.head.line,o.anchor.ch))]}return[i.sel.head,i.sel.anchor]},jumpToMark:function(e,t,r,i){for(var o=t,a=0;a<r.repeat;a++){var l=o;for(var s in i.marks)if(h(s)){var c=i.marks[s].find(),u=r.forward?U(c,l):U(l,c);if(!(u||r.linewise&&c.line==l.line)){var f=K(l,o),d=r.forward?G(l,c,o):G(o,c,l);(f||d)&&(o=c)}}}return r.linewise&&(o=n(o.line,fe(e.getLine(o.line)))),o},moveByCharacters:function(e,t,r){var i=t,o=r.repeat,a=r.forward?i.ch+o:i.ch-o;return n(i.line,a)},moveByLines:function(e,t,r,i){var o=t,a=o.ch;switch(i.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:a=i.lastHPos;break;default:i.lastHPos=a}var l=r.repeat+(r.repeatOffset||0),s=r.forward?o.line+l:o.line-l,c=e.firstLine(),u=e.lastLine();return s<c&&o.line==c?this.moveToStartOfLine(e,t,r,i):s>u&&o.line==u?this.moveToEol(e,t,r,i):(r.toFirstChar&&(a=fe(e.getLine(s)),i.lastHPos=a),i.lastHSPos=e.charCoords(n(s,a),"div").left,n(s,a))},moveByDisplayLines:function(e,t,r,i){var o=t;switch(i.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:i.lastHSPos=e.charCoords(o,"div").left}var a=r.repeat,l=e.findPosV(o,r.forward?a:-a,"line",i.lastHSPos);if(l.hitSide)if(r.forward)var s=e.charCoords(l,"div"),c={top:s.top+8,left:i.lastHSPos},l=e.coordsChar(c,"div");else{var u=e.charCoords(n(e.firstLine(),0),"div");u.left=i.lastHSPos,l=e.coordsChar(u,"div")}return i.lastHPos=l.ch,l},moveByPage:function(e,t,r){var n=t,i=r.repeat;return e.findPosV(n,r.forward?i:-i,"page")},moveByParagraph:function(e,t,r){var n=r.forward?1:-1;return ke(e,t,r.repeat,n)},moveByScroll:function(e,t,r,n){var i=e.getScrollInfo(),o=null,a=r.repeat;a||(a=i.clientHeight/(2*e.defaultTextHeight()));var l=e.charCoords(t,"local");r.repeat=a;var o=_t.moveByDisplayLines(e,t,r,n);if(!o)return null;var s=e.charCoords(o,"local");return e.scrollTo(null,i.top+s.top-l.top),o},moveByWords:function(e,t,r){return ve(e,t,r.repeat,!!r.forward,!!r.wordEnd,!!r.bigWord)},moveTillCharacter:function(e,t,r){var n=r.repeat,i=ye(e,n,r.forward,r.selectedCharacter),o=r.forward?-1:1;return pe(o,r),i?(i.ch+=o,i):null},moveToCharacter:function(e,t,r){var n=r.repeat;return pe(0,r),ye(e,n,r.forward,r.selectedCharacter)||t},moveToSymbol:function(e,t,r){return me(e,r.repeat,r.forward,r.selectedCharacter)||t},moveToColumn:function(e,t,r,n){var i=r.repeat;return n.lastHPos=i-1,n.lastHSPos=e.charCoords(t,"div").left,be(e,i)},moveToEol:function(e,t,r,i){var o=t;i.lastHPos=1/0;var a=n(o.line+r.repeat-1,1/0),l=e.clipPos(a);return l.ch--,i.lastHSPos=e.charCoords(l,"div").left,a},moveToFirstNonWhiteSpaceCharacter:function(e,t){var r=t;return n(r.line,fe(e.getLine(r.line)))},moveToMatchedSymbol:function(e,t){var r,i=t,o=i.line,a=i.ch,l=e.getLine(o);do{if((r=l.charAt(a++))&&p(r)){var s=e.getTokenTypeAt(n(o,a));if("string"!==s&&"comment"!==s)break}}while(r);if(r){return e.findMatchingBracket(n(o,a)).to}return i},moveToStartOfLine:function(e,t){return n(t.line,0)},moveToLineOrEdgeOfDocument:function(e,t,r){var i=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(i=r.repeat-e.getOption("firstLineNumber")),n(i,fe(e.getLine(i)))},textObjectManipulation:function(e,t,r,n){var i={"(":")",")":"(","{":"}","}":"{","[":"]","]":"["},o={"'":!0,'"':!0},a=r.selectedCharacter;"b"==a?a="(":"B"==a&&(a="{");var l,s=!r.textObjectInner;if(i[a])l=Ce(e,t,a,s);else if(o[a])l=Se(e,t,a,s);else if("W"===a)l=de(e,s,!0,!0);else if("w"===a)l=de(e,s,!0,!1);else{if("p"!==a)return null;if(l=ke(e,t,r.repeat,0,s),r.linewise=!0,n.visualMode)n.visualLine||(n.visualLine=!0);else{var c=n.inputState.operatorArgs;c&&(c.linewise=!0),l.end.line--}}return e.state.vim.visualMode?ie(e,l.start,l.end):[l.start,l.end]},repeatLastCharacterSearch:function(e,t,r){var n=wt.lastCharacterSearch,i=r.repeat,o=r.forward===n.forward,a=(n.increment?1:0)*(o?-1:1);e.moveH(-a,"char"),r.inclusive=!!o;var l=ye(e,i,o,n.selectedCharacter);return l?(l.ch+=a,l):(e.moveH(a,"char"),t)}},Mt={change:function(t,r,i){var o,a,l=t.state.vim;if(wt.macroModeState.lastInsertModeChanges.inVisualBlock=l.visualBlock,l.visualMode){a=t.getSelection();var s=I("",i.length);t.replaceSelections(s),o=V(i[0].head,i[0].anchor)}else{var c=i[0].anchor,u=i[0].head;a=t.getRange(c,u);var f=l.lastEditInputState||{};if("moveByWords"==f.motion&&!v(a)){var d=/\s+$/.exec(a);d&&f.motionArgs&&f.motionArgs.forward&&(u=z(u,0,-d[0].length),a=a.slice(0,-d[0].length))}var h=new n(c.line-1,Number.MAX_VALUE),p=t.firstLine()==t.lastLine();u.line>t.lastLine()&&r.linewise&&!p?t.replaceRange("",h,u):t.replaceRange("",c,u),r.linewise&&(p||(t.setCursor(h),e.commands.newlineAndIndent(t)),c.ch=Number.MAX_VALUE),o=c}wt.registerController.pushText(r.registerName,"change",a,r.linewise,i.length>1),Lt.enterInsertMode(t,{head:o},t.state.vim)},delete:function(e,t,r){var i,o,a=e.state.vim;if(a.visualBlock){o=e.getSelection();var l=I("",r.length);e.replaceSelections(l),i=r[0].anchor}else{var s=r[0].anchor,c=r[0].head;t.linewise&&c.line!=e.firstLine()&&s.line==e.lastLine()&&s.line==c.line-1&&(s.line==e.firstLine()?s.ch=0:s=n(s.line-1,X(e,s.line-1))),o=e.getRange(s,c),e.replaceRange("",s,c),i=s,t.linewise&&(i=_t.moveToFirstNonWhiteSpaceCharacter(e,s))}return wt.registerController.pushText(t.registerName,"delete",o,t.linewise,a.visualBlock),R(e,i)},indent:function(e,t,r){var n=e.state.vim,i=r[0].anchor.line,o=n.visualBlock?r[r.length-1].anchor.line:r[0].head.line,a=n.visualMode?t.repeat:1;t.linewise&&o--;for(var l=i;l<=o;l++)for(var s=0;s<a;s++)e.indentLine(l,t.indentRight);return _t.moveToFirstNonWhiteSpaceCharacter(e,r[0].anchor)},changeCase:function(e,t,r,n,i){for(var o=e.getSelections(),a=[],l=t.toLower,s=0;s<o.length;s++){var c=o[s],u="";if(l===!0)u=c.toLowerCase();else if(l===!1)u=c.toUpperCase();else for(var f=0;f<c.length;f++){var d=c.charAt(f);u+=g(d)?d.toLowerCase():d.toUpperCase()}a.push(u)}return e.replaceSelections(a),t.shouldMoveCursor?i:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?_t.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:V(r[0].anchor,r[0].head)},yank:function(e,t,r,n){var i=e.state.vim,o=e.getSelection(),a=i.visualMode?V(i.sel.anchor,i.sel.head,r[0].head,r[0].anchor):n;return wt.registerController.pushText(t.registerName,"yank",o,t.linewise,i.visualBlock),a}},Lt={jumpListWalk:function(e,t,r){if(!r.visualMode){var n=t.repeat,i=t.forward,o=wt.jumpList,a=o.move(e,i?n:-n),l=a?a.find():void 0;l=l?l:e.getCursor(),e.setCursor(l)}},scroll:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,i=e.defaultTextHeight(),o=e.getScrollInfo().top,a=i*n,l=t.forward?o+a:o-a,s=j(e.getCursor()),c=e.charCoords(s,"local");if(t.forward)l>c.top?(s.line+=(l-c.top)/i,s.line=Math.ceil(s.line),e.setCursor(s),c=e.charCoords(s,"local"),e.scrollTo(null,c.top)):e.scrollTo(null,l);else{var u=l+e.getScrollInfo().clientHeight;u<c.bottom?(s.line-=(c.bottom-u)/i,s.line=Math.floor(s.line),e.setCursor(s),c=e.charCoords(s,"local"),e.scrollTo(null,c.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,l)}}},scrollToCursor:function(e,t){var r=e.getCursor().line,i=e.charCoords(n(r,0),"local"),o=e.getScrollInfo().clientHeight,a=i.top,l=i.bottom-a;switch(t.position){case"center":a=a-o/2+l;break;case"bottom":a=a-o+l}e.scrollTo(null,a)},replayMacro:function(e,t,r){var n=t.selectedCharacter,i=t.repeat,o=wt.macroModeState;for("@"==n&&(n=o.latestRegister);i--;)Ye(e,r,o,n)},enterMacroRecordMode:function(e,t){var r=wt.macroModeState,n=t.selectedCharacter;r.enterMacroRecordMode(e,n)},toggleOverwrite:function(t){t.state.overwrite?(t.toggleOverwrite(!1),t.setOption("keyMap","vim-insert"),e.signal(t,"vim-mode-change",{mode:"insert"})):(t.toggleOverwrite(!0),t.setOption("keyMap","vim-replace"),e.signal(t,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(t,r,i){if(!t.getOption("readOnly")){i.insertMode=!0,i.insertModeRepeat=r&&r.repeat||1;var o=r?r.insertAt:null,a=i.sel,l=r.head||t.getCursor("head"),s=t.listSelections().length;if("eol"==o)l=n(l.line,X(t,l.line));else if("charAfter"==o)l=z(l,0,1);else if("firstNonBlank"==o)l=_t.moveToFirstNonWhiteSpaceCharacter(t,l);else if("startOfSelectedArea"==o)i.visualBlock?(l=n(Math.min(a.head.line,a.anchor.line),Math.min(a.head.ch,a.anchor.ch)),s=Math.abs(a.head.line-a.anchor.line)+1):l=a.head.line<a.anchor.line?a.head:n(a.anchor.line,0);else if("endOfSelectedArea"==o)i.visualBlock?(l=n(Math.min(a.head.line,a.anchor.line),Math.max(a.head.ch+1,a.anchor.ch)),s=Math.abs(a.head.line-a.anchor.line)+1):l=a.head.line>=a.anchor.line?z(a.head,0,1):n(a.anchor.line,0);else if("inplace"==o&&i.visualMode)return;t.setOption("disableInput",!1),r&&r.replace?(t.toggleOverwrite(!0),t.setOption("keyMap","vim-replace"),e.signal(t,"vim-mode-change",{mode:"replace"})):(t.toggleOverwrite(!1),t.setOption("keyMap","vim-insert"),e.signal(t,"vim-mode-change",{mode:"insert"})),wt.macroModeState.isPlaying||(t.on("change",et),e.on(t.getInputField(),"keydown",ot)),i.visualMode&&se(t),ee(t,l,s)}},toggleVisualMode:function(t,r,i){var o,a=r.repeat,l=t.getCursor();i.visualMode?i.visualLine^r.linewise||i.visualBlock^r.blockwise?(i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,e.signal(t,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),oe(t)):se(t):(i.visualMode=!0,i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,o=R(t,n(l.line,l.ch+a-1),!0),i.sel={anchor:l,head:o},e.signal(t,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),oe(t),xe(t,i,"<",V(l,o)),xe(t,i,">",$(l,o)))},reselectLastSelection:function(t,r,n){var i=n.lastSelection;if(n.visualMode&&ne(t,n),i){var o=i.anchorMark.find(),a=i.headMark.find();if(!o||!a)return;n.sel={anchor:o,head:a},n.visualMode=!0,n.visualLine=i.visualLine,n.visualBlock=i.visualBlock,oe(t),xe(t,n,"<",V(o,a)),xe(t,n,">",$(o,a)),e.signal(t,"vim-mode-change",{mode:"visual",subMode:n.visualLine?"linewise":n.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var i,o;if(r.visualMode){if(i=e.getCursor("anchor"),o=e.getCursor("head"),U(o,i)){var a=o;o=i,i=a}o.ch=X(e,o.line)-1}else{var l=Math.max(t.repeat,2);i=e.getCursor(),o=R(e,n(i.line+l-1,1/0))}for(var s=0,c=i.line;c<o.line;c++){s=X(e,i.line);var a=n(i.line+1,X(e,i.line+1)),u=e.getRange(i,a);u=u.replace(/\n\s*/g," "),e.replaceRange(u,i,a)}var f=n(i.line,s);r.visualMode&&se(e,!1),e.setCursor(f)},newLineAndEnterInsertMode:function(t,r,i){i.insertMode=!0;var o=j(t.getCursor());if(o.line!==t.firstLine()||r.after){o.line=r.after?o.line:o.line-1,o.ch=X(t,o.line),t.setCursor(o);(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(t)}else t.replaceRange("\n",n(t.firstLine(),0)),t.setCursor(t.firstLine(),0);this.enterInsertMode(t,{repeat:r.repeat},i)},paste:function(e,t,r){var i=j(e.getCursor()),o=wt.registerController.getRegister(t.registerName),a=o.toString();if(a){if(t.matchIndent){var l=e.getOption("tabSize"),s=function(e){var t=e.split("\t").length-1,r=e.split(" ").length-1;return t*l+1*r},c=e.getLine(e.getCursor().line),u=s(c.match(/^\s*/)[0]),f=a.replace(/\n$/,""),d=a!==f,h=s(a.match(/^\s*/)[0]),a=f.replace(/^\s*/gm,function(t){var r=u+(s(t)-h);if(r<0)return"";if(e.getOption("indentWithTabs")){var n=Math.floor(r/l);return Array(n+1).join("\t")}return Array(r+1).join(" ")});a+=d?"\n":""}if(t.repeat>1)var a=Array(t.repeat+1).join(a);var p=o.linewise,m=o.blockwise;if(p)r.visualMode?a=r.visualLine?a.slice(0,-1):"\n"+a.slice(0,a.length-1)+"\n":t.after?(a="\n"+a.slice(0,a.length-1),i.ch=X(e,i.line)):i.ch=0;else{if(m){a=a.split("\n");for(var g=0;g<a.length;g++)a[g]=""==a[g]?" ":a[g]}i.ch+=t.after?1:0}var v,y;if(r.visualMode){r.lastPastedText=a;var b,x=re(e,r),w=x[0],k=x[1],C=e.getSelection(),S=e.listSelections(),_=new Array(S.length).join("1").split("1");r.lastSelection&&(b=r.lastSelection.headMark.find()),wt.registerController.unnamedRegister.setText(C),m?(e.replaceSelections(_),k=n(w.line+a.length-1,w.ch),e.setCursor(w),Z(e,k),e.replaceSelections(a),v=w):r.visualBlock?(e.replaceSelections(_),e.setCursor(w),e.replaceRange(a,w,w),v=w):(e.replaceRange(a,w,k),v=e.posFromIndex(e.indexFromPos(w)+a.length-1)),b&&(r.lastSelection.headMark=e.setBookmark(b)),p&&(v.ch=0)}else if(m){e.setCursor(i);for(var g=0;g<a.length;g++){var M=i.line+g;M>e.lastLine()&&e.replaceRange("\n",n(M,0));var L=X(e,M);L<i.ch&&J(e,M,i.ch)}e.setCursor(i),Z(e,n(i.line+a.length-1,i.ch)),e.replaceSelections(a),v=i}else e.replaceRange(a,i),p&&t.after?v=n(i.line+1,fe(e.getLine(i.line+1))):p&&!t.after?v=n(i.line,fe(e.getLine(i.line))):!p&&t.after?(y=e.indexFromPos(i),v=e.posFromIndex(y+a.length-1)):(y=e.indexFromPos(i),v=e.posFromIndex(y+a.length));r.visualMode&&se(e,!1),e.setCursor(v)}},undo:function(t,r){t.operation(function(){H(t,e.commands.undo,r.repeat)(),t.setCursor(t.getCursor("anchor"))})},redo:function(t,r){H(t,e.commands.redo,r.repeat)()},setRegister:function(e,t,r){r.inputState.registerName=t.selectedCharacter},setMark:function(e,t,r){xe(e,r,t.selectedCharacter,e.getCursor())},replace:function(t,r,i){var o,a,l=r.selectedCharacter,s=t.getCursor(),c=t.listSelections();if(i.visualMode)s=t.getCursor("start"),a=t.getCursor("end");else{var u=t.getLine(s.line);o=s.ch+r.repeat,o>u.length&&(o=u.length),a=n(s.line,o)}if("\n"==l)i.visualMode||t.replaceRange("",s,a),(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(t);else{var f=t.getRange(s,a);if(f=f.replace(/[^\n]/g,l),i.visualBlock){var d=new Array(t.getOption("tabSize")+1).join(" ");f=t.getSelection(),f=f.replace(/\t/g,d).replace(/[^\n]/g,l).split("\n"),t.replaceSelections(f)}else t.replaceRange(f,s,a);i.visualMode?(s=U(c[0].anchor,c[0].head)?c[0].anchor:c[0].head,t.setCursor(s),se(t,!1)):t.setCursor(z(a,0,-1))}},incrementNumberToken:function(e,t){for(var r,i,o,a,l,s=e.getCursor(),c=e.getLine(s.line),u=/-?\d+/g;null!==(r=u.exec(c))&&(l=r[0],i=r.index,o=i+l.length,!(s.ch<o)););if((t.backtrack||!(o<=s.ch))&&l){var f=t.increase?1:-1,d=parseInt(l)+f*t.repeat,h=n(s.line,i),p=n(s.line,o);a=d.toString(),e.replaceRange(a,h,p),e.setCursor(n(s.line,i+a.length-1))}},repeatLastEdit:function(e,t,r){if(r.lastEditInputState){var n=t.repeat;n&&t.repeatIsExplicit?r.lastEditInputState.repeatOverride=n:n=r.lastEditInputState.repeatOverride||n,at(e,r,n,!1)}},indent:function(e,t){e.indentLine(e.getCursor().line,t.indentRight)},exitInsertMode:$e},Tt={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},At={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(++e.depth>=1)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?"]":"[")===e.symb?"{":"}"},isComplete:function(e){return 0===e.index&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t="*"===e.lastCh&&"/"===e.nextCh;return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb="m"===e.symb?"{":"}",e.reverseSymb="{"===e.symb?"}":"{"},isComplete:function(e){return e.nextCh===e.symb}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if("#"===e.nextCh){var t=e.lineText.match(/#(\w+)/)[1];if("endif"===t){if(e.forward&&0===e.depth)return!0;e.depth++}else if("if"===t){if(!e.forward&&0===e.depth)return!0;e.depth--}if("else"===t&&0===e.depth)return!0}return!1}}};b("pcre",!0,"boolean"),_e.prototype={getQuery:function(){return wt.query},setQuery:function(e){wt.query=e},getOverlay:function(){return this.searchOverlay},setOverlay:function(e){this.searchOverlay=e},isReversed:function(){return wt.isReversed},setReversed:function(e){wt.isReversed=e},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(e){this.annotate=e}};var Ot={"\\n":"\n","\\r":"\r","\\t":"\t"},Et={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":"\t"},It="(Javascript regexp)",Nt=function(){this.buildCommandMap_()};Nt.prototype={processCommand:function(e,t,r){var n=this;e.operation(function(){e.curOp.isVimOp=!0,n._processCommand(e,t,r)})},_processCommand:function(t,r,n){var i=t.state.vim,o=wt.registerController.getRegister(":"),a=o.toString();i.visualMode&&se(t);var l=new e.StringStream(r);o.setText(r);var s=n||{};s.input=r;try{this.parseInput_(t,l,s)}catch(e){throw Pe(t,e),e}var c,u;if(s.commandName){if(c=this.matchCommand_(s.commandName)){if(u=c.name,c.excludeFromCommandHistory&&o.setText(a),this.parseCommandArgs_(l,s,c),"exToKey"==c.type){for(var f=0;f<c.toKeys.length;f++)e.Vim.handleKey(t,c.toKeys[f],"mapping");return}if("exToEx"==c.type)return void this.processCommand(t,c.toInput)}}else void 0!==s.line&&(u="move");if(!u)return void Pe(t,'Not an editor command ":'+r+'"');try{Pt[u](t,s),c&&c.possiblyAsync||!s.callback||s.callback()}catch(e){throw Pe(t,e),e}},parseInput_:function(e,t,r){t.eatWhile(":"),t.eat("%")?(r.line=e.firstLine(),r.lineEnd=e.lastLine()):(r.line=this.parseLineSpec_(e,t),void 0!==r.line&&t.eat(",")&&(r.lineEnd=this.parseLineSpec_(e,t)));var n=t.match(/^(\w+)/);return r.commandName=n?n[1]:t.match(/.*/)[0],r},parseLineSpec_:function(e,t){var r=t.match(/^(\d+)/);if(r)return parseInt(r[1],10)-1;switch(t.next()){case".":return e.getCursor().line;case"$":return e.lastLine();case"'":var n=t.next(),i=Ue(e,e.state.vim,n);if(!i)throw new Error("Mark not set");return i.line;default:return void t.backUp(1)}},parseCommandArgs_:function(e,t,r){if(!e.eol()){t.argString=e.match(/.*/)[0];var n=r.argDelimiter||/\s+/,i=Y(t.argString).split(n);i.length&&i[0]&&(t.args=i)}},matchCommand_:function(e){for(var t=e.length;t>0;t--){var r=e.substring(0,t);if(this.commandMap_[r]){var n=this.commandMap_[r];if(0===n.name.indexOf(e))return n}}return null},buildCommandMap_:function(){this.commandMap_={};for(var e=0;e<r.length;e++){var t=r[e],n=t.shortName||t.name;this.commandMap_[n]=t}},map:function(e,r,n){if(":"!=e&&":"==e.charAt(0)){if(n)throw Error("Mode not supported for ex mappings");var i=e.substring(1);":"!=r&&":"==r.charAt(0)?this.commandMap_[i]={name:i,type:"exToEx",toInput:r.substring(1),user:!0}:this.commandMap_[i]={name:i,type:"exToKey",toKeys:r,user:!0}}else if(":"!=r&&":"==r.charAt(0)){var o={keys:e,type:"keyToEx",exArgs:{input:r.substring(1)}};n&&(o.context=n),t.unshift(o)}else{var o={keys:e,type:"keyToKey",toKeys:r};n&&(o.context=n),t.unshift(o)}},unmap:function(e,r){if(":"!=e&&":"==e.charAt(0)){if(r)throw Error("Mode not supported for ex mappings");var n=e.substring(1);if(this.commandMap_[n]&&this.commandMap_[n].user)return void delete this.commandMap_[n]}else for(var i=e,o=0;o<t.length;o++)if(i==t[o].keys&&t[o].context===r)return void t.splice(o,1);throw Error("No such mapping.")}};var Pt={colorscheme:function(e,t){if(!t.args||t.args.length<1)return void Pe(e,e.getOption("theme"));e.setOption("theme",t.args[0])},map:function(e,t,r){var n=t.args;if(!n||n.length<2)return void(e&&Pe(e,"Invalid mapping: "+t.input));Rt.map(n[0],n[1],r)},imap:function(e,t){this.map(e,t,"insert")},nmap:function(e,t){this.map(e,t,"normal")},vmap:function(e,t){this.map(e,t,"visual")},unmap:function(e,t,r){var n=t.args;if(!n||n.length<1)return void(e&&Pe(e,"No such mapping: "+t.input));Rt.unmap(n[0],r)},move:function(e,t){St.processCommand(e,e.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:t.line+1})},set:function(e,t){var r=t.args,n=t.setCfg||{};if(!r||r.length<1)return void(e&&Pe(e,"Invalid mapping: "+t.input));var i=r[0].split("="),o=i[0],a=i[1],l=!1;if("?"==o.charAt(o.length-1)){if(a)throw Error("Trailing characters: "+t.argString);o=o.substring(0,o.length-1),l=!0}void 0===a&&"no"==o.substring(0,2)&&(o=o.substring(2),a=!1);var s=yt[o]&&"boolean"==yt[o].type;if(s&&void 0==a&&(a=!0),!s&&void 0===a||l){var c=w(o,e,n);c===!0||c===!1?Pe(e," "+(c?"":"no")+o):Pe(e," "+o+"="+c)}else x(o,a,e,n)},setlocal:function(e,t){t.setCfg={scope:"local"},this.set(e,t)},setglobal:function(e,t){t.setCfg={scope:"global"},this.set(e,t)},registers:function(e,t){var r=t.args,n=wt.registerController.registers,i="----------Registers----------<br><br>";if(r){var o;r=r.join("");for(var a=0;a<r.length;a++)if(o=r.charAt(a),wt.registerController.isValidRegister(o)){var l=n[o]||new L;i+='"'+o+" "+l.toString()+"<br>"}}else for(var o in n){var s=n[o].toString();s.length&&(i+='"'+o+" "+s+"<br>")}Pe(e,i)},sort:function(t,r){function i(e,t){if(a){var r;r=e,e=t,t=r}l&&(e=e.toLowerCase(),t=t.toLowerCase());var n=c&&v.exec(e),i=c&&v.exec(t);return n?(n=parseInt((n[1]+n[2]).toLowerCase(),y),i=parseInt((i[1]+i[2]).toLowerCase(),y),n-i):e<t?-1:1}function o(e,t){if(a){var r;r=e,e=t,t=r}return l&&(e[0]=e[0].toLowerCase(),t[0]=t[0].toLowerCase()),e[0]<t[0]?-1:1}var a,l,s,c,u,f=function(){if(r.argString){var t=new e.StringStream(r.argString);if(t.eat("!")&&(a=!0),t.eol())return;if(!t.eatSpace())return"Invalid arguments";var n=t.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!n&&!t.eol())return"Invalid arguments";if(n[1]){l=n[1].indexOf("i")!=-1,s=n[1].indexOf("u")!=-1;var i=n[1].indexOf("d")!=-1||n[1].indexOf("n")!=-1&&1,o=n[1].indexOf("x")!=-1&&1,f=n[1].indexOf("o")!=-1&&1;if(i+o+f>1)return"Invalid arguments";c=i&&"decimal"||o&&"hex"||f&&"octal"}n[2]&&(u=new RegExp(n[2].substr(1,n[2].length-2),l?"i":""))}}();if(f)return void Pe(t,f+": "+r.argString);var d=r.line||t.firstLine(),h=r.lineEnd||r.line||t.lastLine();if(d!=h){var p=n(d,0),m=n(h,X(t,h)),g=t.getRange(p,m).split("\n"),v=u?u:"decimal"==c?/(-?)([\d]+)/:"hex"==c?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==c?/([0-7]+)/:null,y="decimal"==c?10:"hex"==c?16:"octal"==c?8:null,b=[],x=[];if(c||u)for(var w=0;w<g.length;w++){var k=u?g[w].match(u):null;k&&""!=k[0]?b.push(k):!u&&v.exec(g[w])?b.push(g[w]):x.push(g[w])}else x=g;if(b.sort(u?o:i),u)for(var w=0;w<b.length;w++)b[w]=b[w].input;else c||x.sort(i);if(g=a?b.concat(x):x.concat(b),s){var C,S=g;g=[];for(var w=0;w<S.length;w++)S[w]!=C&&g.push(S[w]),C=S[w]}t.replaceRange(g.join("\n"),p,m)}},global:function(e,t){var r=t.argString;if(!r)return void Pe(e,"Regular Expression missing from global");var n,i=void 0!==t.line?t.line:e.firstLine(),o=t.lineEnd||t.line||e.lastLine(),a=Te(r),l=r;if(a.length&&(l=a[0],n=a.slice(1,a.length).join("/")),l)try{De(e,l,!0,!0)}catch(t){return void Pe(e,"Invalid regex: "+l)}for(var s=Me(e).getQuery(),c=[],u="",f=i;f<=o;f++){s.test(e.getLine(f))&&(c.push(f+1),u+=e.getLine(f)+"<br>")}if(!n)return void Pe(e,u);var d=0,h=function(){if(d<c.length){var t=c[d]+n;Rt.processCommand(e,t,{callback:h})}d++};h()},substitute:function(e,t){if(!e.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var r,i,o,a,l=t.argString,s=l?Te(l):[],c="",u=!1,f=!1;if(s.length)r=s[0],c=s[1],void 0!==c&&(c=w("pcre")?Ie(c):Ee(c),wt.lastSubstituteReplacePart=c),i=s[2]?s[2].split(" "):[];else if(l&&l.length)return void Pe(e,"Substitutions should be of the form :s/pattern/replace/");if(i&&(o=i[0],a=parseInt(i[1]),o&&(o.indexOf("c")!=-1&&(u=!0,o.replace("c","")),o.indexOf("g")!=-1&&(f=!0,o.replace("g","")),r=r+"/"+o)),r)try{De(e,r,!0,!0)}catch(t){return void Pe(e,"Invalid regex: "+r)}if(void 0===(c=c||wt.lastSubstituteReplacePart))return void Pe(e,"No previous substitute regular expression");var d=Me(e),h=d.getQuery(),p=void 0!==t.line?t.line:e.getCursor().line,m=t.lineEnd||p;p==e.firstLine()&&m==e.lastLine()&&(m=1/0),a&&(p=m,m=p+a-1);var g=R(e,n(p,0)),v=e.getSearchCursor(h,g);Ve(e,u,f,p,m,v,h,c,t.callback)},redo:e.commands.redo,undo:e.commands.undo,write:function(t){
|
13 |
-
e.commands.save?e.commands.save(t):t.save&&t.save()},nohlsearch:function(e){He(e)},yank:function(e){var t=j(e.getCursor()),r=t.line,n=e.getLine(r);wt.registerController.pushText("0","yank",n,!0,!0)},delmarks:function(t,r){if(!r.argString||!Y(r.argString))return void Pe(t,"Argument required");for(var n=t.state.vim,i=new e.StringStream(Y(r.argString));!i.eol();){i.eatSpace();var o=i.pos;if(!i.match(/[a-zA-Z]/,!1))return void Pe(t,"Invalid argument: "+r.argString.substring(o));var a=i.next();if(i.match("-",!0)){if(!i.match(/[a-zA-Z]/,!1))return void Pe(t,"Invalid argument: "+r.argString.substring(o));var l=a,s=i.next();if(!(h(l)&&h(s)||g(l)&&g(s)))return void Pe(t,"Invalid argument: "+l+"-");var c=l.charCodeAt(0),u=s.charCodeAt(0);if(c>=u)return void Pe(t,"Invalid argument: "+r.argString.substring(o));for(var f=0;f<=u-c;f++){var d=String.fromCharCode(c+f);delete n.marks[d]}}else delete n.marks[a]}}},Rt=new Nt;return e.keyMap.vim={attach:l,detach:a,call:s},b("insertModeEscKeysTimeout",200,"number"),e.keyMap["vim-insert"]={fallthrough:["default"],attach:l,detach:a,call:s},e.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:l,detach:a,call:s},S(),Ct}()}),console.log(window.heshOptions),function(e,t,r,n,i){"use strict";function o(){te.theme=i.theme,te.lineNumbers=!!i.lineNumbers,te.foldGutter=!!i.foldGutter,te.gutters=te.foldGutter?["CodeMirror-linenumbers","CodeMirror-foldgutter"]:[],te.tabSize=te.indentUnit=+i.tabSize,te.lineWrapping=!!i.lineWrapping,te.matchBrackets=!!i.matchBrackets,te.autoCloseTags=!!i.autoCloseTags,te.autoCloseBrackets=!!i.autoCloseBrackets,te.highlightSelectionMatches=!!i.highlightSelectionMatches,te.matchTags=!!i.matchTags&&{bothTags:!0},te.scrollbarStyle=i.scrollbarStyle?"overlay":null,te.keyMap=i.keyMap,te.autofocus=e.getElementById("title")&&!!e.getElementById("title").value&&e.getElementById("title").value.length>0}function a(e){var r=!1;return function(){var n=this,i=arguments;r||(e.apply(n,i),r=!0,t.requestAnimationFrame(function(){t.requestAnimationFrame(function(){r=!1})}))}}function l(){for(var e=-1;e<U.children.length;e++){var t=e<0?K:U.children[e];null!=t&&(t.style.position="",t.style.top="",t.style.left="",t.style.right="",t.style.width="")}}function s(){for(var t=$.getBoundingClientRect(),r=-1;r<U.children.length;r++){var n=r<0?K:U.children[r];null!=n&&(n.style.position="fixed",n.style.top=t.bottom+"px",n.style.right=e.documentElement.getBoundingClientRect().width-t.right+"px",n.id.match(/toggle/gi)||(n.style.left=t.left+"px",n.style.width="auto"))}}function c(){for(var e=$.getBoundingClientRect(),t=H.getWrapperElement().getBoundingClientRect(),r=-1;r<U.children.length;r++){var n=r<0?K:U.children[r];null!=n&&(n.style.position="absolute",n.style.top=(t.top-e.bottom)*-1+"px",n.style.left="",n.style.right="",n.style.width="")}}function u(e){f();var t=ee.settingsPosition();if(t!==ee.previousSettingsPosition||e&&"resize"===e.type)switch(_(),t){case"top":l();break;case"middle":s();break;case"bottom":c();break;case"normal":case"none":}}function f(){if(V){var r=V.getBoundingClientRect().top,n=e.getElementById("post-status-info").getBoundingClientRect().top,i=n-r,o=t.innerHeight-r;V.style.maxHeight=Math.min(i,o)-6+"px",ne&&(V.style.height=V.style.maxHeight)}}function d(){V.style.maxHeight="",ne&&(V.style.height="")}function h(){Z&&(Z.addEventListener("change",p),p())}function p(){ee.isFullHeight()?(H.setOption("viewportMargin",1/0),H.on("change",_),t.addEventListener("scroll",re),t.addEventListener("resize",re),t.addEventListener("resize",ae),H.getWrapperElement().style.height="auto",u(),L(),t.setTimeout(function(){f(),_()},100)):(H.setOption("viewportMargin",te.viewportMargin),H.off("change",_),t.removeEventListener("scroll",re),t.removeEventListener("resize",re),t.removeEventListener("resize",ae),H.getWrapperElement().style.marginTop="",d(),l(),M())}function m(e){for(var t=0;t<e.length;t++){var r=e[t];if(r.addedNodes[0]&&r.addedNodes[0].classList.contains("CodeMirror-dialog")){K=r.addedNodes[0];for(var n=K.getElementsByTagName("button"),i=0;i<n.length;i++){n[i].classList="button button-small"}}else K=void 0}}function g(){H.getWrapperElement().appendChild(U),U.style.display="block",U.querySelector(".CodeMirror-settings__toggle").addEventListener("click",v),U.querySelector(".CodeMirror-settings__toggle-advanced").addEventListener("click",v),new MutationObserver(m).observe(H.getWrapperElement(),{childList:!0});for(var e=U.querySelectorAll(".CodeMirror-settings__option"),t=0;t<e.length;t++){var r=e[t];r.addEventListener("change",k),r.addEventListener("change",x)}}function v(e){y(e.target.id.match(/advanced/gi)?U.classList.contains("open-advanced")?"open":"advanced":U.classList.contains("open")?"closed":"open")}function y(e){switch(e){case"open":U.classList.add("open"),U.classList.remove("open-advanced"),U.classList.remove("closed");break;case"advanced":U.classList.add("open"),U.classList.add("open-advanced"),U.classList.remove("closed");break;default:U.classList.remove("open"),U.classList.remove("open-advanced"),U.classList.add("closed")}}function b(){ee.charWidth=H.defaultCharWidth()*(i.fontSize/13)}function x(e){var t=+e.target.value;switch(t=isNaN(t)?e.target.value:t,"checkbox"===e.target.type&&(t=e.target.checked),e.target.id){case"fontSize":i.fontSize=t,j.style.fontSize=t+"px",b(),H.refresh();break;case"lineHeight":i.lineHeight=t,j.style.lineHeight=t+"em",H.refresh();break;case"matchTags":i.matchTags=t,H.setOption("matchTags",t?{bothTags:!0}:null);break;case"scrollbarStyle":i.scrollbarStyle=t,H.setOption("scrollbarStyle",t?"overlay":null);break;case"foldGutter":H.setOption("gutters",t?["CodeMirror-linenumbers","CodeMirror-foldgutter"]:[]);case"tabSize":H.setOption("indentUnit",t);default:i[e.target.id]=t,H.setOption(e.target.id,t)}switch(e.target.id){case"lineNumbers":t&&i.foldGutter&&H.setOption("gutters",["CodeMirror-linenumbers","CodeMirror-foldgutter"])}}function w(e,t){j.style.fontSize=e+"px",i.fontSize=e,j.style.lineHeight=t+"em",i.lineHeight=t,b(),H.refresh()}function k(){var e=n("#CodeMirror-settings__form").serializeArray();n.post(i.ajaxUrl,e,function(e){})}function C(){$.insertAdjacentHTML("afterbegin",'<button type="button" id="cm_content_fullscreen" class="ed_button qt-dfw" title="Full Screen"></button>'),e.getElementById("cm_content_fullscreen").onclick=S}function S(e){e=e===!0,ee.isFullHeight()?ie.classList.remove(oe):(ie.classList.contains(oe)||e?ie.classList.remove(oe):ie.classList.add(oe),H.focus())}function _(){H.save(),H.getTextArea().style.height=H.getWrapperElement().getBoundingClientRect().height+"px"}function M(){H.getWrapperElement().style.height=H.getTextArea().style.height}function L(){H.getWrapperElement().style.marginTop=$.offsetHeight+"px"}function T(){e.getElementById("content-resize-handle").addEventListener("mousedown",function(){e.addEventListener("mousemove",M)}),e.addEventListener("mouseup",function(){e.removeEventListener("mousemove",M)})}function A(){function t(e){l=r+(e.pageY-o),H.getWrapperElement().style.height=Math.max(n,l)+"px"}var r=500,n=200;H.getWrapperElement().style.height=r+"px";var i=e.createElement("div");i.className="hesh-content-resize-handle",i.id="content-resize-handle",H.getWrapperElement().appendChild(i);var o,a=!1,l=r;e.getElementById("content-resize-handle").addEventListener("mousedown",function(r){o=r.pageY,a=!0,e.addEventListener("mousemove",t),r.preventDefault()}),e.addEventListener("mouseup",function(){a=!1,r=Math.max(n,l),e.removeEventListener("mousemove",t),H.refresh()})}function O(){var t=e.querySelector(".fileedit-sub .alignleft"),r=t.textContent.match(/\.[a-z\d]{2,}/gi),n=r[r.length-1].match(/[a-z]*/gi)[1],i={php:"php",css:"css",xml:"xml",html:"htmlmixed",js:"javascript",json:"javascript"};te.mode=i[n]}function E(t){var r="; "+e.cookie,n=r.split("; "+t+"=");if(2===n.length)return n.pop().split(";").shift()}function I(){var e=(E("hesh_plugin_selection_state")||"0,0,0,0,0,0,0").split(",");J===e[0]&&(H.doc.setSelection({line:+e[1],ch:+e[2]},{line:+e[3],ch:+e[4]},{scroll:!1}),H.scrollTo(+e[5],+e[6]))}function N(){var t=H.doc.listSelections()[0],r=H.getScrollInfo();e.cookie="hesh_plugin_selection_state="+J+","+t.anchor.line+","+t.anchor.ch+","+t.head.line+","+t.head.ch+","+r.left+","+r.top}function P(){var t=".CodeMirror pre > * { text-indent: 0px; }",n=e.head||e.getElementsByTagName("head")[0],i=e.createElement("style");i.type="text/css",i.styleSheet?i.styleSheet.cssText=t:i.appendChild(e.createTextNode(t)),n.appendChild(i);H.on("renderLine",function(e,t,n){var i=r.countColumn(t.text,null,e.getOption("tabSize"))*ee.charWidth;n.style.textIndent="-"+i+"px",n.style.paddingLeft=4+i+"px"}),H.refresh()}function R(){var e,t,r,n=H.doc.listSelections()[0];e=t=r=0,H.doc.eachLine(function(i){r<=n.head.line-1&&(e+=i.text.length+1),r<=n.anchor.line-1&&(t+=i.text.length+1),r++}),e+=n.head.ch,t+=n.anchor.ch,H.getTextArea().setSelectionRange(Math.min(t,e),Math.max(t,e)),H.getTextArea().focus(),B()}function B(){var e=H.getTextArea().value.length,r=t.setInterval(function(){e!==H.getTextArea().value.length&&(t.clearInterval(r),z())},10),n=function(){t.clearInterval(r),H.off("focus",n)};H.on("focus",n)}function z(){var e=H.getTextArea().selectionStart,r=H.getTextArea().selectionEnd,n=H.getScrollInfo(),i={top:t.pageYOffset,left:t.pageXOffset};H.doc.setValue(H.getTextArea().value),H.focus();for(var o=0,a=0,l=0,s=e,c=r,u=H.getLineHandle(l).text.length+1;u<=s&&u<=c;)l++,u<=s&&(s-=u,o=l),u<=c&&(c-=u,a=l),u=H.getLineHandle(l).text.length+1;H.doc.setSelection({line:o,ch:s},{line:a,ch:c},{scroll:!1}),t.scrollTo(i.left,i.top),H.scrollTo(n.left,n.top),H.save()}function D(){var e=t.send_to_editor,r=function(r){ee.isActive()&&"content"===t.wpActiveEditor?(H.replaceSelection(r),H.save()):e(r)};t.send_to_editor=r}function W(){ee.isActive()||(o(),ee.isThemeOrPlugin&&O(),H=r.fromTextArea(G,te),j=H.getWrapperElement().querySelector(".CodeMirror-code"),G.classList.add("CodeMirror-mirrored"),H.on("change",function(){H.save()}),I(),H.on("cursorActivity",le),H.on("scroll",le),ee.isThemeOrPlugin?(A(),Q=e.getElementById("submit")):($.addEventListener("mousedown",R),D(),T(),h(),C()),g(),w(+i.fontSize,+i.lineHeight),P())}function q(){ee.isActive()&&(y("closed"),H.toTextArea())}function F(){if(ee.isThemeOrPlugin)W();else if(ee.textTabHasSibilings){X.addEventListener("click",function(){t.setTimeout(W,0)});for(var e=0;e<Y.length;e++){var r=Y[e];"content-html"!==r.id&&r.addEventListener("click",q)}ee.isTextTabSelected()&&W()}else W()}var H,j,K,U=e.getElementById("CodeMirror-settings"),V=e.getElementById("CodeMirror-settings__form"),$=e.getElementById("ed_toolbar"),G=e.getElementById("content")||e.getElementById("newcontent"),X=e.getElementById("content-html"),Y=e.getElementsByClassName("wp-switch-editor"),Q=e.getElementById("save-post")||e.getElementById("publish"),J=null!=e.getElementById("post_ID")?e.getElementById("post_ID").value:0,Z=e.getElementById("editor-expand-toggle"),ee={textTabHasSibilings:Y.length>1,isThemeOrPlugin:null!=e.getElementById("newcontent"),isActive:function(){return null!=e.getElementsByClassName("CodeMirror")[0]},isTextTabSelected:function(){return null!=e.getElementsByClassName("html-active")[0]},isFullHeight:function(){return!!Z&&Z.checked},previousSettingsPosition:"none",settingsPosition:function(){var e,r=this;return e=$?"absolute"===$.style.position?"0px"===$.style.top?"top":"bottom":"fixed"===$.style.position?"middle":"normal":"none",t.setTimeout(function(){r.previousSettingsPosition=e},0),e},charWidth:0},te={mode:"wordpresspost",tabMode:"indent",indentWithTabs:!0,enterMode:"keep",styleActiveLine:!0,electricChars:!1,showCursorWhenSelecting:!0,viewportMargin:10,extraKeys:{F11:function(){S()},Esc:function(){S(!0)},"Ctrl-S":function(){Q.click()},"Cmd-S":function(){Q.click()}}},re=a(u),ne=!!navigator.userAgent.match(/Trident/gi),ie=e.getElementById("wp-content-editor-container"),oe="heshFullscreen",ae=a(L),le=a(N);"complete"!==e.readyState?t.addEventListener?t.addEventListener("load",F,!1):t.attachEvent&&t.attachEvent("onload",F):F()}(document,window,window.CodeMirror,window.jQuery,window.heshOptions);
|
10 |
;var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return r(e)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:f[t]}function r(e){var t=e.state.closeBrackets;return!t||t.override?t:e.getModeAt(e.getCursor()).closeBrackets||t}function n(n){var i=r(n);if(!i||n.getOption("disableInput"))return e.Pass;for(var o=t(i,"pairs"),a=n.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return e.Pass;var c=s(n,a[l].head);if(!c||o.indexOf(c)%2!=0)return e.Pass}for(var l=a.length-1;l>=0;l--){var u=a[l].head;n.replaceRange("",d(u.line,u.ch-1),d(u.line,u.ch+1),"+delete")}}function i(n){var i=r(n),o=i&&t(i,"explode");if(!o||n.getOption("disableInput"))return e.Pass;for(var a=n.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return e.Pass;var c=s(n,a[l].head);if(!c||o.indexOf(c)%2!=0)return e.Pass}n.operation(function(){n.replaceSelection("\n\n",null),n.execCommand("goCharLeft"),a=n.listSelections();for(var e=0;e<a.length;e++){var t=a[e].head.line;n.indentLine(t,null,!0),n.indentLine(t+1,null,!0)}})}function o(t){var r=e.cmpPos(t.anchor,t.head)>0;return{anchor:new d(t.anchor.line,t.anchor.ch+(r?-1:1)),head:new d(t.head.line,t.head.ch+(r?1:-1))}}function a(n,i){var a=r(n);if(!a||n.getOption("disableInput"))return e.Pass;var s=t(a,"pairs"),f=s.indexOf(i);if(f==-1)return e.Pass;for(var h,p=t(a,"triples"),m=s.charAt(f+1)==i,g=n.listSelections(),v=f%2==0,y=0;y<g.length;y++){var b,x=g[y],w=x.head,k=n.getRange(w,d(w.line,w.ch+1));if(v&&!x.empty())b="surround";else if(!m&&v||k!=i)if(m&&w.ch>1&&p.indexOf(i)>=0&&n.getRange(d(w.line,w.ch-2),w)==i+i&&(w.ch<=2||n.getRange(d(w.line,w.ch-3),d(w.line,w.ch-2))!=i))b="addFour";else if(m){if(e.isWordChar(k)||!c(n,w,i))return e.Pass;b="both"}else{if(!v||n.getLine(w.line).length!=w.ch&&!l(k,s)&&!/\s/.test(k))return e.Pass;b="both"}else b=m&&u(n,w)?"both":p.indexOf(i)>=0&&n.getRange(w,d(w.line,w.ch+3))==i+i+i?"skipThree":"skip";if(h){if(h!=b)return e.Pass}else h=b}var C=f%2?s.charAt(f-1):i,S=f%2?i:s.charAt(f+1);n.operation(function(){if("skip"==h)n.execCommand("goCharRight");else if("skipThree"==h)for(var e=0;e<3;e++)n.execCommand("goCharRight");else if("surround"==h){for(var t=n.getSelections(),e=0;e<t.length;e++)t[e]=C+t[e]+S;n.replaceSelections(t,"around"),t=n.listSelections().slice();for(var e=0;e<t.length;e++)t[e]=o(t[e]);n.setSelections(t)}else"both"==h?(n.replaceSelection(C+S,null),n.triggerElectric(C+S),n.execCommand("goCharLeft")):"addFour"==h&&(n.replaceSelection(C+C+C+C,"before"),n.execCommand("goCharRight"))})}function l(e,t){var r=t.lastIndexOf(e);return r>-1&&r%2==1}function s(e,t){var r=e.getRange(d(t.line,t.ch-1),d(t.line,t.ch+1));return 2==r.length?r:null}function c(t,r,n){var i=t.getLine(r.line),o=t.getTokenAt(r);if(/\bstring2?\b/.test(o.type)||u(t,r))return!1;var a=new e.StringStream(i.slice(0,r.ch)+n+i.slice(r.ch),4);for(a.pos=a.start=o.start;;){var l=t.getMode().token(a,o.state);if(a.pos>=r.ch+1)return/\bstring2?\b/.test(l);a.start=a.pos}}function u(e,t){var r=e.getTokenAt(d(t.line,t.ch+1));return/\bstring/.test(r.type)&&r.start==t.ch}var f={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"},d=e.Pos;e.defineOption("autoCloseBrackets",!1,function(t,r,n){n&&n!=e.Init&&(t.removeKeyMap(p),t.state.closeBrackets=null),r&&(t.state.closeBrackets=r,t.addKeyMap(p))});for(var h=f.pairs+"`",p={Backspace:n,Enter:i},m=0;m<h.length;m++)p["'"+h.charAt(m)+"'"]=function(e){return function(t){return a(t,e)}}(h.charAt(m))}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/edit/matchbrackets")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(e){"use strict";function t(t,r,n){if(n<0&&0==r.ch)return t.clipPos(h(r.line-1));var i=t.getLine(r.line);if(n>0&&r.ch>=i.length)return t.clipPos(h(r.line+1,0));for(var o,a="start",l=r.ch,s=n<0?0:i.length,c=0;l!=s;l+=n,c++){var u=i.charAt(n<0?l-1:l),f="_"!=u&&e.isWordChar(u)?"w":"o";if("w"==f&&u.toUpperCase()==u&&(f="W"),"start"==a)"o"!=f&&(a="in",o=f);else if("in"==a&&o!=f){if("w"==o&&"W"==f&&n<0&&l--,"W"==o&&"w"==f&&n>0){o="w";continue}break}}return h(r.line,l)}function r(e,r){e.extendSelectionsBy(function(n){return e.display.shift||e.doc.extend||n.empty()?t(e.doc,n.head,r):r<0?n.from():n.to()})}function n(t,r){if(t.isReadOnly())return e.Pass;t.operation(function(){for(var e=t.listSelections().length,n=[],i=-1,o=0;o<e;o++){var a=t.listSelections()[o].head;if(!(a.line<=i)){var l=h(a.line+(r?0:1),0);t.replaceRange("\n",l,null,"+insertLine"),t.indentLine(l.line,null,!0),n.push({head:l,anchor:l}),i=a.line+1}}t.setSelections(n)}),t.execCommand("indentAuto")}function i(t,r){for(var n=r.ch,i=n,o=t.getLine(r.line);n&&e.isWordChar(o.charAt(n-1));)--n;for(;i<o.length&&e.isWordChar(o.charAt(i));)++i;return{from:h(r.line,n),to:h(r.line,i),word:o.slice(n,i)}}function o(e,t,r){for(var n=0;n<e.length;n++)if(e[n].from()==t&&e[n].to()==r)return!0;return!1}function a(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n],o=i.head,a=e.scanForBracket(o,-1);if(!a)return!1;for(;;){var l=e.scanForBracket(o,1);if(!l)return!1;if(l.ch==y.charAt(y.indexOf(a.ch)+1)){r.push({anchor:h(a.pos.line,a.pos.ch+1),head:l.pos});break}o=h(l.pos.line,l.pos.ch+1)}}return e.setSelections(r),!0}function l(t,r){if(t.isReadOnly())return e.Pass;for(var n,i=t.listSelections(),o=[],a=0;a<i.length;a++){var l=i[a];if(!l.empty()){for(var s=l.from().line,c=l.to().line;a<i.length-1&&i[a+1].from().line==c;)c=i[++a].to().line;i[a].to().ch||c--,o.push(s,c)}}o.length?n=!0:o.push(t.firstLine(),t.lastLine()),t.operation(function(){for(var e=[],i=0;i<o.length;i+=2){var a=o[i],l=o[i+1],s=h(a,0),c=h(l),u=t.getRange(s,c,!1);r?u.sort():u.sort(function(e,t){var r=e.toUpperCase(),n=t.toUpperCase();return r!=n&&(e=r,t=n),e<t?-1:e==t?0:1}),t.replaceRange(u,s,c),n&&e.push({anchor:s,head:h(l+1,0)})}n&&t.setSelections(e,0)})}function s(t,r){t.operation(function(){for(var n=t.listSelections(),o=[],a=[],l=0;l<n.length;l++){var s=n[l];s.empty()?(o.push(l),a.push("")):a.push(r(t.getRange(s.from(),s.to())))}t.replaceSelections(a,"around","case");for(var c,l=o.length-1;l>=0;l--){var s=n[o[l]];if(!(c&&e.cmpPos(s.head,c)>0)){var u=i(t,s.head);c=u.from,t.replaceRange(r(u.word),u.from,u.to)}}})}function c(t){var r=t.getCursor("from"),n=t.getCursor("to");if(0==e.cmpPos(r,n)){var o=i(t,r);if(!o.word)return;r=o.from,n=o.to}return{from:r,to:n,query:t.getRange(r,n),word:o}}function u(e,t){var r=c(e);if(r){var n=r.query,i=e.getSearchCursor(n,t?r.to:r.from);(t?i.findNext():i.findPrevious())?e.setSelection(i.from(),i.to()):(i=e.getSearchCursor(n,t?h(e.firstLine(),0):e.clipPos(h(e.lastLine()))),(t?i.findNext():i.findPrevious())?e.setSelection(i.from(),i.to()):r.word&&e.setSelection(r.from,r.to))}}var f=e.keyMap.sublime={fallthrough:"default"},d=e.commands,h=e.Pos,p=e.keyMap.default==e.keyMap.macDefault,m=p?"Cmd-":"Ctrl-",g=p?"Ctrl-":"Alt-";d[f[g+"Left"]="goSubwordLeft"]=function(e){r(e,-1)},d[f[g+"Right"]="goSubwordRight"]=function(e){r(e,1)},p&&(f["Cmd-Left"]="goLineStartSmart");var v=p?"Ctrl-Alt-":"Ctrl-";d[f[v+"Up"]="scrollLineUp"]=function(e){var t=e.getScrollInfo();if(!e.somethingSelected()){var r=e.lineAtHeight(t.top+t.clientHeight,"local");e.getCursor().line>=r&&e.execCommand("goLineUp")}e.scrollTo(null,t.top-e.defaultTextHeight())},d[f[v+"Down"]="scrollLineDown"]=function(e){var t=e.getScrollInfo();if(!e.somethingSelected()){var r=e.lineAtHeight(t.top,"local")+1;e.getCursor().line<=r&&e.execCommand("goLineDown")}e.scrollTo(null,t.top+e.defaultTextHeight())},d[f["Shift-"+m+"L"]="splitSelectionByLine"]=function(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++)for(var i=t[n].from(),o=t[n].to(),a=i.line;a<=o.line;++a)o.line>i.line&&a==o.line&&0==o.ch||r.push({anchor:a==i.line?i:h(a,0),head:a==o.line?o:h(a)});e.setSelections(r,0)},f["Shift-Tab"]="indentLess",d[f.Esc="singleSelectionTop"]=function(e){var t=e.listSelections()[0];e.setSelection(t.anchor,t.head,{scroll:!1})},d[f[m+"L"]="selectLine"]=function(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){var i=t[n];r.push({anchor:h(i.from().line,0),head:h(i.to().line+1,0)})}e.setSelections(r)},f["Shift-Ctrl-K"]="deleteLine",d[f[m+"Enter"]="insertLineAfter"]=function(e){return n(e,!1)},d[f["Shift-"+m+"Enter"]="insertLineBefore"]=function(e){return n(e,!0)},d[f[m+"D"]="selectNextOccurrence"]=function(t){var r=t.getCursor("from"),n=t.getCursor("to"),a=t.state.sublimeFindFullWord==t.doc.sel;if(0==e.cmpPos(r,n)){var l=i(t,r);if(!l.word)return;t.setSelection(l.from,l.to),a=!0}else{var s=t.getRange(r,n),c=a?new RegExp("\\b"+s+"\\b"):s,u=t.getSearchCursor(c,n),f=u.findNext();if(f||(u=t.getSearchCursor(c,h(t.firstLine(),0)),f=u.findNext()),!f||o(t.listSelections(),u.from(),u.to()))return e.Pass;t.addSelection(u.from(),u.to())}a&&(t.state.sublimeFindFullWord=t.doc.sel)};var y="(){}[]";d[f["Shift-"+m+"Space"]="selectScope"]=function(e){a(e)||e.execCommand("selectAll")},d[f["Shift-"+m+"M"]="selectBetweenBrackets"]=function(t){if(!a(t))return e.Pass},d[f[m+"M"]="goToBracket"]=function(t){t.extendSelectionsBy(function(r){var n=t.scanForBracket(r.head,1);if(n&&0!=e.cmpPos(n.pos,r.head))return n.pos;var i=t.scanForBracket(r.head,-1);return i&&h(i.pos.line,i.pos.ch+1)||r.head})};var b=p?"Cmd-Ctrl-":"Shift-Ctrl-";d[f[b+"Up"]="swapLineUp"]=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),n=[],i=t.firstLine()-1,o=[],a=0;a<r.length;a++){var l=r[a],s=l.from().line-1,c=l.to().line;o.push({anchor:h(l.anchor.line-1,l.anchor.ch),head:h(l.head.line-1,l.head.ch)}),0!=l.to().ch||l.empty()||--c,s>i?n.push(s,c):n.length&&(n[n.length-1]=c),i=c}t.operation(function(){for(var e=0;e<n.length;e+=2){var r=n[e],i=n[e+1],a=t.getLine(r);t.replaceRange("",h(r,0),h(r+1,0),"+swapLine"),i>t.lastLine()?t.replaceRange("\n"+a,h(t.lastLine()),null,"+swapLine"):t.replaceRange(a+"\n",h(i,0),null,"+swapLine")}t.setSelections(o),t.scrollIntoView()})},d[f[b+"Down"]="swapLineDown"]=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),n=[],i=t.lastLine()+1,o=r.length-1;o>=0;o--){var a=r[o],l=a.to().line+1,s=a.from().line;0!=a.to().ch||a.empty()||l--,l<i?n.push(l,s):n.length&&(n[n.length-1]=s),i=s}t.operation(function(){for(var e=n.length-2;e>=0;e-=2){var r=n[e],i=n[e+1],o=t.getLine(r);r==t.lastLine()?t.replaceRange("",h(r-1),h(r),"+swapLine"):t.replaceRange("",h(r,0),h(r+1,0),"+swapLine"),t.replaceRange(o+"\n",h(i,0),null,"+swapLine")}t.scrollIntoView()})},d[f[m+"/"]="toggleCommentIndented"]=function(e){e.toggleComment({indent:!0})},d[f[m+"J"]="joinLines"]=function(e){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++){for(var i=t[n],o=i.from(),a=o.line,l=i.to().line;n<t.length-1&&t[n+1].from().line==l;)l=t[++n].to().line;r.push({start:a,end:l,anchor:!i.empty()&&o})}e.operation(function(){for(var t=0,n=[],i=0;i<r.length;i++){for(var o,a=r[i],l=a.anchor&&h(a.anchor.line-t,a.anchor.ch),s=a.start;s<=a.end;s++){var c=s-t;s==a.end&&(o=h(c,e.getLine(c).length+1)),c<e.lastLine()&&(e.replaceRange(" ",h(c),h(c+1,/^\s*/.exec(e.getLine(c+1))[0].length)),++t)}n.push({anchor:l||o,head:o})}e.setSelections(n,0)})},d[f["Shift-"+m+"D"]="duplicateLine"]=function(e){e.operation(function(){for(var t=e.listSelections().length,r=0;r<t;r++){var n=e.listSelections()[r];n.empty()?e.replaceRange(e.getLine(n.head.line)+"\n",h(n.head.line,0)):e.replaceRange(e.getRange(n.from(),n.to()),n.from())}e.scrollIntoView()})},p||(f[m+"T"]="transposeChars"),d[f.F9="sortLines"]=function(e){l(e,!0)},d[f[m+"F9"]="sortLinesInsensitive"]=function(e){l(e,!1)},d[f.F2="nextBookmark"]=function(e){var t=e.state.sublimeBookmarks;if(t)for(;t.length;){var r=t.shift(),n=r.find();if(n)return t.push(r),e.setSelection(n.from,n.to)}},d[f["Shift-F2"]="prevBookmark"]=function(e){var t=e.state.sublimeBookmarks;if(t)for(;t.length;){t.unshift(t.pop());var r=t[t.length-1].find();if(r)return e.setSelection(r.from,r.to);t.pop()}},d[f[m+"F2"]="toggleBookmark"]=function(e){for(var t=e.listSelections(),r=e.state.sublimeBookmarks||(e.state.sublimeBookmarks=[]),n=0;n<t.length;n++){for(var i=t[n].from(),o=t[n].to(),a=e.findMarks(i,o),l=0;l<a.length;l++)if(a[l].sublimeBookmark){a[l].clear();for(var s=0;s<r.length;s++)r[s]==a[l]&&r.splice(s--,1);break}l==a.length&&r.push(e.markText(i,o,{sublimeBookmark:!0,clearWhenEmpty:!1}))}},d[f["Shift-"+m+"F2"]="clearBookmarks"]=function(e){var t=e.state.sublimeBookmarks;if(t)for(var r=0;r<t.length;r++)t[r].clear();t.length=0},d[f["Alt-F2"]="selectBookmarks"]=function(e){var t=e.state.sublimeBookmarks,r=[];if(t)for(var n=0;n<t.length;n++){var i=t[n].find();i?r.push({anchor:i.from,head:i.to}):t.splice(n--,0)}r.length&&e.setSelections(r,0)},f["Alt-Q"]="wrapLines";var x=m+"K ";f[x+m+"Backspace"]="delLineLeft",d[f.Backspace="smartBackspace"]=function(t){if(t.somethingSelected())return e.Pass;t.operation(function(){for(var r=t.listSelections(),n=t.getOption("indentUnit"),i=r.length-1;i>=0;i--){var o=r[i].head,a=t.getRange({line:o.line,ch:0},o),l=e.countColumn(a,null,t.getOption("tabSize")),s=t.findPosH(o,-1,"char",!1);if(a&&!/\S/.test(a)&&l%n==0){var c=new h(o.line,e.findColumn(a,l-n,n));c.ch!=o.ch&&(s=c)}t.replaceRange("",s,o,"+delete")}})},d[f[x+m+"K"]="delLineRight"]=function(e){e.operation(function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange("",t[r].anchor,h(t[r].to().line),"+delete");e.scrollIntoView()})},d[f[x+m+"U"]="upcaseAtCursor"]=function(e){s(e,function(e){return e.toUpperCase()})},d[f[x+m+"L"]="downcaseAtCursor"]=function(e){s(e,function(e){return e.toLowerCase()})},d[f[x+m+"Space"]="setSublimeMark"]=function(e){e.state.sublimeMark&&e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor())},d[f[x+m+"A"]="selectToSublimeMark"]=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&e.setSelection(e.getCursor(),t)},d[f[x+m+"W"]="deleteToSublimeMark"]=function(t){var r=t.state.sublimeMark&&t.state.sublimeMark.find();if(r){var n=t.getCursor(),i=r;if(e.cmpPos(n,i)>0){var o=i;i=n,n=o}t.state.sublimeKilled=t.getRange(n,i),t.replaceRange("",n,i)}},d[f[x+m+"X"]="swapWithSublimeMark"]=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&(e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor()),e.setCursor(t))},d[f[x+m+"Y"]="sublimeYank"]=function(e){null!=e.state.sublimeKilled&&e.replaceSelection(e.state.sublimeKilled,null,"paste")},f[x+m+"G"]="clearBookmarks",d[f[x+m+"C"]="showInCenter"]=function(e){var t=e.cursorCoords(null,"local");e.scrollTo(null,(t.top+t.bottom)/2-e.getScrollInfo().clientHeight/2)};var w=p?"Ctrl-Shift-":"Ctrl-Alt-";d[f[w+"Up"]="selectLinesUpward"]=function(e){e.operation(function(){for(var t=e.listSelections(),r=0;r<t.length;r++){var n=t[r];n.head.line>e.firstLine()&&e.addSelection(h(n.head.line-1,n.head.ch))}})},d[f[w+"Down"]="selectLinesDownward"]=function(e){e.operation(function(){for(var t=e.listSelections(),r=0;r<t.length;r++){var n=t[r];n.head.line<e.lastLine()&&e.addSelection(h(n.head.line+1,n.head.ch))}})},d[f[m+"F3"]="findUnder"]=function(e){u(e,!0)},d[f["Shift-"+m+"F3"]="findUnderPrevious"]=function(e){u(e,!1)},d[f["Alt-F3"]="findAllUnder"]=function(e){var t=c(e);if(t){for(var r=e.getSearchCursor(t.query),n=[],i=-1;r.findNext();)n.push({anchor:r.from(),head:r.to()}),r.from().line<=t.from.line&&r.from().ch<=t.from.ch&&i++;e.setSelections(n,i)}},f["Shift-"+m+"["]="fold",f["Shift-"+m+"]"]="unfold",f[x+m+"0"]=f[x+m+"J"]="unfoldAll",f[m+"I"]="findIncremental",f["Shift-"+m+"I"]="findIncrementalReverse",f[m+"H"]="replace",f.F3="findNext",f["Shift-F3"]="findPrev",e.normalizeKeyMap(f)}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror")):"function"==typeof define&&define.amd?define(["../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return e.line==t.line&&e.ch==t.ch}function r(e){P.push(e),P.length>50&&P.shift()}function n(e){if(!P.length)return r(e);P[P.length-1]+=e}function i(e){return P[P.length-(e?Math.min(e,1):1)]||""}function o(){return P.length>1&&P.pop(),i()}function a(e,i,o,a,l){null==l&&(l=e.getRange(i,o)),a&&R&&R.cm==e&&t(i,R.pos)&&e.isClean(R.gen)?n(l):r(l),e.replaceRange("",i,o,"+delete"),R=a?{cm:e,pos:i,gen:e.changeGeneration()}:null}function l(e,t,r){return e.findPosH(t,r,"char",!0)}function s(e,t,r){return e.findPosH(t,r,"word",!0)}function c(e,t,r){return e.findPosV(t,r,"line",e.doc.sel.goalColumn)}function u(e,t,r){return e.findPosV(t,r,"page",e.doc.sel.goalColumn)}function f(e,t,r){for(var n=t.line,i=e.getLine(n),o=/\S/.test(r<0?i.slice(0,t.ch):i.slice(t.ch)),a=e.firstLine(),l=e.lastLine();;){if((n+=r)<a||n>l)return e.clipPos(N(n-r,r<0?0:null));i=e.getLine(n);if(/\S/.test(i))o=!0;else if(o)return N(n,0)}}function d(e,t,r){for(var n=t.line,i=t.ch,o=e.getLine(t.line),a=!1;;){var l=o.charAt(i+(r<0?-1:0));if(l){if(a&&/[!?.]/.test(l))return N(n,i+(r>0?1:0));a||(a=/\w/.test(l)),i+=r}else{if(n==(r<0?e.firstLine():e.lastLine()))return N(n,i);if(o=e.getLine(n+r),!/\S/.test(o))return N(n,i);n+=r,i=r<0?o.length:0}}}function h(e,r,n){var i;if(e.findMatchingBracket&&(i=e.findMatchingBracket(r,!0))&&i.match&&(i.forward?1:-1)==n)return n>0?N(i.to.line,i.to.ch+1):i.to;for(var o=!0;;o=!1){var a=e.getTokenAt(r),l=N(r.line,n<0?a.start:a.end);if(!(o&&n>0&&a.end==r.ch)&&/\w/.test(a.string))return l;var s=e.findPosH(l,n,"char");if(t(l,s))return r;r=s}}function p(e,t){var r=e.state.emacsPrefix;return r?(k(e),"-"==r?-1:Number(r)):t?null:1}function m(e){var t="string"==typeof e?function(t){t.execCommand(e)}:e;return function(e){var r=p(e);t(e);for(var n=1;n<r;++n)t(e)}}function g(e,r,n,i){var o=p(e);o<0&&(i=-i,o=-o);for(var a=0;a<o;++a){var l=n(e,r,i);if(t(l,r))break;r=l}return r}function v(e,t){var r=function(r){r.extendSelection(g(r,r.getCursor(),e,t))};return r.motion=!0,r}function y(e,t,r){for(var n,i=e.listSelections(),o=i.length;o--;)n=i[o].head,a(e,n,g(e,n,t,r),!0)}function b(e){if(e.somethingSelected()){for(var t,r=e.listSelections(),n=r.length;n--;)t=r[n],a(e,t.anchor,t.head);return!0}}function x(e,t){if(e.state.emacsPrefix)return void("-"!=t&&(e.state.emacsPrefix+=t));e.state.emacsPrefix=t,e.on("keyHandled",w),e.on("inputRead",C)}function w(e,t){e.state.emacsPrefixMap||B.hasOwnProperty(t)||k(e)}function k(e){e.state.emacsPrefix=null,e.off("keyHandled",w),e.off("inputRead",C)}function C(e,t){var r=p(e);if(r>1&&"+input"==t.origin){for(var n=t.text.join("\n"),i="",o=1;o<r;++o)i+=n;e.replaceSelection(i)}}function S(e){e.state.emacsPrefixMap=!0,e.addKeyMap(D),e.on("keyHandled",_),e.on("inputRead",_)}function _(e,t){("string"!=typeof t||!/^\d$/.test(t)&&"Ctrl-U"!=t)&&(e.removeKeyMap(D),e.state.emacsPrefixMap=!1,e.off("keyHandled",_),e.off("inputRead",_))}function M(e){e.setCursor(e.getCursor()),e.setExtending(!e.getExtending()),e.on("change",function(){e.setExtending(!1)})}function L(e){e.setExtending(!1),e.setCursor(e.getCursor())}function T(e,t,r){e.openDialog?e.openDialog(t+': <input type="text" style="width: 10em"/>',r,{bottom:!0}):r(prompt(t,""))}function A(e,t){var r=e.getCursor(),n=e.findPosH(r,1,"word");e.replaceRange(t(e.getRange(r,n)),r,n),e.setCursor(n)}function O(e){for(var t=e.getCursor(),r=t.line,n=t.ch,i=[];r>=e.firstLine();){for(var o=e.getLine(r),a=null==n?o.length:n;a>0;){var n=o.charAt(--a);if(")"==n)i.push("(");else if("]"==n)i.push("[");else if("}"==n)i.push("{");else if(/[\(\{\[]/.test(n)&&(!i.length||i.pop()!=n))return e.extendSelection(N(r,a))}--r,n=null}}function E(e){e.execCommand("clearSearch"),L(e)}function I(e){D[e]=function(t){x(t,e)},z["Ctrl-"+e]=function(t){x(t,e)},B["Ctrl-"+e]=!0}var N=e.Pos,P=[],R=null,B={"Alt-G":!0,"Ctrl-X":!0,"Ctrl-Q":!0,"Ctrl-U":!0};e.emacs={kill:a,killRegion:b,repeated:m};for(var z=e.keyMap.emacs=e.normalizeKeyMap({"Ctrl-W":function(e){a(e,e.getCursor("start"),e.getCursor("end"))},"Ctrl-K":m(function(e){var t=e.getCursor(),r=e.clipPos(N(t.line)),n=e.getRange(t,r);/\S/.test(n)||(n+="\n",r=N(t.line+1,0)),a(e,t,r,!0,n)}),"Alt-W":function(e){r(e.getSelection()),L(e)},"Ctrl-Y":function(e){var t=e.getCursor();e.replaceRange(i(p(e)),t,t,"paste"),e.setSelection(t,e.getCursor())},"Alt-Y":function(e){e.replaceSelection(o(),"around","paste")},"Ctrl-Space":M,"Ctrl-Shift-2":M,"Ctrl-F":v(l,1),"Ctrl-B":v(l,-1),Right:v(l,1),Left:v(l,-1),"Ctrl-D":function(e){y(e,l,1)},Delete:function(e){b(e)||y(e,l,1)},"Ctrl-H":function(e){y(e,l,-1)},Backspace:function(e){b(e)||y(e,l,-1)},"Alt-F":v(s,1),"Alt-B":v(s,-1),"Alt-D":function(e){y(e,s,1)},"Alt-Backspace":function(e){y(e,s,-1)},"Ctrl-N":v(c,1),"Ctrl-P":v(c,-1),Down:v(c,1),Up:v(c,-1),"Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd",End:"goLineEnd",Home:"goLineStart","Alt-V":v(u,-1),"Ctrl-V":v(u,1),PageUp:v(u,-1),PageDown:v(u,1),"Ctrl-Up":v(f,-1),"Ctrl-Down":v(f,1),"Alt-A":v(d,-1),"Alt-E":v(d,1),"Alt-K":function(e){y(e,d,1)},"Ctrl-Alt-K":function(e){y(e,h,1)},"Ctrl-Alt-Backspace":function(e){y(e,h,-1)},"Ctrl-Alt-F":v(h,1),"Ctrl-Alt-B":v(h,-1),"Shift-Ctrl-Alt-2":function(e){var t=e.getCursor();e.setSelection(g(e,t,h,1),t)},"Ctrl-Alt-T":function(e){var t=h(e,e.getCursor(),-1),r=h(e,t,1),n=h(e,r,1),i=h(e,n,-1);e.replaceRange(e.getRange(i,n)+e.getRange(r,i)+e.getRange(t,r),t,n)},"Ctrl-Alt-U":m(O),"Alt-Space":function(e){for(var t=e.getCursor(),r=t.ch,n=t.ch,i=e.getLine(t.line);r&&/\s/.test(i.charAt(r-1));)--r;for(;n<i.length&&/\s/.test(i.charAt(n));)++n;e.replaceRange(" ",N(t.line,r),N(t.line,n))},"Ctrl-O":m(function(e){e.replaceSelection("\n","start")}),"Ctrl-T":m(function(e){e.execCommand("transposeChars")}),"Alt-C":m(function(e){A(e,function(e){var t=e.search(/\w/);return t==-1?e:e.slice(0,t)+e.charAt(t).toUpperCase()+e.slice(t+1).toLowerCase()})}),"Alt-U":m(function(e){A(e,function(e){return e.toUpperCase()})}),"Alt-L":m(function(e){A(e,function(e){return e.toLowerCase()})}),"Alt-;":"toggleComment","Ctrl-/":m("undo"),"Shift-Ctrl--":m("undo"),"Ctrl-Z":m("undo"),"Cmd-Z":m("undo"),"Shift-Alt-,":"goDocStart","Shift-Alt-.":"goDocEnd","Ctrl-S":"findNext","Ctrl-R":"findPrev","Ctrl-G":E,"Shift-Alt-5":"replace","Alt-/":"autocomplete",Enter:"newlineAndIndent","Ctrl-J":m(function(e){e.replaceSelection("\n","end")}),Tab:"indentAuto","Alt-G G":function(e){var t=p(e,!0);if(null!=t&&t>0)return e.setCursor(t-1);T(e,"Goto line",function(t){var r;t&&!isNaN(r=Number(t))&&r==(0|r)&&r>0&&e.setCursor(r-1)})},"Ctrl-X Tab":function(e){e.indentSelection(p(e,!0)||e.getOption("indentUnit"))},"Ctrl-X Ctrl-X":function(e){e.setSelection(e.getCursor("head"),e.getCursor("anchor"))},"Ctrl-X Ctrl-S":"save","Ctrl-X Ctrl-W":"save","Ctrl-X S":"saveAll","Ctrl-X F":"open","Ctrl-X U":m("undo"),"Ctrl-X K":"close","Ctrl-X Delete":function(e){a(e,e.getCursor(),d(e,e.getCursor(),1),!0)},"Ctrl-X H":"selectAll","Ctrl-Q Tab":m("insertTab"),"Ctrl-U":S}),D={"Ctrl-G":k},W=0;W<10;++W)I(String(W));I("-")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(e){"use strict";var t=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},
|
11 |
context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],r=[{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"}],n=e.Pos;e.Vim=function(){function i(t){t.setOption("disableInput",!0),t.setOption("showCursorWhenSelecting",!1),e.signal(t,"vim-mode-change",{mode:"normal"}),t.on("cursorActivity",tt),C(t),e.on(t.getInputField(),"paste",u(t))}function o(t){t.setOption("disableInput",!1),t.off("cursorActivity",tt),e.off(t.getInputField(),"paste",u(t)),t.state.vim=null}function a(t,r){this==e.keyMap.vim&&e.rmClass(t.getWrapperElement(),"cm-fat-cursor"),r&&r.attach==l||o(t,!1)}function l(t,r){this==e.keyMap.vim&&e.addClass(t.getWrapperElement(),"cm-fat-cursor"),r&&r.attach==l||i(t)}function s(t,r){if(r){if(this[t])return this[t];var n=c(t);if(!n)return!1;var i=e.Vim.findKey(r,n);return"function"==typeof i&&e.signal(r,"vim-keypress",n),i}}function c(e){if("'"==e.charAt(0))return e.charAt(1);var t=e.split(/-(?!$)/),r=t[t.length-1];if(1==t.length&&1==t[0].length)return!1;if(2==t.length&&"Shift"==t[0]&&1==r.length)return!1;for(var n=!1,i=0;i<t.length;i++){var o=t[i];o in st?t[i]=st[o]:n=!0,o in ct&&(t[i]=ct[o])}return!!n&&(g(r)&&(t[t.length-1]=r.toLowerCase()),"<"+t.join("-")+">")}function u(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(z(e.getCursor(),0,1)),Lt.enterInsertMode(e,{},t))}),t.onPasteFn}function f(e,t){for(var r=[],n=e;n<e+t;n++)r.push(String.fromCharCode(n));return r}function d(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function h(e){return/^[a-z]$/.test(e)}function p(e){return"()[]{}".indexOf(e)!=-1}function m(e){return ut.test(e)}function g(e){return/^[A-Z]$/.test(e)}function v(e){return/^\s*$/.test(e)}function y(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}function b(e,t,r,n,i){if(void 0===t&&!i)throw Error("defaultValue is required unless callback is provided");if(r||(r="string"),yt[e]={type:r,defaultValue:t,callback:i},n)for(var o=0;o<n.length;o++)yt[n[o]]=yt[e];t&&x(e,t)}function x(e,t,r,n){var i=yt[e];n=n||{};var o=n.scope;if(!i)throw Error("Unknown option: "+e);if("boolean"==i.type){if(t&&t!==!0)throw Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}i.callback?("local"!==o&&i.callback(t,void 0),"global"!==o&&r&&i.callback(t,r)):("local"!==o&&(i.value="boolean"==i.type?!!t:t),"global"!==o&&r&&(r.state.vim.options[e]={value:t}))}function w(e,t,r){var n=yt[e];r=r||{};var i=r.scope;if(!n)throw Error("Unknown option: "+e);{if(!n.callback){var o="global"!==i&&t&&t.state.vim.options[e];return(o||"local"!==i&&n||{}).value}var o=t&&n.callback(void 0,t);if("global"!==i&&void 0!==o)return o;if("local"!==i)return n.callback()}}function k(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=xt()}function C(e){return e.state.vim||(e.state.vim={inputState:new _,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}}),e.state.vim}function S(){wt={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:bt(),macroModeState:new k,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new A({}),searchHistoryController:new O({}),exCommandHistoryController:new O({})};for(var e in yt){var t=yt[e];t.value=t.defaultValue}}function _(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null}function M(t,r){t.state.vim.inputState=new _,e.signal(t,"vim-command-done",r)}function L(e,t,r){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!r}function T(e,t){var r=wt.registerController.registers[e];if(!e||1!=e.length)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,vt.push(e)}function A(e){this.registers=e,this.unnamedRegister=e['"']=new L,e["."]=new L,e[":"]=new L,e["/"]=new L}function O(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}function E(e,t){_t[e]=t}function I(e,t){for(var r=[],n=0;n<t;n++)r.push(e);return r}function N(e,t){Mt[e]=t}function P(e,t){Lt[e]=t}function R(e,t,r){var i=Math.min(Math.max(e.firstLine(),t.line),e.lastLine()),o=X(e,i)-1;o=r?o+1:o;var a=Math.min(Math.max(0,t.ch),o);return n(i,a)}function B(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function z(e,t,r){return"object"==typeof t&&(r=t.ch,t=t.line),n(e.line+t,e.ch+r)}function D(e,t){return{line:t.line-e.line,ch:t.line-e.line}}function W(e,t,r,n){for(var i,o=[],a=[],l=0;l<t.length;l++){var s=t[l];"insert"==r&&"insert"!=s.context||s.context&&s.context!=r||n.operator&&"action"==s.type||!(i=q(e,s.keys))||("partial"==i&&o.push(s),"full"==i&&a.push(s))}return{partial:o.length&&o,full:a.length&&a}}function q(e,t){if("<character>"==t.slice(-11)){var r=t.length-11,n=e.slice(0,r),i=t.slice(0,r);return n==i&&e.length>r?"full":0==i.indexOf(n)&&"partial"}return e==t?"full":0==t.indexOf(e)&&"partial"}function F(e){var t=/^.*(<[\w\-]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(r.length>1)switch(r){case"<CR>":r="\n";break;case"<Space>":r=" "}return r}function H(e,t,r){return function(){for(var n=0;n<r;n++)t(e)}}function j(e){return n(e.line,e.ch)}function K(e,t){return e.ch==t.ch&&e.line==t.line}function U(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function V(e,t){return arguments.length>2&&(t=V.apply(void 0,Array.prototype.slice.call(arguments,1))),U(e,t)?e:t}function $(e,t){return arguments.length>2&&(t=$.apply(void 0,Array.prototype.slice.call(arguments,1))),U(e,t)?t:e}function G(e,t,r){var n=U(e,t),i=U(t,r);return n&&i}function X(e,t){return e.getLine(t).length}function Y(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Q(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function J(e,t,r){var i=X(e,t),o=new Array(r-i+1).join(" ");e.setCursor(n(t,i)),e.replaceRange(o,e.getCursor())}function Z(e,t){var r=[],i=e.listSelections(),o=j(e.clipPos(t)),a=!K(t,o),l=e.getCursor("head"),s=te(i,l),c=K(i[s].head,i[s].anchor),u=i.length-1,f=u-s>s?u:0,d=i[f].anchor,h=Math.min(d.line,o.line),p=Math.max(d.line,o.line),m=d.ch,g=o.ch,v=i[f].head.ch-m,y=g-m;v>0&&y<=0?(m++,a||g--):v<0&&y>=0?(m--,c||g++):v<0&&y==-1&&(m--,g++);for(var b=h;b<=p;b++){var x={anchor:new n(b,m),head:new n(b,g)};r.push(x)}return s=o.line==p?r.length-1:0,e.setSelections(r),t.ch=g,d.ch=m,d}function ee(e,t,r){for(var n=[],i=0;i<r;i++){var o=z(t,i,0);n.push({anchor:o,head:o})}e.setSelections(n,0)}function te(e,t,r){for(var n=0;n<e.length;n++){var i="head"!=r&&K(e[n].anchor,t),o="anchor"!=r&&K(e[n].head,t);if(i||o)return n}return-1}function re(e,t){var r=t.lastSelection;return t.visualMode?function(){var t=e.listSelections(),r=t[0],n=t[t.length-1];return[U(r.anchor,r.head)?r.anchor:r.head,U(n.anchor,n.head)?n.head:n.anchor]}():function(){var t=e.getCursor(),i=e.getCursor(),o=r.visualBlock;if(o){var a=o.width,l=o.height;i=n(t.line+l,t.ch+a);for(var s=[],c=t.line;c<i.line;c++){var u=n(c,t.ch),f=n(c,i.ch),d={anchor:u,head:f};s.push(d)}e.setSelections(s)}else{var h=r.anchorMark.find(),p=r.headMark.find(),m=p.line-h.line,g=p.ch-h.ch;i={line:i.line+m,ch:m?i.ch:g+i.ch},r.visualLine&&(t=n(t.line,0),i=n(i.line,X(e,i.line))),e.setSelection(t,i)}return[t,i]}()}function ne(e,t){var r=t.sel.anchor,n=t.sel.head;t.lastPastedText&&(n=e.posFromIndex(e.indexFromPos(r)+t.lastPastedText.length),t.lastPastedText=null),t.lastSelection={anchorMark:e.setBookmark(r),headMark:e.setBookmark(n),anchor:j(r),head:j(n),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function ie(e,t,r){var i,o=e.state.vim.sel,a=o.head,l=o.anchor;return U(r,t)&&(i=r,r=t,t=i),U(a,l)?(a=V(t,a),l=$(l,r)):(l=V(t,l),a=$(a,r),a=z(a,0,-1),a.ch==-1&&a.line!=e.firstLine()&&(a=n(a.line-1,X(e,a.line-1)))),[l,a]}function oe(e,t,r){var n=e.state.vim;t=t||n.sel;var r=r||n.visualLine?"line":n.visualBlock?"block":"char",i=ae(e,t,r);e.setSelections(i.ranges,i.primary),rt(e)}function ae(e,t,r,i){var o=j(t.head),a=j(t.anchor);if("char"==r){var l=i||U(t.head,t.anchor)?0:1,s=U(t.head,t.anchor)?1:0;return o=z(t.head,0,l),a=z(t.anchor,0,s),{ranges:[{anchor:a,head:o}],primary:0}}if("line"==r){if(U(t.head,t.anchor))o.ch=0,a.ch=X(e,a.line);else{a.ch=0;var c=e.lastLine();o.line>c&&(o.line=c),o.ch=X(e,o.line)}return{ranges:[{anchor:a,head:o}],primary:0}}if("block"==r){for(var u=Math.min(a.line,o.line),f=Math.min(a.ch,o.ch),d=Math.max(a.line,o.line),h=Math.max(a.ch,o.ch)+1,p=d-u+1,m=o.line==u?0:p-1,g=[],v=0;v<p;v++)g.push({anchor:n(u+v,f),head:n(u+v,h)});return{ranges:g,primary:m}}}function le(e){var t=e.getCursor("head");return 1==e.getSelection().length&&(t=V(t,e.getCursor("anchor"))),t}function se(t,r){var n=t.state.vim;r!==!1&&t.setCursor(R(t,n.sel.head)),ne(t,n),n.visualMode=!1,n.visualLine=!1,n.visualBlock=!1,e.signal(t,"vim-mode-change",{mode:"normal"}),n.fakeCursor&&n.fakeCursor.clear()}function ce(e,t,r){var n=e.getRange(t,r);if(/\n\s*$/.test(n)){var i=n.split("\n");i.pop();for(var o,o=i.pop();i.length>0&&o&&v(o);o=i.pop())r.line--,r.ch=0;o?(r.line--,r.ch=X(e,r.line)):r.ch=0}}function ue(e,t,r){t.ch=0,r.ch=0,r.line++}function fe(e){if(!e)return 0;var t=e.search(/\S/);return t==-1?e.length:t}function de(e,t,r,i,o){for(var a=le(e),l=e.getLine(a.line),s=a.ch,c=o?ft[0]:dt[0];!c(l.charAt(s));)if(++s>=l.length)return null;i?c=dt[0]:(c=ft[0])(l.charAt(s))||(c=ft[1]);for(var u=s,f=s;c(l.charAt(u))&&u<l.length;)u++;for(;c(l.charAt(f))&&f>=0;)f--;if(f++,t){for(var d=u;/\s/.test(l.charAt(u))&&u<l.length;)u++;if(d==u){for(var h=f;/\s/.test(l.charAt(f-1))&&f>0;)f--;f||(f=h)}}return{start:n(a.line,f),end:n(a.line,u)}}function he(e,t,r){K(t,r)||wt.jumpList.add(e,t,r)}function pe(e,t){wt.lastCharacterSearch.increment=e,wt.lastCharacterSearch.forward=t.forward,wt.lastCharacterSearch.selectedCharacter=t.selectedCharacter}function me(e,t,r,i){var o=j(e.getCursor()),a=r?1:-1,l=r?e.lineCount():-1,s=o.ch,c=o.line,u=e.getLine(c),f={lineText:u,nextCh:u.charAt(s),lastCh:null,index:s,symb:i,reverseSymb:(r?{")":"(","}":"{"}:{"(":")","{":"}"})[i],forward:r,depth:0,curMoveThrough:!1},d=Tt[i];if(!d)return o;var h=At[d].init,p=At[d].isComplete;for(h&&h(f);c!==l&&t;){if(f.index+=a,f.nextCh=f.lineText.charAt(f.index),!f.nextCh){if(c+=a,f.lineText=e.getLine(c)||"",a>0)f.index=0;else{var m=f.lineText.length;f.index=m>0?m-1:0}f.nextCh=f.lineText.charAt(f.index)}p(f)&&(o.line=c,o.ch=f.index,t--)}return f.nextCh||f.curMoveThrough?n(c,f.index):o}function ge(e,t,r,n,i){var o=t.line,a=t.ch,l=e.getLine(o),s=r?1:-1,c=n?dt:ft;if(i&&""==l){if(o+=s,l=e.getLine(o),!d(e,o))return null;a=r?0:l.length}for(;;){if(i&&""==l)return{from:0,to:0,line:o};for(var u=s>0?l.length:-1,f=u,h=u;a!=u;){for(var p=!1,m=0;m<c.length&&!p;++m)if(c[m](l.charAt(a))){for(f=a;a!=u&&c[m](l.charAt(a));)a+=s;if(h=a,p=f!=h,f==t.ch&&o==t.line&&h==f+s)continue;return{from:Math.min(f,h+1),to:Math.max(f,h),line:o}}p||(a+=s)}if(o+=s,!d(e,o))return null;l=e.getLine(o),a=s>0?0:l.length}}function ve(e,t,r,i,o,a){var l=j(t),s=[];(i&&!o||!i&&o)&&r++;for(var c=!(i&&o),u=0;u<r;u++){var f=ge(e,t,i,a,c);if(!f){var d=X(e,e.lastLine());s.push(i?{line:e.lastLine(),from:d,to:d}:{line:0,from:0,to:0});break}s.push(f),t=n(f.line,i?f.to-1:f.from)}var h=s.length!=r,p=s[0],m=s.pop();return i&&!o?(h||p.from==l.ch&&p.line==l.line||(m=s.pop()),n(m.line,m.from)):i&&o?n(m.line,m.to-1):!i&&o?(h||p.to==l.ch&&p.line==l.line||(m=s.pop()),n(m.line,m.to)):n(m.line,m.from)}function ye(e,t,r,i){for(var o,a=e.getCursor(),l=a.ch,s=0;s<t;s++){if((o=we(l,e.getLine(a.line),i,r,!0))==-1)return null;l=o}return n(e.getCursor().line,o)}function be(e,t){var r=e.getCursor().line;return R(e,n(r,t-1))}function xe(e,t,r,n){y(r,gt)&&(t.marks[r]&&t.marks[r].clear(),t.marks[r]=e.setBookmark(n))}function we(e,t,r,n,i){var o;return n?(o=t.indexOf(r,e+1))==-1||i||(o-=1):(o=t.lastIndexOf(r,e-1))==-1||i||(o+=1),o}function ke(e,t,r,i,o){function a(t){return!e.getLine(t)}function l(e,t,r){return r?a(e)!=a(e+t):!a(e)&&a(e+t)}var s,c,u=t.line,f=e.firstLine(),d=e.lastLine(),h=u;if(i){for(;f<=h&&h<=d&&r>0;)l(h,i)&&r--,h+=i;return new n(h,0)}var p=e.state.vim;if(p.visualLine&&l(u,1,!0)){var m=p.sel.anchor;l(m.line,-1,!0)&&(o&&m.line==u||(u+=1))}var g=a(u);for(h=u;h<=d&&r;h++)l(h,1,!0)&&(o&&a(h)==g||r--);for(c=new n(h,0),h>d&&!g?g=!0:o=!1,h=u;h>f&&(o&&a(h)!=g&&h!=u||!l(h,-1,!0));h--);return s=new n(h,0),{start:s,end:c}}function Ce(e,t,r,i){var o,a,l=t,s={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[r],c={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[r],u=e.getLine(l.line).charAt(l.ch),f=u===c?1:0;if(o=e.scanForBracket(n(l.line,l.ch+f),-1,null,{bracketRegex:s}),a=e.scanForBracket(n(l.line,l.ch+f),1,null,{bracketRegex:s}),!o||!a)return{start:l,end:l};if(o=o.pos,a=a.pos,o.line==a.line&&o.ch>a.ch||o.line>a.line){var d=o;o=a,a=d}return i?a.ch+=1:o.ch+=1,{start:o,end:a}}function Se(e,t,r,i){var o,a,l,s,c=j(t),u=e.getLine(c.line),f=u.split(""),d=f.indexOf(r);if(c.ch<d?c.ch=d:d<c.ch&&f[c.ch]==r&&(a=c.ch,--c.ch),f[c.ch]!=r||a)for(l=c.ch;l>-1&&!o;l--)f[l]==r&&(o=l+1);else o=c.ch+1;if(o&&!a)for(l=o,s=f.length;l<s&&!a;l++)f[l]==r&&(a=l);return o&&a?(i&&(--o,++a),{start:n(c.line,o),end:n(c.line,a)}):{start:c,end:c}}function _e(){}function Me(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new _e)}function Le(e,t,r,n,i){e.openDialog?e.openDialog(t,n,{bottom:!0,value:i.value,onKeyDown:i.onKeyDown,onKeyUp:i.onKeyUp,selectValueOnOpen:!1}):n(prompt(r,""))}function Te(e){var t=Ae(e)||[];if(!t.length)return[];var r=[];if(0===t[0]){for(var n=0;n<t.length;n++)"number"==typeof t[n]&&r.push(e.substring(t[n]+1,t[n+1]));return r}}function Ae(e){for(var t=!1,r=[],n=0;n<e.length;n++){var i=e.charAt(n);t||"/"!=i||r.push(n),t=!t&&"\\"==i}return r}function Oe(e){for(var t="|(){",r="}",n=!1,i=[],o=-1;o<e.length;o++){var a=e.charAt(o)||"",l=e.charAt(o+1)||"",s=l&&t.indexOf(l)!=-1;n?("\\"===a&&s||i.push(a),n=!1):"\\"===a?(n=!0,l&&r.indexOf(l)!=-1&&(s=!0),s&&"\\"!==l||i.push(a)):(i.push(a),s&&"\\"!==l&&i.push("\\"))}return i.join("")}function Ee(e){for(var t=!1,r=[],n=-1;n<e.length;n++){var i=e.charAt(n)||"",o=e.charAt(n+1)||"";Ot[i+o]?(r.push(Ot[i+o]),n++):t?(r.push(i),t=!1):"\\"===i?(t=!0,m(o)||"$"===o?r.push("$"):"/"!==o&&"\\"!==o&&r.push("\\")):("$"===i&&r.push("$"),r.push(i),"/"===o&&r.push("\\"))}return r.join("")}function Ie(t){for(var r=new e.StringStream(t),n=[];!r.eol();){for(;r.peek()&&"\\"!=r.peek();)n.push(r.next());var i=!1;for(var o in Et)if(r.match(o,!0)){i=!0,n.push(Et[o]);break}i||n.push(r.next())}return n.join("")}function Ne(e,t,r){if(wt.registerController.getRegister("/").setText(e),e instanceof RegExp)return e;var n,i,o=Ae(e);if(o.length){n=e.substring(0,o[0]);i=e.substring(o[0]).indexOf("i")!=-1}else n=e;return n?(w("pcre")||(n=Oe(n)),r&&(t=/^[^A-Z]*$/.test(n)),new RegExp(n,t||i?"i":void 0)):null}function Pe(e,t){e.openNotification?e.openNotification('<span style="color: red">'+t+"</span>",{bottom:!0,duration:5e3}):alert(t)}function Re(e,t){var r='<span style="font-family: monospace; white-space: pre">'+(e||"")+'<input type="text"></span>';return t&&(r+=' <span style="color: #888">'+t+"</span>"),r}function Be(e,t){var r=(t.prefix||"")+" "+(t.desc||"");Le(e,Re(t.prefix,t.desc),r,t.onClose,t)}function ze(e,t){if(e instanceof RegExp&&t instanceof RegExp){for(var r=["global","multiline","ignoreCase","source"],n=0;n<r.length;n++){var i=r[n];if(e[i]!==t[i])return!1}return!0}return!1}function De(e,t,r,n){if(t){var i=Me(e),o=Ne(t,!!r,!!n);if(o)return qe(e,o),ze(o,i.getQuery())?o:(i.setQuery(o),o)}}function We(e){if("^"==e.source.charAt(0))var t=!0;return{token:function(r){if(t&&!r.sol())return void r.skipToEnd();var n=r.match(e,!1);if(n)return 0==n[0].length?(r.next(),"searching"):r.sol()||(r.backUp(1),e.exec(r.next()+n[0]))?(r.match(e),"searching"):(r.next(),null);for(;!r.eol()&&(r.next(),!r.match(e,!1)););},query:e}}function qe(e,t){var r=Me(e),n=r.getOverlay();n&&t==n.query||(n&&e.removeOverlay(n),n=We(t),e.addOverlay(n),e.showMatchesOnScrollbar&&(r.getScrollbarAnnotate()&&r.getScrollbarAnnotate().clear(),r.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))),r.setOverlay(n))}function Fe(e,t,r,i){return void 0===i&&(i=1),e.operation(function(){for(var o=e.getCursor(),a=e.getSearchCursor(r,o),l=0;l<i;l++){var s=a.find(t);if(0==l&&s&&K(a.from(),o)&&(s=a.find(t)),!s&&(a=e.getSearchCursor(r,t?n(e.lastLine()):n(e.firstLine(),0)),!a.find(t)))return}return a.from()})}function He(e){var t=Me(e);e.removeOverlay(Me(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function je(e,t,r){return"number"!=typeof e&&(e=e.line),t instanceof Array?y(e,t):r?e>=t&&e<=r:e==t}function Ke(e){var t=e.getScrollInfo(),r=e.coordsChar({left:0,top:6+t.top},"local"),n=t.clientHeight-10+t.top,i=e.coordsChar({left:0,top:n},"local");return{top:r.line,bottom:i.line}}function Ue(e,t,r){if("'"==r){var n=e.doc.history.done,i=n[n.length-2];return i&&i.ranges&&i.ranges[0].head}var o=t.marks[r];return o&&o.find()}function Ve(t,r,n,i,o,a,l,s,c){function u(){t.operation(function(){for(;!m;)f(),d();h()})}function f(){var e=t.getRange(a.from(),a.to()),r=e.replace(l,s);a.replace(r)}function d(){for(;a.findNext()&&je(a.from(),i,o);)if(n||!g||a.from().line!=g.line)return t.scrollIntoView(a.from(),30),t.setSelection(a.from(),a.to()),g=a.from(),void(m=!1);m=!0}function h(e){if(e&&e(),t.focus(),g){t.setCursor(g);var r=t.state.vim;r.exMode=!1,r.lastHPos=r.lastHSPos=g.ch}c&&c()}function p(r,n,i){switch(e.e_stop(r),e.keyName(r)){case"Y":f(),d();break;case"N":d();break;case"A":var o=c;c=void 0,t.operation(u),c=o;break;case"L":f();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":h(i)}return m&&h(i),!0}t.state.vim.exMode=!0;var m=!1,g=a.from();return d(),m?void Pe(t,"No matches for "+l.source):r?void Be(t,{prefix:"replace with <strong>"+s+"</strong> (y/n/a/q/l)",onKeyDown:p}):(u(),void(c&&c()))}function $e(t){var r=t.state.vim,n=wt.macroModeState,i=wt.registerController.getRegister("."),o=n.isPlaying,a=n.lastInsertModeChanges,l=[];if(!o){for(var s=a.inVisualBlock?r.lastSelection.visualBlock.height:1,c=a.changes,l=[],u=0;u<c.length;)l.push(c[u]),c[u]instanceof it?u++:u+=s;a.changes=l,t.off("change",et),e.off(t.getInputField(),"keydown",ot)}!o&&r.insertModeRepeat>1&&(at(t,r,r.insertModeRepeat-1,!0),r.lastEditInputState.repeatOverride=r.insertModeRepeat),delete r.insertModeRepeat,r.insertMode=!1,t.setCursor(t.getCursor().line,t.getCursor().ch-1),t.setOption("keyMap","vim"),t.setOption("disableInput",!0),t.toggleOverwrite(!1),i.setText(a.changes.join("")),e.signal(t,"vim-mode-change",{mode:"normal"}),n.isRecording&&Je(n)}function Ge(e){t.unshift(e)}function Xe(e,t,r,n,i){var o={keys:e,type:t};o[t]=r,o[t+"Args"]=n;for(var a in i)o[a]=i[a];Ge(o)}function Ye(t,r,n,i){var o=wt.registerController.getRegister(i);if(":"==i)return o.keyBuffer[0]&&Rt.processCommand(t,o.keyBuffer[0]),void(n.isPlaying=!1);var a=o.keyBuffer,l=0;n.isPlaying=!0,n.replaySearchQueries=o.searchQueries.slice(0);for(var s=0;s<a.length;s++)for(var c,u,f=a[s];f;)if(c=/<\w+-.+?>|<\w+>|./.exec(f),u=c[0],f=f.substring(c.index+u.length),e.Vim.handleKey(t,u,"macro"),r.insertMode){var d=o.insertModeChanges[l++].changes;wt.macroModeState.lastInsertModeChanges.changes=d,lt(t,d,1),$e(t)}n.isPlaying=!1}function Qe(e,t){if(!e.isPlaying){var r=e.latestRegister,n=wt.registerController.getRegister(r);n&&n.pushText(t)}}function Je(e){if(!e.isPlaying){var t=e.latestRegister,r=wt.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}function Ze(e,t){if(!e.isPlaying){var r=e.latestRegister,n=wt.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}function et(e,t){var r=wt.macroModeState,n=r.lastInsertModeChanges;if(!r.isPlaying)for(;t;){if(n.expectCursorActivityForChange=!0,"+input"==t.origin||"paste"==t.origin||void 0===t.origin){var i=t.text.join("\n");n.maybeReset&&(n.changes=[],n.maybeReset=!1),n.changes.push(i)}t=t.next}}function tt(e){var t=e.state.vim;if(t.insertMode){var r=wt.macroModeState;if(r.isPlaying)return;var n=r.lastInsertModeChanges;n.expectCursorActivityForChange?n.expectCursorActivityForChange=!1:n.maybeReset=!0}else e.curOp.isVimOp||nt(e,t);t.visualMode&&rt(e)}function rt(e){var t=e.state.vim,r=R(e,j(t.sel.head)),n=z(r,0,1);t.fakeCursor&&t.fakeCursor.clear(),t.fakeCursor=e.markText(r,n,{className:"cm-animate-fat-cursor"})}function nt(t,r){var n=t.getCursor("anchor"),i=t.getCursor("head");if(r.visualMode&&!t.somethingSelected()?se(t,!1):r.visualMode||r.insertMode||!t.somethingSelected()||(r.visualMode=!0,r.visualLine=!1,e.signal(t,"vim-mode-change",{mode:"visual"})),r.visualMode){var o=U(i,n)?0:-1,a=U(i,n)?-1:0;i=z(i,0,o),n=z(n,0,a),r.sel={anchor:n,head:i},xe(t,r,"<",V(i,n)),xe(t,r,">",$(i,n))}else r.insertMode||(r.lastHPos=t.getCursor().ch)}function it(e){this.keyName=e}function ot(t){function r(){return i.maybeReset&&(i.changes=[],i.maybeReset=!1),i.changes.push(new it(o)),!0}var n=wt.macroModeState,i=n.lastInsertModeChanges,o=e.keyName(t);o&&(o.indexOf("Delete")==-1&&o.indexOf("Backspace")==-1||e.lookupKey(o,"vim-insert",r))}function at(e,t,r,n){function i(){l?St.processAction(e,t,t.lastEditActionCommand):St.evalInput(e,t)}function o(r){if(a.lastInsertModeChanges.changes.length>0){r=t.lastEditActionCommand?r:1;var n=a.lastInsertModeChanges;lt(e,n.changes,r)}}var a=wt.macroModeState;a.isPlaying=!0;var l=!!t.lastEditActionCommand,s=t.inputState;if(t.inputState=t.lastEditInputState,l&&t.lastEditActionCommand.interlaceInsertRepeat)for(var c=0;c<r;c++)i(),o(1);else n||i(),o(r);t.inputState=s,t.insertMode&&!n&&$e(e),a.isPlaying=!1}function lt(t,r,n){function i(r){return"string"==typeof r?e.commands[r](t):r(t),!0}var o=t.getCursor("head"),a=wt.macroModeState.lastInsertModeChanges.inVisualBlock;if(a){var l=t.state.vim,s=l.lastSelection,c=D(s.anchor,s.head);ee(t,o,c.line+1),n=t.listSelections().length,t.setCursor(o)}for(var u=0;u<n;u++){a&&t.setCursor(z(o,u,0));for(var f=0;f<r.length;f++){var d=r[f];if(d instanceof it)e.lookupKey(d.keyName,"vim-insert",i);else{var h=t.getCursor();t.replaceRange(d,h,h)}}}a&&t.setCursor(z(o,0,1))}e.defineOption("vimMode",!1,function(t,r,n){r&&"vim"!=t.getOption("keyMap")?t.setOption("keyMap","vim"):!r&&n!=e.Init&&/^vim/.test(t.getOption("keyMap"))&&t.setOption("keyMap","default")});var st={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},ct={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"},ut=/[\d]/,ft=[e.isWordChar,function(t){return t&&!e.isWordChar(t)&&!/\s/.test(t)}],dt=[function(e){return/\S/.test(e)}],ht=f(65,26),pt=f(97,26),mt=f(48,10),gt=[].concat(ht,pt,mt,["<",">"]),vt=[].concat(ht,pt,mt,["-",'"',".",":","/"]),yt={};b("filetype",void 0,"string",["ft"],function(e,t){if(void 0!==t){if(void 0===e){var r=t.getOption("mode");return"null"==r?"":r}var r=""==e?"null":e;t.setOption("mode",r)}});var bt=function(){function e(e,t,l){function s(t){var i=++n%r,o=a[i];o&&o.clear(),a[i]=e.setBookmark(t)}var c=n%r,u=a[c];if(u){var f=u.find();f&&!K(f,t)&&s(t)}else s(t);s(l),i=n,(o=n-r+1)<0&&(o=0)}function t(e,t){n+=t,n>i?n=i:n<o&&(n=o);var l=a[(r+n)%r];if(l&&!l.find()){var s,c=t>0?1:-1,u=e.getCursor();do{if(n+=c,(l=a[(r+n)%r])&&(s=l.find())&&!K(u,s))break}while(n<i&&n>o)}return l}var r=100,n=-1,i=0,o=0,a=new Array(r);return{cachedCursor:void 0,add:e,move:t}},xt=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};k.prototype={exitMacroRecordMode:function(){var e=wt.macroModeState;e.onRecordingDone&&e.onRecordingDone(),e.onRecordingDone=void 0,e.isRecording=!1},enterMacroRecordMode:function(e,t){var r=wt.registerController.getRegister(t);r&&(r.clear(),this.latestRegister=t,e.openDialog&&(this.onRecordingDone=e.openDialog("(recording)["+t+"]",null,{bottom:!0})),this.isRecording=!0)}};var wt,kt,Ct={buildKeyMap:function(){},getRegisterController:function(){return wt.registerController},resetVimGlobalState_:S,getVimGlobalState_:function(){return wt},maybeInitVimState_:C,suppressErrorLogging:!1,InsertModeKey:it,map:function(e,t,r){Rt.map(e,t,r)},unmap:function(e,t){Rt.unmap(e,t)},setOption:x,getOption:w,defineOption:b,defineEx:function(e,t,r){if(t){if(0!==e.indexOf(t))throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered')}else t=e;Pt[e]=r,Rt.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if("function"==typeof n)return n()},findKey:function(r,n,i){function o(){var e=wt.macroModeState;if(e.isRecording){if("q"==n)return e.exitMacroRecordMode(),M(r),!0;"mapping"!=i&&Qe(e,n)}}function a(){if("<Esc>"==n)return M(r),c.visualMode?se(r):c.insertMode&&$e(r),!0}function l(t){for(var i;t;)i=/<\w+-.+?>|<\w+>|./.exec(t),n=i[0],t=t.substring(i.index+n.length),e.Vim.handleKey(r,n,"mapping")}var s,c=C(r);return s=c.insertMode?function(){if(a())return!0;for(var e=c.inputState.keyBuffer=c.inputState.keyBuffer+n,i=1==n.length,o=St.matchCommand(e,t,c.inputState,"insert");e.length>1&&"full"!=o.type;){var e=c.inputState.keyBuffer=e.slice(1),l=St.matchCommand(e,t,c.inputState,"insert");"none"!=l.type&&(o=l)}if("none"==o.type)return M(r),!1;if("partial"==o.type)return kt&&window.clearTimeout(kt),kt=window.setTimeout(function(){c.insertMode&&c.inputState.keyBuffer&&M(r)},w("insertModeEscKeysTimeout")),!i;if(kt&&window.clearTimeout(kt),i){for(var s=r.listSelections(),u=0;u<s.length;u++){var f=s[u].head;r.replaceRange("",z(f,0,-(e.length-1)),f,"+input")}wt.macroModeState.lastInsertModeChanges.changes.pop()}return M(r),o.command}():function(){if(o()||a())return!0;var e=c.inputState.keyBuffer=c.inputState.keyBuffer+n;if(/^[1-9]\d*$/.test(e))return!0;var i=/^(\d*)(.*)$/.exec(e);if(!i)return M(r),!1;var l=c.visualMode?"visual":"normal",s=St.matchCommand(i[2]||i[1],t,c.inputState,l);if("none"==s.type)return M(r),!1;if("partial"==s.type)return!0;c.inputState.keyBuffer="";var i=/^(\d*)(.*)$/.exec(e);return i[1]&&"0"!=i[1]&&c.inputState.pushRepeatDigit(i[1]),s.command}(),s===!1?void 0:s===!0?function(){return!0}:function(){return r.operation(function(){r.curOp.isVimOp=!0;try{"keyToKey"==s.type?l(s.toKeys):St.processCommand(r,c,s)}catch(t){throw r.state.vim=void 0,C(r),e.Vim.suppressErrorLogging||console.log(t),t}return!0})}},handleEx:function(e,t){Rt.processCommand(e,t)},defineMotion:E,defineAction:P,defineOperator:N,mapCommand:Xe,_mapCommand:Ge,defineRegister:T,exitVisualMode:se,exitInsertMode:$e};_.prototype.pushRepeatDigit=function(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)},_.prototype.getRepeat=function(){var e=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(e=1,this.prefixRepeat.length>0&&(e*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(e*=parseInt(this.motionRepeat.join(""),10))),e},L.prototype={setText:function(e,t,r){this.keyBuffer=[e||""],this.linewise=!!t,this.blockwise=!!r},pushText:function(e,t){t&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(e)},pushInsertModeChanges:function(e){this.insertModeChanges.push(xt(e))},pushSearchQuery:function(e){this.searchQueries.push(e)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},A.prototype={pushText:function(e,t,r,n,i){n&&"\n"==r.charAt(0)&&(r=r.slice(1)+"\n"),n&&"\n"!==r.charAt(r.length-1)&&(r+="\n");var o=this.isValidRegister(e)?this.getRegister(e):null;if(!o){switch(t){case"yank":
|
12 |
this.registers[0]=new L(r,n,i);break;case"delete":case"change":r.indexOf("\n")==-1?this.registers["-"]=new L(r,n):(this.shiftNumericRegisters_(),this.registers[1]=new L(r,n))}return void this.unnamedRegister.setText(r,n,i)}g(e)?o.pushText(r,n):o.setText(r,n,i),this.unnamedRegister.setText(o.toString(),n)},getRegister:function(e){return this.isValidRegister(e)?(e=e.toLowerCase(),this.registers[e]||(this.registers[e]=new L),this.registers[e]):this.unnamedRegister},isValidRegister:function(e){return e&&y(e,vt)},shiftNumericRegisters_:function(){for(var e=9;e>=2;e--)this.registers[e]=this.getRegister(""+(e-1))}},O.prototype={nextMatch:function(e,t){var r=this.historyBuffer,n=t?-1:1;null===this.initialPrefix&&(this.initialPrefix=e);for(var i=this.iterator+n;t?i>=0:i<r.length;i+=n)for(var o=r[i],a=0;a<=o.length;a++)if(this.initialPrefix==o.substring(0,a))return this.iterator=i,o;return i>=r.length?(this.iterator=r.length,this.initialPrefix):i<0?e:void 0},pushInput:function(e){var t=this.historyBuffer.indexOf(e);t>-1&&this.historyBuffer.splice(t,1),e.length&&this.historyBuffer.push(e)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var St={matchCommand:function(e,t,r,n){var i=W(e,t,n,r);if(!i.full&&!i.partial)return{type:"none"};if(!i.full&&i.partial)return{type:"partial"};for(var o,a=0;a<i.full.length;a++){var l=i.full[a];o||(o=l)}return"<character>"==o.keys.slice(-11)&&(r.selectedCharacter=F(e)),{type:"full",command:o}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r)}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=B(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator){if(n.operator==r.operator)return n.motion="expandToLine",n.motionArgs={linewise:!0},void this.evalInput(e,t);M(e)}n.operator=r.operator,n.operatorArgs=B(r.operatorArgs),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,i=B(r.operatorMotionArgs);i&&n&&i.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,i=n.getRepeat(),o=!!i,a=B(r.actionArgs)||{};n.selectedCharacter&&(a.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),a.repeat=i||1,a.repeatIsExplicit=o,a.registerName=n.registerName,M(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),Lt[r.action](e,a,t)},processSearch:function(t,r,n){function i(e,i,o){wt.searchHistoryController.pushInput(e),wt.searchHistoryController.reset();try{De(t,e,i,o)}catch(r){return Pe(t,"Invalid regex: "+e),void M(t)}St.processMotion(t,r,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:n.searchArgs.toJumplist}})}function o(e){t.scrollTo(d.left,d.top),i(e,!0,!0);var r=wt.macroModeState;r.isRecording&&Ze(r,e)}function a(r,n,i){var o,a,l=e.keyName(r);"Up"==l||"Down"==l?(o="Up"==l,a=r.target?r.target.selectionEnd:0,n=wt.searchHistoryController.nextMatch(n,o)||"",i(n),a&&r.target&&(r.target.selectionEnd=r.target.selectionStart=Math.min(a,r.target.value.length))):"Left"!=l&&"Right"!=l&&"Ctrl"!=l&&"Alt"!=l&&"Shift"!=l&&wt.searchHistoryController.reset();var c;try{c=De(t,n,!0,!0)}catch(e){}c?t.scrollIntoView(Fe(t,!s,c),30):(He(t),t.scrollTo(d.left,d.top))}function l(r,n,i){var o=e.keyName(r);"Esc"==o||"Ctrl-C"==o||"Ctrl-["==o||"Backspace"==o&&""==n?(wt.searchHistoryController.pushInput(n),wt.searchHistoryController.reset(),De(t,f),He(t),t.scrollTo(d.left,d.top),e.e_stop(r),M(t),i(),t.focus()):"Up"==o||"Down"==o?e.e_stop(r):"Ctrl-U"==o&&(e.e_stop(r),i(""))}if(t.getSearchCursor){var s=n.searchArgs.forward,c=n.searchArgs.wholeWordOnly;Me(t).setReversed(!s);var u=s?"/":"?",f=Me(t).getQuery(),d=t.getScrollInfo();switch(n.searchArgs.querySrc){case"prompt":var h=wt.macroModeState;if(h.isPlaying){var p=h.replaySearchQueries.shift();i(p,!0,!1)}else Be(t,{onClose:o,prefix:u,desc:It,onKeyUp:a,onKeyDown:l});break;case"wordUnderCursor":var m=de(t,!1,!0,!1,!0),g=!0;if(m||(m=de(t,!1,!0,!1,!1),g=!1),!m)return;var p=t.getLine(m.start.line).substring(m.start.ch,m.end.ch);p=g&&c?"\\b"+p+"\\b":Q(p),wt.jumpList.cachedCursor=t.getCursor(),t.setCursor(m.start),i(p,!0,!1)}}},processEx:function(t,r,n){function i(e){wt.exCommandHistoryController.pushInput(e),wt.exCommandHistoryController.reset(),Rt.processCommand(t,e)}function o(r,n,i){var o,a,l=e.keyName(r);("Esc"==l||"Ctrl-C"==l||"Ctrl-["==l||"Backspace"==l&&""==n)&&(wt.exCommandHistoryController.pushInput(n),wt.exCommandHistoryController.reset(),e.e_stop(r),M(t),i(),t.focus()),"Up"==l||"Down"==l?(e.e_stop(r),o="Up"==l,a=r.target?r.target.selectionEnd:0,n=wt.exCommandHistoryController.nextMatch(n,o)||"",i(n),a&&r.target&&(r.target.selectionEnd=r.target.selectionStart=Math.min(a,r.target.value.length))):"Ctrl-U"==l?(e.e_stop(r),i("")):"Left"!=l&&"Right"!=l&&"Ctrl"!=l&&"Alt"!=l&&"Shift"!=l&&wt.exCommandHistoryController.reset()}"keyToEx"==n.type?Rt.processCommand(t,n.exArgs.input):r.visualMode?Be(t,{onClose:i,prefix:":",value:"'<,'>",onKeyDown:o}):Be(t,{onClose:i,prefix:":",onKeyDown:o})},evalInput:function(e,t){var r,i,o,a=t.inputState,l=a.motion,s=a.motionArgs||{},c=a.operator,u=a.operatorArgs||{},f=a.registerName,d=t.sel,h=j(t.visualMode?R(e,d.head):e.getCursor("head")),p=j(t.visualMode?R(e,d.anchor):e.getCursor("anchor")),m=j(h),g=j(p);if(c&&this.recordLastEdit(t,a),o=void 0!==a.repeatOverride?a.repeatOverride:a.getRepeat(),o>0&&s.explicitRepeat?s.repeatIsExplicit=!0:(s.noRepeat||!s.explicitRepeat&&0===o)&&(o=1,s.repeatIsExplicit=!1),a.selectedCharacter&&(s.selectedCharacter=u.selectedCharacter=a.selectedCharacter),s.repeat=o,M(e),l){var v=_t[l](e,h,s,t);if(t.lastMotion=_t[l],!v)return;if(s.toJumplist){var y=wt.jumpList,b=y.cachedCursor;b?(he(e,b,v),delete y.cachedCursor):he(e,h,v)}v instanceof Array?(i=v[0],r=v[1]):r=v,r||(r=j(h)),t.visualMode?(t.visualBlock&&r.ch===1/0||(r=R(e,r,t.visualBlock)),i&&(i=R(e,i,!0)),i=i||g,d.anchor=i,d.head=r,oe(e),xe(e,t,"<",U(i,r)?i:r),xe(e,t,">",U(i,r)?r:i)):c||(r=R(e,r),e.setCursor(r.line,r.ch))}if(c){if(u.lastSel){i=g;var x=u.lastSel,w=Math.abs(x.head.line-x.anchor.line),k=Math.abs(x.head.ch-x.anchor.ch);r=x.visualLine?n(g.line+w,g.ch):x.visualBlock?n(g.line+w,g.ch+k):x.head.line==x.anchor.line?n(g.line,g.ch+k):n(g.line+w,g.ch),t.visualMode=!0,t.visualLine=x.visualLine,t.visualBlock=x.visualBlock,d=t.sel={anchor:i,head:r},oe(e)}else t.visualMode&&(u.lastSel={anchor:j(d.anchor),head:j(d.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var C,S,_,L,T;if(t.visualMode){if(C=V(d.head,d.anchor),S=$(d.head,d.anchor),_=t.visualLine||u.linewise,L=t.visualBlock?"block":_?"line":"char",T=ae(e,{anchor:C,head:S},L),_){var A=T.ranges;if("block"==L)for(var O=0;O<A.length;O++)A[O].head.ch=X(e,A[O].head.line);else"line"==L&&(A[0].head=n(A[0].head.line+1,0))}}else{if(C=j(i||g),S=j(r||m),U(S,C)){var E=C;C=S,S=E}_=s.linewise||u.linewise,_?ue(e,C,S):s.forward&&ce(e,C,S),L="char";T=ae(e,{anchor:C,head:S},L,!s.inclusive||_)}e.setSelections(T.ranges,T.primary),t.lastMotion=null,u.repeat=o,u.registerName=f,u.linewise=_;var I=Mt[c](e,u,T.ranges,g,r);t.visualMode&&se(e,null!=I),I&&e.setCursor(I)}},recordLastEdit:function(e,t,r){var n=wt.macroModeState;n.isPlaying||(e.lastEditInputState=t,e.lastEditActionCommand=r,n.lastInsertModeChanges.changes=[],n.lastInsertModeChanges.expectCursorActivityForChange=!1)}},_t={moveToTopLine:function(e,t,r){var i=Ke(e).top+r.repeat-1;return n(i,fe(e.getLine(i)))},moveToMiddleLine:function(e){var t=Ke(e),r=Math.floor(.5*(t.top+t.bottom));return n(r,fe(e.getLine(r)))},moveToBottomLine:function(e,t,r){var i=Ke(e).bottom-r.repeat+1;return n(i,fe(e.getLine(i)))},expandToLine:function(e,t,r){return n(t.line+r.repeat-1,1/0)},findNext:function(e,t,r){var n=Me(e),i=n.getQuery();if(i){var o=!r.forward;return o=n.isReversed()?!o:o,qe(e,i),Fe(e,o,i,r.repeat)}},goToMark:function(e,t,r,n){var i=Ue(e,n,r.selectedCharacter);return i?r.linewise?{line:i.line,ch:fe(e.getLine(i.line))}:i:null},moveToOtherHighlightedEnd:function(e,t,r,i){if(i.visualBlock&&r.sameLine){var o=i.sel;return[R(e,n(o.anchor.line,o.head.ch)),R(e,n(o.head.line,o.anchor.ch))]}return[i.sel.head,i.sel.anchor]},jumpToMark:function(e,t,r,i){for(var o=t,a=0;a<r.repeat;a++){var l=o;for(var s in i.marks)if(h(s)){var c=i.marks[s].find(),u=r.forward?U(c,l):U(l,c);if(!(u||r.linewise&&c.line==l.line)){var f=K(l,o),d=r.forward?G(l,c,o):G(o,c,l);(f||d)&&(o=c)}}}return r.linewise&&(o=n(o.line,fe(e.getLine(o.line)))),o},moveByCharacters:function(e,t,r){var i=t,o=r.repeat,a=r.forward?i.ch+o:i.ch-o;return n(i.line,a)},moveByLines:function(e,t,r,i){var o=t,a=o.ch;switch(i.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:a=i.lastHPos;break;default:i.lastHPos=a}var l=r.repeat+(r.repeatOffset||0),s=r.forward?o.line+l:o.line-l,c=e.firstLine(),u=e.lastLine();return s<c&&o.line==c?this.moveToStartOfLine(e,t,r,i):s>u&&o.line==u?this.moveToEol(e,t,r,i):(r.toFirstChar&&(a=fe(e.getLine(s)),i.lastHPos=a),i.lastHSPos=e.charCoords(n(s,a),"div").left,n(s,a))},moveByDisplayLines:function(e,t,r,i){var o=t;switch(i.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:i.lastHSPos=e.charCoords(o,"div").left}var a=r.repeat,l=e.findPosV(o,r.forward?a:-a,"line",i.lastHSPos);if(l.hitSide)if(r.forward)var s=e.charCoords(l,"div"),c={top:s.top+8,left:i.lastHSPos},l=e.coordsChar(c,"div");else{var u=e.charCoords(n(e.firstLine(),0),"div");u.left=i.lastHSPos,l=e.coordsChar(u,"div")}return i.lastHPos=l.ch,l},moveByPage:function(e,t,r){var n=t,i=r.repeat;return e.findPosV(n,r.forward?i:-i,"page")},moveByParagraph:function(e,t,r){var n=r.forward?1:-1;return ke(e,t,r.repeat,n)},moveByScroll:function(e,t,r,n){var i=e.getScrollInfo(),o=null,a=r.repeat;a||(a=i.clientHeight/(2*e.defaultTextHeight()));var l=e.charCoords(t,"local");r.repeat=a;var o=_t.moveByDisplayLines(e,t,r,n);if(!o)return null;var s=e.charCoords(o,"local");return e.scrollTo(null,i.top+s.top-l.top),o},moveByWords:function(e,t,r){return ve(e,t,r.repeat,!!r.forward,!!r.wordEnd,!!r.bigWord)},moveTillCharacter:function(e,t,r){var n=r.repeat,i=ye(e,n,r.forward,r.selectedCharacter),o=r.forward?-1:1;return pe(o,r),i?(i.ch+=o,i):null},moveToCharacter:function(e,t,r){var n=r.repeat;return pe(0,r),ye(e,n,r.forward,r.selectedCharacter)||t},moveToSymbol:function(e,t,r){return me(e,r.repeat,r.forward,r.selectedCharacter)||t},moveToColumn:function(e,t,r,n){var i=r.repeat;return n.lastHPos=i-1,n.lastHSPos=e.charCoords(t,"div").left,be(e,i)},moveToEol:function(e,t,r,i){var o=t;i.lastHPos=1/0;var a=n(o.line+r.repeat-1,1/0),l=e.clipPos(a);return l.ch--,i.lastHSPos=e.charCoords(l,"div").left,a},moveToFirstNonWhiteSpaceCharacter:function(e,t){var r=t;return n(r.line,fe(e.getLine(r.line)))},moveToMatchedSymbol:function(e,t){var r,i=t,o=i.line,a=i.ch,l=e.getLine(o);do{if((r=l.charAt(a++))&&p(r)){var s=e.getTokenTypeAt(n(o,a));if("string"!==s&&"comment"!==s)break}}while(r);if(r){return e.findMatchingBracket(n(o,a)).to}return i},moveToStartOfLine:function(e,t){return n(t.line,0)},moveToLineOrEdgeOfDocument:function(e,t,r){var i=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(i=r.repeat-e.getOption("firstLineNumber")),n(i,fe(e.getLine(i)))},textObjectManipulation:function(e,t,r,n){var i={"(":")",")":"(","{":"}","}":"{","[":"]","]":"["},o={"'":!0,'"':!0},a=r.selectedCharacter;"b"==a?a="(":"B"==a&&(a="{");var l,s=!r.textObjectInner;if(i[a])l=Ce(e,t,a,s);else if(o[a])l=Se(e,t,a,s);else if("W"===a)l=de(e,s,!0,!0);else if("w"===a)l=de(e,s,!0,!1);else{if("p"!==a)return null;if(l=ke(e,t,r.repeat,0,s),r.linewise=!0,n.visualMode)n.visualLine||(n.visualLine=!0);else{var c=n.inputState.operatorArgs;c&&(c.linewise=!0),l.end.line--}}return e.state.vim.visualMode?ie(e,l.start,l.end):[l.start,l.end]},repeatLastCharacterSearch:function(e,t,r){var n=wt.lastCharacterSearch,i=r.repeat,o=r.forward===n.forward,a=(n.increment?1:0)*(o?-1:1);e.moveH(-a,"char"),r.inclusive=!!o;var l=ye(e,i,o,n.selectedCharacter);return l?(l.ch+=a,l):(e.moveH(a,"char"),t)}},Mt={change:function(t,r,i){var o,a,l=t.state.vim;if(wt.macroModeState.lastInsertModeChanges.inVisualBlock=l.visualBlock,l.visualMode){a=t.getSelection();var s=I("",i.length);t.replaceSelections(s),o=V(i[0].head,i[0].anchor)}else{var c=i[0].anchor,u=i[0].head;a=t.getRange(c,u);var f=l.lastEditInputState||{};if("moveByWords"==f.motion&&!v(a)){var d=/\s+$/.exec(a);d&&f.motionArgs&&f.motionArgs.forward&&(u=z(u,0,-d[0].length),a=a.slice(0,-d[0].length))}var h=new n(c.line-1,Number.MAX_VALUE),p=t.firstLine()==t.lastLine();u.line>t.lastLine()&&r.linewise&&!p?t.replaceRange("",h,u):t.replaceRange("",c,u),r.linewise&&(p||(t.setCursor(h),e.commands.newlineAndIndent(t)),c.ch=Number.MAX_VALUE),o=c}wt.registerController.pushText(r.registerName,"change",a,r.linewise,i.length>1),Lt.enterInsertMode(t,{head:o},t.state.vim)},delete:function(e,t,r){var i,o,a=e.state.vim;if(a.visualBlock){o=e.getSelection();var l=I("",r.length);e.replaceSelections(l),i=r[0].anchor}else{var s=r[0].anchor,c=r[0].head;t.linewise&&c.line!=e.firstLine()&&s.line==e.lastLine()&&s.line==c.line-1&&(s.line==e.firstLine()?s.ch=0:s=n(s.line-1,X(e,s.line-1))),o=e.getRange(s,c),e.replaceRange("",s,c),i=s,t.linewise&&(i=_t.moveToFirstNonWhiteSpaceCharacter(e,s))}return wt.registerController.pushText(t.registerName,"delete",o,t.linewise,a.visualBlock),R(e,i)},indent:function(e,t,r){var n=e.state.vim,i=r[0].anchor.line,o=n.visualBlock?r[r.length-1].anchor.line:r[0].head.line,a=n.visualMode?t.repeat:1;t.linewise&&o--;for(var l=i;l<=o;l++)for(var s=0;s<a;s++)e.indentLine(l,t.indentRight);return _t.moveToFirstNonWhiteSpaceCharacter(e,r[0].anchor)},changeCase:function(e,t,r,n,i){for(var o=e.getSelections(),a=[],l=t.toLower,s=0;s<o.length;s++){var c=o[s],u="";if(l===!0)u=c.toLowerCase();else if(l===!1)u=c.toUpperCase();else for(var f=0;f<c.length;f++){var d=c.charAt(f);u+=g(d)?d.toLowerCase():d.toUpperCase()}a.push(u)}return e.replaceSelections(a),t.shouldMoveCursor?i:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?_t.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:V(r[0].anchor,r[0].head)},yank:function(e,t,r,n){var i=e.state.vim,o=e.getSelection(),a=i.visualMode?V(i.sel.anchor,i.sel.head,r[0].head,r[0].anchor):n;return wt.registerController.pushText(t.registerName,"yank",o,t.linewise,i.visualBlock),a}},Lt={jumpListWalk:function(e,t,r){if(!r.visualMode){var n=t.repeat,i=t.forward,o=wt.jumpList,a=o.move(e,i?n:-n),l=a?a.find():void 0;l=l?l:e.getCursor(),e.setCursor(l)}},scroll:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,i=e.defaultTextHeight(),o=e.getScrollInfo().top,a=i*n,l=t.forward?o+a:o-a,s=j(e.getCursor()),c=e.charCoords(s,"local");if(t.forward)l>c.top?(s.line+=(l-c.top)/i,s.line=Math.ceil(s.line),e.setCursor(s),c=e.charCoords(s,"local"),e.scrollTo(null,c.top)):e.scrollTo(null,l);else{var u=l+e.getScrollInfo().clientHeight;u<c.bottom?(s.line-=(c.bottom-u)/i,s.line=Math.floor(s.line),e.setCursor(s),c=e.charCoords(s,"local"),e.scrollTo(null,c.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,l)}}},scrollToCursor:function(e,t){var r=e.getCursor().line,i=e.charCoords(n(r,0),"local"),o=e.getScrollInfo().clientHeight,a=i.top,l=i.bottom-a;switch(t.position){case"center":a=a-o/2+l;break;case"bottom":a=a-o+l}e.scrollTo(null,a)},replayMacro:function(e,t,r){var n=t.selectedCharacter,i=t.repeat,o=wt.macroModeState;for("@"==n&&(n=o.latestRegister);i--;)Ye(e,r,o,n)},enterMacroRecordMode:function(e,t){var r=wt.macroModeState,n=t.selectedCharacter;r.enterMacroRecordMode(e,n)},toggleOverwrite:function(t){t.state.overwrite?(t.toggleOverwrite(!1),t.setOption("keyMap","vim-insert"),e.signal(t,"vim-mode-change",{mode:"insert"})):(t.toggleOverwrite(!0),t.setOption("keyMap","vim-replace"),e.signal(t,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(t,r,i){if(!t.getOption("readOnly")){i.insertMode=!0,i.insertModeRepeat=r&&r.repeat||1;var o=r?r.insertAt:null,a=i.sel,l=r.head||t.getCursor("head"),s=t.listSelections().length;if("eol"==o)l=n(l.line,X(t,l.line));else if("charAfter"==o)l=z(l,0,1);else if("firstNonBlank"==o)l=_t.moveToFirstNonWhiteSpaceCharacter(t,l);else if("startOfSelectedArea"==o)i.visualBlock?(l=n(Math.min(a.head.line,a.anchor.line),Math.min(a.head.ch,a.anchor.ch)),s=Math.abs(a.head.line-a.anchor.line)+1):l=a.head.line<a.anchor.line?a.head:n(a.anchor.line,0);else if("endOfSelectedArea"==o)i.visualBlock?(l=n(Math.min(a.head.line,a.anchor.line),Math.max(a.head.ch+1,a.anchor.ch)),s=Math.abs(a.head.line-a.anchor.line)+1):l=a.head.line>=a.anchor.line?z(a.head,0,1):n(a.anchor.line,0);else if("inplace"==o&&i.visualMode)return;t.setOption("disableInput",!1),r&&r.replace?(t.toggleOverwrite(!0),t.setOption("keyMap","vim-replace"),e.signal(t,"vim-mode-change",{mode:"replace"})):(t.toggleOverwrite(!1),t.setOption("keyMap","vim-insert"),e.signal(t,"vim-mode-change",{mode:"insert"})),wt.macroModeState.isPlaying||(t.on("change",et),e.on(t.getInputField(),"keydown",ot)),i.visualMode&&se(t),ee(t,l,s)}},toggleVisualMode:function(t,r,i){var o,a=r.repeat,l=t.getCursor();i.visualMode?i.visualLine^r.linewise||i.visualBlock^r.blockwise?(i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,e.signal(t,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),oe(t)):se(t):(i.visualMode=!0,i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,o=R(t,n(l.line,l.ch+a-1),!0),i.sel={anchor:l,head:o},e.signal(t,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),oe(t),xe(t,i,"<",V(l,o)),xe(t,i,">",$(l,o)))},reselectLastSelection:function(t,r,n){var i=n.lastSelection;if(n.visualMode&&ne(t,n),i){var o=i.anchorMark.find(),a=i.headMark.find();if(!o||!a)return;n.sel={anchor:o,head:a},n.visualMode=!0,n.visualLine=i.visualLine,n.visualBlock=i.visualBlock,oe(t),xe(t,n,"<",V(o,a)),xe(t,n,">",$(o,a)),e.signal(t,"vim-mode-change",{mode:"visual",subMode:n.visualLine?"linewise":n.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var i,o;if(r.visualMode){if(i=e.getCursor("anchor"),o=e.getCursor("head"),U(o,i)){var a=o;o=i,i=a}o.ch=X(e,o.line)-1}else{var l=Math.max(t.repeat,2);i=e.getCursor(),o=R(e,n(i.line+l-1,1/0))}for(var s=0,c=i.line;c<o.line;c++){s=X(e,i.line);var a=n(i.line+1,X(e,i.line+1)),u=e.getRange(i,a);u=u.replace(/\n\s*/g," "),e.replaceRange(u,i,a)}var f=n(i.line,s);r.visualMode&&se(e,!1),e.setCursor(f)},newLineAndEnterInsertMode:function(t,r,i){i.insertMode=!0;var o=j(t.getCursor());if(o.line!==t.firstLine()||r.after){o.line=r.after?o.line:o.line-1,o.ch=X(t,o.line),t.setCursor(o);(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(t)}else t.replaceRange("\n",n(t.firstLine(),0)),t.setCursor(t.firstLine(),0);this.enterInsertMode(t,{repeat:r.repeat},i)},paste:function(e,t,r){var i=j(e.getCursor()),o=wt.registerController.getRegister(t.registerName),a=o.toString();if(a){if(t.matchIndent){var l=e.getOption("tabSize"),s=function(e){var t=e.split("\t").length-1,r=e.split(" ").length-1;return t*l+1*r},c=e.getLine(e.getCursor().line),u=s(c.match(/^\s*/)[0]),f=a.replace(/\n$/,""),d=a!==f,h=s(a.match(/^\s*/)[0]),a=f.replace(/^\s*/gm,function(t){var r=u+(s(t)-h);if(r<0)return"";if(e.getOption("indentWithTabs")){var n=Math.floor(r/l);return Array(n+1).join("\t")}return Array(r+1).join(" ")});a+=d?"\n":""}if(t.repeat>1)var a=Array(t.repeat+1).join(a);var p=o.linewise,m=o.blockwise;if(p)r.visualMode?a=r.visualLine?a.slice(0,-1):"\n"+a.slice(0,a.length-1)+"\n":t.after?(a="\n"+a.slice(0,a.length-1),i.ch=X(e,i.line)):i.ch=0;else{if(m){a=a.split("\n");for(var g=0;g<a.length;g++)a[g]=""==a[g]?" ":a[g]}i.ch+=t.after?1:0}var v,y;if(r.visualMode){r.lastPastedText=a;var b,x=re(e,r),w=x[0],k=x[1],C=e.getSelection(),S=e.listSelections(),_=new Array(S.length).join("1").split("1");r.lastSelection&&(b=r.lastSelection.headMark.find()),wt.registerController.unnamedRegister.setText(C),m?(e.replaceSelections(_),k=n(w.line+a.length-1,w.ch),e.setCursor(w),Z(e,k),e.replaceSelections(a),v=w):r.visualBlock?(e.replaceSelections(_),e.setCursor(w),e.replaceRange(a,w,w),v=w):(e.replaceRange(a,w,k),v=e.posFromIndex(e.indexFromPos(w)+a.length-1)),b&&(r.lastSelection.headMark=e.setBookmark(b)),p&&(v.ch=0)}else if(m){e.setCursor(i);for(var g=0;g<a.length;g++){var M=i.line+g;M>e.lastLine()&&e.replaceRange("\n",n(M,0));var L=X(e,M);L<i.ch&&J(e,M,i.ch)}e.setCursor(i),Z(e,n(i.line+a.length-1,i.ch)),e.replaceSelections(a),v=i}else e.replaceRange(a,i),p&&t.after?v=n(i.line+1,fe(e.getLine(i.line+1))):p&&!t.after?v=n(i.line,fe(e.getLine(i.line))):!p&&t.after?(y=e.indexFromPos(i),v=e.posFromIndex(y+a.length-1)):(y=e.indexFromPos(i),v=e.posFromIndex(y+a.length));r.visualMode&&se(e,!1),e.setCursor(v)}},undo:function(t,r){t.operation(function(){H(t,e.commands.undo,r.repeat)(),t.setCursor(t.getCursor("anchor"))})},redo:function(t,r){H(t,e.commands.redo,r.repeat)()},setRegister:function(e,t,r){r.inputState.registerName=t.selectedCharacter},setMark:function(e,t,r){xe(e,r,t.selectedCharacter,e.getCursor())},replace:function(t,r,i){var o,a,l=r.selectedCharacter,s=t.getCursor(),c=t.listSelections();if(i.visualMode)s=t.getCursor("start"),a=t.getCursor("end");else{var u=t.getLine(s.line);o=s.ch+r.repeat,o>u.length&&(o=u.length),a=n(s.line,o)}if("\n"==l)i.visualMode||t.replaceRange("",s,a),(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(t);else{var f=t.getRange(s,a);if(f=f.replace(/[^\n]/g,l),i.visualBlock){var d=new Array(t.getOption("tabSize")+1).join(" ");f=t.getSelection(),f=f.replace(/\t/g,d).replace(/[^\n]/g,l).split("\n"),t.replaceSelections(f)}else t.replaceRange(f,s,a);i.visualMode?(s=U(c[0].anchor,c[0].head)?c[0].anchor:c[0].head,t.setCursor(s),se(t,!1)):t.setCursor(z(a,0,-1))}},incrementNumberToken:function(e,t){for(var r,i,o,a,l,s=e.getCursor(),c=e.getLine(s.line),u=/-?\d+/g;null!==(r=u.exec(c))&&(l=r[0],i=r.index,o=i+l.length,!(s.ch<o)););if((t.backtrack||!(o<=s.ch))&&l){var f=t.increase?1:-1,d=parseInt(l)+f*t.repeat,h=n(s.line,i),p=n(s.line,o);a=d.toString(),e.replaceRange(a,h,p),e.setCursor(n(s.line,i+a.length-1))}},repeatLastEdit:function(e,t,r){if(r.lastEditInputState){var n=t.repeat;n&&t.repeatIsExplicit?r.lastEditInputState.repeatOverride=n:n=r.lastEditInputState.repeatOverride||n,at(e,r,n,!1)}},indent:function(e,t){e.indentLine(e.getCursor().line,t.indentRight)},exitInsertMode:$e},Tt={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},At={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(++e.depth>=1)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?"]":"[")===e.symb?"{":"}"},isComplete:function(e){return 0===e.index&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t="*"===e.lastCh&&"/"===e.nextCh;return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb="m"===e.symb?"{":"}",e.reverseSymb="{"===e.symb?"}":"{"},isComplete:function(e){return e.nextCh===e.symb}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if("#"===e.nextCh){var t=e.lineText.match(/#(\w+)/)[1];if("endif"===t){if(e.forward&&0===e.depth)return!0;e.depth++}else if("if"===t){if(!e.forward&&0===e.depth)return!0;e.depth--}if("else"===t&&0===e.depth)return!0}return!1}}};b("pcre",!0,"boolean"),_e.prototype={getQuery:function(){return wt.query},setQuery:function(e){wt.query=e},getOverlay:function(){return this.searchOverlay},setOverlay:function(e){this.searchOverlay=e},isReversed:function(){return wt.isReversed},setReversed:function(e){wt.isReversed=e},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(e){this.annotate=e}};var Ot={"\\n":"\n","\\r":"\r","\\t":"\t"},Et={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":"\t"},It="(Javascript regexp)",Nt=function(){this.buildCommandMap_()};Nt.prototype={processCommand:function(e,t,r){var n=this;e.operation(function(){e.curOp.isVimOp=!0,n._processCommand(e,t,r)})},_processCommand:function(t,r,n){var i=t.state.vim,o=wt.registerController.getRegister(":"),a=o.toString();i.visualMode&&se(t);var l=new e.StringStream(r);o.setText(r);var s=n||{};s.input=r;try{this.parseInput_(t,l,s)}catch(e){throw Pe(t,e),e}var c,u;if(s.commandName){if(c=this.matchCommand_(s.commandName)){if(u=c.name,c.excludeFromCommandHistory&&o.setText(a),this.parseCommandArgs_(l,s,c),"exToKey"==c.type){for(var f=0;f<c.toKeys.length;f++)e.Vim.handleKey(t,c.toKeys[f],"mapping");return}if("exToEx"==c.type)return void this.processCommand(t,c.toInput)}}else void 0!==s.line&&(u="move");if(!u)return void Pe(t,'Not an editor command ":'+r+'"');try{Pt[u](t,s),c&&c.possiblyAsync||!s.callback||s.callback()}catch(e){throw Pe(t,e),e}},parseInput_:function(e,t,r){t.eatWhile(":"),t.eat("%")?(r.line=e.firstLine(),r.lineEnd=e.lastLine()):(r.line=this.parseLineSpec_(e,t),void 0!==r.line&&t.eat(",")&&(r.lineEnd=this.parseLineSpec_(e,t)));var n=t.match(/^(\w+)/);return r.commandName=n?n[1]:t.match(/.*/)[0],r},parseLineSpec_:function(e,t){var r=t.match(/^(\d+)/);if(r)return parseInt(r[1],10)-1;switch(t.next()){case".":return e.getCursor().line;case"$":return e.lastLine();case"'":var n=t.next(),i=Ue(e,e.state.vim,n);if(!i)throw new Error("Mark not set");return i.line;default:return void t.backUp(1)}},parseCommandArgs_:function(e,t,r){if(!e.eol()){t.argString=e.match(/.*/)[0];var n=r.argDelimiter||/\s+/,i=Y(t.argString).split(n);i.length&&i[0]&&(t.args=i)}},matchCommand_:function(e){for(var t=e.length;t>0;t--){var r=e.substring(0,t);if(this.commandMap_[r]){var n=this.commandMap_[r];if(0===n.name.indexOf(e))return n}}return null},buildCommandMap_:function(){this.commandMap_={};for(var e=0;e<r.length;e++){var t=r[e],n=t.shortName||t.name;this.commandMap_[n]=t}},map:function(e,r,n){if(":"!=e&&":"==e.charAt(0)){if(n)throw Error("Mode not supported for ex mappings");var i=e.substring(1);":"!=r&&":"==r.charAt(0)?this.commandMap_[i]={name:i,type:"exToEx",toInput:r.substring(1),user:!0}:this.commandMap_[i]={name:i,type:"exToKey",toKeys:r,user:!0}}else if(":"!=r&&":"==r.charAt(0)){var o={keys:e,type:"keyToEx",exArgs:{input:r.substring(1)}};n&&(o.context=n),t.unshift(o)}else{var o={keys:e,type:"keyToKey",toKeys:r};n&&(o.context=n),t.unshift(o)}},unmap:function(e,r){if(":"!=e&&":"==e.charAt(0)){if(r)throw Error("Mode not supported for ex mappings");var n=e.substring(1);if(this.commandMap_[n]&&this.commandMap_[n].user)return void delete this.commandMap_[n]}else for(var i=e,o=0;o<t.length;o++)if(i==t[o].keys&&t[o].context===r)return void t.splice(o,1);throw Error("No such mapping.")}};var Pt={colorscheme:function(e,t){if(!t.args||t.args.length<1)return void Pe(e,e.getOption("theme"));e.setOption("theme",t.args[0])},map:function(e,t,r){var n=t.args;if(!n||n.length<2)return void(e&&Pe(e,"Invalid mapping: "+t.input));Rt.map(n[0],n[1],r)},imap:function(e,t){this.map(e,t,"insert")},nmap:function(e,t){this.map(e,t,"normal")},vmap:function(e,t){this.map(e,t,"visual")},unmap:function(e,t,r){var n=t.args;if(!n||n.length<1)return void(e&&Pe(e,"No such mapping: "+t.input));Rt.unmap(n[0],r)},move:function(e,t){St.processCommand(e,e.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:t.line+1})},set:function(e,t){var r=t.args,n=t.setCfg||{};if(!r||r.length<1)return void(e&&Pe(e,"Invalid mapping: "+t.input));var i=r[0].split("="),o=i[0],a=i[1],l=!1;if("?"==o.charAt(o.length-1)){if(a)throw Error("Trailing characters: "+t.argString);o=o.substring(0,o.length-1),l=!0}void 0===a&&"no"==o.substring(0,2)&&(o=o.substring(2),a=!1);var s=yt[o]&&"boolean"==yt[o].type;if(s&&void 0==a&&(a=!0),!s&&void 0===a||l){var c=w(o,e,n);c===!0||c===!1?Pe(e," "+(c?"":"no")+o):Pe(e," "+o+"="+c)}else x(o,a,e,n)},setlocal:function(e,t){t.setCfg={scope:"local"},this.set(e,t)},setglobal:function(e,t){t.setCfg={scope:"global"},this.set(e,t)},registers:function(e,t){var r=t.args,n=wt.registerController.registers,i="----------Registers----------<br><br>";if(r){var o;r=r.join("");for(var a=0;a<r.length;a++)if(o=r.charAt(a),wt.registerController.isValidRegister(o)){var l=n[o]||new L;i+='"'+o+" "+l.toString()+"<br>"}}else for(var o in n){var s=n[o].toString();s.length&&(i+='"'+o+" "+s+"<br>")}Pe(e,i)},sort:function(t,r){function i(e,t){if(a){var r;r=e,e=t,t=r}l&&(e=e.toLowerCase(),t=t.toLowerCase());var n=c&&v.exec(e),i=c&&v.exec(t);return n?(n=parseInt((n[1]+n[2]).toLowerCase(),y),i=parseInt((i[1]+i[2]).toLowerCase(),y),n-i):e<t?-1:1}function o(e,t){if(a){var r;r=e,e=t,t=r}return l&&(e[0]=e[0].toLowerCase(),t[0]=t[0].toLowerCase()),e[0]<t[0]?-1:1}var a,l,s,c,u,f=function(){if(r.argString){var t=new e.StringStream(r.argString);if(t.eat("!")&&(a=!0),t.eol())return;if(!t.eatSpace())return"Invalid arguments";var n=t.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!n&&!t.eol())return"Invalid arguments";if(n[1]){l=n[1].indexOf("i")!=-1,s=n[1].indexOf("u")!=-1;var i=n[1].indexOf("d")!=-1||n[1].indexOf("n")!=-1&&1,o=n[1].indexOf("x")!=-1&&1,f=n[1].indexOf("o")!=-1&&1;if(i+o+f>1)return"Invalid arguments";c=i&&"decimal"||o&&"hex"||f&&"octal"}n[2]&&(u=new RegExp(n[2].substr(1,n[2].length-2),l?"i":""))}}();if(f)return void Pe(t,f+": "+r.argString);var d=r.line||t.firstLine(),h=r.lineEnd||r.line||t.lastLine();if(d!=h){var p=n(d,0),m=n(h,X(t,h)),g=t.getRange(p,m).split("\n"),v=u?u:"decimal"==c?/(-?)([\d]+)/:"hex"==c?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==c?/([0-7]+)/:null,y="decimal"==c?10:"hex"==c?16:"octal"==c?8:null,b=[],x=[];if(c||u)for(var w=0;w<g.length;w++){var k=u?g[w].match(u):null;k&&""!=k[0]?b.push(k):!u&&v.exec(g[w])?b.push(g[w]):x.push(g[w])}else x=g;if(b.sort(u?o:i),u)for(var w=0;w<b.length;w++)b[w]=b[w].input;else c||x.sort(i);if(g=a?b.concat(x):x.concat(b),s){var C,S=g;g=[];for(var w=0;w<S.length;w++)S[w]!=C&&g.push(S[w]),C=S[w]}t.replaceRange(g.join("\n"),p,m)}},global:function(e,t){var r=t.argString;if(!r)return void Pe(e,"Regular Expression missing from global");var n,i=void 0!==t.line?t.line:e.firstLine(),o=t.lineEnd||t.line||e.lastLine(),a=Te(r),l=r;if(a.length&&(l=a[0],n=a.slice(1,a.length).join("/")),l)try{De(e,l,!0,!0)}catch(t){return void Pe(e,"Invalid regex: "+l)}for(var s=Me(e).getQuery(),c=[],u="",f=i;f<=o;f++){s.test(e.getLine(f))&&(c.push(f+1),u+=e.getLine(f)+"<br>")}if(!n)return void Pe(e,u);var d=0,h=function(){if(d<c.length){var t=c[d]+n;Rt.processCommand(e,t,{callback:h})}d++};h()},substitute:function(e,t){if(!e.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var r,i,o,a,l=t.argString,s=l?Te(l):[],c="",u=!1,f=!1;if(s.length)r=s[0],c=s[1],void 0!==c&&(c=w("pcre")?Ie(c):Ee(c),wt.lastSubstituteReplacePart=c),i=s[2]?s[2].split(" "):[];else if(l&&l.length)return void Pe(e,"Substitutions should be of the form :s/pattern/replace/");if(i&&(o=i[0],a=parseInt(i[1]),o&&(o.indexOf("c")!=-1&&(u=!0,o.replace("c","")),o.indexOf("g")!=-1&&(f=!0,o.replace("g","")),r=r+"/"+o)),r)try{De(e,r,!0,!0)}catch(t){return void Pe(e,"Invalid regex: "+r)}if(void 0===(c=c||wt.lastSubstituteReplacePart))return void Pe(e,"No previous substitute regular expression");var d=Me(e),h=d.getQuery(),p=void 0!==t.line?t.line:e.getCursor().line,m=t.lineEnd||p;p==e.firstLine()&&m==e.lastLine()&&(m=1/0),a&&(p=m,m=p+a-1);var g=R(e,n(p,0)),v=e.getSearchCursor(h,g);Ve(e,u,f,p,m,v,h,c,t.callback)},redo:e.commands.redo,undo:e.commands.undo,write:function(t){
|
13 |
+
e.commands.save?e.commands.save(t):t.save&&t.save()},nohlsearch:function(e){He(e)},yank:function(e){var t=j(e.getCursor()),r=t.line,n=e.getLine(r);wt.registerController.pushText("0","yank",n,!0,!0)},delmarks:function(t,r){if(!r.argString||!Y(r.argString))return void Pe(t,"Argument required");for(var n=t.state.vim,i=new e.StringStream(Y(r.argString));!i.eol();){i.eatSpace();var o=i.pos;if(!i.match(/[a-zA-Z]/,!1))return void Pe(t,"Invalid argument: "+r.argString.substring(o));var a=i.next();if(i.match("-",!0)){if(!i.match(/[a-zA-Z]/,!1))return void Pe(t,"Invalid argument: "+r.argString.substring(o));var l=a,s=i.next();if(!(h(l)&&h(s)||g(l)&&g(s)))return void Pe(t,"Invalid argument: "+l+"-");var c=l.charCodeAt(0),u=s.charCodeAt(0);if(c>=u)return void Pe(t,"Invalid argument: "+r.argString.substring(o));for(var f=0;f<=u-c;f++){var d=String.fromCharCode(c+f);delete n.marks[d]}}else delete n.marks[a]}}},Rt=new Nt;return e.keyMap.vim={attach:l,detach:a,call:s},b("insertModeEscKeysTimeout",200,"number"),e.keyMap["vim-insert"]={fallthrough:["default"],attach:l,detach:a,call:s},e.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:l,detach:a,call:s},S(),Ct}()}),console.log(window.heshOptions),function(e,t,r,n,i){"use strict";function o(){te.theme=i.theme,te.lineNumbers=!!i.lineNumbers,te.foldGutter=!!i.foldGutter,te.gutters=te.foldGutter?["CodeMirror-linenumbers","CodeMirror-foldgutter"]:[],te.tabSize=te.indentUnit=+i.tabSize,te.lineWrapping=!!i.lineWrapping,te.matchBrackets=!!i.matchBrackets,te.autoCloseTags=!!i.autoCloseTags,te.autoCloseBrackets=!!i.autoCloseBrackets,te.highlightSelectionMatches=!!i.highlightSelectionMatches,te.matchTags=!!i.matchTags&&{bothTags:!0},te.scrollbarStyle=i.scrollbarStyle?"overlay":null,te.keyMap=i.keyMap,te.autofocus=e.getElementById("title")&&!!e.getElementById("title").value&&e.getElementById("title").value.length>0}function a(e){var r=!1;return function(){var n=this,i=arguments;r||(e.apply(n,i),r=!0,t.requestAnimationFrame(function(){t.requestAnimationFrame(function(){r=!1})}))}}function l(){for(var e=-1;e<U.children.length;e++){var t=e<0?K:U.children[e];null!=t&&(t.style.position="",t.style.top="",t.style.left="",t.style.right="",t.style.width="")}}function s(){for(var t=$.getBoundingClientRect(),r=-1;r<U.children.length;r++){var n=r<0?K:U.children[r];null!=n&&(n.style.position="fixed",n.style.top=t.bottom+"px",n.style.right=e.documentElement.getBoundingClientRect().width-t.right+"px",n.id.match(/toggle/gi)||(n.style.left=t.left+"px",n.style.width="auto"))}}function c(){for(var e=$.getBoundingClientRect(),t=H.getWrapperElement().getBoundingClientRect(),r=-1;r<U.children.length;r++){var n=r<0?K:U.children[r];null!=n&&(n.style.position="absolute",n.style.top=(t.top-e.bottom)*-1+"px",n.style.left="",n.style.right="",n.style.width="")}}function u(e){f();var t=ee.settingsPosition();if(t!==ee.previousSettingsPosition||e&&"resize"===e.type)switch(_(),t){case"top":l();break;case"middle":s();break;case"bottom":c();break;case"normal":case"none":}}function f(){if(V){var r=V.getBoundingClientRect().top,n=e.getElementById("post-status-info").getBoundingClientRect().top,i=n-r,o=t.innerHeight-r;V.style.maxHeight=Math.min(i,o)-6+"px",ne&&(V.style.height=V.style.maxHeight)}}function d(){V.style.maxHeight="",ne&&(V.style.height="")}function h(){Z&&(Z.addEventListener("change",p),p())}function p(){ee.isFullHeight()?(H.setOption("viewportMargin",1/0),H.on("change",_),t.addEventListener("scroll",re),t.addEventListener("resize",re),t.addEventListener("resize",ae),H.getWrapperElement().style.height="auto",u(),L(),t.setTimeout(function(){f(),_()},100)):(H.setOption("viewportMargin",te.viewportMargin),H.off("change",_),t.removeEventListener("scroll",re),t.removeEventListener("resize",re),t.removeEventListener("resize",ae),H.getWrapperElement().style.marginTop="",d(),l(),M())}function m(e){for(var t=0;t<e.length;t++){var r=e[t];if(r.addedNodes[0]&&r.addedNodes[0].classList.contains("CodeMirror-dialog")){K=r.addedNodes[0];for(var n=K.getElementsByTagName("button"),i=0;i<n.length;i++){n[i].classList="button button-small"}}else K=void 0}}function g(){H.getWrapperElement().appendChild(U),U.style.display="block",U.querySelector(".CodeMirror-settings__toggle").addEventListener("click",v),U.querySelector(".CodeMirror-settings__toggle-advanced").addEventListener("click",v),new MutationObserver(m).observe(H.getWrapperElement(),{childList:!0});for(var e=U.querySelectorAll(".CodeMirror-settings__option"),t=0;t<e.length;t++){var r=e[t];r.addEventListener("change",k),r.addEventListener("change",x)}}function v(e){y(e.target.id.match(/advanced/gi)?U.classList.contains("open-advanced")?"open":"advanced":U.classList.contains("open")?"closed":"open")}function y(e){switch(e){case"open":U.classList.add("open"),U.classList.remove("open-advanced"),U.classList.remove("closed");break;case"advanced":U.classList.add("open"),U.classList.add("open-advanced"),U.classList.remove("closed");break;default:U.classList.remove("open"),U.classList.remove("open-advanced"),U.classList.add("closed")}}function b(){ee.charWidth=H.defaultCharWidth()*(i.fontSize/13)}function x(e){var t=+e.target.value;switch(t=isNaN(t)?e.target.value:t,"checkbox"===e.target.type&&(t=e.target.checked),e.target.id){case"fontSize":i.fontSize=t,j.style.fontSize=t+"px",b(),H.refresh();break;case"lineHeight":i.lineHeight=t,j.style.lineHeight=t+"em",H.refresh();break;case"matchTags":i.matchTags=t,H.setOption("matchTags",t?{bothTags:!0}:null);break;case"scrollbarStyle":i.scrollbarStyle=t,H.setOption("scrollbarStyle",t?"overlay":null);break;case"foldGutter":H.setOption("gutters",t?["CodeMirror-linenumbers","CodeMirror-foldgutter"]:[]);case"tabSize":H.setOption("indentUnit",t);default:i[e.target.id]=t,H.setOption(e.target.id,t)}switch(e.target.id){case"lineNumbers":t&&i.foldGutter&&H.setOption("gutters",["CodeMirror-linenumbers","CodeMirror-foldgutter"])}}function w(e,t){j.style.fontSize=e+"px",i.fontSize=e,j.style.lineHeight=t+"em",i.lineHeight=t,b(),H.refresh()}function k(){var e=n("#CodeMirror-settings__form").serializeArray();n.post(i.ajaxUrl,e,function(e){})}function C(){$.insertAdjacentHTML("afterbegin",'<button type="button" id="cm_content_fullscreen" class="ed_button qt-dfw" title="Full Screen"></button>'),e.getElementById("cm_content_fullscreen").onclick=S}function S(e){e=e===!0,ee.isFullHeight()?ie.classList.remove(oe):(ie.classList.contains(oe)||e?ie.classList.remove(oe):ie.classList.add(oe),H.focus())}function _(){H.save(),H.getTextArea().style.height=H.getWrapperElement().getBoundingClientRect().height+"px"}function M(){H.getWrapperElement().style.height=H.getTextArea().style.height}function L(){H.getWrapperElement().style.marginTop=$.offsetHeight+"px"}function T(){e.getElementById("content-resize-handle").addEventListener("mousedown",function(){e.addEventListener("mousemove",M)}),e.addEventListener("mouseup",function(){e.removeEventListener("mousemove",M)})}function A(){function t(e){l=r+(e.pageY-o),H.getWrapperElement().style.height=Math.max(n,l)+"px"}var r=500,n=200;H.getWrapperElement().style.height=r+"px";var i=e.createElement("div");i.className="hesh-content-resize-handle",i.id="content-resize-handle",H.getWrapperElement().appendChild(i);var o,a=!1,l=r;e.getElementById("content-resize-handle").addEventListener("mousedown",function(r){o=r.pageY,a=!0,e.addEventListener("mousemove",t),r.preventDefault()}),e.addEventListener("mouseup",function(){a=!1,r=Math.max(n,l),e.removeEventListener("mousemove",t),H.refresh()})}function O(){var t=e.querySelector(".fileedit-sub .alignleft"),r=t.textContent.match(/\.[a-z\d]{2,}/gi),n=r[r.length-1].match(/[a-z]*/gi)[1],i={php:"php",css:"css",xml:"xml",html:"htmlmixed",js:"javascript",json:"javascript"};te.mode=i[n]}function E(t){var r="; "+e.cookie,n=r.split("; "+t+"=");if(2===n.length)return n.pop().split(";").shift()}function I(){var e=(E("hesh_plugin_selection_state")||"0,0,0,0,0,0,0").split(",");J===e[0]&&(H.doc.setSelection({line:+e[1],ch:+e[2]},{line:+e[3],ch:+e[4]},{scroll:!1}),H.scrollTo(+e[5],+e[6]))}function N(){var t=H.doc.listSelections()[0],r=H.getScrollInfo();e.cookie="hesh_plugin_selection_state="+J+","+t.anchor.line+","+t.anchor.ch+","+t.head.line+","+t.head.ch+","+r.left+","+r.top}function P(){var t=".CodeMirror pre > * { text-indent: 0px; }",n=e.head||e.getElementsByTagName("head")[0],i=e.createElement("style");i.type="text/css",i.styleSheet?i.styleSheet.cssText=t:i.appendChild(e.createTextNode(t)),n.appendChild(i);H.on("renderLine",function(e,t,n){var i=r.countColumn(t.text,null,e.getOption("tabSize"))*ee.charWidth;n.style.textIndent="-"+i+"px",n.style.paddingLeft=4+i+"px"}),H.refresh()}function R(){var e,t,r,n=H.doc.listSelections()[0];e=t=r=0,H.doc.eachLine(function(i){r<=n.head.line-1&&(e+=i.text.length+1),r<=n.anchor.line-1&&(t+=i.text.length+1),r++}),e+=n.head.ch,t+=n.anchor.ch,H.getTextArea().setSelectionRange(Math.min(t,e),Math.max(t,e)),H.getTextArea().focus(),B()}function B(){var e=H.getTextArea().value.length,r=t.setInterval(function(){e!==H.getTextArea().value.length&&(t.clearInterval(r),z())},10),n=function(){t.clearInterval(r),H.off("focus",n)};H.on("focus",n)}function z(){var e=H.getTextArea().selectionStart,r=H.getTextArea().selectionEnd,n=H.getScrollInfo(),i={top:t.pageYOffset,left:t.pageXOffset};H.doc.setValue(H.getTextArea().value),H.focus();for(var o=0,a=0,l=0,s=e,c=r,u=H.getLineHandle(l).text.length+1;u<=s&&u<=c;)l++,u<=s&&(s-=u,o=l),u<=c&&(c-=u,a=l),u=H.getLineHandle(l).text.length+1;H.doc.setSelection({line:o,ch:s},{line:a,ch:c},{scroll:!1}),t.scrollTo(i.left,i.top),H.scrollTo(n.left,n.top),H.save()}function D(){var e=t.send_to_editor,r=function(r){ee.isActive()&&"content"===t.wpActiveEditor?(H.replaceSelection(r),H.save()):e(r)};t.send_to_editor=r}function W(){ee.isActive()||(o(),ee.isThemeOrPlugin&&O(),H=r.fromTextArea(G,te),j=H.getWrapperElement().querySelector(".CodeMirror-code"),G.classList.add("CodeMirror-mirrored"),H.on("change",function(){H.save()}),I(),H.on("cursorActivity",le),H.on("scroll",le),ee.isThemeOrPlugin?(A(),Q=e.getElementById("submit")):($.addEventListener("mousedown",R),D(),T(),h(),C()),g(),w(+i.fontSize,+i.lineHeight),P())}function q(){ee.isActive()&&(y("closed"),H.toTextArea())}function F(){ee.isThemeOrPlugin?W():ee.isVisualEnabled?(X.addEventListener("click",function(){t.setTimeout(W,0)}),Y.addEventListener("click",q),ee.isVisualActive()||W()):(W(),e.body.className+=" visual-editor-is-disabled")}var H,j,K,U=e.getElementById("CodeMirror-settings"),V=e.getElementById("CodeMirror-settings__form"),$=e.getElementById("ed_toolbar"),G=e.getElementById("content")||e.getElementById("newcontent"),X=e.getElementById("content-html"),Y=e.getElementById("content-tmce"),Q=e.getElementById("save-post")||e.getElementById("publish"),J=null!=e.getElementById("post_ID")?e.getElementById("post_ID").value:0,Z=e.getElementById("editor-expand-toggle"),ee={isVisualEnabled:null!=e.getElementById("content-tmce"),isThemeOrPlugin:null!=e.getElementById("newcontent"),isActive:function(){return null!=e.getElementsByClassName("CodeMirror")[0]},isVisualActive:function(){return null!=e.getElementsByClassName("tmce-active")[0]},isFullHeight:function(){return!!Z&&Z.checked},previousSettingsPosition:"none",settingsPosition:function(){var e,r=this;return e=$?"absolute"===$.style.position?"0px"===$.style.top?"top":"bottom":"fixed"===$.style.position?"middle":"normal":"none",t.setTimeout(function(){r.previousSettingsPosition=e},0),e},charWidth:0},te={mode:"wordpresspost",tabMode:"indent",indentWithTabs:!0,enterMode:"keep",styleActiveLine:!0,electricChars:!1,showCursorWhenSelecting:!0,viewportMargin:10,extraKeys:{F11:function(){S()},Esc:function(){S(!0)},"Ctrl-S":function(){Q.click()},"Cmd-S":function(){Q.click()}}},re=a(u),ne=!!navigator.userAgent.match(/Trident/gi),ie=e.getElementById("wp-content-editor-container"),oe="heshFullscreen",ae=a(L),le=a(N);"complete"!==e.readyState?t.addEventListener?t.addEventListener("load",F,!1):t.attachEvent&&t.attachEvent("onload",F):F()}(document,window,window.CodeMirror,window.jQuery,window.heshOptions);
|
html-editor-syntax-highlighter.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
|
4 |
/**
|
5 |
-
* @since 2.2.
|
6 |
* @package HESH_plugin
|
7 |
*
|
8 |
* Plugin Name: HTML Editor Syntax Highlighter
|
@@ -17,10 +17,10 @@
|
|
17 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
18 |
* GitHub Branch: master
|
19 |
* GitHub Plugin URI: https://github.com/mukhortov/HESH-WordPress-Plugin
|
20 |
-
* Version: 2.2.
|
21 |
* Requires at least: 4.0.15
|
22 |
* Tested up to: 4.8.1
|
23 |
-
* Stable tag: 2.2.
|
24 |
**/
|
25 |
|
26 |
// Check for required PHP version
|
2 |
|
3 |
|
4 |
/**
|
5 |
+
* @since 2.2.1
|
6 |
* @package HESH_plugin
|
7 |
*
|
8 |
* Plugin Name: HTML Editor Syntax Highlighter
|
17 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
18 |
* GitHub Branch: master
|
19 |
* GitHub Plugin URI: https://github.com/mukhortov/HESH-WordPress-Plugin
|
20 |
+
* Version: 2.2.1
|
21 |
* Requires at least: 4.0.15
|
22 |
* Tested up to: 4.8.1
|
23 |
+
* Stable tag: 2.2.1
|
24 |
**/
|
25 |
|
26 |
// Check for required PHP version
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/mukhortov/5
|
|
4 |
Tags: syntax highlighter, codemirror, text editor, code highlighter, code coloring, editor, html editor, theme editor, plugin editor, syntax, highlighting, highlighter, syntax highlighting, codemirror.js, code,
|
5 |
Requires at least: 4.0.15
|
6 |
Tested up to: 4.8.1
|
7 |
-
Stable tag: 2.2.
|
8 |
License: GPL-2.0
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -41,6 +41,9 @@ Yes! Seach with `Ctrl+F` (`Cmd+F` on Mac). Replace with `Ctrl+alt+F` (`Cmd+alt+F
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
44 |
= 2.2.0 =
|
45 |
* added search & replace with dialog
|
46 |
* added highlighing options
|
4 |
Tags: syntax highlighter, codemirror, text editor, code highlighter, code coloring, editor, html editor, theme editor, plugin editor, syntax, highlighting, highlighter, syntax highlighting, codemirror.js, code,
|
5 |
Requires at least: 4.0.15
|
6 |
Tested up to: 4.8.1
|
7 |
+
Stable tag: 2.2.1
|
8 |
License: GPL-2.0
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 2.2.1 =
|
45 |
+
* fixed bug: editor was not stopping when switching between visual editor and text editor
|
46 |
+
|
47 |
= 2.2.0 =
|
48 |
* added search & replace with dialog
|
49 |
* added highlighing options
|