?
Path : /home/admin/public_html/old/media/editors/codemirror/addon/search/ |
Current File : /home/admin/public_html/old/media/editors/codemirror/addon/search/match-highlighter.min.js |
!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function b(a){"object"==typeof a&&(this.minChars=a.minChars,this.style=a.style,this.showToken=a.showToken,this.delay=a.delay,this.wordsOnly=a.wordsOnly),null==this.style&&(this.style=i),null==this.minChars&&(this.minChars=h),null==this.delay&&(this.delay=j),null==this.wordsOnly&&(this.wordsOnly=k),this.overlay=this.timeout=null}function c(a){var b=a.state.matchHighlighter;clearTimeout(b.timeout),b.timeout=setTimeout(function(){d(a)},b.delay)}function d(a){a.operation(function(){var b=a.state.matchHighlighter;if(b.overlay&&(a.removeOverlay(b.overlay),b.overlay=null),!a.somethingSelected()&&b.showToken){for(var c=b.showToken===!0?/[\w$]/:b.showToken,d=a.getCursor(),f=a.getLine(d.line),h=d.ch,i=h;h&&c.test(f.charAt(h-1));)--h;for(;i<f.length&&c.test(f.charAt(i));)++i;return void(i>h&&a.addOverlay(b.overlay=g(f.slice(h,i),c,b.style)))}var j=a.getCursor("from"),k=a.getCursor("to");if(j.line==k.line&&(!b.wordsOnly||e(a,j,k))){var l=a.getRange(j,k).replace(/^\s+|\s+$/g,"");l.length>=b.minChars&&a.addOverlay(b.overlay=g(l,!1,b.style))}})}function e(a,b,c){var d=a.getRange(b,c);if(null!==d.match(/^\w+$/)){if(b.ch>0){var e={line:b.line,ch:b.ch-1},f=a.getRange(e,b);if(null===f.match(/\W/))return!1}if(c.ch<a.getLine(b.line).length){var e={line:c.line,ch:c.ch+1},f=a.getRange(c,e);if(null===f.match(/\W/))return!1}return!0}return!1}function f(a,b){return!(a.start&&b.test(a.string.charAt(a.start-1))||a.pos!=a.string.length&&b.test(a.string.charAt(a.pos)))}function g(a,b,c){return{token:function(d){return!d.match(a)||b&&!f(d,b)?(d.next(),void(d.skipTo(a.charAt(0))||d.skipToEnd())):c}}}var h=2,i="matchhighlight",j=100,k=!1;a.defineOption("highlightSelectionMatches",!1,function(e,f,g){if(g&&g!=a.Init){var h=e.state.matchHighlighter.overlay;h&&e.removeOverlay(h),clearTimeout(e.state.matchHighlighter.timeout),e.state.matchHighlighter=null,e.off("cursorActivity",c)}f&&(e.state.matchHighlighter=new b(f),d(e),e.on("cursorActivity",c))})});