Current File : /home/pacjaorg/public_html/kmm/media/vendor/codemirror/addon/search/matchesonscrollbar.min.js |
(function(n){typeof exports=="object"&&typeof module=="object"?n(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):typeof define=="function"&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],n):n(CodeMirror)})(function(n){"use strict";n.defineExtension("showMatchesOnScrollbar",function(t,e,i){return typeof i=="string"&&(i={className:i}),i||(i={}),new o(this,t,e,i)});function o(t,e,i,s){this.cm=t,this.options=s;var r={listenForChanges:!1};for(var a in s)r[a]=s[a];r.className||(r.className="CodeMirror-search-match"),this.annotation=t.annotateScrollbar(r),this.query=e,this.caseFold=i,this.gap={from:t.firstLine(),to:t.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var f=this;t.on("change",this.changeHandler=function(l,c){f.onChange(c)})}var u=1e3;o.prototype.findMatches=function(){if(this.gap){for(var t=0;t<this.matches.length;t++){var e=this.matches[t];if(e.from.line>=this.gap.to)break;e.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var i=this.cm.getSearchCursor(this.query,n.Pos(this.gap.from,0),{caseFold:this.caseFold,multiline:this.options.multiline}),s=this.options&&this.options.maxMatches||u;i.findNext();){var e={from:i.from(),to:i.to()};if(e.from.line>=this.gap.to||(this.matches.splice(t++,0,e),this.matches.length>s))break}this.gap=null}};function h(t,e,i){return t<=e?t:Math.max(e,t+i)}o.prototype.onChange=function(t){var e=t.from.line,i=n.changeEnd(t).line,s=i-t.to.line;if(this.gap?(this.gap.from=Math.min(h(this.gap.from,e,s),t.from.line),this.gap.to=Math.max(h(this.gap.to,e,s),t.from.line)):this.gap={from:t.from.line,to:i+1},s)for(var r=0;r<this.matches.length;r++){var a=this.matches[r],f=h(a.from.line,e,s);f!=a.from.line&&(a.from=n.Pos(f,a.from.ch));var l=h(a.to.line,e,s);l!=a.to.line&&(a.to=n.Pos(l,a.to.ch))}clearTimeout(this.update);var c=this;this.update=setTimeout(function(){c.updateAfterChange()},250)},o.prototype.updateAfterChange=function(){this.findMatches(),this.annotation.update(this.matches)},o.prototype.clear=function(){this.cm.off("change",this.changeHandler),this.annotation.clear()}});