import { Graphics } from "@thegraid/easeljs-module"; import { Binding, KeyScope } from "./key-binder.js"; import { PaintableShape, TextInRect, type TextInRectOptions, type TextStyle } from "./paintable.js"; /** a Container with a [rectangle] Shape and a Text. * keystrokes to the Shape are inserted into the Text. * * EditBox: * localSetKey(BS,DEL,C-A, C-K, C-W, C-Y, C-B, C-F) to edit functions...? */ export declare class EditBox extends TextInRect implements TextStyle { /** shared among all EditBox instances */ static killBuf: string[]; readonly buf: string[]; point: number; cmark: PaintableShape; /** * A box that can display & edit Text * @param text initial Text or string in EditBox. * @param style * * bgColor: fillColor for box * * fontSize: for text in box * * fontName: for text in box * * textColor: for text in box */ constructor(text?: string, style?: TextStyle & TextInRectOptions); /** * set color (and Graphics) for cursor; the mark at 'point' between chars. * * default is a simple vertical line. * @param color [current color | BLACK] color to paint * @param dy [1] inset from top & bottom of edit rectangle * @param cgf [s(color).mt(0,dy).lt(0,fs-dy)] paint function for cursor. */ paintCursor(color?: string, dy?: number, cgf?: (c: string, g?: Graphics) => Graphics): void; keyScope: KeyScope; /** single/simple keys selfInsert, pluse a few emacs navigation keys */ initKeys(): void; /** S.click -> this.setFocus(true) & stopPropagation(event) * * if you want additional click effects, will need to override/extend */ clickToFocus(): void; /** * take or release the keyboard focus. * * Note: puts a capture-phase click listener on stage will setFocus(false) * * @param f [true] focus(this); false -> focus(global keyBinder) */ setFocus(f?: boolean): void; /** * invoked when KeyBinder gives/takes focus from this EditBox * * default is to view/hide cmark. * * subclass could: @example * this.cmark.paint(f ? alpha1 : alpha0) */ onFocus(f: boolean): void; /** initialize buffer contents with given text string and style. */ setText0(text?: string, style?: TextStyle): void; /** * * edit method?: replace buffer contents with given text string and style; repaint() */ setText(text?: string, style?: TextStyle): this; /** disp.text OR buf.join('') */ get innerText(): string; /** * Primary buffer modification routine; * splice into the buffer (combination delete & insert) * * @example * this.buf.splice(pt, n, text); * this.labelactchEvent('splice'); * * @param pt start deletion (current point) * @param n chars to delete (all the rest) * @param text string to insert ('') */ splice(pt?: number, n?: number, ...text: string[]): void; alignCmark(text?: string, pt?: number): void; /** after content change: set cursor position and stage.update() */ repaint(): this; /** * KeyBinder function to move point * @param argVal 'min' 'max' '+' '-' or number (offset into this.buf == this.text.text) * @param eStr (ignored) */ movePoint(argVal: any, eStr?: string): this; /** * Insert (argVal ?? keyStr) into text at point++ (insert-before-point) * @param argVal char-string to insert, else use eStr * @param keyStr the keyCodeToString, probably from regexp */ selfInsert(argVal?: string, keyStr?: string): this; /** selfInsert newline */ newline(argVal?: any, eStr?: string): void; /** delete char before cursor */ delBack(argVal?: any, eStr?: string): this; delForw(argVal?: any, eStr?: string): this; /** edit method to kill to eob, saving in killBuf * @param rpt [false] true to append to killBuf */ kill(pt?: number, n?: number, rpt?: boolean): this; /** Binding func to insert killBuf into buf at point */ yank(argVal?: any, eStr?: string): this; /** * insert text from window system clipboard: await navigator.clipboard.readText(); * * S.splice when complete * @param pt where to inject text [this.point] * @param n number of following chars to delete [0], if n<0 delete ALL following chars */ pasteClipboard(pt?: number, n?: number): Promise; setBind(w: number, h: number, init?: string, focus?: Binding, blur?: Binding): void; }