@opentui/core 0.1.28 → 0.1.30
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 +1 -1
- package/3d.js.map +1 -1
- package/README.md +10 -0
- package/Renderable.d.ts +25 -24
- package/buffer.d.ts +4 -7
- package/edit-buffer.d.ts +80 -0
- package/editor-view.d.ts +53 -0
- package/{index-phjxdb6g.js → index-0qmm1k4p.js} +1709 -323
- package/{index-phjxdb6g.js.map → index-0qmm1k4p.js.map} +18 -17
- package/index.d.ts +4 -0
- package/index.js +1505 -65
- package/index.js.map +13 -6
- package/lib/hast-styled-text.d.ts +2 -3
- package/lib/index.d.ts +0 -1
- package/lib/keymapping.d.ts +10 -0
- package/lib/objects-in-viewport.d.ts +14 -0
- 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 +8 -7
- package/renderables/Code.d.ts +1 -1
- package/renderables/EditBufferRenderable.d.ts +113 -0
- package/renderables/Text.d.ts +0 -3
- package/renderables/TextBufferRenderable.d.ts +8 -14
- package/renderables/Textarea.d.ts +87 -0
- package/renderables/index.d.ts +1 -0
- package/renderer.d.ts +6 -2
- package/{lib/syntax-style.d.ts → syntax-style.d.ts} +21 -5
- package/testing/mock-keys.d.ts +37 -2
- package/testing.js +52 -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 +145 -23
- package/lib/word-jumps.d.ts +0 -2
|
@@ -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 {};
|
|
@@ -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.1.
|
|
7
|
+
"version": "0.1.30",
|
|
8
8
|
"description": "OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -35,6 +35,7 @@
|
|
|
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
|
},
|
|
@@ -54,11 +55,11 @@
|
|
|
54
55
|
"bun-webgpu": "0.1.3",
|
|
55
56
|
"planck": "^1.4.2",
|
|
56
57
|
"three": "0.177.0",
|
|
57
|
-
"@opentui/core-darwin-x64": "0.1.
|
|
58
|
-
"@opentui/core-darwin-arm64": "0.1.
|
|
59
|
-
"@opentui/core-linux-x64": "0.1.
|
|
60
|
-
"@opentui/core-linux-arm64": "0.1.
|
|
61
|
-
"@opentui/core-win32-x64": "0.1.
|
|
62
|
-
"@opentui/core-win32-arm64": "0.1.
|
|
58
|
+
"@opentui/core-darwin-x64": "0.1.30",
|
|
59
|
+
"@opentui/core-darwin-arm64": "0.1.30",
|
|
60
|
+
"@opentui/core-linux-x64": "0.1.30",
|
|
61
|
+
"@opentui/core-linux-arm64": "0.1.30",
|
|
62
|
+
"@opentui/core-win32-x64": "0.1.30",
|
|
63
|
+
"@opentui/core-win32-arm64": "0.1.30"
|
|
63
64
|
}
|
|
64
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,113 @@
|
|
|
1
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
2
|
+
import { Selection, type LocalSelectionBounds } from "../lib/selection";
|
|
3
|
+
import { EditBuffer, type CursorPosition } 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
|
+
editBuffer: EditBuffer;
|
|
46
|
+
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 cursor(): CursorPosition;
|
|
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
|
+
}
|
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;
|
|
@@ -0,0 +1,87 @@
|
|
|
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";
|
|
7
|
+
export type KeyBinding = BaseKeyBinding<TextareaAction>;
|
|
8
|
+
export interface TextareaOptions extends EditBufferOptions {
|
|
9
|
+
value?: string;
|
|
10
|
+
backgroundColor?: ColorInput;
|
|
11
|
+
textColor?: ColorInput;
|
|
12
|
+
focusedBackgroundColor?: ColorInput;
|
|
13
|
+
focusedTextColor?: ColorInput;
|
|
14
|
+
placeholder?: string | null;
|
|
15
|
+
placeholderColor?: ColorInput;
|
|
16
|
+
keyBindings?: KeyBinding[];
|
|
17
|
+
}
|
|
18
|
+
export declare class TextareaRenderable extends EditBufferRenderable {
|
|
19
|
+
private _placeholder;
|
|
20
|
+
private _unfocusedBackgroundColor;
|
|
21
|
+
private _unfocusedTextColor;
|
|
22
|
+
private _focusedBackgroundColor;
|
|
23
|
+
private _focusedTextColor;
|
|
24
|
+
private _placeholderColor;
|
|
25
|
+
private _keyBindingsMap;
|
|
26
|
+
private _actionHandlers;
|
|
27
|
+
private static readonly defaults;
|
|
28
|
+
constructor(ctx: RenderContext, options: TextareaOptions);
|
|
29
|
+
private buildActionHandlers;
|
|
30
|
+
handlePaste(text: string): void;
|
|
31
|
+
handleKeyPress(key: KeyEvent | string): boolean;
|
|
32
|
+
get value(): string;
|
|
33
|
+
set value(value: string);
|
|
34
|
+
private updateValue;
|
|
35
|
+
private updateColors;
|
|
36
|
+
insertChar(char: string): void;
|
|
37
|
+
insertText(text: string): void;
|
|
38
|
+
deleteChar(): boolean;
|
|
39
|
+
deleteCharBackward(): boolean;
|
|
40
|
+
private deleteSelectedText;
|
|
41
|
+
newLine(): boolean;
|
|
42
|
+
deleteLine(): boolean;
|
|
43
|
+
moveCursorLeft(options?: {
|
|
44
|
+
select?: boolean;
|
|
45
|
+
}): boolean;
|
|
46
|
+
moveCursorRight(options?: {
|
|
47
|
+
select?: boolean;
|
|
48
|
+
}): boolean;
|
|
49
|
+
moveCursorUp(options?: {
|
|
50
|
+
select?: boolean;
|
|
51
|
+
}): boolean;
|
|
52
|
+
moveCursorDown(options?: {
|
|
53
|
+
select?: boolean;
|
|
54
|
+
}): boolean;
|
|
55
|
+
gotoLine(line: number): void;
|
|
56
|
+
gotoLineHome(options?: {
|
|
57
|
+
select?: boolean;
|
|
58
|
+
}): boolean;
|
|
59
|
+
gotoLineEnd(options?: {
|
|
60
|
+
select?: boolean;
|
|
61
|
+
}): boolean;
|
|
62
|
+
gotoBufferHome(): boolean;
|
|
63
|
+
gotoBufferEnd(): boolean;
|
|
64
|
+
deleteToLineEnd(): boolean;
|
|
65
|
+
undo(): boolean;
|
|
66
|
+
redo(): boolean;
|
|
67
|
+
moveWordForward(options?: {
|
|
68
|
+
select?: boolean;
|
|
69
|
+
}): boolean;
|
|
70
|
+
moveWordBackward(options?: {
|
|
71
|
+
select?: boolean;
|
|
72
|
+
}): boolean;
|
|
73
|
+
deleteWordForward(): boolean;
|
|
74
|
+
deleteWordBackward(): boolean;
|
|
75
|
+
private handleShiftSelection;
|
|
76
|
+
focus(): void;
|
|
77
|
+
blur(): void;
|
|
78
|
+
get placeholder(): string | null;
|
|
79
|
+
set placeholder(value: string | null);
|
|
80
|
+
get backgroundColor(): RGBA;
|
|
81
|
+
set backgroundColor(value: RGBA | string | undefined);
|
|
82
|
+
get textColor(): RGBA;
|
|
83
|
+
set textColor(value: RGBA | string | undefined);
|
|
84
|
+
set focusedBackgroundColor(value: ColorInput);
|
|
85
|
+
set focusedTextColor(value: ColorInput);
|
|
86
|
+
set placeholderColor(value: ColorInput);
|
|
87
|
+
}
|
package/renderables/index.d.ts
CHANGED
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
|
}
|
package/testing/mock-keys.d.ts
CHANGED
|
@@ -52,17 +52,52 @@ export declare const KeyCodes: {
|
|
|
52
52
|
readonly ALT_A: "\u001Ba";
|
|
53
53
|
readonly ALT_B: "\u001Bb";
|
|
54
54
|
readonly ALT_C: "\u001Bc";
|
|
55
|
+
readonly ALT_D: "\u001Bd";
|
|
56
|
+
readonly ALT_E: "\u001Be";
|
|
57
|
+
readonly ALT_F: "\u001Bf";
|
|
58
|
+
readonly ALT_G: "\u001Bg";
|
|
59
|
+
readonly ALT_H: "\u001Bh";
|
|
60
|
+
readonly ALT_I: "\u001Bi";
|
|
61
|
+
readonly ALT_J: "\u001Bj";
|
|
62
|
+
readonly ALT_K: "\u001Bk";
|
|
63
|
+
readonly ALT_L: "\u001Bl";
|
|
64
|
+
readonly ALT_M: "\u001Bm";
|
|
65
|
+
readonly ALT_N: "\u001Bn";
|
|
66
|
+
readonly ALT_O: "\u001Bo";
|
|
67
|
+
readonly ALT_P: "\u001Bp";
|
|
68
|
+
readonly ALT_Q: "\u001Bq";
|
|
69
|
+
readonly ALT_R: "\u001Br";
|
|
70
|
+
readonly ALT_S: "\u001Bs";
|
|
71
|
+
readonly ALT_T: "\u001Bt";
|
|
72
|
+
readonly ALT_U: "\u001Bu";
|
|
73
|
+
readonly ALT_V: "\u001Bv";
|
|
74
|
+
readonly ALT_W: "\u001Bw";
|
|
75
|
+
readonly ALT_X: "\u001Bx";
|
|
76
|
+
readonly ALT_Y: "\u001By";
|
|
77
|
+
readonly ALT_Z: "\u001Bz";
|
|
78
|
+
readonly ALT_LEFT: "\u001B\u001B[D";
|
|
79
|
+
readonly ALT_RIGHT: "\u001B\u001B[C";
|
|
80
|
+
readonly ALT_UP: "\u001B\u001B[A";
|
|
81
|
+
readonly ALT_DOWN: "\u001B\u001B[B";
|
|
55
82
|
};
|
|
56
83
|
export type KeyInput = string | keyof typeof KeyCodes;
|
|
57
84
|
export declare function createMockKeys(renderer: CliRenderer): {
|
|
58
85
|
pressKeys: (keys: KeyInput[], delayMs?: number) => Promise<void>;
|
|
59
|
-
pressKey: (key: KeyInput
|
|
86
|
+
pressKey: (key: KeyInput, modifiers?: {
|
|
87
|
+
shift?: boolean;
|
|
88
|
+
ctrl?: boolean;
|
|
89
|
+
meta?: boolean;
|
|
90
|
+
}) => void;
|
|
60
91
|
typeText: (text: string, delayMs?: number) => Promise<void>;
|
|
61
92
|
pressEnter: () => void;
|
|
62
93
|
pressEscape: () => void;
|
|
63
94
|
pressTab: () => void;
|
|
64
95
|
pressBackspace: () => void;
|
|
65
|
-
pressArrow: (direction: "up" | "down" | "left" | "right"
|
|
96
|
+
pressArrow: (direction: "up" | "down" | "left" | "right", modifiers?: {
|
|
97
|
+
shift?: boolean;
|
|
98
|
+
ctrl?: boolean;
|
|
99
|
+
meta?: boolean;
|
|
100
|
+
}) => void;
|
|
66
101
|
pressCtrlC: () => void;
|
|
67
102
|
pasteBracketedText: (text: string) => Promise<void>;
|
|
68
103
|
};
|
package/testing.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ANSI,
|
|
4
4
|
CliRenderer,
|
|
5
5
|
resolveRenderLib
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-0qmm1k4p.js";
|
|
7
7
|
|
|
8
8
|
// src/testing/mock-keys.ts
|
|
9
9
|
var KeyCodes = {
|
|
@@ -59,7 +59,34 @@ var KeyCodes = {
|
|
|
59
59
|
CTRL_Z: "\x1A",
|
|
60
60
|
ALT_A: "\x1Ba",
|
|
61
61
|
ALT_B: "\x1Bb",
|
|
62
|
-
ALT_C: "\x1Bc"
|
|
62
|
+
ALT_C: "\x1Bc",
|
|
63
|
+
ALT_D: "\x1Bd",
|
|
64
|
+
ALT_E: "\x1Be",
|
|
65
|
+
ALT_F: "\x1Bf",
|
|
66
|
+
ALT_G: "\x1Bg",
|
|
67
|
+
ALT_H: "\x1Bh",
|
|
68
|
+
ALT_I: "\x1Bi",
|
|
69
|
+
ALT_J: "\x1Bj",
|
|
70
|
+
ALT_K: "\x1Bk",
|
|
71
|
+
ALT_L: "\x1Bl",
|
|
72
|
+
ALT_M: "\x1Bm",
|
|
73
|
+
ALT_N: "\x1Bn",
|
|
74
|
+
ALT_O: "\x1Bo",
|
|
75
|
+
ALT_P: "\x1Bp",
|
|
76
|
+
ALT_Q: "\x1Bq",
|
|
77
|
+
ALT_R: "\x1Br",
|
|
78
|
+
ALT_S: "\x1Bs",
|
|
79
|
+
ALT_T: "\x1Bt",
|
|
80
|
+
ALT_U: "\x1Bu",
|
|
81
|
+
ALT_V: "\x1Bv",
|
|
82
|
+
ALT_W: "\x1Bw",
|
|
83
|
+
ALT_X: "\x1Bx",
|
|
84
|
+
ALT_Y: "\x1By",
|
|
85
|
+
ALT_Z: "\x1Bz",
|
|
86
|
+
ALT_LEFT: "\x1B\x1B[D",
|
|
87
|
+
ALT_RIGHT: "\x1B\x1B[C",
|
|
88
|
+
ALT_UP: "\x1B\x1B[A",
|
|
89
|
+
ALT_DOWN: "\x1B\x1B[B"
|
|
63
90
|
};
|
|
64
91
|
function createMockKeys(renderer) {
|
|
65
92
|
const pressKeys = async (keys, delayMs = 0) => {
|
|
@@ -83,7 +110,7 @@ function createMockKeys(renderer) {
|
|
|
83
110
|
}
|
|
84
111
|
}
|
|
85
112
|
};
|
|
86
|
-
const pressKey = (key) => {
|
|
113
|
+
const pressKey = (key, modifiers) => {
|
|
87
114
|
let keyCode;
|
|
88
115
|
if (typeof key === "string") {
|
|
89
116
|
if (key in KeyCodes) {
|
|
@@ -97,6 +124,25 @@ function createMockKeys(renderer) {
|
|
|
97
124
|
throw new Error(`Unknown key: ${key}`);
|
|
98
125
|
}
|
|
99
126
|
}
|
|
127
|
+
if (modifiers) {
|
|
128
|
+
if (keyCode.startsWith("\x1B[") && keyCode.length > 2) {
|
|
129
|
+
const modifier = 1 + (modifiers.shift ? 1 : 0) + (modifiers.meta ? 2 : 0) + (modifiers.ctrl ? 4 : 0);
|
|
130
|
+
if (modifier > 1) {
|
|
131
|
+
const ending = keyCode.slice(-1);
|
|
132
|
+
keyCode = `\x1B[1;${modifier}${ending}`;
|
|
133
|
+
}
|
|
134
|
+
} else if (keyCode.length === 1 && !modifiers.ctrl) {
|
|
135
|
+
let char = keyCode;
|
|
136
|
+
if (modifiers.shift && char >= "a" && char <= "z") {
|
|
137
|
+
char = char.toUpperCase();
|
|
138
|
+
}
|
|
139
|
+
if (modifiers.meta) {
|
|
140
|
+
keyCode = `\x1B${char}`;
|
|
141
|
+
} else {
|
|
142
|
+
keyCode = char;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
100
146
|
renderer.stdin.emit("data", Buffer.from(keyCode));
|
|
101
147
|
};
|
|
102
148
|
const typeText = async (text, delayMs = 0) => {
|
|
@@ -115,14 +161,14 @@ function createMockKeys(renderer) {
|
|
|
115
161
|
const pressBackspace = () => {
|
|
116
162
|
pressKey(KeyCodes.BACKSPACE);
|
|
117
163
|
};
|
|
118
|
-
const pressArrow = (direction) => {
|
|
164
|
+
const pressArrow = (direction, modifiers) => {
|
|
119
165
|
const keyMap = {
|
|
120
166
|
up: KeyCodes.ARROW_UP,
|
|
121
167
|
down: KeyCodes.ARROW_DOWN,
|
|
122
168
|
left: KeyCodes.ARROW_LEFT,
|
|
123
169
|
right: KeyCodes.ARROW_RIGHT
|
|
124
170
|
};
|
|
125
|
-
pressKey(keyMap[direction]);
|
|
171
|
+
pressKey(keyMap[direction], modifiers);
|
|
126
172
|
};
|
|
127
173
|
const pressCtrlC = () => {
|
|
128
174
|
pressKey(KeyCodes.CTRL_C);
|
|
@@ -364,5 +410,5 @@ export {
|
|
|
364
410
|
KeyCodes
|
|
365
411
|
};
|
|
366
412
|
|
|
367
|
-
//# debugId=
|
|
413
|
+
//# debugId=4F737E7B09ACF94364756E2164756E21
|
|
368
414
|
//# sourceMappingURL=testing.js.map
|