import type { ExtractSegmentsResult, SliceResult } from "@vib-rato/natives"; /** Ellipsis strategy for bounded terminal truncation. Values match the native enum. */ export declare enum Ellipsis { Unicode = 0, Ascii = 1, Omit = 2 } export { getDefaultTabWidth, getIndentation } from "@vib-rato/utils"; /** Test-only performance counters for advisory baseline tests. */ export declare const __textHelperPerfCounters: { truncateToWidthCalls: number; wrapTextWithAnsiCalls: number; truncateLinesToWidthCalls: number; visibleWidthsCalls: number; reset(): void; }; export declare function invalidateTabWidthCache(): void; export declare function isPrintableAscii(text: string): boolean; export declare function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean | null): SliceResult; export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind?: Ellipsis | null, pad?: boolean | null): string; export declare function truncateLinesToWidth(lines: readonly string[], maxWidth: number, ellipsisKind?: Ellipsis | null, pad?: boolean | null): string[]; export declare function wrapTextWithAnsi(text: string, width: number): string[]; export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean): ExtractSegmentsResult; /** * Tab width in columns for `file`, using `process.cwd()` as the project root for relative paths. */ export declare function getIndentationNoescape(file?: string): number; export declare function replaceTabs(text: string, file?: string): string; /** * Returns a string of n spaces. Uses a pre-allocated buffer for efficiency. */ export declare function padding(n: number): string; /** * Get the shared grapheme segmenter instance. */ export declare function getSegmenter(): Intl.Segmenter; export interface ViewportAnchorSpan { graphemeStart: number; graphemeEnd: number; cellStart: number; cellEnd: number; } export interface ViewportAnchorAnnotation { text: string; nextGrapheme: number; nextCell: number; token: string; } export declare const VIEWPORT_ANCHOR_PREFIX = "\u001B_AVIB_ANCHOR:"; /** * Tag every visible grapheme with an APC marker that survives ANSI-aware * wrapping. The marker contains source grapheme and monotonic cell offsets. */ export declare function annotateViewportAnchorGraphemes(text: string, startGrapheme?: number, startCell?: number, token?: `${string}-${string}-${string}-${string}-${string}`): ViewportAnchorAnnotation; /** Remove viewport anchor markers and return the exact marked span for each row. */ export declare function extractViewportAnchorRows(lines: readonly string[], token: string): { lines: string[]; spans: Array; }; export declare function visibleWidthRaw(str: string): number; /** * Calculate the visible width of a string in terminal columns. */ export declare function visibleWidth(str: string): number; export declare function visibleWidthsNative(lines: readonly string[]): number[]; export declare function visibleWidths(lines: readonly string[]): number[]; /** * Normalize text for terminal output without changing logical editor content. * Some terminals render canonically decomposed Hangul jamo or precomposed * Thai/Lao AM vowels inconsistently during differential repaint. Emit a stable * terminal form while keeping the component/source strings unchanged. */ export declare function normalizeTerminalOutput(str: string): string; /** * Check if a character is whitespace. */ export declare function isWhitespaceChar(char: string): boolean; /** * Check if a character is punctuation. */ export declare function isPunctuationChar(char: string): boolean; export type WordNavKind = "whitespace" | "delimiter" | "cjk" | "word" | "other"; /** * Coarse Unicode-aware character classification for word navigation (Option/Alt + Left/Right). * This intentionally avoids language-specific word segmentation for predictability across scripts. */ export declare function getWordNavKind(grapheme: string): WordNavKind; export declare function isWordNavJoiner(grapheme: string): boolean; /** * Move the cursor one "word" to the left using Unicode-aware coarse navigation. * * Returns a new cursor index in the range [0, text.length]. */ export declare function moveWordLeft(text: string, cursor: number): number; /** * Move the cursor one "word" to the right using Unicode-aware coarse navigation. * * Returns a new cursor index in the range [0, text.length]. */ export declare function moveWordRight(text: string, cursor: number): number; /** * Apply background color to a line, padding to full width. * * @param line - Line of text (may contain ANSI codes) * @param width - Total width to pad to * @param bgFn - Background color function * @returns Line with background applied and padded to width */ export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string; /** * Extract a range of visible columns from a line. Handles ANSI codes and wide chars. * * @param strict - If true, exclude wide chars at boundary that would extend past the range */ export declare function sliceByColumn(line: string, startCol: number, length: number, strict?: boolean): string;