1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
|
|
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).search=e()}}(function(){return function s(o,l,a){function h(i,e){if(!l[i]){if(!o[i]){var t="function"==typeof require&&require;if(!e&&t)return t(i,!0);if(f)return f(i,!0);var r=new Error("Cannot find module '"+i+"'");throw r.code="MODULE_NOT_FOUND",r}var n=l[i]={exports:{}};o[i][0].call(n.exports,function(e){return h(o[i][1][e]||e)},n,n.exports,s,o,l,a)}return l[i].exports}for(var f="function"==typeof require&&require,e=0;e<a.length;e++)h(a[e]);return h}({1:[function(e,i,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=" ~!@#$%^&*()+`-=[]{}|;:\"',./<>?",n=(s.prototype.findNext=function(e,i){var t,r=i.incremental;if(!e||0===e.length)return this._terminal.clearSelection(),!1;var n=0,s=this._terminal.buffer.viewportY;if(this._terminal.hasSelection()){var o=this._terminal.getSelectionPosition();s=r?o.startRow:o.endRow,n=r?o.startColumn:o.endColumn}this._initLinesCache();for(var l=s,a=n;this._terminal.buffer.getLine(l).isWrapped;)l--,a+=this._terminal.cols;if(!(t=this._findInLine(e,l,a,i)))for(var h=s+1;h<this._terminal.buffer.baseY+this._terminal.rows&&!(t=this._findInLine(e,h,0,i));h++);if(!t)for(h=0;h<l&&!(t=this._findInLine(e,h,0,i));h++);return this._selectResult(t)},s.prototype.findPrevious=function(e,i){var t;if(!e||0===e.length)return this._terminal.clearSelection(),!1;var r=this._terminal.buffer.viewportY+this._terminal.rows-1,n=this._terminal.cols;if(this._terminal.hasSelection()){var s=this._terminal.getSelectionPosition();r=s.startRow,n=s.startColumn}if(this._initLinesCache(),!(t=this._findInLine(e,r,n,i,!0))){var o=this._terminal.cols;this._terminal.buffer.getLine(r).isWrapped&&(o+=n);for(var l=r-1;0<=l&&!(t=this._findInLine(e,l,o,i,!0));l--)this._terminal.buffer.getLine(l).isWrapped?o+=this._terminal.cols:o=this._terminal.cols}if(!t){var a=this._terminal.buffer.baseY+this._terminal.rows-1;for(o=this._terminal.cols,l=a;r<=l&&!(t=this._findInLine(e,l,o,i,!0));l--)this._terminal.buffer.getLine(l).isWrapped?o+=this._terminal.cols:o=this._terminal.cols}return this._selectResult(t)},s.prototype._initLinesCache=function(){var e=this;this._linesCache||(this._linesCache=new Array(this._terminal.buffer.length),this._cursorMoveListener=this._terminal.onCursorMove(function(){return e._destroyLinesCache()}),this._resizeListener=this._terminal.onResize(function(){return e._destroyLinesCache()})),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout(function(){return e._destroyLinesCache()},15e3)},s.prototype._destroyLinesCache=function(){this._linesCache=null,this._cursorMoveListener&&(this._cursorMoveListener.dispose(),this._cursorMoveListener=void 0),this._resizeListener&&(this._resizeListener.dispose(),this._resizeListener=void 0),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)},s.prototype._isWholeWord=function(e,i,t){return!(0!==e&&-1===r.indexOf(i[e-1])||e+t.length!==i.length&&-1===r.indexOf(i[e+t.length]))},s.prototype._findInLine=function(e,i,t,r,n){if(void 0===r&&(r={}),void 0===n&&(n=!1),!this._terminal.buffer.getLine(i).isWrapped){var s=this._linesCache?this._linesCache[i]:void 0;void 0===s&&(s=this.translateBufferLineToStringWithWrap(i,!0),this._linesCache&&(this._linesCache[i]=s));var o=r.caseSensitive?e:e.toLowerCase(),l=r.caseSensitive?s:s.toLowerCase(),a=-1;if(r.regex){var h=RegExp(o,"g"),f=void 0;if(n)for(;f=h.exec(l.slice(0,t));)a=h.lastIndex-f[0].length,e=f[0],h.lastIndex-=e.length-1;else(f=h.exec(l.slice(t)))&&0<f[0].length&&(a=t+(h.lastIndex-f[0].length),e=f[0])}else n?0<=t-o.length&&(a=l.lastIndexOf(o,t-o.length)):a=l.indexOf(o,t);if(0<=a){if(a>=this._terminal.cols&&(i+=Math.floor(a/this._terminal.cols),a%=this._terminal.cols),r.wholeWord&&!this._isWholeWord(a,l,e))return;for(var c=this._terminal.buffer.getLine(i),u=0;u<a;u++){var _=c.get
|