Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/media/editors/codemirror/addon/search/ |
| [Home] [System Details] [Kill Me] |
!(function(a){"object"==typeof
exports&&"object"==typeof
module?a(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof
define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],a):a(CodeMirror)})((function(a){"use
strict";function b(a,b){return"string"==typeof a?a=new
RegExp(a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),b?"gi":"g"):a.global||(a=new
RegExp(a.source,a.ignoreCase?"gi":"g")),{token:function(b){a.lastIndex=b.pos;var
c=a.exec(b.string);if(c&&c.index==b.pos)return
b.pos+=c[0].length||1,"searching";c?b.pos=c.index:b.skipToEnd()}}}function
c(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function
d(a){return a.state.search||(a.state.search=new c)}function
e(a){return"string"==typeof
a&&a==a.toLowerCase()}function f(a,b,c){return
a.getSearchCursor(b,c,{caseFold:e(b),multiline:!0})}function
g(a,b,c,d,e){a.openDialog(b,d,{value:c,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){o(a)},onKeyDown:e})}function
h(a,b,c,d,e){a.openDialog?a.openDialog(b,e,{value:d,selectValueOnOpen:!0}):e(prompt(c,d))}function
i(a,b,c,d){a.openConfirm?a.openConfirm(b,d):confirm(c)&&d[0]()}function
j(a){return
a.replace(/\\([nrt\\])/g,(function(a,b){return"n"==b?"\n":"r"==b?"\r":"t"==b?"\t":"\\"==b?"\\":a}))}function
k(a){var b=a.match(/^\/(.*)\/([a-z]*)$/);if(b)try{a=new
RegExp(b[1],-1==b[2].indexOf("i")?"":"i")}catch(a){}else
a=j(a);return("string"==typeof
a?""==a:a.test(""))&&(a=/x^/),a}function
l(a,c,d){c.queryText=d,c.query=k(d),a.removeOverlay(c.overlay,e(c.query)),c.overlay=b(c.query,e(c.query)),a.addOverlay(c.overlay),a.showMatchesOnScrollbar&&(c.annotate&&(c.annotate.clear(),c.annotate=null),c.annotate=a.showMatchesOnScrollbar(c.query,e(c.query)))}function
m(b,c,e,f){var i=d(b);if(i.query)return n(b,c);var
j=b.getSelection()||i.lastQuery;if(j instanceof
RegExp&&"x^"==j.source&&(j=null),e&&b.openDialog){var
k=null,m=function(c,d){a.e_stop(d),c&&(c!=i.queryText&&(l(b,i,c),i.posFrom=i.posTo=b.getCursor()),k&&(k.style.opacity=1),n(b,d.shiftKey,(function(a,c){var
d;c.line<3&&document.querySelector&&(d=b.display.wrapper.querySelector(".CodeMirror-dialog"))&&d.getBoundingClientRect().bottom-4>b.cursorCoords(c,"window").top&&((k=d).style.opacity=.4)})))};g(b,p(b),j,m,(function(c,e){var
f=a.keyName(c),g=b.getOption("extraKeys"),h=g&&g[f]||a.keyMap[b.getOption("keyMap")][f];"findNext"==h||"findPrev"==h||"findPersistentNext"==h||"findPersistentPrev"==h?(a.e_stop(c),l(b,d(b),e),b.execCommand(h)):"find"!=h&&"findPersistent"!=h||(a.e_stop(c),m(e,c))})),f&&j&&(l(b,i,j),n(b,c))}else
h(b,p(b),"Search
for:",j,(function(a){a&&!i.query&&b.operation((function(){l(b,i,a),i.posFrom=i.posTo=b.getCursor(),n(b,c)}))}))}function
n(b,c,e){b.operation((function(){var
g=d(b),h=f(b,g.query,c?g.posFrom:g.posTo);(h.find(c)||(h=f(b,g.query,c?a.Pos(b.lastLine()):a.Pos(b.firstLine(),0)),h.find(c)))&&(b.setSelection(h.from(),h.to()),b.scrollIntoView({from:h.from(),to:h.to()},20),g.posFrom=h.from(),g.posTo=h.to(),e&&e(h.from(),h.to()))}))}function
o(a){a.operation((function(){var
b=d(a);b.lastQuery=b.query,b.query&&(b.query=b.queryText=null,a.removeOverlay(b.overlay),b.annotate&&(b.annotate.clear(),b.annotate=null))}))}function
p(a){return'<span
class="CodeMirror-search-label">'+a.phrase("Search:")+'</span>
<input type="text" style="width: 10em"
class="CodeMirror-search-field"/> <span style="color:
#888"
class="CodeMirror-search-hint">'+a.phrase("(Use /re/
syntax for regexp search)")+"</span>"}function
q(a){return' <input type="text" style="width:
10em" class="CodeMirror-search-field"/> <span
style="color: #888"
class="CodeMirror-search-hint">'+a.phrase("(Use /re/
syntax for regexp search)")+"</span>"}function
r(a){return'<span
class="CodeMirror-search-label">'+a.phrase("With:")+'</span>
<input type="text" style="width: 10em"
class="CodeMirror-search-field"/>'}function
s(a){return'<span
class="CodeMirror-search-label">'+a.phrase("Replace?")+"</span>
<button>"+a.phrase("Yes")+"</button>
<button>"+a.phrase("No")+"</button>
<button>"+a.phrase("All")+"</button>
<button>"+a.phrase("Stop")+"</button>
"}function t(a,b,c){a.operation((function(){for(var
d=f(a,b);d.findNext();)if("string"!=typeof b){var
e=a.getRange(d.from(),d.to()).match(b);d.replace(c.replace(/\$(\d)/g,(function(a,b){return
e[b]})))}else d.replace(c)}))}function
u(a,b){if(!a.getOption("readOnly")){var
c=a.getSelection()||d(a).lastQuery,e='<span
class="CodeMirror-search-label">'+(b?a.phrase("Replace
all:"):a.phrase("Replace:"))+"</span>";h(a,e+q(a),e,c,(function(c){c&&(c=k(c),h(a,r(a),a.phrase("Replace
with:"),"",(function(d){if(d=j(d),b)t(a,c,d);else{o(a);var
e=f(a,c,a.getCursor("from")),g=function(){var
b,j=e.from();!(b=e.findNext())&&(e=f(a,c),!(b=e.findNext())||j&&e.from().line==j.line&&e.from().ch==j.ch)||(a.setSelection(e.from(),e.to()),a.scrollIntoView({from:e.from(),to:e.to()}),i(a,s(a),a.phrase("Replace?"),[function(){h(b)},g,function(){t(a,c,d)}]))},h=function(a){e.replace("string"==typeof
c?d:d.replace(/\$(\d)/g,(function(b,c){return
a[c]}))),g()};g()}})))}))}}a.commands.find=function(a){o(a),m(a)},a.commands.findPersistent=function(a){o(a),m(a,!1,!0)},a.commands.findPersistentNext=function(a){m(a,!1,!0,!0)},a.commands.findPersistentPrev=function(a){m(a,!0,!0,!0)},a.commands.findNext=m,a.commands.findPrev=function(a){m(a,!0)},a.commands.clearSearch=o,a.commands.replace=u,a.commands.replaceAll=function(a){u(a,!0)}}));