1 line
23 KiB
JavaScript
1 line
23 KiB
JavaScript
ace.define("ace/occur",["require","exports","module","ace/lib/oop","ace/range","ace/search","ace/edit_session","ace/search_highlight","ace/lib/dom"],(function(e,n,t){"use strict";var a=e("./lib/oop"),o=(e("./range").Range,e("./search").Search),r=e("./edit_session").EditSession,i=e("./search_highlight").SearchHighlight;function s(){}a.inherits(s,o),function(){this.enter=function(e,n){if(!n.needle)return!1;var t=e.getCursorPosition();this.displayOccurContent(e,n);var a=this.originalToOccurPosition(e.session,t);return e.moveCursorToPosition(a),!0},this.exit=function(e,n){var t=n.translatePosition&&e.getCursorPosition(),a=t&&this.occurToOriginalPosition(e.session,t);return this.displayOriginalContent(e),a&&e.moveCursorToPosition(a),!0},this.highlight=function(e,n){(e.$occurHighlight=e.$occurHighlight||e.addDynamicMarker(new i(null,"ace_occur-highlight","text"))).setRegexp(n),e._emit("changeBackMarker")},this.displayOccurContent=function(e,n){this.$originalSession=e.session;var t=this.matchingLines(e.session,n),a=t.map((function(e){return e.content})),o=new r(a.join("\n"));o.$occur=this,o.$occurMatchingLines=t,e.setSession(o),this.$useEmacsStyleLineStart=this.$originalSession.$useEmacsStyleLineStart,o.$useEmacsStyleLineStart=this.$useEmacsStyleLineStart,this.highlight(o,n.re),o._emit("changeBackMarker")},this.displayOriginalContent=function(e){e.setSession(this.$originalSession),this.$originalSession.$useEmacsStyleLineStart=this.$useEmacsStyleLineStart},this.originalToOccurPosition=function(e,n){var t=e.$occurMatchingLines,a={row:0,column:0};if(!t)return a;for(var o=0;o<t.length;o++)if(t[o].row===n.row)return{row:o,column:n.column};return a},this.occurToOriginalPosition=function(e,n){var t=e.$occurMatchingLines;return t&&t[n.row]?{row:t[n.row].row,column:n.column}:n},this.matchingLines=function(e,n){if(n=a.mixin({},n),!e||!n.needle)return[];var t=new o;return t.set(n),t.findAll(e).reduce((function(n,t){var a=t.start.row,o=n[n.length-1];return o&&o.row===a?n:n.concat({row:a,content:e.getLine(a)})}),[])}}.call(s.prototype),e("./lib/dom").importCssString(".ace_occur-highlight {\n border-radius: 4px;\n background-color: rgba(87, 255, 8, 0.25);\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n box-shadow: 0 0 4px rgb(91, 255, 50);\n}\n.ace_dark .ace_occur-highlight {\n background-color: rgb(80, 140, 85);\n box-shadow: 0 0 4px rgb(60, 120, 70);\n}\n","incremental-occur-highlighting",!1),n.Occur=s})),ace.define("ace/commands/occur_commands",["require","exports","module","ace/config","ace/occur","ace/keyboard/hash_handler","ace/lib/oop"],(function(e,n,t){e("../config");var a=e("../occur").Occur,o={name:"occur",exec:function(e,n){var t=!!e.session.$occur;(new a).enter(e,n)&&!t&&s.installIn(e)},readOnly:!0},r=[{name:"occurexit",bindKey:"esc|Ctrl-G",exec:function(e){var n=e.session.$occur;n&&(n.exit(e,{}),e.session.$occur||s.uninstallFrom(e))},readOnly:!0},{name:"occuraccept",bindKey:"enter",exec:function(e){var n=e.session.$occur;n&&(n.exit(e,{translatePosition:!0}),e.session.$occur||s.uninstallFrom(e))},readOnly:!0}],i=e("../keyboard/hash_handler").HashHandler;function s(){}e("../lib/oop").inherits(s,i),function(){this.isOccurHandler=!0,this.attach=function(e){i.call(this,r,e.commands.platform),this.$editor=e};var e=this.handleKeyboard;this.handleKeyboard=function(n,t,a,o){var r=e.call(this,n,t,a,o);return r&&r.command?r:void 0}}.call(s.prototype),s.installIn=function(e){var n=new this;e.keyBinding.addKeyboardHandler(n),e.commands.addCommands(r)},s.uninstallFrom=function(e){e.commands.removeCommands(r);var n=e.getKeyboardHandler();n.isOccurHandler&&e.keyBinding.removeKeyboardHandler(n)},n.occurStartCommand=o})),ace.define("ace/commands/incremental_search_commands",["require","exports","module","ace/config","ace/lib/oop","ace/keyboard/hash_handler","ace/commands/occur_commands"],(function(e,n,t){var a=e("../config"),o=e("../lib/oop"),r=e("../keyboard/hash_handler").HashHandler,i=e("./occur_commands").occurStartCommand;function s(e){this.$iSearch=e}n.iSearchStartCommands=[{name:"iSearch",bindKey:{win:"Ctrl-F",mac:"Command-F"},exec:function(e,n){a.loadModule(["core","ace/incremental_search"],(function(t){var a=t.iSearch=t.iSearch||new t.IncrementalSearch;a.activate(e,n.backwards),n.jumpToFirstMatch&&a.next(n)}))},readOnly:!0},{name:"iSearchBackwards",exec:function(e,n){e.execCommand("iSearch",{backwards:!0})},readOnly:!0},{name:"iSearchAndGo",bindKey:{win:"Ctrl-K",mac:"Command-G"},exec:function(e,n){e.execCommand("iSearch",{jumpToFirstMatch:!0,useCurrentOrPrevSearch:!0})},readOnly:!0},{name:"iSearchBackwardsAndGo",bindKey:{win:"Ctrl-Shift-K",mac:"Command-Shift-G"},exec:function(e){e.execCommand("iSearch",{jumpToFirstMatch:!0,backwards:!0,useCurrentOrPrevSearch:!0})},readOnly:!0}],n.iSearchCommands=[{name:"restartSearch",bindKey:{win:"Ctrl-F",mac:"Command-F"},exec:function(e){e.cancelSearch(!0)}},{name:"searchForward",bindKey:{win:"Ctrl-S|Ctrl-K",mac:"Ctrl-S|Command-G"},exec:function(e,n){n.useCurrentOrPrevSearch=!0,e.next(n)}},{name:"searchBackward",bindKey:{win:"Ctrl-R|Ctrl-Shift-K",mac:"Ctrl-R|Command-Shift-G"},exec:function(e,n){n.useCurrentOrPrevSearch=!0,n.backwards=!0,e.next(n)}},{name:"extendSearchTerm",exec:function(e,n){e.addString(n)}},{name:"extendSearchTermSpace",bindKey:"space",exec:function(e){e.addString(" ")}},{name:"shrinkSearchTerm",bindKey:"backspace",exec:function(e){e.removeChar()}},{name:"confirmSearch",bindKey:"return",exec:function(e){e.deactivate()}},{name:"cancelSearch",bindKey:"esc|Ctrl-G",exec:function(e){e.deactivate(!0)}},{name:"occurisearch",bindKey:"Ctrl-O",exec:function(e){var n=o.mixin({},e.$options);e.deactivate(),i.exec(e.$editor,n)}},{name:"yankNextWord",bindKey:"Ctrl-w",exec:function(e){var n=e.$editor,t=n.selection.getRangeOfMovements((function(e){e.moveCursorWordRight()})),a=n.session.getTextRange(t);e.addString(a)}},{name:"yankNextChar",bindKey:"Ctrl-Alt-y",exec:function(e){var n=e.$editor,t=n.selection.getRangeOfMovements((function(e){e.moveCursorRight()})),a=n.session.getTextRange(t);e.addString(a)}},{name:"recenterTopBottom",bindKey:"Ctrl-l",exec:function(e){e.$editor.execCommand("recenterTopBottom")}},{name:"selectAllMatches",bindKey:"Ctrl-space",exec:function(e){var n=e.$editor,t=n.session.$isearchHighlight,a=t&&t.cache?t.cache.reduce((function(e,n){return e.concat(n||[])}),[]):[];e.deactivate(!1),a.forEach(n.selection.addRange.bind(n.selection))}},{name:"searchAsRegExp",bindKey:"Alt-r",exec:function(e){e.convertNeedleToRegExp()}}].map((function(e){return e.readOnly=!0,e.isIncrementalSearchCommand=!0,e.scrollIntoView="animate-cursor",e})),o.inherits(s,r),function(){this.attach=function(e){var t=this.$iSearch;r.call(this,n.iSearchCommands,e.commands.platform),this.$commandExecHandler=e.commands.on("exec",(function(n){if(!n.command.isIncrementalSearchCommand)return t.deactivate();n.stopPropagation(),n.preventDefault();var a=e.session.getScrollTop(),o=n.command.exec(t,n.args||{});return e.renderer.scrollCursorIntoView(null,.5),e.renderer.animateScrolling(a),o}))},this.detach=function(e){this.$commandExecHandler&&(e.commands.off("exec",this.$commandExecHandler),delete this.$commandExecHandler)};var e=this.handleKeyboard;this.handleKeyboard=function(n,t,a,o){if((1===t||8===t)&&"v"===a||1===t&&"y"===a)return null;var r=e.call(this,n,t,a,o);if(r&&r.command)return r;if(-1==t){var i=this.commands.extendSearchTerm;if(i)return{command:i,args:a}}return!1}}.call(s.prototype),n.IncrementalSearchKeyboardHandler=s})),ace.define("ace/incremental_search",["require","exports","module","ace/lib/oop","ace/range","ace/search","ace/search_highlight","ace/commands/incremental_search_commands","ace/lib/dom","ace/commands/command_manager","ace/editor","ace/config"],(function(e,n,t){"use strict";var a=e("./lib/oop"),o=e("./range").Range,r=e("./search").Search,i=e("./search_highlight").SearchHighlight,s=e("./commands/incremental_search_commands"),c=s.IncrementalSearchKeyboardHandler;function l(){this.$options={wrap:!1,skipCurrent:!1},this.$keyboardHandler=new c(this)}function d(e){return e instanceof RegExp}function h(e){var n=String(e),t=n.indexOf("/"),a=n.lastIndexOf("/");return{expression:n.slice(t+1,a),flags:n.slice(a+1)}}function m(e,n){try{return new RegExp(e,n)}catch(t){return e}}function u(e){return m(e.expression,e.flags)}a.inherits(l,r),function(){this.activate=function(e,n){this.$editor=e,this.$startPos=this.$currentPos=e.getCursorPosition(),this.$options.needle="",this.$options.backwards=n,e.keyBinding.addKeyboardHandler(this.$keyboardHandler),this.$originalEditorOnPaste=e.onPaste,e.onPaste=this.onPaste.bind(this),this.$mousedownHandler=e.on("mousedown",this.onMouseDown.bind(this)),this.selectionFix(e),this.statusMessage(!0)},this.deactivate=function(e){this.cancelSearch(e);var n=this.$editor;n.keyBinding.removeKeyboardHandler(this.$keyboardHandler),this.$mousedownHandler&&(n.off("mousedown",this.$mousedownHandler),delete this.$mousedownHandler),n.onPaste=this.$originalEditorOnPaste,this.message("")},this.selectionFix=function(e){e.selection.isEmpty()&&!e.session.$emacsMark&&e.clearSelection()},this.highlight=function(e){var n=this.$editor.session;(n.$isearchHighlight=n.$isearchHighlight||n.addDynamicMarker(new i(null,"ace_isearch-result","text"))).setRegexp(e),n._emit("changeBackMarker")},this.cancelSearch=function(e){var n=this.$editor;return this.$prevNeedle=this.$options.needle,this.$options.needle="",e?(n.moveCursorToPosition(this.$startPos),this.$currentPos=this.$startPos):n.pushEmacsMark&&n.pushEmacsMark(this.$startPos,!1),this.highlight(null),o.fromPoints(this.$currentPos,this.$currentPos)},this.highlightAndFindWithNeedle=function(e,n){if(!this.$editor)return null;var t=this.$options;if(n&&(t.needle=n.call(this,t.needle||"")||""),0===t.needle.length)return this.statusMessage(!0),this.cancelSearch(!0);t.start=this.$currentPos;var a=this.$editor.session,r=this.find(a),i=this.$editor.emacsMark?!!this.$editor.emacsMark():!this.$editor.selection.isEmpty();return r&&(t.backwards&&(r=o.fromPoints(r.end,r.start)),this.$editor.selection.setRange(o.fromPoints(i?this.$startPos:r.end,r.end)),e&&(this.$currentPos=r.end),this.highlight(t.re)),this.statusMessage(r),r},this.addString=function(e){return this.highlightAndFindWithNeedle(!1,(function(n){if(!d(n))return n+e;var t=h(n);return t.expression+=e,u(t)}))},this.removeChar=function(e){return this.highlightAndFindWithNeedle(!1,(function(e){if(!d(e))return e.substring(0,e.length-1);var n=h(e);return n.expression=n.expression.substring(0,n.expression.length-1),u(n)}))},this.next=function(e){return e=e||{},this.$options.backwards=!!e.backwards,this.$currentPos=this.$editor.getCursorPosition(),this.highlightAndFindWithNeedle(!0,(function(n){return e.useCurrentOrPrevSearch&&0===n.length?this.$prevNeedle||"":n}))},this.onMouseDown=function(e){return this.deactivate(),!0},this.onPaste=function(e){this.addString(e)},this.convertNeedleToRegExp=function(){return this.highlightAndFindWithNeedle(!1,(function(e){return d(e)?e:m(e,"ig")}))},this.convertNeedleToString=function(){return this.highlightAndFindWithNeedle(!1,(function(e){return d(e)?h(e).expression:e}))},this.statusMessage=function(e){var n=this.$options,t="";t+=n.backwards?"reverse-":"",t+="isearch: "+n.needle,t+=e?"":" (not found)",this.message(t)},this.message=function(e){this.$editor.showCommandLine&&(this.$editor.showCommandLine(e),this.$editor.focus())}}.call(l.prototype),n.IncrementalSearch=l,e("./lib/dom").importCssString(".ace_marker-layer .ace_isearch-result { position: absolute; z-index: 6; box-sizing: border-box;}div.ace_isearch-result { border-radius: 4px; background-color: rgba(255, 200, 0, 0.5); box-shadow: 0 0 4px rgb(255, 200, 0);}.ace_dark div.ace_isearch-result { background-color: rgb(100, 110, 160); box-shadow: 0 0 4px rgb(80, 90, 140);}","incremental-search-highlighting",!1);var g=e("./commands/command_manager");(function(){this.setupIncrementalSearch=function(e,n){if(this.usesIncrementalSearch!=n){this.usesIncrementalSearch=n;var t=s.iSearchStartCommands;this[n?"addCommands":"removeCommands"](t)}}}).call(g.CommandManager.prototype);var f=e("./editor").Editor;e("./config").defineOptions(f.prototype,"editor",{useIncrementalSearch:{set:function(e){this.keyBinding.$handlers.forEach((function(n){n.setupIncrementalSearch&&n.setupIncrementalSearch(this,e)})),this._emit("incrementalSearchSettingChanged",{isEnabled:e})}}})})),ace.define("ace/keyboard/emacs",["require","exports","module","ace/lib/dom","ace/incremental_search","ace/commands/incremental_search_commands","ace/keyboard/hash_handler","ace/lib/keys"],(function(e,n,t){"use strict";var a=e("../lib/dom");e("../incremental_search");var o=e("../commands/incremental_search_commands"),r=e("./hash_handler").HashHandler;n.handler=new r,n.handler.isEmacs=!0,n.handler.$id="ace/keyboard/emacs";var i,s,c=!1;n.handler.attach=function(e){c||(c=!0,a.importCssString(" .emacs-mode .ace_cursor{ border: 1px rgba(50,250,50,0.8) solid!important; box-sizing: border-box!important; background-color: rgba(0,250,0,0.9); opacity: 0.5; } .emacs-mode .ace_hidden-cursors .ace_cursor{ opacity: 1; background-color: transparent; } .emacs-mode .ace_overwrite-cursors .ace_cursor { opacity: 1; background-color: transparent; border-width: 0 0 2px 2px !important; } .emacs-mode .ace_text-layer { z-index: 4 } .emacs-mode .ace_cursor-layer { z-index: 2 }","emacsMode")),i=e.session.$selectLongWords,e.session.$selectLongWords=!0,s=e.session.$useEmacsStyleLineStart,e.session.$useEmacsStyleLineStart=!0,e.session.$emacsMark=null,e.session.$emacsMarkRing=e.session.$emacsMarkRing||[],e.emacsMark=function(){return this.session.$emacsMark},e.setEmacsMark=function(e){this.session.$emacsMark=e},e.pushEmacsMark=function(e,n){var t=this.session.$emacsMark;t&&this.session.$emacsMarkRing.push(t),!e||n?this.setEmacsMark(e):this.session.$emacsMarkRing.push(e)},e.popEmacsMark=function(){var e=this.emacsMark();return e?(this.setEmacsMark(null),e):this.session.$emacsMarkRing.pop()},e.getLastEmacsMark=function(e){return this.session.$emacsMark||this.session.$emacsMarkRing.slice(-1)[0]},e.emacsMarkForSelection=function(e){var n=this.selection,t=this.multiSelect?this.multiSelect.getAllRanges().length:1,a=n.index||0,o=this.session.$emacsMarkRing,r=o.length-(t-a),i=o[r]||n.anchor;return e&&o.splice(r,1,"row"in e&&"column"in e?e:void 0),i},e.on("click",d),e.on("changeSession",l),e.renderer.$blockCursor=!0,e.setStyle("emacs-mode"),e.commands.addCommands(u),n.handler.platform=e.commands.platform,e.$emacsModeHandler=this,e.on("copy",this.onCopy),e.on("paste",this.onPaste)},n.handler.detach=function(e){e.renderer.$blockCursor=!1,e.session.$selectLongWords=i,e.session.$useEmacsStyleLineStart=s,e.off("click",d),e.off("changeSession",l),e.unsetStyle("emacs-mode"),e.commands.removeCommands(u),e.off("copy",this.onCopy),e.off("paste",this.onPaste),e.$emacsModeHandler=null};var l=function(e){e.oldSession&&(e.oldSession.$selectLongWords=i,e.oldSession.$useEmacsStyleLineStart=s),i=e.session.$selectLongWords,e.session.$selectLongWords=!0,s=e.session.$useEmacsStyleLineStart,e.session.$useEmacsStyleLineStart=!0,e.session.hasOwnProperty("$emacsMark")||(e.session.$emacsMark=null),e.session.hasOwnProperty("$emacsMarkRing")||(e.session.$emacsMarkRing=[])},d=function(e){e.editor.session.$emacsMark=null},h=e("../lib/keys").KEY_MODS,m={C:"ctrl",S:"shift",M:"alt",CMD:"command"};["C-S-M-CMD","S-M-CMD","C-M-CMD","C-S-CMD","C-S-M","M-CMD","S-CMD","S-M","C-CMD","C-M","C-S","CMD","M","S","C"].forEach((function(e){var n=0;e.split("-").forEach((function(e){n|=h[m[e]]})),m[n]=e.toLowerCase()+"-"})),n.handler.onCopy=function(e,t){t.$handlesEmacsOnCopy||(t.$handlesEmacsOnCopy=!0,n.handler.commands.killRingSave.exec(t),t.$handlesEmacsOnCopy=!1)},n.handler.onPaste=function(e,n){n.pushEmacsMark(n.getCursorPosition())},n.handler.bindKey=function(e,n){if("object"==typeof e&&(e=e[this.platform]),e){var t=this.commandKeyBinding;e.split("|").forEach((function(e){e=e.toLowerCase(),t[e]=n,e.split(" ").slice(0,-1).reduce((function(e,n,t){var a=e[t-1]?e[t-1]+" ":"";return e.concat([a+n])}),[]).forEach((function(e){t[e]||(t[e]="null")}))}),this)}},n.handler.getStatusText=function(e,n){var t="";return n.count&&(t+=n.count),n.keyChain&&(t+=" "+n.keyChain),t},n.handler.handleKeyboard=function(e,n,t,a){if(-1!==a){var o=e.editor;if(o._signal("changeStatus"),-1==n&&(o.pushEmacsMark(),e.count)){var r=new Array(e.count+1).join(t);return e.count=null,{command:"insertstring",args:r}}var i=m[n];if("c-"==i||e.count)if("number"===typeof(l=parseInt(t[t.length-1]))&&!isNaN(l))return e.count=Math.max(e.count,0)||0,e.count=10*e.count+l,{command:"null"};i&&(t=i+t),e.keyChain&&(t=e.keyChain+=" "+t);var s=this.commandKeyBinding[t];if(e.keyChain="null"==s?t:"",s){if("null"===s)return{command:"null"};if("universalArgument"===s)return e.count=-4,{command:"null"};var c;if("string"!==typeof s&&(c=s.args,s.command&&(s=s.command),"goorselect"===s&&(s=o.emacsMark()?c[1]:c[0],c=null)),"string"!==typeof s||("insertstring"!==s&&"splitline"!==s&&"togglecomment"!==s||o.pushEmacsMark(),s=this.commands[s]||o.commands.commands[s])){if(s.readOnly||s.isYank||(e.lastCommand=null),!s.readOnly&&o.emacsMark()&&o.setEmacsMark(null),e.count){var l=e.count;if(e.count=0,!s||!s.handlesCount)return{args:c,command:{exec:function(e,n){for(var t=0;t<l;t++)s.exec(e,n)},multiSelectAction:s.multiSelectAction}};c||(c={}),"object"===typeof c&&(c.count=l)}return{command:s,args:c}}}}},n.emacsKeys={"Up|C-p":{command:"goorselect",args:["golineup","selectup"]},"Down|C-n":{command:"goorselect",args:["golinedown","selectdown"]},"Left|C-b":{command:"goorselect",args:["gotoleft","selectleft"]},"Right|C-f":{command:"goorselect",args:["gotoright","selectright"]},"C-Left|M-b":{command:"goorselect",args:["gotowordleft","selectwordleft"]},"C-Right|M-f":{command:"goorselect",args:["gotowordright","selectwordright"]},"Home|C-a":{command:"goorselect",args:["gotolinestart","selecttolinestart"]},"End|C-e":{command:"goorselect",args:["gotolineend","selecttolineend"]},"C-Home|S-M-,":{command:"goorselect",args:["gotostart","selecttostart"]},"C-End|S-M-.":{command:"goorselect",args:["gotoend","selecttoend"]},"S-Up|S-C-p":"selectup","S-Down|S-C-n":"selectdown","S-Left|S-C-b":"selectleft","S-Right|S-C-f":"selectright","S-C-Left|S-M-b":"selectwordleft","S-C-Right|S-M-f":"selectwordright","S-Home|S-C-a":"selecttolinestart","S-End|S-C-e":"selecttolineend","S-C-Home":"selecttostart","S-C-End":"selecttoend","C-l":"recenterTopBottom","M-s":"centerselection","M-g":"gotoline","C-x C-p":"selectall","C-Down":{command:"goorselect",args:["gotopagedown","selectpagedown"]},"C-Up":{command:"goorselect",args:["gotopageup","selectpageup"]},"PageDown|C-v":{command:"goorselect",args:["gotopagedown","selectpagedown"]},"PageUp|M-v":{command:"goorselect",args:["gotopageup","selectpageup"]},"S-C-Down":"selectpagedown","S-C-Up":"selectpageup","C-s":"iSearch","C-r":"iSearchBackwards","M-C-s":"findnext","M-C-r":"findprevious","S-M-5":"replace",Backspace:"backspace","Delete|C-d":"del","Return|C-m":{command:"insertstring",args:"\n"},"C-o":"splitline","M-d|C-Delete":{command:"killWord",args:"right"},"C-Backspace|M-Backspace|M-Delete":{command:"killWord",args:"left"},"C-k":"killLine","C-y|S-Delete":"yank","M-y":"yankRotate","C-g":"keyboardQuit","C-w|C-S-W":"killRegion","M-w":"killRingSave","C-Space":"setMark","C-x C-x":"exchangePointAndMark","C-t":"transposeletters","M-u":"touppercase","M-l":"tolowercase","M-/":"autocomplete","C-u":"universalArgument","M-;":"togglecomment","C-/|C-x u|S-C--|C-z":"undo","S-C-/|S-C-x u|C--|S-C-z":"redo","C-x r":"selectRectangularRegion","M-x":{command:"focusCommandLine",args:"M-x "}},n.handler.bindKeys(n.emacsKeys),n.handler.addCommands({recenterTopBottom:function(e){var n=e.renderer,t=n.$cursorLayer.getPixelPosition(),a=n.$size.scrollerHeight-n.lineHeight,o=n.scrollTop;o=Math.abs(t.top-o)<2?t.top-a:Math.abs(t.top-o-.5*a)<2?t.top:t.top-.5*a,e.session.setScrollTop(o)},selectRectangularRegion:function(e){e.multiSelect.toggleBlockSelection()},setMark:{exec:function(e,n){if(n&&n.count)return e.inMultiSelectMode?e.forEachSelection(i):i(),void i();var t=e.emacsMark(),a=e.selection.getAllRanges(),o=a.map((function(e){return{row:e.start.row,column:e.start.column}})),r=a.every((function(e){return e.isEmpty()}));if(t||!r)return e.inMultiSelectMode?e.forEachSelection({exec:e.clearSelection.bind(e)}):e.clearSelection(),void(t&&e.pushEmacsMark(null));if(!t)return o.forEach((function(n){e.pushEmacsMark(n)})),void e.setEmacsMark(o[o.length-1]);function i(){var n=e.popEmacsMark();n&&e.moveCursorToPosition(n)}},readOnly:!0,handlesCount:!0},exchangePointAndMark:{exec:function(e,n){var t=e.selection;if(n.count||t.isEmpty())if(n.count){var a={row:t.lead.row,column:t.lead.column};t.clearSelection(),t.moveCursorToPosition(e.emacsMarkForSelection(a))}else t.selectToPosition(e.emacsMarkForSelection());else t.setSelectionRange(t.getRange(),!t.isBackwards())},readOnly:!0,handlesCount:!0,multiSelectAction:"forEach"},killWord:{exec:function(e,t){e.clearSelection(),"left"==t?e.selection.selectWordLeft():e.selection.selectWordRight();var a=e.getSelectionRange(),o=e.session.getTextRange(a);n.killRing.add(o),e.session.remove(a),e.clearSelection()},multiSelectAction:"forEach"},killLine:function(e){e.pushEmacsMark(null),e.clearSelection();var t=e.getSelectionRange(),a=e.session.getLine(t.start.row);t.end.column=a.length,a=a.substr(t.start.column);var o=e.session.getFoldLine(t.start.row);o&&t.end.row!=o.end.row&&(t.end.row=o.end.row,a="x"),/^\s*$/.test(a)&&(t.end.row++,a=e.session.getLine(t.end.row),t.end.column=/^\s*$/.test(a)?a.length:0);var r=e.session.getTextRange(t);e.prevOp.command==this?n.killRing.append(r):n.killRing.add(r),e.session.remove(t),e.clearSelection()},yank:function(e){e.onPaste(n.killRing.get()||""),e.keyBinding.$data.lastCommand="yank"},yankRotate:function(e){"yank"==e.keyBinding.$data.lastCommand&&(e.undo(),e.session.$emacsMarkRing.pop(),e.onPaste(n.killRing.rotate()),e.keyBinding.$data.lastCommand="yank")},killRegion:{exec:function(e){n.killRing.add(e.getCopyText()),e.commands.byName.cut.exec(e),e.setEmacsMark(null)},readOnly:!0,multiSelectAction:"forEach"},killRingSave:{exec:function(e){e.$handlesEmacsOnCopy=!0;var t=e.session.$emacsMarkRing.slice(),a=[];n.killRing.add(e.getCopyText()),setTimeout((function(){function n(){var n=e.selection,t=n.getRange(),o=n.isBackwards()?t.end:t.start;a.push({row:o.row,column:o.column}),n.clearSelection()}e.$handlesEmacsOnCopy=!1,e.inMultiSelectMode?e.forEachSelection({exec:n}):n(),e.setEmacsMark(null),e.session.$emacsMarkRing=t.concat(a.reverse())}),0)},readOnly:!0},keyboardQuit:function(e){e.selection.clearSelection(),e.setEmacsMark(null),e.keyBinding.$data.count=null},focusCommandLine:function(e,n){e.showCommandLine&&e.showCommandLine(n)}}),n.handler.addCommands(o.iSearchStartCommands);var u=n.handler.commands;u.yank.isYank=!0,u.yankRotate.isYank=!0,n.killRing={$data:[],add:function(e){e&&this.$data.push(e),this.$data.length>30&&this.$data.shift()},append:function(e){var n=this.$data.length-1,t=this.$data[n]||"";e&&(t+=e),t&&(this.$data[n]=t)},get:function(e){return e=e||1,this.$data.slice(this.$data.length-e,this.$data.length).reverse().join("\n")},pop:function(){return this.$data.length>1&&this.$data.pop(),this.get()},rotate:function(){return this.$data.unshift(this.$data.pop()),this.get()}}})),ace.require(["ace/keyboard/emacs"],(function(e){"object"==typeof module&&"object"==typeof exports&&module&&(module.exports=e)})); |