feat: 终端内搜索.

This commit is contained in:
lijiahangmax
2024-01-13 02:22:03 +08:00
parent c16a461e5c
commit c0475dc7de
10 changed files with 314 additions and 77 deletions

View File

@@ -7,7 +7,7 @@ import { InputProtocol } from '../types/terminal.protocol';
import { ITerminalOptions, Terminal } from 'xterm';
import { FitAddon } from 'xterm-addon-fit';
import { WebLinksAddon } from 'xterm-addon-web-links';
import { SearchAddon } from 'xterm-addon-search';
import { ISearchOptions, SearchAddon } from 'xterm-addon-search';
import { ImageAddon } from 'xterm-addon-image';
import { CanvasAddon } from 'xterm-addon-canvas';
import { WebglAddon } from 'xterm-addon-webgl';
@@ -235,6 +235,15 @@ export default class TerminalSession implements ITerminalSession {
return selection;
}
// 查找
find(word: string, next: boolean, options: ISearchOptions): void {
if (next) {
this.addons.search.findNext(word, options);
} else {
this.addons.search.findPrevious(word, options);
}
}
// 去顶部
toTop(): void {
this.inst.scrollToTop();