UNPKG

@bitblit/asyncglk

Version:
125 lines (124 loc) 3.77 kB
import type { BufferWindowImage, ContentUpdate, GraphicsWindowOperation, InputUpdate, TextRun, WindowStyles, WindowUpdate as SizeUpdate } from '../common/protocol.js'; import type { GlkArray, GlkWindow } from './interface.js'; import { type Stream, WindowStream } from './streams.js'; export type Window = BlankWindow | BufferWindow | GraphicsWindow | GridWindow | PairWindow; type WindowTypes = 'blank' | 'buffer' | 'graphics' | 'grid' | 'pair'; export interface WindowBox { bottom: number; left: number; right: number; top: number; } export interface WindowUpdate { content: ContentUpdate | null; input: InputUpdate | null; size: SizeUpdate | null; } declare abstract class WindowBase implements GlkWindow { box: WindowBox; disprock: number; echostr: Stream | null; input: InputUpdate; next: Window | null; parent: PairWindow | null; prev: Window | null; rock: number; str: WindowStream; abstract type: WindowTypes; abstract typenum: number; constructor(rock: number); clear(): void; put_string(_str: string, _style?: string): void; set_css(_name: string, _val?: string | number): void; set_hyperlink(_val: number): void; set_style(_style: string): void; update(): WindowUpdate; } export declare class BlankWindow extends WindowBase { type: "blank"; typenum: number; } export declare abstract class TextWindow extends WindowBase { cleared: boolean; line_input_buf?: GlkArray; request_echo_line_input: boolean; stylehints: WindowStyles; uni_input?: boolean; constructor(rock: number, stylehints: WindowStyles); update(): WindowUpdate; } export interface Paragraph { /** Append to last input */ append?: boolean; /** Line data */ content: ParagraphTextRun[]; /** Paragraph breaks after floating images */ flowbreak?: boolean; } type ParagraphTextRun = BufferWindowImage | TextRun; export declare class BufferWindow extends TextWindow { content: Paragraph[]; echo_line_input: boolean; private last_par; private last_textrun; type: "buffer"; typenum: number; constructor(rock: number, stylehints: WindowStyles); clear(): void; clear_content(): void; private clone_textrun; put_image(img: BufferWindowImage): void; put_string(str: string, style?: string): void; set_css(name: string, val?: string | number): void; set_flow_break(): void; set_hyperlink(val?: number): void; set_style(style: string): void; update(): WindowUpdate; } export declare class GraphicsWindow extends WindowBase { draw: GraphicsWindowOperation[]; height: number; type: "graphics"; typenum: number; uni_input?: boolean; width: number; clear(): void; update(): WindowUpdate; } interface GridLine { content: TextRun[]; changed: boolean; } export declare class GridWindow extends TextWindow { private current_styles; height: number; lines: GridLine[]; type: "grid"; typenum: number; width: number; x: number; y: number; clear(): void; fit_cursor(): true | undefined; put_string(str: string, style?: string): void; set_css(name: string, val?: string | number): void; set_hyperlink(val: number): void; set_style(style: string): void; update_size(height: number, width: number): void; update(): WindowUpdate; } export declare class PairWindow extends WindowBase { backward: boolean; child1: Window | null; child2: Window | null; border: boolean; dir: number; fixed: boolean; key: Window | null; size: number; type: "pair"; typenum: number; vertical: boolean; constructor(keywin: Window, method: number, size: number); } export {};