@opentui/core
Version:
OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)
141 lines (140 loc) • 4.36 kB
TypeScript
import { EventEmitter } from "events";
import type { CliRenderer, ColorInput, MouseEvent } from ".";
import { OptimizedBuffer } from "./buffer";
import { Capture } from "./lib/output.capture";
import { type KeyBinding as BaseKeyBinding, type KeyAliasMap } from "./lib/keymapping";
export declare const capture: Capture;
export declare enum ConsolePosition {
TOP = "top",
BOTTOM = "bottom",
LEFT = "left",
RIGHT = "right"
}
export type ConsoleAction = "scroll-up" | "scroll-down" | "scroll-to-top" | "scroll-to-bottom" | "position-previous" | "position-next" | "size-increase" | "size-decrease" | "save-logs" | "copy-selection";
export type ConsoleKeyBinding = BaseKeyBinding<ConsoleAction>;
export interface ConsoleOptions {
position?: ConsolePosition;
sizePercent?: number;
zIndex?: number;
colorInfo?: ColorInput;
colorWarn?: ColorInput;
colorError?: ColorInput;
colorDebug?: ColorInput;
colorDefault?: ColorInput;
backgroundColor?: ColorInput;
startInDebugMode?: boolean;
title?: string;
titleBarColor?: ColorInput;
titleBarTextColor?: ColorInput;
cursorColor?: ColorInput;
maxStoredLogs?: number;
maxDisplayLines?: number;
onCopySelection?: (text: string) => void;
keyBindings?: ConsoleKeyBinding[];
keyAliasMap?: KeyAliasMap;
selectionColor?: ColorInput;
copyButtonColor?: ColorInput;
}
export declare class TerminalConsole extends EventEmitter {
private isVisible;
private isFocused;
private renderer;
private keyHandler;
private options;
private _debugModeEnabled;
private frameBuffer;
private consoleX;
private consoleY;
private consoleWidth;
private consoleHeight;
private scrollTopIndex;
private isScrolledToBottom;
private currentLineIndex;
private _displayLines;
private _allLogEntries;
private _needsFrameBufferUpdate;
private _entryListener;
private _selectionStart;
private _selectionEnd;
private _isDragging;
private _copyButtonBounds;
private _autoScrollInterval;
private _keyBindingsMap;
private _keyAliasMap;
private _keyBindings;
private _mergedKeyBindings;
private _actionHandlers;
private markNeedsRerender;
private getCopyButtonLabel;
private _rgbaInfo;
private _rgbaWarn;
private _rgbaError;
private _rgbaDebug;
private _rgbaDefault;
private backgroundColor;
private _rgbaTitleBar;
private _rgbaTitleBarText;
private _title;
private _rgbaCursor;
private _rgbaSelection;
private _rgbaCopyButton;
private _positions;
constructor(renderer: CliRenderer, options?: ConsoleOptions);
private buildActionHandlers;
activate(): void;
deactivate(): void;
private _handleNewLog;
private _updateConsoleDimensions;
private handleKeyPress;
private scrollUp;
private scrollDown;
private scrollToTop;
private scrollToBottomAction;
private positionPrevious;
private positionNext;
private sizeIncrease;
private sizeDecrease;
private saveLogsAction;
private triggerCopyAction;
private attachStdin;
private detachStdin;
private formatTimestamp;
private formatArguments;
resize(width: number, height: number): void;
clear(): void;
toggle(): void;
focus(): void;
blur(): void;
show(): void;
hide(): void;
destroy(): void;
getCachedLogs(): string;
private updateFrameBuffer;
renderToBuffer(buffer: OptimizedBuffer): void;
setDebugMode(enabled: boolean): void;
toggleDebugMode(): void;
set keyBindings(bindings: ConsoleKeyBinding[]);
set keyAliasMap(aliases: KeyAliasMap);
set onCopySelection(callback: ((text: string) => void) | undefined);
get onCopySelection(): ((text: string) => void) | undefined;
private _scrollToBottom;
private _processLogEntry;
private _processCachedLogs;
private hasSelection;
private normalizeSelection;
private getSelectedText;
private clearSelection;
private stopAutoScroll;
private startAutoScroll;
private triggerCopy;
private getLineSelectionRange;
handleMouse(event: MouseEvent): boolean;
get visible(): boolean;
get bounds(): {
x: number;
y: number;
width: number;
height: number;
};
private saveLogsToFile;
}