import { Injector } from '@angular/core' import { Observable, Subject, AsyncSubject, ReplaySubject, BehaviorSubject } from 'rxjs' import { BaseTerminalProfile, ResizeEvent } from '../api/interfaces' export interface SearchOptions { regex?: boolean wholeWord?: boolean caseSensitive?: boolean incremental?: true } export interface SearchState { resultIndex?: number resultCount: number } /** * Extend to add support for a different VT frontend implementation */ export abstract class Frontend { enableResizing = true protected ready = new AsyncSubject() protected title = new ReplaySubject(1) protected alternateScreenActive = new BehaviorSubject(false) protected mouseEvent = new Subject() protected bell = new Subject() protected contentUpdated = new Subject() protected input = new Subject() protected resize = new ReplaySubject(1) protected dragOver = new Subject() protected drop = new Subject() protected destroyed = new Subject() get ready$ (): Observable { return this.ready } get title$ (): Observable { return this.title } get alternateScreenActive$ (): Observable { return this.alternateScreenActive } get mouseEvent$ (): Observable { return this.mouseEvent } get bell$ (): Observable { return this.bell } get contentUpdated$ (): Observable { return this.contentUpdated } get input$ (): Observable { return this.input } get resize$ (): Observable { return this.resize } get dragOver$ (): Observable { return this.dragOver } get drop$ (): Observable { return this.drop } get destroyed$ (): Observable { return this.destroyed } constructor (protected injector: Injector) { } destroy (): void { this.destroyed.next() for (const o of [ this.ready, this.title, this.alternateScreenActive, this.mouseEvent, this.bell, this.contentUpdated, this.input, this.resize, this.dragOver, this.drop, this.destroyed, ]) { o.complete() } } abstract attach (host: HTMLElement, profile: BaseTerminalProfile): Promise detach (host: HTMLElement): void { } // eslint-disable-line abstract getSelection (): string abstract copySelection (): void abstract selectAll (): void abstract clearSelection (): void abstract focus (): void abstract write (data: string): Promise abstract clear (): void abstract visualBell (): void abstract scrollToTop (): void abstract scrollLines (amount: number): void abstract scrollPages (pages: number): void abstract scrollToBottom (): void abstract configure (profile: BaseTerminalProfile): void abstract setZoom (zoom: number): void abstract findNext (term: string, searchOptions?: SearchOptions): SearchState abstract findPrevious (term: string, searchOptions?: SearchOptions): SearchState abstract cancelSearch (): void abstract saveState (): any abstract restoreState (state: string): void abstract supportsBracketedPaste (): boolean abstract isAlternateScreenActive (): boolean }