]> git.proxmox.com Git - mirror_xterm.js.git/blob - src/addons/search/search.ts
Merge branch 'master' into bad_getOption_param
[mirror_xterm.js.git] / src / addons / search / search.ts
1 /**
2 * @license MIT
3 */
4
5 import { SearchHelper } from './SearchHelper';
6
7 declare var exports: any;
8 declare var module: any;
9 declare var define: any;
10 declare var require: any;
11 declare var window: any;
12
13 (function (addon) {
14 if ('Terminal' in window) {
15 /**
16 * Plain browser environment
17 */
18 addon(window.Terminal);
19 } else if (typeof exports === 'object' && typeof module === 'object') {
20 /**
21 * CommonJS environment
22 */
23 const xterm = '../../xterm';
24 module.exports = addon(require(xterm));
25 } else if (typeof define == 'function') {
26 /**
27 * Require.js is available
28 */
29 define(['../../xterm'], addon);
30 }
31 })((Terminal: any) => {
32 /**
33 * Find the next instance of the term, then scroll to and select it. If it
34 * doesn't exist, do nothing.
35 * @param term Tne search term.
36 * @return Whether a result was found.
37 */
38 Terminal.prototype.findNext = function(term: string): boolean {
39 if (!this._searchHelper) {
40 this.searchHelper = new SearchHelper(this, Terminal.translateBufferLineToString);
41 }
42 return (<SearchHelper>this.searchHelper).findNext(term);
43 };
44
45 /**
46 * Find the previous instance of the term, then scroll to and select it. If it
47 * doesn't exist, do nothing.
48 * @param term Tne search term.
49 * @return Whether a result was found.
50 */
51 Terminal.prototype.findPrevious = function(term: string): boolean {
52 if (!this._searchHelper) {
53 this.searchHelper = new SearchHelper(this, Terminal.translateBufferLineToString);
54 }
55 return (<SearchHelper>this.searchHelper).findPrevious(term);
56 };
57 });