/**
 * Hand back the single grapheme segmenter that the whole module shares.
 */
export declare function getSegmenter(): Intl.Segmenter;
export declare class GraphemeHandler {
    segment(text: string): Intl.Segments;
    iterator(text: string): Generator<string>;
}
export declare class TextWidthCalculator {
    getWidth(text: string): number;
    clearCache(): void;
}
export declare const textWidthCalculator: TextWidthCalculator;
/**
 * Compute how many columns a whole string takes up when rendered to a terminal.
 */
export declare function visibleWidth(str: string): number;
/**
 * If an ANSI escape sequence begins exactly at the given index, return it along
 * with how many characters it spans; otherwise return null.
 */
export declare function extractAnsiCode(str: string, pos: number): {
    code: string;
    length: number;
} | null;
/**
 * Word-wrap text without losing its ANSI styling.
 *
 * This handles wrapping alone — it never pads lines out or paints backgrounds.
 * Every returned line has a visible width no greater than the limit, and any
 * styling active at a break point is re-applied on the following line.
 *
 * @param text - the text to wrap, possibly carrying ANSI codes and newlines
 * @param width - the largest visible width a single line may reach
 * @returns the wrapped lines, left un-padded
 */
export declare class AnsiCodeManager {
    private readonly tracker;
    process(ansiCode: string): void;
    toAnsiString(): string;
    reset(): void;
}
export declare class TextWrapper {
    wrap(text: string, width: number): string[];
}
export declare const textWrapper: TextWrapper;
export declare function wrapTextWithAnsi(text: string, width: number): string[];
/**
 * Report whether the given character counts as whitespace.
 */
export declare function isWhitespaceChar(char: string): boolean;
/**
 * Report whether the given character is a punctuation mark.
 */
export declare function isPunctuationChar(char: string): boolean;
/**
 * Pad a line out to the full width, then run a background-color function over
 * the result so the colour fills the entire column span.
 *
 * @param line - the line to colour (ANSI codes allowed)
 * @param width - the column width to pad up to
 * @param bgFn - the function that applies the background colour
 * @returns the padded line with its background applied
 */
export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string;
/**
 * Shorten text so its visible width stays within a cap, tacking on an ellipsis
 * when something had to be cut. The result can optionally be padded out so it
 * lands on exactly maxWidth. ANSI escapes are respected and never counted
 * toward the width.
 *
 * @param text - the text to shorten (ANSI codes allowed)
 * @param maxWidth - the largest visible width permitted
 * @param ellipsis - what to append once truncation happens (defaults to "...")
 * @param pad - when true, pad the output with spaces up to exactly maxWidth (defaults to false)
 * @returns the shortened text, padded to maxWidth if requested
 */
export declare function truncateToWidth(text: string, maxWidth: number, ellipsis?: string, pad?: boolean): string;
/**
 * Cut out a span of visible columns from a line, coping correctly with ANSI
 * codes and double-width characters.
 * @param strict - when true, a wide char straddling the far edge is left out rather than included
 */
export declare function sliceByColumn(line: string, startCol: number, length: number, strict?: boolean): string;
/** Same as sliceByColumn, but additionally reports the visible width of what it returns. */
export declare function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean): {
    text: string;
    width: number;
};
/**
 * In one traversal, pull out the text that precedes an overlay region and the
 * text that follows it. This feeds overlay compositing, where both the content
 * before and the content after the overlay are needed. Styling established
 * before the overlay is carried over so it still governs the "after" portion.
 */
export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter?: boolean): {
    before: string;
    beforeWidth: number;
    after: string;
    afterWidth: number;
};
