@opentui/core 0.0.0-20251010-2eed09fd → 0.0.0-20251026-8b7fde6b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/3d.js +140 -140
- package/3d.js.map +3 -3
- package/README.md +10 -0
- package/Renderable.d.ts +25 -24
- package/buffer.d.ts +4 -7
- package/edit-buffer.d.ts +77 -0
- package/editor-view.d.ts +55 -0
- package/{index-kqk5knmb.js → index-hgxcxzxa.js} +2557 -469
- package/index-hgxcxzxa.js.map +55 -0
- package/index.d.ts +4 -0
- package/index.js +3527 -2025
- package/index.js.map +19 -12
- package/lib/extmarks-history.d.ts +17 -0
- package/lib/extmarks.d.ts +80 -0
- package/lib/hast-styled-text.d.ts +2 -3
- package/lib/index.d.ts +1 -1
- package/lib/keymapping.d.ts +10 -0
- package/lib/objects-in-viewport.d.ts +14 -0
- package/lib/parse.keypress.d.ts +1 -1
- package/lib/tree-sitter/index.d.ts +0 -2
- package/lib/tree-sitter-styled-text.d.ts +1 -1
- package/lib/yoga.options.d.ts +6 -6
- package/package.json +9 -7
- package/renderables/Code.d.ts +1 -1
- package/renderables/EditBufferRenderable.d.ts +119 -0
- package/renderables/Text.d.ts +0 -3
- package/renderables/TextBufferRenderable.d.ts +8 -14
- package/renderables/TextNode.d.ts +2 -1
- package/renderables/Textarea.d.ts +95 -0
- package/renderables/index.d.ts +11 -9
- package/renderer.d.ts +6 -2
- package/{lib/syntax-style.d.ts → syntax-style.d.ts} +21 -5
- package/testing/mock-keys.d.ts +39 -2
- package/testing.js +54 -6
- package/testing.js.map +3 -3
- package/text-buffer-view.d.ts +31 -0
- package/text-buffer.d.ts +28 -21
- package/types.d.ts +10 -0
- package/zig-structs.d.ts +22 -0
- package/zig.d.ts +147 -23
- package/index-kqk5knmb.js.map +0 -52
- package/lib/word-jumps.d.ts +0 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Extmark } from "./extmarks";
|
|
2
|
+
export interface ExtmarksSnapshot {
|
|
3
|
+
extmarks: Map<number, Extmark>;
|
|
4
|
+
nextId: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class ExtmarksHistory {
|
|
7
|
+
private undoStack;
|
|
8
|
+
private redoStack;
|
|
9
|
+
saveSnapshot(extmarks: Map<number, Extmark>, nextId: number): void;
|
|
10
|
+
undo(): ExtmarksSnapshot | null;
|
|
11
|
+
redo(): ExtmarksSnapshot | null;
|
|
12
|
+
pushRedo(snapshot: ExtmarksSnapshot): void;
|
|
13
|
+
pushUndo(snapshot: ExtmarksSnapshot): void;
|
|
14
|
+
clear(): void;
|
|
15
|
+
canUndo(): boolean;
|
|
16
|
+
canRedo(): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { EditBuffer } from "../edit-buffer";
|
|
2
|
+
import type { EditorView } from "../editor-view";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
export interface Extmark {
|
|
5
|
+
id: number;
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
virtual: boolean;
|
|
9
|
+
styleId?: number;
|
|
10
|
+
priority?: number;
|
|
11
|
+
data?: any;
|
|
12
|
+
}
|
|
13
|
+
export interface ExtmarkDeletedEvent {
|
|
14
|
+
extmark: Extmark;
|
|
15
|
+
trigger: "backspace" | "delete" | "manual";
|
|
16
|
+
}
|
|
17
|
+
export interface ExtmarkOptions {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
virtual?: boolean;
|
|
21
|
+
styleId?: number;
|
|
22
|
+
priority?: number;
|
|
23
|
+
data?: any;
|
|
24
|
+
}
|
|
25
|
+
export interface ExtmarksControllerEvents {
|
|
26
|
+
"extmark-deleted": (event: ExtmarkDeletedEvent) => void;
|
|
27
|
+
"extmark-updated": (extmark: Extmark) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare class ExtmarksController extends EventEmitter {
|
|
30
|
+
private editBuffer;
|
|
31
|
+
private editorView;
|
|
32
|
+
private extmarks;
|
|
33
|
+
private nextId;
|
|
34
|
+
private destroyed;
|
|
35
|
+
private history;
|
|
36
|
+
private originalMoveCursorLeft;
|
|
37
|
+
private originalMoveCursorRight;
|
|
38
|
+
private originalSetCursorByOffset;
|
|
39
|
+
private originalMoveUpVisual;
|
|
40
|
+
private originalMoveDownVisual;
|
|
41
|
+
private originalDeleteCharBackward;
|
|
42
|
+
private originalDeleteChar;
|
|
43
|
+
private originalInsertText;
|
|
44
|
+
private originalInsertChar;
|
|
45
|
+
private originalDeleteRange;
|
|
46
|
+
private originalSetText;
|
|
47
|
+
private originalClear;
|
|
48
|
+
private originalNewLine;
|
|
49
|
+
private originalDeleteLine;
|
|
50
|
+
private originalEditorViewDeleteSelectedText;
|
|
51
|
+
private originalUndo;
|
|
52
|
+
private originalRedo;
|
|
53
|
+
constructor(editBuffer: EditBuffer, editorView: EditorView);
|
|
54
|
+
private wrapCursorMovement;
|
|
55
|
+
private wrapDeletion;
|
|
56
|
+
private wrapInsertion;
|
|
57
|
+
private wrapEditorViewDeleteSelectedText;
|
|
58
|
+
private setupContentChangeListener;
|
|
59
|
+
private findVirtualExtmarkContaining;
|
|
60
|
+
private adjustExtmarksAfterInsertion;
|
|
61
|
+
adjustExtmarksAfterDeletion(deleteOffset: number, length: number): void;
|
|
62
|
+
private offsetToPosition;
|
|
63
|
+
private positionToOffset;
|
|
64
|
+
private getLineStartOffset;
|
|
65
|
+
private updateHighlights;
|
|
66
|
+
private offsetToCharOffset;
|
|
67
|
+
create(options: ExtmarkOptions): number;
|
|
68
|
+
update(id: number, options: Partial<ExtmarkOptions>): boolean;
|
|
69
|
+
delete(id: number): boolean;
|
|
70
|
+
get(id: number): Extmark | null;
|
|
71
|
+
getAll(): Extmark[];
|
|
72
|
+
getVirtual(): Extmark[];
|
|
73
|
+
getAtOffset(offset: number): Extmark[];
|
|
74
|
+
clear(): void;
|
|
75
|
+
private saveSnapshot;
|
|
76
|
+
private restoreSnapshot;
|
|
77
|
+
private wrapUndoRedo;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
}
|
|
80
|
+
export declare function createExtmarksController(editBuffer: EditBuffer, editorView: EditorView): ExtmarksController;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyledText } from "./styled-text";
|
|
2
|
-
import { SyntaxStyle } from "
|
|
2
|
+
import { SyntaxStyle } from "../syntax-style";
|
|
3
3
|
export interface HASTText {
|
|
4
4
|
type: "text";
|
|
5
5
|
value: string;
|
|
@@ -13,6 +13,5 @@ export interface HASTElement {
|
|
|
13
13
|
children: HASTNode[];
|
|
14
14
|
}
|
|
15
15
|
export type HASTNode = HASTText | HASTElement;
|
|
16
|
-
export {
|
|
17
|
-
export type { StyleDefinition } from "./syntax-style";
|
|
16
|
+
export type { StyleDefinition } from "../syntax-style";
|
|
18
17
|
export declare function hastToStyledText(hast: HASTNode, syntaxStyle: SyntaxStyle): StyledText;
|
package/lib/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface KeyBinding<Action extends string = string> {
|
|
2
|
+
name: string;
|
|
3
|
+
ctrl?: boolean;
|
|
4
|
+
shift?: boolean;
|
|
5
|
+
meta?: boolean;
|
|
6
|
+
action: Action;
|
|
7
|
+
}
|
|
8
|
+
export declare function mergeKeyBindings<Action extends string>(defaults: KeyBinding<Action>[], custom: KeyBinding<Action>[]): KeyBinding<Action>[];
|
|
9
|
+
export declare function getKeyBindingKey<Action extends string>(binding: KeyBinding<Action>): string;
|
|
10
|
+
export declare function buildKeyBindingsMap<Action extends string>(bindings: KeyBinding<Action>[]): Map<string, Action>;
|
|
@@ -6,5 +6,19 @@ interface ViewportObject {
|
|
|
6
6
|
height: number;
|
|
7
7
|
zIndex: number;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns objects that overlap with the viewport bounds.
|
|
11
|
+
*
|
|
12
|
+
* @param viewport - The viewport bounds to check against
|
|
13
|
+
* @param objects - Array of objects MUST be sorted by position (y for column, x for row direction)
|
|
14
|
+
* @param direction - Primary scroll direction: "column" (vertical) or "row" (horizontal)
|
|
15
|
+
* @param padding - Extra padding around viewport to include nearby objects
|
|
16
|
+
* @param minTriggerSize - Minimum array size to use binary search optimization
|
|
17
|
+
* @returns Array of visible objects sorted by zIndex
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Objects must be pre-sorted by their start position (y for column direction, x for row direction).
|
|
21
|
+
* Unsorted input will produce incorrect results.
|
|
22
|
+
*/
|
|
9
23
|
export declare function getObjectsInViewport<T extends ViewportObject>(viewport: ViewportBounds, objects: T[], direction?: "row" | "column", padding?: number, minTriggerSize?: number): T[];
|
|
10
24
|
export {};
|
package/lib/parse.keypress.d.ts
CHANGED
|
@@ -21,4 +21,4 @@ export interface ParsedKey {
|
|
|
21
21
|
export type ParseKeypressOptions = {
|
|
22
22
|
useKittyKeyboard?: boolean;
|
|
23
23
|
};
|
|
24
|
-
export declare const parseKeypress: (s?: Buffer | string, options?: ParseKeypressOptions) => ParsedKey;
|
|
24
|
+
export declare const parseKeypress: (s?: Buffer | string, options?: ParseKeypressOptions) => ParsedKey | null;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { TreeSitterClient } from "./client";
|
|
2
2
|
export * from "./client";
|
|
3
3
|
export * from "../tree-sitter-styled-text";
|
|
4
|
-
export * from "../syntax-style";
|
|
5
4
|
export * from "./types";
|
|
6
|
-
export * from "../syntax-style";
|
|
7
5
|
export * from "./resolve-ft";
|
|
8
6
|
export type { UpdateOptions } from "./assets/update";
|
|
9
7
|
export { updateAssets } from "./assets/update";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TextChunk } from "../text-buffer";
|
|
2
2
|
import { StyledText } from "./styled-text";
|
|
3
|
-
import { SyntaxStyle } from "
|
|
3
|
+
import { SyntaxStyle } from "../syntax-style";
|
|
4
4
|
import { TreeSitterClient } from "./tree-sitter/client";
|
|
5
5
|
import type { SimpleHighlight } from "./tree-sitter/types";
|
|
6
6
|
export declare function treeSitterToTextChunks(content: string, highlights: SimpleHighlight[], syntaxStyle: SyntaxStyle): TextChunk[];
|
package/lib/yoga.options.d.ts
CHANGED
|
@@ -14,18 +14,18 @@ export type OverflowString = "visible" | "hidden" | "scroll";
|
|
|
14
14
|
export type PositionTypeString = "static" | "relative" | "absolute";
|
|
15
15
|
export type UnitString = "undefined" | "point" | "percent" | "auto";
|
|
16
16
|
export type WrapString = "no-wrap" | "wrap" | "wrap-reverse";
|
|
17
|
-
export declare function parseAlign(value: string): Align;
|
|
17
|
+
export declare function parseAlign(value: string | null | undefined): Align;
|
|
18
18
|
export declare function parseBoxSizing(value: string): BoxSizing;
|
|
19
19
|
export declare function parseDimension(value: string): Dimension;
|
|
20
20
|
export declare function parseDirection(value: string): Direction;
|
|
21
21
|
export declare function parseDisplay(value: string): Display;
|
|
22
22
|
export declare function parseEdge(value: string): Edge;
|
|
23
|
-
export declare function parseFlexDirection(value: string): FlexDirection;
|
|
23
|
+
export declare function parseFlexDirection(value: string | null | undefined): FlexDirection;
|
|
24
24
|
export declare function parseGutter(value: string): Gutter;
|
|
25
|
-
export declare function parseJustify(value: string): Justify;
|
|
25
|
+
export declare function parseJustify(value: string | null | undefined): Justify;
|
|
26
26
|
export declare function parseLogLevel(value: string): LogLevel;
|
|
27
27
|
export declare function parseMeasureMode(value: string): MeasureMode;
|
|
28
|
-
export declare function parseOverflow(value: string): Overflow;
|
|
29
|
-
export declare function parsePositionType(value: string): PositionType;
|
|
28
|
+
export declare function parseOverflow(value: string | null | undefined): Overflow;
|
|
29
|
+
export declare function parsePositionType(value: string | null | undefined): PositionType;
|
|
30
30
|
export declare function parseUnit(value: string): Unit;
|
|
31
|
-
export declare function parseWrap(value: string): Wrap;
|
|
31
|
+
export declare function parseWrap(value: string | null | undefined): Wrap;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.0-
|
|
7
|
+
"version": "0.0.0-20251026-8b7fde6b",
|
|
8
8
|
"description": "OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -35,11 +35,13 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"bun-ffi-structs": "^0.1.0",
|
|
38
39
|
"jimp": "1.6.0",
|
|
39
40
|
"yoga-layout": "3.2.1"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@types/bun": "latest",
|
|
44
|
+
"@types/node": "latest",
|
|
43
45
|
"@types/three": "0.177.0",
|
|
44
46
|
"commander": "^13.1.0",
|
|
45
47
|
"typescript": "^5",
|
|
@@ -53,11 +55,11 @@
|
|
|
53
55
|
"bun-webgpu": "0.1.3",
|
|
54
56
|
"planck": "^1.4.2",
|
|
55
57
|
"three": "0.177.0",
|
|
56
|
-
"@opentui/core-darwin-x64": "0.0.0-
|
|
57
|
-
"@opentui/core-darwin-arm64": "0.0.0-
|
|
58
|
-
"@opentui/core-linux-x64": "0.0.0-
|
|
59
|
-
"@opentui/core-linux-arm64": "0.0.0-
|
|
60
|
-
"@opentui/core-win32-x64": "0.0.0-
|
|
61
|
-
"@opentui/core-win32-arm64": "0.0.0-
|
|
58
|
+
"@opentui/core-darwin-x64": "0.0.0-20251026-8b7fde6b",
|
|
59
|
+
"@opentui/core-darwin-arm64": "0.0.0-20251026-8b7fde6b",
|
|
60
|
+
"@opentui/core-linux-x64": "0.0.0-20251026-8b7fde6b",
|
|
61
|
+
"@opentui/core-linux-arm64": "0.0.0-20251026-8b7fde6b",
|
|
62
|
+
"@opentui/core-win32-x64": "0.0.0-20251026-8b7fde6b",
|
|
63
|
+
"@opentui/core-win32-arm64": "0.0.0-20251026-8b7fde6b"
|
|
62
64
|
}
|
|
63
65
|
}
|
package/renderables/Code.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RenderContext } from "../types";
|
|
2
|
-
import { SyntaxStyle } from "../
|
|
2
|
+
import { SyntaxStyle } from "../syntax-style";
|
|
3
3
|
import { TreeSitterClient } from "../lib/tree-sitter";
|
|
4
4
|
import { TextBufferRenderable, type TextBufferOptions } from "./TextBufferRenderable";
|
|
5
5
|
export interface CodeOptions extends TextBufferOptions {
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
2
|
+
import { Selection, type LocalSelectionBounds } from "../lib/selection";
|
|
3
|
+
import { EditBuffer, type LogicalCursor } from "../edit-buffer";
|
|
4
|
+
import { EditorView, type VisualCursor } from "../editor-view";
|
|
5
|
+
import { RGBA } from "../lib/RGBA";
|
|
6
|
+
import { type RenderContext, type Highlight } from "../types";
|
|
7
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
8
|
+
import type { SyntaxStyle } from "../syntax-style";
|
|
9
|
+
export interface CursorChangeEvent {
|
|
10
|
+
line: number;
|
|
11
|
+
visualColumn: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ContentChangeEvent {
|
|
14
|
+
}
|
|
15
|
+
export interface EditBufferOptions extends RenderableOptions<EditBufferRenderable> {
|
|
16
|
+
textColor?: string | RGBA;
|
|
17
|
+
backgroundColor?: string | RGBA;
|
|
18
|
+
selectionBg?: string | RGBA;
|
|
19
|
+
selectionFg?: string | RGBA;
|
|
20
|
+
selectable?: boolean;
|
|
21
|
+
attributes?: number;
|
|
22
|
+
wrapMode?: "none" | "char" | "word";
|
|
23
|
+
scrollMargin?: number;
|
|
24
|
+
showCursor?: boolean;
|
|
25
|
+
cursorColor?: string | RGBA;
|
|
26
|
+
syntaxStyle?: SyntaxStyle;
|
|
27
|
+
onCursorChange?: (event: CursorChangeEvent) => void;
|
|
28
|
+
onContentChange?: (event: ContentChangeEvent) => void;
|
|
29
|
+
}
|
|
30
|
+
export declare abstract class EditBufferRenderable extends Renderable {
|
|
31
|
+
protected _focusable: boolean;
|
|
32
|
+
selectable: boolean;
|
|
33
|
+
protected _textColor: RGBA;
|
|
34
|
+
protected _backgroundColor: RGBA;
|
|
35
|
+
protected _defaultAttributes: number;
|
|
36
|
+
protected _selectionBg: RGBA | undefined;
|
|
37
|
+
protected _selectionFg: RGBA | undefined;
|
|
38
|
+
protected _wrapMode: "none" | "char" | "word";
|
|
39
|
+
protected _scrollMargin: number;
|
|
40
|
+
protected _showCursor: boolean;
|
|
41
|
+
protected _cursorColor: RGBA;
|
|
42
|
+
protected lastLocalSelection: LocalSelectionBounds | null;
|
|
43
|
+
private _cursorChangeListener;
|
|
44
|
+
private _contentChangeListener;
|
|
45
|
+
readonly editBuffer: EditBuffer;
|
|
46
|
+
readonly editorView: EditorView;
|
|
47
|
+
protected _defaultOptions: {
|
|
48
|
+
textColor: RGBA;
|
|
49
|
+
backgroundColor: string;
|
|
50
|
+
selectionBg: undefined;
|
|
51
|
+
selectionFg: undefined;
|
|
52
|
+
selectable: true;
|
|
53
|
+
attributes: number;
|
|
54
|
+
wrapMode: "none" | "char" | "word";
|
|
55
|
+
scrollMargin: number;
|
|
56
|
+
showCursor: true;
|
|
57
|
+
cursorColor: RGBA;
|
|
58
|
+
};
|
|
59
|
+
constructor(ctx: RenderContext, options: EditBufferOptions);
|
|
60
|
+
private setupEventListeners;
|
|
61
|
+
get plainText(): string;
|
|
62
|
+
get logicalCursor(): LogicalCursor;
|
|
63
|
+
get visualCursor(): VisualCursor;
|
|
64
|
+
get cursorOffset(): number;
|
|
65
|
+
set cursorOffset(offset: number);
|
|
66
|
+
get textColor(): RGBA;
|
|
67
|
+
set textColor(value: RGBA | string | undefined);
|
|
68
|
+
get selectionBg(): RGBA | undefined;
|
|
69
|
+
set selectionBg(value: RGBA | string | undefined);
|
|
70
|
+
get selectionFg(): RGBA | undefined;
|
|
71
|
+
set selectionFg(value: RGBA | string | undefined);
|
|
72
|
+
get backgroundColor(): RGBA;
|
|
73
|
+
set backgroundColor(value: RGBA | string | undefined);
|
|
74
|
+
get attributes(): number;
|
|
75
|
+
set attributes(value: number);
|
|
76
|
+
get wrapMode(): "none" | "char" | "word";
|
|
77
|
+
set wrapMode(value: "none" | "char" | "word");
|
|
78
|
+
get showCursor(): boolean;
|
|
79
|
+
set showCursor(value: boolean);
|
|
80
|
+
get cursorColor(): RGBA;
|
|
81
|
+
set cursorColor(value: RGBA | string);
|
|
82
|
+
protected onResize(width: number, height: number): void;
|
|
83
|
+
protected refreshLocalSelection(): boolean;
|
|
84
|
+
private updateLocalSelection;
|
|
85
|
+
shouldStartSelection(x: number, y: number): boolean;
|
|
86
|
+
onSelectionChanged(selection: Selection | null): boolean;
|
|
87
|
+
getSelectedText(): string;
|
|
88
|
+
hasSelection(): boolean;
|
|
89
|
+
getSelection(): {
|
|
90
|
+
start: number;
|
|
91
|
+
end: number;
|
|
92
|
+
} | null;
|
|
93
|
+
private setupMeasureFunc;
|
|
94
|
+
render(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
95
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
96
|
+
protected renderCursor(buffer: OptimizedBuffer): void;
|
|
97
|
+
focus(): void;
|
|
98
|
+
blur(): void;
|
|
99
|
+
protected onRemove(): void;
|
|
100
|
+
destroy(): void;
|
|
101
|
+
set onCursorChange(handler: ((event: CursorChangeEvent) => void) | undefined);
|
|
102
|
+
get onCursorChange(): ((event: CursorChangeEvent) => void) | undefined;
|
|
103
|
+
set onContentChange(handler: ((event: ContentChangeEvent) => void) | undefined);
|
|
104
|
+
get onContentChange(): ((event: ContentChangeEvent) => void) | undefined;
|
|
105
|
+
get syntaxStyle(): SyntaxStyle | null;
|
|
106
|
+
set syntaxStyle(style: SyntaxStyle | null);
|
|
107
|
+
addHighlight(lineIdx: number, highlight: Highlight): void;
|
|
108
|
+
addHighlightByCharRange(highlight: Highlight): void;
|
|
109
|
+
removeHighlightsByRef(hlRef: number): void;
|
|
110
|
+
clearLineHighlights(lineIdx: number): void;
|
|
111
|
+
clearAllHighlights(): void;
|
|
112
|
+
getLineHighlights(lineIdx: number): Array<Highlight>;
|
|
113
|
+
setText(text: string, opts?: {
|
|
114
|
+
history?: boolean;
|
|
115
|
+
}): void;
|
|
116
|
+
clear(): void;
|
|
117
|
+
deleteRange(startLine: number, startCol: number, endLine: number, endCol: number): void;
|
|
118
|
+
insertText(text: string): void;
|
|
119
|
+
}
|
package/renderables/Text.d.ts
CHANGED
|
@@ -22,9 +22,6 @@ export declare class TextRenderable extends TextBufferRenderable {
|
|
|
22
22
|
get chunks(): TextChunk[];
|
|
23
23
|
get textNode(): RootTextNodeRenderable;
|
|
24
24
|
set content(value: StyledText | string);
|
|
25
|
-
insertChunk(chunk: TextChunk, index?: number): void;
|
|
26
|
-
removeChunkByObject(chunk: TextChunk): void;
|
|
27
|
-
replaceChunkByObject(chunk: TextChunk, oldChunk: TextChunk): void;
|
|
28
25
|
private updateTextFromNodes;
|
|
29
26
|
add(obj: TextNodeRenderable | StyledText | string, index?: number): number;
|
|
30
27
|
remove(id: string): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
2
2
|
import { Selection, type LocalSelectionBounds } from "../lib/selection";
|
|
3
|
-
import { TextBuffer
|
|
3
|
+
import { TextBuffer } from "../text-buffer";
|
|
4
|
+
import { TextBufferView } from "../text-buffer-view";
|
|
4
5
|
import { RGBA } from "../lib/RGBA";
|
|
5
6
|
import { type RenderContext } from "../types";
|
|
6
7
|
import type { OptimizedBuffer } from "../buffer";
|
|
@@ -12,8 +13,7 @@ export interface TextBufferOptions extends RenderableOptions<TextBufferRenderabl
|
|
|
12
13
|
selectionFg?: string | RGBA;
|
|
13
14
|
selectable?: boolean;
|
|
14
15
|
attributes?: number;
|
|
15
|
-
|
|
16
|
-
wrapMode?: "char" | "word";
|
|
16
|
+
wrapMode?: "none" | "char" | "word";
|
|
17
17
|
}
|
|
18
18
|
export declare abstract class TextBufferRenderable extends Renderable {
|
|
19
19
|
selectable: boolean;
|
|
@@ -22,10 +22,10 @@ export declare abstract class TextBufferRenderable extends Renderable {
|
|
|
22
22
|
protected _defaultAttributes: number;
|
|
23
23
|
protected _selectionBg: RGBA | undefined;
|
|
24
24
|
protected _selectionFg: RGBA | undefined;
|
|
25
|
-
protected
|
|
26
|
-
protected _wrapMode: "char" | "word";
|
|
25
|
+
protected _wrapMode: "none" | "char" | "word";
|
|
27
26
|
protected lastLocalSelection: LocalSelectionBounds | null;
|
|
28
27
|
protected textBuffer: TextBuffer;
|
|
28
|
+
protected textBufferView: TextBufferView;
|
|
29
29
|
protected _lineInfo: LineInfo;
|
|
30
30
|
protected _defaultOptions: {
|
|
31
31
|
fg: RGBA;
|
|
@@ -34,8 +34,7 @@ export declare abstract class TextBufferRenderable extends Renderable {
|
|
|
34
34
|
selectionFg: undefined;
|
|
35
35
|
selectable: true;
|
|
36
36
|
attributes: number;
|
|
37
|
-
|
|
38
|
-
wrapMode: "char" | "word";
|
|
37
|
+
wrapMode: "none" | "char" | "word";
|
|
39
38
|
};
|
|
40
39
|
constructor(ctx: RenderContext, options: TextBufferOptions);
|
|
41
40
|
get plainText(): string;
|
|
@@ -50,10 +49,8 @@ export declare abstract class TextBufferRenderable extends Renderable {
|
|
|
50
49
|
set bg(value: RGBA | string | undefined);
|
|
51
50
|
get attributes(): number;
|
|
52
51
|
set attributes(value: number);
|
|
53
|
-
get
|
|
54
|
-
set
|
|
55
|
-
get wrapMode(): "char" | "word";
|
|
56
|
-
set wrapMode(value: "char" | "word");
|
|
52
|
+
get wrapMode(): "none" | "char" | "word";
|
|
53
|
+
set wrapMode(value: "none" | "char" | "word");
|
|
57
54
|
protected onResize(width: number, height: number): void;
|
|
58
55
|
protected refreshLocalSelection(): boolean;
|
|
59
56
|
private updateLocalSelection;
|
|
@@ -61,9 +58,6 @@ export declare abstract class TextBufferRenderable extends Renderable {
|
|
|
61
58
|
private updateLineInfo;
|
|
62
59
|
private updateWrapWidth;
|
|
63
60
|
private setupMeasureFunc;
|
|
64
|
-
insertChunk(chunk: TextChunk, index?: number): void;
|
|
65
|
-
removeChunk(index: number): void;
|
|
66
|
-
replaceChunk(index: number, chunk: TextChunk): void;
|
|
67
61
|
shouldStartSelection(x: number, y: number): boolean;
|
|
68
62
|
onSelectionChanged(selection: Selection | null): boolean;
|
|
69
63
|
getSelectedText(): string;
|
|
@@ -25,7 +25,7 @@ export declare class TextNodeRenderable extends BaseRenderable {
|
|
|
25
25
|
add(obj: TextNodeRenderable | StyledText | string, index?: number): number;
|
|
26
26
|
replace(obj: TextNodeRenderable | string, index: number): void;
|
|
27
27
|
insertBefore(child: string | TextNodeRenderable | StyledText, anchorNode: TextNodeRenderable | string | unknown): this;
|
|
28
|
-
remove(
|
|
28
|
+
remove(id: string): this;
|
|
29
29
|
clear(): void;
|
|
30
30
|
mergeStyles(parentStyle: {
|
|
31
31
|
fg?: RGBA;
|
|
@@ -51,6 +51,7 @@ export declare class TextNodeRenderable extends BaseRenderable {
|
|
|
51
51
|
getChildren(): BaseRenderable[];
|
|
52
52
|
getChildrenCount(): number;
|
|
53
53
|
getRenderable(id: string): BaseRenderable | undefined;
|
|
54
|
+
getRenderableIndex(id: string): number;
|
|
54
55
|
get fg(): RGBA | undefined;
|
|
55
56
|
set fg(fg: RGBA | string | undefined);
|
|
56
57
|
set bg(bg: RGBA | string | undefined);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type RenderContext } from "../types";
|
|
2
|
+
import { EditBufferRenderable, type EditBufferOptions } from "./EditBufferRenderable";
|
|
3
|
+
import type { KeyEvent } from "../lib/KeyHandler";
|
|
4
|
+
import { RGBA, type ColorInput } from "../lib/RGBA";
|
|
5
|
+
import { type KeyBinding as BaseKeyBinding } from "../lib/keymapping";
|
|
6
|
+
export type TextareaAction = "move-left" | "move-right" | "move-up" | "move-down" | "select-left" | "select-right" | "select-up" | "select-down" | "line-home" | "line-end" | "select-line-home" | "select-line-end" | "buffer-home" | "buffer-end" | "delete-line" | "delete-to-line-end" | "backspace" | "delete" | "newline" | "undo" | "redo" | "word-forward" | "word-backward" | "select-word-forward" | "select-word-backward" | "delete-word-forward" | "delete-word-backward" | "submit";
|
|
7
|
+
export type KeyBinding = BaseKeyBinding<TextareaAction>;
|
|
8
|
+
export interface SubmitEvent {
|
|
9
|
+
}
|
|
10
|
+
export interface TextareaOptions extends EditBufferOptions {
|
|
11
|
+
initialValue?: string;
|
|
12
|
+
backgroundColor?: ColorInput;
|
|
13
|
+
textColor?: ColorInput;
|
|
14
|
+
focusedBackgroundColor?: ColorInput;
|
|
15
|
+
focusedTextColor?: ColorInput;
|
|
16
|
+
placeholder?: string | null;
|
|
17
|
+
placeholderColor?: ColorInput;
|
|
18
|
+
keyBindings?: KeyBinding[];
|
|
19
|
+
onSubmit?: (event: SubmitEvent) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare class TextareaRenderable extends EditBufferRenderable {
|
|
22
|
+
private _placeholder;
|
|
23
|
+
private _unfocusedBackgroundColor;
|
|
24
|
+
private _unfocusedTextColor;
|
|
25
|
+
private _focusedBackgroundColor;
|
|
26
|
+
private _focusedTextColor;
|
|
27
|
+
private _placeholderColor;
|
|
28
|
+
private _keyBindingsMap;
|
|
29
|
+
private _actionHandlers;
|
|
30
|
+
private _initialValueSet;
|
|
31
|
+
private _submitListener;
|
|
32
|
+
private static readonly defaults;
|
|
33
|
+
constructor(ctx: RenderContext, options: TextareaOptions);
|
|
34
|
+
private buildActionHandlers;
|
|
35
|
+
handlePaste(text: string): void;
|
|
36
|
+
handleKeyPress(key: KeyEvent | string): boolean;
|
|
37
|
+
private updateColors;
|
|
38
|
+
insertChar(char: string): void;
|
|
39
|
+
insertText(text: string): void;
|
|
40
|
+
deleteChar(): boolean;
|
|
41
|
+
deleteCharBackward(): boolean;
|
|
42
|
+
private deleteSelectedText;
|
|
43
|
+
newLine(): boolean;
|
|
44
|
+
deleteLine(): boolean;
|
|
45
|
+
moveCursorLeft(options?: {
|
|
46
|
+
select?: boolean;
|
|
47
|
+
}): boolean;
|
|
48
|
+
moveCursorRight(options?: {
|
|
49
|
+
select?: boolean;
|
|
50
|
+
}): boolean;
|
|
51
|
+
moveCursorUp(options?: {
|
|
52
|
+
select?: boolean;
|
|
53
|
+
}): boolean;
|
|
54
|
+
moveCursorDown(options?: {
|
|
55
|
+
select?: boolean;
|
|
56
|
+
}): boolean;
|
|
57
|
+
gotoLine(line: number): void;
|
|
58
|
+
gotoLineHome(options?: {
|
|
59
|
+
select?: boolean;
|
|
60
|
+
}): boolean;
|
|
61
|
+
gotoLineEnd(options?: {
|
|
62
|
+
select?: boolean;
|
|
63
|
+
}): boolean;
|
|
64
|
+
gotoBufferHome(): boolean;
|
|
65
|
+
gotoBufferEnd(): boolean;
|
|
66
|
+
deleteToLineEnd(): boolean;
|
|
67
|
+
undo(): boolean;
|
|
68
|
+
redo(): boolean;
|
|
69
|
+
moveWordForward(options?: {
|
|
70
|
+
select?: boolean;
|
|
71
|
+
}): boolean;
|
|
72
|
+
moveWordBackward(options?: {
|
|
73
|
+
select?: boolean;
|
|
74
|
+
}): boolean;
|
|
75
|
+
deleteWordForward(): boolean;
|
|
76
|
+
deleteWordBackward(): boolean;
|
|
77
|
+
private handleShiftSelection;
|
|
78
|
+
focus(): void;
|
|
79
|
+
blur(): void;
|
|
80
|
+
get placeholder(): string | null;
|
|
81
|
+
set placeholder(value: string | null);
|
|
82
|
+
get backgroundColor(): RGBA;
|
|
83
|
+
set backgroundColor(value: RGBA | string | undefined);
|
|
84
|
+
get textColor(): RGBA;
|
|
85
|
+
set textColor(value: RGBA | string | undefined);
|
|
86
|
+
set focusedBackgroundColor(value: ColorInput);
|
|
87
|
+
set focusedTextColor(value: ColorInput);
|
|
88
|
+
set placeholderColor(value: ColorInput);
|
|
89
|
+
set initialValue(value: string);
|
|
90
|
+
submit(): boolean;
|
|
91
|
+
set onSubmit(handler: ((event: SubmitEvent) => void) | undefined);
|
|
92
|
+
get onSubmit(): ((event: SubmitEvent) => void) | undefined;
|
|
93
|
+
set keyBindings(bindings: KeyBinding[]);
|
|
94
|
+
get extmarks(): any;
|
|
95
|
+
}
|
package/renderables/index.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
export * from "./ASCIIFont";
|
|
1
2
|
export * from "./Box";
|
|
2
3
|
export * from "./Code";
|
|
4
|
+
export * from "./composition/constructs";
|
|
5
|
+
export * from "./composition/VRenderable";
|
|
6
|
+
export * from "./composition/vnode";
|
|
3
7
|
export * from "./FrameBuffer";
|
|
4
|
-
export * from "./TextBufferRenderable";
|
|
5
|
-
export * from "./Text";
|
|
6
|
-
export * from "./TextNode";
|
|
7
|
-
export * from "./ASCIIFont";
|
|
8
8
|
export * from "./Input";
|
|
9
|
+
export * from "./ScrollBar";
|
|
10
|
+
export * from "./ScrollBox";
|
|
9
11
|
export * from "./Select";
|
|
12
|
+
export * from "./Slider";
|
|
10
13
|
export * from "./TabSelect";
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./composition/VRenderable";
|
|
14
|
+
export * from "./Text";
|
|
15
|
+
export * from "./TextBufferRenderable";
|
|
16
|
+
export * from "./TextNode";
|
|
17
|
+
export * from "./Textarea";
|
package/renderer.d.ts
CHANGED
|
@@ -255,8 +255,12 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
|
|
|
255
255
|
get hasSelection(): boolean;
|
|
256
256
|
getSelectionContainer(): Renderable | null;
|
|
257
257
|
clearSelection(): void;
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Start a new selection at the given coordinates.
|
|
260
|
+
* Used by both mouse and keyboard selection.
|
|
261
|
+
*/
|
|
262
|
+
startSelection(renderable: Renderable, x: number, y: number): void;
|
|
263
|
+
updateSelection(currentRenderable: Renderable | undefined, x: number, y: number): void;
|
|
260
264
|
requestSelectionUpdate(): void;
|
|
261
265
|
private isWithinContainer;
|
|
262
266
|
private finishSelection;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { RGBA, type ColorInput } from "./RGBA";
|
|
1
|
+
import { RGBA, type ColorInput } from "./lib/RGBA";
|
|
2
|
+
import { type RenderLib } from "./zig";
|
|
3
|
+
import { type Pointer } from "bun:ffi";
|
|
2
4
|
export interface StyleDefinition {
|
|
3
5
|
fg?: RGBA;
|
|
4
6
|
bg?: RGBA;
|
|
@@ -25,12 +27,26 @@ export interface ThemeTokenStyle {
|
|
|
25
27
|
}
|
|
26
28
|
export declare function convertThemeToStyles(theme: ThemeTokenStyle[]): Record<string, StyleDefinition>;
|
|
27
29
|
export declare class SyntaxStyle {
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
|
|
30
|
+
private lib;
|
|
31
|
+
private stylePtr;
|
|
32
|
+
private _destroyed;
|
|
33
|
+
private nameCache;
|
|
34
|
+
private styleDefs;
|
|
35
|
+
private mergedCache;
|
|
36
|
+
constructor(lib: RenderLib, ptr: Pointer);
|
|
37
|
+
static create(): SyntaxStyle;
|
|
31
38
|
static fromTheme(theme: ThemeTokenStyle[]): SyntaxStyle;
|
|
32
|
-
|
|
39
|
+
static fromStyles(styles: Record<string, StyleDefinition>): SyntaxStyle;
|
|
40
|
+
private guard;
|
|
41
|
+
registerStyle(name: string, style: StyleDefinition): number;
|
|
42
|
+
resolveStyleId(name: string): number | null;
|
|
43
|
+
getStyleId(name: string): number | null;
|
|
44
|
+
get ptr(): Pointer;
|
|
45
|
+
getStyleCount(): number;
|
|
46
|
+
clearNameCache(): void;
|
|
33
47
|
getStyle(name: string): StyleDefinition | undefined;
|
|
48
|
+
mergeStyles(...styleNames: string[]): MergedStyle;
|
|
34
49
|
clearCache(): void;
|
|
35
50
|
getCacheSize(): number;
|
|
51
|
+
destroy(): void;
|
|
36
52
|
}
|