import { XYWH } from "@thegraid/common-lib"; import { EditBox } from "./edit-box.js"; import type { TextInRectOptions, TextStyle } from "./paintable.js"; /** a multi-line EditBox. with keybindings to move up/down lines */ export declare class EditLines extends EditBox { /** number of lines displayed in box */ nlines: number; /** n-th newline of buf; first line to display, shown at top of box */ d0: number; /** beginning of line holding point (set by this.bol()) */ bol0: number; /** N lines of text displayed in box; N = floor(box.height / fontSize) */ dlines: string[]; /** current line of display holding point */ linen: number; /** postion of cmark: buf[point - col - 1] = '\n' */ col: number; /** target col for [repeated] upLine/downLine TBD: prev-cmd */ col0: number; /** * * @param text [''] * @param style [] * @param rect [{x:0, y:0, w:80, h:40}] bounds of viewing rectangle */ constructor(text?: string, style?: TextStyle & TextInRectOptions, rect?: XYWH); /** return count of newlines between p0 and p1; negative if p0 > p1. * * return index[] of each newline * @returns [count, bol[]] tuple */ countLines(p0: number, p1: number): [number, number[]]; /** display text from buf[bol0 ... eob) */ fillDisplay(bol0: number): void; /** * Find line containing point, 'scroll' so that cursor is within dlines. * * compute this.col, this.linen; * * @param dlines */ moveCursor(dlines?: string[]): void; /** * repaint multi-line display, scroll text to show cursor. * * invokes fillDisplay(...) * @param text [ignored] the whole buffer text (EditLines extracts from d0; join/split) */ repaint(): this; initKeys(): void; /** set this.bol0 = bol(0) and return index of nth bol */ bol(n?: number): number; eol(n?: number): number; /** argVal: bol, min, max, pt */ movePoint(argVal: any, eStr?: string): this; /** insert newline after point */ openLine(): this; /** Binding.func: kill to eol, saving to killBuf * @param argVal kill to nth eol */ killLine(n?: number): void; /** * edit method to kill multiple lines, saving into killBuf (for yank) * @param n [1] kill to eol(n) * @param rpt [false] if true concat to killBuf * @returns this */ killLines(n?: number, rpt?: boolean): this; /** return col0 if lastFunc was upLine or downLine, else normal current this.col */ get keyCol(): number; /** a Binding.func that uses/sets col0 for repeated calls */ upLine(): void; /** Binding.func that uses/sets col0 for repeated calls */ downLine(): void; /** edit method to move up in same columns */ upLines(n?: number): this; /** edit method to move down in same column */ downLines(n?: number): this; }