export type Direction = "left" | "right" | "up" | "down" | "wordLeft" | "wordRight" | "home" | "end";
export interface Viewport {
    height: number;
    width: number;
}
export default class TextBuffer {
    private lines;
    private cursorRow;
    private cursorCol;
    private scrollRow;
    private scrollCol;
    /**
     * When the user moves the caret vertically we try to keep their original
     * horizontal column even when passing through shorter lines.  We remember
     * that *preferred* column in this field while the user is still travelling
     * vertically.  Any explicit horizontal movement resets the preference.
     */
    private preferredCol;
    private version;
    private undoStack;
    private redoStack;
    private historyLimit;
    private clipboard;
    constructor(text?: string, initialCursorIdx?: number);
    private line;
    private lineLen;
    private ensureCursorInRange;
    /**
     * Sets the cursor position based on a character offset from the start of the document.
     * @param idx The character offset to move to (0-based)
     * @returns true if successful, false if the index was invalid
     */
    private setCursorIdx;
    private snapshot;
    private pushUndo;
    /**
     * Restore a snapshot and return true if restoration happened.
     */
    private restore;
    private ensureCursorVisible;
    getVersion(): number;
    getCursor(): [number, number];
    getVisibleLines(vp: Viewport): Array<string>;
    getText(): string;
    getLines(): Array<string>;
    undo(): boolean;
    redo(): boolean;
    /**
     * Insert a single character or string without newlines. If the string
     * contains a newline we delegate to insertStr so that line splitting
     * logic is shared.
     */
    insert(ch: string): void;
    newline(): void;
    backspace(): void;
    del(): void;
    /**
     * Delete everything from the caret to the *end* of the current line. The
     * caret itself stays in place (column remains unchanged). Mirrors the
     * common Ctrl+K shortcut in many shells and editors.
     */
    deleteToLineEnd(): void;
    /**
     * Delete everything from the *start* of the current line up to (but not
     * including) the caret.  The caret is moved to column-0, mirroring the
     * behaviour of the familiar Ctrl+U binding.
     */
    deleteToLineStart(): void;
    /** Delete the word to the *left* of the caret, mirroring common
     *  Ctrl/Alt+Backspace behaviour in editors & terminals.  Both the adjacent
     *  whitespace *and* the word characters immediately preceding the caret are
     *  removed.  If the caret is already at column‑0 this becomes a no-op. */
    deleteWordLeft(): void;
    /** Delete the word to the *right* of the caret, akin to many editors'
     *  Ctrl/Alt+Delete shortcut.  Removes any whitespace/punctuation that
     *  follows the caret and the next contiguous run of word characters. */
    deleteWordRight(): void;
    move(dir: Direction): void;
    /** Move caret to *absolute* beginning of the buffer (row-0, col-0). */
    private moveToStartOfDocument;
    /** Move caret to *absolute* end of the buffer (last row, last column). */
    private moveToEndOfDocument;
    /**
     * Insert an arbitrary string, possibly containing internal newlines.
     * Returns true if the buffer was modified.
     */
    insertStr(str: string): boolean;
    private selectionAnchor;
    startSelection(): void;
    endSelection(): void;
    /** Extract selected text. Returns null if no valid selection. */
    private getSelectedText;
    copy(): string | null;
    paste(): boolean;
    handleInput(input: string | undefined, key: Record<string, boolean>, vp: Viewport): boolean;
}
