/** * Strip ANSI escape codes from a string to get plain text * * This removes all ANSI escape sequences (e.g., color codes, cursor movements) * from the input string, returning only the visible characters. * * @param text - String that may contain ANSI escape codes * @returns Plain text with all ANSI codes removed * * @example * stripAnsi('\x1b[31mHello\x1b[0m') // 'Hello' */ export declare function stripAnsi(text: string): string; /** * Truncate text to a maximum visual width while preserving ANSI escape codes * * This function truncates text based on its visual width (ignoring ANSI codes), * but preserves all ANSI escape sequences in the output. Active ANSI codes are * preserved in the truncated result. * * @param text - Text that may contain ANSI escape codes * @param maxWidth - Maximum visual width (number of visible characters) * @returns Truncated text with ANSI codes preserved (no ellipsis added) * * @example * truncateToWidth('\x1b[31mHello World\x1b[0m', 8) // '\x1b[31mHello Wo\x1b[0m' */ export declare function truncateToWidth(text: string, maxWidth: number): string; /** * Truncate text with ellipsis at the end, preserving ANSI escape codes * * Active ANSI codes from the truncated portion are preserved, and the ellipsis * is added after the truncated text (without ANSI codes). * * @param text - Text that may contain ANSI escape codes * @param maxWidth - Maximum visual width (number of visible characters) * @returns Truncated text with '...' at the end, ANSI codes preserved * * @example * truncateEnd('\x1b[31mHello World\x1b[0m', 8) // '\x1b[31mHello...\x1b[0m' */ export declare function truncateEnd(text: string, maxWidth: number): string; /** * Truncate text with ellipsis at the beginning, preserving ANSI escape codes * * When truncating from the start, we preserve ANSI codes that are active in the * remaining portion. The ellipsis is added at the beginning (without ANSI codes), * and active codes from the original text are re-applied to the remaining portion. * * @param text - Text that may contain ANSI escape codes * @param maxWidth - Maximum visual width (number of visible characters) * @returns Truncated text with '...' at the beginning, ANSI codes preserved * * @example * truncateStart('\x1b[31mHello World\x1b[0m', 8) // '...\x1b[31mWorld\x1b[0m' */ export declare function truncateStart(text: string, maxWidth: number): string; /** * Truncate text with ellipsis in the middle, preserving ANSI escape codes * * When truncating in the middle, we preserve ANSI codes from the start portion * and re-apply them to the end portion to maintain consistent styling. * * @param text - Text that may contain ANSI escape codes * @param maxWidth - Maximum visual width (number of visible characters) * @returns Truncated text with '...' in the middle, ANSI codes preserved * * @example * truncateMiddle('\x1b[31mHello World\x1b[0m', 8) // '\x1b[31mHel...ld\x1b[0m' */ export declare function truncateMiddle(text: string, maxWidth: number): string; /** * Map an original column position to its display position in truncated text * * This function takes the original text, the truncated result, and the visible range * that was shown, and maps an original column to where it appears in the truncated text. * * @param originalText - The original text (plain, no ANSI) * @param truncatedText - The truncated text result (may have ellipsis) * @param visibleStartCol - The first column that was shown (1-based, includes truncated before) * @param visibleEndCol - The last column that was shown (1-based, includes truncated after) * @param originalCol - The original column to map (1-based) * @param rangeStartCol - The start column of the main range (1-based, optional, for better accuracy) * @param rangeEndCol - The end column of the main range (1-based, optional, for better accuracy) * @returns The display position in the truncated text (1-based, visible characters) */ export declare function mapColumnToDisplay(originalText: string, truncatedText: string, visibleStartCol: number, visibleEndCol: number, originalCol: number, rangeStartCol?: number, rangeEndCol?: number): number; /** * Result of truncateFocusRange, including information about what range was shown */ export interface TruncateFocusRangeResult { /** The truncated text with target range visible */ text: string; /** The first column that was shown (1-based, includes truncated before portion) */ visibleStartCol: number; /** The last column that was shown (1-based, includes truncated after portion) */ visibleEndCol: number; /** The start column of the main range (1-based, the focused portion) */ rangeStartCol: number; /** The end column of the main range (1-based, the focused portion) */ rangeEndCol: number; } /** * Truncate text to show a specific column range, with ellipsis as needed * * This function ensures a target range (startCol to endCol) is visible in the output, * adding ellipsis at the start, end, or both as needed to fit within maxWidth. * All ANSI codes and OSC 8 hyperlinks are preserved. * * @param text - Text that may contain ANSI escape codes * @param maxWidth - Maximum visual width (number of visible characters) * @param targetStartCol - Start column of target range (1-based) * @param targetEndCol - End column of target range (1-based, optional) * @param maxColumn - Maximum column to show (optional, for limiting display) * @returns Truncated text with target range visible, ANSI codes preserved, and visible range info * * @example * truncateFocusRange('console.log("hello world");', 20, 1, 11) * // Returns text showing columns 1-11 with ellipsis if needed */ export declare function truncateFocusRange(text: string, maxWidth: number, targetStartCol: number, targetEndCol?: number, maxColumn?: number): TruncateFocusRangeResult; /** * Wrap text to fit within a width, breaking on spaces * Never breaks words mid-word - if a word is too long, it will extend the line * ANSI-aware: calculates width based on visible characters, not raw string length */ export declare function wrapText(text: string, width: number): string[]; /** * Get the visual width of text (accounting for ANSI codes) */ export declare function getTextWidth(text: string): number; export declare function getTrimmedTextWidth(text: string): number; /** * Count visible characters in text, skipping ANSI escape codes * More efficient than stripAnsi().length as it doesn't create a new string * * @param text - Text that may contain ANSI escape codes * @returns Number of visible characters */ export declare function countVisibleChars(text: string): number; /** * Split text at a specific visible character position, preserving ANSI codes * * When splitting, we preserve any active ANSI color codes: * - The "before" part gets the codes closed with \x1b[0m if needed * - The "after" part gets the active codes re-applied at the start * * @param text - Text that may contain ANSI escape codes * @param visiblePos - Position in visible characters (0-based) * @returns Object with { before: string, after: string } split at the visible position * * @example * splitAtVisiblePos('\x1b[31mHello World', 5) * // { before: '\x1b[31mHello\x1b[0m', after: '\x1b[31m World' } */ export declare function splitAtVisiblePos(text: string, visiblePos: number): { before: string; after: string; }; //# sourceMappingURL=text.d.ts.map