|
|
|
!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(u){"use strict";var r=u.commands,d=u.Pos;function t(t,n){t.extendSelectionsBy(function(e){return t.display.shift||t.doc.extend||e.empty()?function(e,t,n){if(n<0&&0==t.ch)return e.clipPos(d(t.line-1));var r=e.getLine(t.line);if(0<n&&t.ch>=r.length)return e.clipPos(d(t.line+1,0));for(var o,i="start",l=t.ch,a=l,s=n<0?0:r.length;a!=s;a+=n,0){var c=r.charAt(n<0?a-1:a),f="_"!=c&&u.isWordChar(c)?"w":"o";if("w"==f&&c.toUpperCase()==c&&(f="W"),"start"==i)"o"!=f?(i="in",o=f):l=a+n;else if("in"==i&&o!=f){if("w"==o&&"W"==f&&n<0&&a--,"W"==o&&"w"==f&&0<n){if(a==l+1){o="w";continue}a--}break}}return d(t.line,a)}(t.doc,e.head,n):n<0?e.from():e.to()})}function n(l,a){if(l.isReadOnly())return u.Pass;l.operation(function(){for(var e=l.listSelections().length,t=[],n=-1,r=0;r<e;r++){var o,i=l.listSelections()[r].head;i.line<=n||(o=d(i.line+(a?0:1),0),l.replaceRange("\n",o,null,"+insertLine"),l.indentLine(o.line,null,!0),t.push({head:o,anchor:o}),n=i.line+1)}l.setSelections(t)}),l.execCommand("indentAuto")}function c(e,t){for(var n=t.ch,r=n,o=e.getLine(t.line);n&&u.isWordChar(o.charAt(n-1));)--n;for(;r<o.length&&u.isWordChar(o.charAt(r));)++r;return{from:d(t.line,n),to:d(t.line,r),word:o.slice(n,r)}}function o(e,t){for(var n=e.listSelections(),r=[],o=0;o<n.length;o++){var i=n[o],l=e.findPosV(i.anchor,t,"line",i.anchor.goalColumn),a=e.findPosV(i.head,t,"line",i.head.goalColumn);l.goalColumn=null!=i.anchor.goalColumn?i.anchor.goalColumn:e.cursorCoords(i.anchor,"div").left,a.goalColumn=null!=i.head.goalColumn?i.head.goalColumn:e.cursorCoords(i.head,"div").left;var s={anchor:l,head:a};r.push(i),r.push(s)}e.setSelections(r)}r.goSubwordLeft=function(e){t(e,-1)},r.goSubwordRight=function(e){t(e,1)},r.scrollLineUp=function(e){var t,n=e.getScrollInfo();e.somethingSelected()||(t=e.lineAtHeight(n.top+n.clientHeight,"local"),e.getCursor().line>=t&&e.execCommand("goLineUp")),e.scrollTo(null,n.top-e.defaultTextHeight())},r.scrollLineDown=function(e){var t,n=e.getScrollInfo();e.somethingSelected()||(t=e.lineAtHeight(n.top,"local")+1,e.getCursor().line<=t&&e.execCommand("goLineDown")),e.scrollTo(null,n.top+e.defaultTextHeight())},r.splitSelectionByLine=function(e){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++)for(var o=t[r].from(),i=t[r].to(),l=o.line;l<=i.line;++l)i.line>o.line&&l==i.line&&0==i.ch||n.push({anchor:l==o.line?o:d(l,0),head:l==i.line?i:d(l)});e.setSelections(n,0)},r.singleSelectionTop=function(e){var t=e.listSelections()[0];e.setSelection(t.anchor,t.head,{scroll:!1})},r.selectLine=function(e){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){var o=t[r];n.push({anchor:d(o.from().line,0),head:d(o.to().line+1,0)})}e.setSelections(n)},r.insertLineAfter=function(e){return n(e,!1)},r.insertLineBefore=function(e){return n(e,!0)},r.selectNextOccurrence=function(e){var t=e.getCursor("from"),n=e.getCursor("to"),r=e.state.sublimeFindFullWord==e.doc.sel;if(0==u.cmpPos(t,n)){var o=c(e,t);if(!o.word)return;e.setSelection(o.from,o.to),r=!0}else{var i=e.getRange(t,n),l=r?new RegExp("\\b"+i+"\\b"):i,a=e.getSearchCursor(l,n);if(!(a.findNext()||(a=e.getSearchCursor(l,d(e.firstLine(),0))).findNext())||function(e,t,n){for(var r=0;r<e.length;r++)if(0==u.cmpPos(e[r].from(),t)&&0==u.cmpPos(e[r].to(),n))return!0;return!1}(e.listSelections(),a.from(),a.to()))return;e.addSelection(a.from(),a.to())}r&&(e.state.sublimeFindFullWord=e.doc.sel)},r.skipAndSelectNextOccurrence=function(e){var t=e.getCursor("anchor"),n=e.getCursor("head");r.selectNextOccurrence(e),0!=u.cmpPos(t,n)&&e.doc.setSelections(e.doc.listSelections().filter(function(e){return e.anchor!=t||e.head!=n}))},r.addCursorToPrevLine=function(e){o(e,-1)},r.addCursorToNextLine=function(e){o(e,1)};var f="(){}[]";function i(e){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){var
|