import { ICommandInfo, parseCommand } from '@tcbox/command-parser'; import { Eveit } from 'eveit'; import { HistoryStack } from 'history-stack'; import { Dom } from 'link-dom'; export interface IEditorOptions { header?: string; paddingLeft?: number; paddingTop?: number; size?: "full" | "auto"; fontSize?: number; mode?: "full" | "inline"; tab?: string; } export interface ICursorChangeData { x: number; y: number; word: string; wordWidth: number; beforeValue: string; value: string; } declare class Editor extends Eveit<{ key: [ "Enter" | "ArrowUp" | "ArrowDown" | "Tab" ]; input: [ ]; "cursor-change": [ ICursorChangeData ]; "edit-done": [ string ]; "edit-cancel": [ ]; }> { SingleCharWidth: number; MultiCharWidth: number; fontSize: number; lineHeight: number; container: Dom; textarea: Dom; cursor: Dom; private cursorText; ctx: CanvasRenderingContext2D; wrapLine: boolean; private paddingTop; private paddingLeft; store: import("link-dom").IStore<{ cx: number; cy: number; }, import("link-dom").IActions<{ cx: number; cy: number; }, unknown>>; setFontSize(v: number): void; private size; private mode; get value(): string; get fullValue(): string; get beforeValue(): string; constructor({ header, paddingTop, paddingLeft, size, mode, tab, fontSize, }: IEditorOptions); header: string; private _prevHeader; private _prevHeaderWidth; get headerWidth(): number; private _monitorStart; render(): void; private _pasteTimer; private initEvents; private _countContentHeight; private _countContentSize; private countSingleLineInfo; private _onSelectionChange; private compatSelChange; private measureTextWidth; private _getLineBoxWidth; private _prevPos; private getCursorPosition; private _isShowCursor; private showCursor; private relocateCursorPosition; focus(): void; pushText(v: string): void; insertText(content: string): void; replaceText(v: string): void; clearContent(relocate?: boolean): void; setCursorToHead(): void; setCursorPos(n: number): void; resize(fromInit?: boolean): void; } export type IPromiseMaybe = Promise | T; export interface IWebTermEvents { "enter": [ string ]; "tab": [ string ]; "input": [ string, string ]; "cursor-change": [ ICursorChangeData ]; "command": [ ICommandInfo, ICommandInfo[] ]; } export interface IWebTermStyle { padding?: number; color?: string; background?: string; selectionColor?: string; selectionBackground?: string; fontSize?: number; } export interface IWebTermOptions { title?: string; titleHtml?: boolean; container?: string | HTMLElement; historyMax?: number; storageProvider?: { read: () => IPromiseMaybe; write: (history: string) => IPromiseMaybe; }; header?: string; theme?: "dark" | "light"; style?: IWebTermStyle; parseCommand?: boolean; } export type IContent = string | number | boolean | Dom | HTMLElement; declare class TermHistory { history: HistoryStack; pushedCurrent: boolean; provider: Required["storageProvider"]; constructor(max: number, provider: Required["storageProvider"]); private _initHistory; up(line: string): string | null; down(): string | null; checkLatest(line: string): void; push(content: string): void; private save; clear(): void; } declare class TermDisplay { container: Dom; constructor(); pushContent(content: IContent, html: boolean): void; } declare class TermBelow { container: Dom; constructor(); write(content: IContent, html: boolean): void; push(content: IContent, html: boolean): void; clear(): void; } export declare class WebTerm extends Eveit { history: TermHistory; container: Dom; title: string; mainContainer: Dom; input: Editor; display: TermDisplay; below: TermBelow; style: Required; store: import("link-dom").IStore<{ showEditor: boolean; }, import("link-dom").IActions<{ showEditor: boolean; }, unknown>>; theme: "dark" | "light"; private editManager; private _parseCommand; constructor({ title, titleHtml, historyMax, storageProvider, container, header, theme, style, parseCommand, }?: IWebTermOptions); get value(): string; get beforeValue(): string; get header(): string; private initEvents; private render; setTheme(theme: "light" | "dark"): void; setColor(opt: Pick): void; private _setFontSize; get fontSize(): number; setFontSize(size: number): void; clearInputHistory(): void; write(content: IContent, { html, clear, }?: { html?: boolean; clear?: boolean; }): void; insertText(content: string): void; clearContent(): void; setCursorPos(index: number): void; edit(v?: string, opt?: { title?: string; html?: boolean; }): Editor; clearTerminal(): void; newLine(html?: boolean): void; setHeader(header: string): void; scrollToBottom(): void; focus(): void; writeBelow(content: IContent, html?: boolean): void; pushBelow(content: IContent, html?: boolean): void; clearBelow(): void; resize(): void; parseCommand(v: string): import("@tcbox/command-parser").ICommandInfo[]; } export declare function isCtrlPressed(e: KeyboardEvent): boolean; export { ICommandInfo, parseCommand, }; export {};