import type { ActionDefinition } from "@tooee/commands"; import type { DecorationLayer } from "@tooee/renderers"; import type { NavigationState } from "@tooee/shell"; import type { Key } from "react"; import type { FoldRange, FoldView } from "./fold-model.js"; /** Fold state over a full row array and the visible projection it produces. */ export interface FoldState { /** The visible rows: pass this array to the document controller and the renderer. */ rows: readonly T[]; /** The full-array row count. */ rowCount: number; ranges: readonly FoldRange[]; view: FoldView; closedKeys: ReadonlySet; setClosedKeys: (keys: ReadonlySet) => void; /** External decoration layers projected onto the visible rows. */ decorations: DecorationLayer[]; /** One-based full-array row number for each visible row, or `undefined` when nothing is hidden. */ rowNumbers: readonly number[] | undefined; } /** * Hold the closed fold keys for `rows` and project the rows, decorations and * gutter numbers onto what stays visible. `ranges` and `decorations` use * full-array row indices. With no closed fold, `rows` and `decorations` pass * through unchanged. */ export declare const useFoldState: (rows: readonly T[], ranges: readonly FoldRange[], decorations: DecorationLayer[]) => FoldState; /** Fold operations. Row arguments are full-array row indices. */ export interface FoldActions { /** Toggle the innermost fold that contains `row`. Returns false when no fold contains it. */ toggle: (row: number) => boolean; /** Close the innermost open fold that contains `row`. Returns false when there is none. */ close: (row: number) => boolean; /** Open the innermost closed fold that contains `row`. Returns false when there is none. */ open: (row: number) => boolean; /** Open a fold at `row` when one is closed, else close the innermost open fold. */ toggleBlock: (row: number) => boolean; closeAll: () => void; openAll: () => void; } /** * Fold operations over a fold state. Any change that hides the document * cursor row first moves the cursor to the header of the outermost closed * fold that hides it, and key preservation keeps it there. This holds for * every target row, so a fold closed from the outline also keeps the cursor * visible. */ export declare const useFoldActions: (folds: FoldState, navigation: Pick) => FoldActions; /** * The Vim fold commands (`z a`, `z c`, `z o`, `z z`, `z shift+m`, * `z shift+r`) as action definitions. The row commands act on `targetRow()`: * the document cursor row on the root surface, or the selected heading in the * outline. `idPrefix` keeps the ids apart on each surface, and `noFoldMessage` * is the warning when no fold contains the target row. */ export declare const foldActionDefinitions: (actions: FoldActions, targetRow: () => number | undefined, idPrefix: string, noFoldMessage: string) => ActionDefinition[]; /** Register the fold commands on the current surface, acting on the document cursor row. */ export declare const useFoldCommands: (folds: FoldState, actions: FoldActions, navigation: Pick) => void; //# sourceMappingURL=use-folds.d.ts.map