@opentui/core 0.0.0-20250908-4906ddad
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/SpriteResourceManager.d.ts +74 -0
- package/3d/SpriteUtils.d.ts +13 -0
- package/3d/TextureUtils.d.ts +24 -0
- package/3d/WGPURenderer.d.ts +59 -0
- package/3d/animation/ExplodingSpriteEffect.d.ts +71 -0
- package/3d/animation/PhysicsExplodingSpriteEffect.d.ts +76 -0
- package/3d/animation/SpriteAnimator.d.ts +124 -0
- package/3d/animation/SpriteParticleGenerator.d.ts +62 -0
- package/3d/canvas.d.ts +42 -0
- package/3d/index.d.ts +11 -0
- package/3d/physics/PlanckPhysicsAdapter.d.ts +19 -0
- package/3d/physics/RapierPhysicsAdapter.d.ts +19 -0
- package/3d/physics/physics-interface.d.ts +27 -0
- package/3d.d.ts +2 -0
- package/3d.js +33847 -0
- package/3d.js.map +154 -0
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/Renderable.d.ts +266 -0
- package/animation/Timeline.d.ts +125 -0
- package/ansi.d.ts +28 -0
- package/buffer.d.ts +74 -0
- package/console.d.ts +86 -0
- package/index-d6kwx5pm.js +8837 -0
- package/index-d6kwx5pm.js.map +36 -0
- package/index.d.ts +12 -0
- package/index.js +3721 -0
- package/index.js.map +23 -0
- package/lib/KeyHandler.d.ts +11 -0
- package/lib/RGBA.d.ts +24 -0
- package/lib/TrackedNode.d.ts +36 -0
- package/lib/ascii.font.d.ts +301 -0
- package/lib/border.d.ts +47 -0
- package/lib/hast-styled-text.d.ts +38 -0
- package/lib/index.d.ts +11 -0
- package/lib/output.capture.d.ts +24 -0
- package/lib/parse.keypress.d.ts +14 -0
- package/lib/parse.mouse.d.ts +23 -0
- package/lib/selection.d.ts +63 -0
- package/lib/styled-text.d.ts +73 -0
- package/lib/word-jumps.d.ts +2 -0
- package/lib/yoga.options.d.ts +31 -0
- package/package.json +48 -0
- package/post/filters.d.ts +105 -0
- package/renderables/ASCIIFont.d.ts +43 -0
- package/renderables/Box.d.ts +70 -0
- package/renderables/FrameBuffer.d.ts +16 -0
- package/renderables/Input.d.ts +70 -0
- package/renderables/ScrollBar.d.ts +77 -0
- package/renderables/ScrollBox.d.ts +82 -0
- package/renderables/Select.d.ts +102 -0
- package/renderables/Slider.d.ts +31 -0
- package/renderables/TabSelect.d.ts +86 -0
- package/renderables/Text.d.ts +72 -0
- package/renderables/composition/VRenderable.d.ts +16 -0
- package/renderables/composition/constructs.d.ts +12 -0
- package/renderables/composition/vnode.d.ts +46 -0
- package/renderables/index.d.ts +12 -0
- package/renderer.d.ts +232 -0
- package/singleton.d.ts +5 -0
- package/text-buffer.d.ts +52 -0
- package/types.d.ts +56 -0
- package/utils.d.ts +10 -0
- package/zig.d.ts +110 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BoxSizing, Align, Dimension, Direction, Display, Edge, FlexDirection, Gutter, Justify, LogLevel, MeasureMode, Overflow, PositionType, Unit, Wrap } from "yoga-layout";
|
|
2
|
+
export type AlignString = "auto" | "flex-start" | "center" | "flex-end" | "stretch" | "baseline" | "space-between" | "space-around" | "space-evenly";
|
|
3
|
+
export type BoxSizingString = "border-box" | "content-box";
|
|
4
|
+
export type DimensionString = "width" | "height";
|
|
5
|
+
export type DirectionString = "inherit" | "ltr" | "rtl";
|
|
6
|
+
export type DisplayString = "flex" | "none" | "contents";
|
|
7
|
+
export type EdgeString = "left" | "top" | "right" | "bottom" | "start" | "end" | "horizontal" | "vertical" | "all";
|
|
8
|
+
export type FlexDirectionString = "column" | "column-reverse" | "row" | "row-reverse";
|
|
9
|
+
export type GutterString = "column" | "row" | "all";
|
|
10
|
+
export type JustifyString = "flex-start" | "center" | "flex-end" | "space-between" | "space-around" | "space-evenly";
|
|
11
|
+
export type LogLevelString = "error" | "warn" | "info" | "debug" | "verbose" | "fatal";
|
|
12
|
+
export type MeasureModeString = "undefined" | "exactly" | "at-most";
|
|
13
|
+
export type OverflowString = "visible" | "hidden" | "scroll";
|
|
14
|
+
export type PositionTypeString = "static" | "relative" | "absolute";
|
|
15
|
+
export type UnitString = "undefined" | "point" | "percent" | "auto";
|
|
16
|
+
export type WrapString = "no-wrap" | "wrap" | "wrap-reverse";
|
|
17
|
+
export declare function parseAlign(value: string): Align;
|
|
18
|
+
export declare function parseBoxSizing(value: string): BoxSizing;
|
|
19
|
+
export declare function parseDimension(value: string): Dimension;
|
|
20
|
+
export declare function parseDirection(value: string): Direction;
|
|
21
|
+
export declare function parseDisplay(value: string): Display;
|
|
22
|
+
export declare function parseEdge(value: string): Edge;
|
|
23
|
+
export declare function parseFlexDirection(value: string): FlexDirection;
|
|
24
|
+
export declare function parseGutter(value: string): Gutter;
|
|
25
|
+
export declare function parseJustify(value: string): Justify;
|
|
26
|
+
export declare function parseLogLevel(value: string): LogLevel;
|
|
27
|
+
export declare function parseMeasureMode(value: string): MeasureMode;
|
|
28
|
+
export declare function parseOverflow(value: string): Overflow;
|
|
29
|
+
export declare function parsePositionType(value: string): PositionType;
|
|
30
|
+
export declare function parseUnit(value: string): Unit;
|
|
31
|
+
export declare function parseWrap(value: string): Wrap;
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentui/core",
|
|
3
|
+
"module": "index.js",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"version": "0.0.0-20250908-4906ddad",
|
|
8
|
+
"description": "OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/sst/opentui",
|
|
13
|
+
"directory": "packages/core"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./index.js",
|
|
18
|
+
"require": "./index.js",
|
|
19
|
+
"types": "./index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./3d": {
|
|
22
|
+
"import": "./3d.js",
|
|
23
|
+
"require": "./3d.js",
|
|
24
|
+
"types": "./3d.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"jimp": "1.6.0",
|
|
29
|
+
"yoga-layout": "3.2.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/bun": "latest",
|
|
33
|
+
"@types/three": "0.177.0",
|
|
34
|
+
"commander": "^13.1.0"
|
|
35
|
+
},
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"@dimforge/rapier2d-simd-compat": "^0.17.3",
|
|
38
|
+
"bun-webgpu": "0.1.3",
|
|
39
|
+
"planck": "^1.4.2",
|
|
40
|
+
"three": "0.177.0",
|
|
41
|
+
"@opentui/core-darwin-x64": "0.0.0-20250908-4906ddad",
|
|
42
|
+
"@opentui/core-darwin-arm64": "0.0.0-20250908-4906ddad",
|
|
43
|
+
"@opentui/core-linux-x64": "0.0.0-20250908-4906ddad",
|
|
44
|
+
"@opentui/core-linux-arm64": "0.0.0-20250908-4906ddad",
|
|
45
|
+
"@opentui/core-win32-x64": "0.0.0-20250908-4906ddad",
|
|
46
|
+
"@opentui/core-win32-arm64": "0.0.0-20250908-4906ddad"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
2
|
+
/**
|
|
3
|
+
* Applies a scanline effect by darkening every nth row.
|
|
4
|
+
*/
|
|
5
|
+
export declare function applyScanlines(buffer: OptimizedBuffer, strength?: number, step?: number): void;
|
|
6
|
+
/**
|
|
7
|
+
* Converts the buffer colors to grayscale.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyGrayscale(buffer: OptimizedBuffer): void;
|
|
10
|
+
/**
|
|
11
|
+
* Applies a sepia tone to the buffer.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applySepia(buffer: OptimizedBuffer): void;
|
|
14
|
+
/**
|
|
15
|
+
* Inverts the colors in the buffer.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyInvert(buffer: OptimizedBuffer): void;
|
|
18
|
+
/**
|
|
19
|
+
* Adds random noise to the buffer colors.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyNoise(buffer: OptimizedBuffer, strength?: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Applies a simplified chromatic aberration effect.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyChromaticAberration(buffer: OptimizedBuffer, strength?: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Converts the buffer to ASCII art based on background brightness.
|
|
28
|
+
*/
|
|
29
|
+
export declare function applyAsciiArt(buffer: OptimizedBuffer, ramp?: string): void;
|
|
30
|
+
export declare class DistortionEffect {
|
|
31
|
+
glitchChancePerSecond: number;
|
|
32
|
+
maxGlitchLines: number;
|
|
33
|
+
minGlitchDuration: number;
|
|
34
|
+
maxGlitchDuration: number;
|
|
35
|
+
maxShiftAmount: number;
|
|
36
|
+
shiftFlipRatio: number;
|
|
37
|
+
colorGlitchChance: number;
|
|
38
|
+
private lastGlitchTime;
|
|
39
|
+
private glitchDuration;
|
|
40
|
+
private activeGlitches;
|
|
41
|
+
constructor(options?: Partial<DistortionEffect>);
|
|
42
|
+
/**
|
|
43
|
+
* Applies the animated distortion/glitch effect to the buffer.
|
|
44
|
+
*/
|
|
45
|
+
apply(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Applies a vignette effect by darkening the corners, optimized with precomputation.
|
|
49
|
+
*/
|
|
50
|
+
export declare class VignetteEffect {
|
|
51
|
+
private _strength;
|
|
52
|
+
private precomputedBaseAttenuation;
|
|
53
|
+
private cachedWidth;
|
|
54
|
+
private cachedHeight;
|
|
55
|
+
constructor(strength?: number);
|
|
56
|
+
set strength(newStrength: number);
|
|
57
|
+
get strength(): number;
|
|
58
|
+
private _computeFactors;
|
|
59
|
+
/**
|
|
60
|
+
* Applies the vignette effect using precomputed base attenuation and current strength.
|
|
61
|
+
*/
|
|
62
|
+
apply(buffer: OptimizedBuffer): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adjusts the overall brightness of the buffer.
|
|
66
|
+
*/
|
|
67
|
+
export declare class BrightnessEffect {
|
|
68
|
+
private _brightness;
|
|
69
|
+
constructor(brightness?: number);
|
|
70
|
+
set brightness(newBrightness: number);
|
|
71
|
+
get brightness(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Applies the brightness adjustment to the buffer.
|
|
74
|
+
*/
|
|
75
|
+
apply(buffer: OptimizedBuffer): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Applies a simple box blur. (Expensive and may look bad with text).
|
|
79
|
+
*/
|
|
80
|
+
export declare class BlurEffect {
|
|
81
|
+
private _radius;
|
|
82
|
+
constructor(radius?: number);
|
|
83
|
+
set radius(newRadius: number);
|
|
84
|
+
get radius(): number;
|
|
85
|
+
/**
|
|
86
|
+
* Applies an optimized separable box blur using a moving average (sliding window).
|
|
87
|
+
*/
|
|
88
|
+
apply(buffer: OptimizedBuffer): void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Applies a bloom effect based on bright areas (Simplified).
|
|
92
|
+
*/
|
|
93
|
+
export declare class BloomEffect {
|
|
94
|
+
private _threshold;
|
|
95
|
+
private _strength;
|
|
96
|
+
private _radius;
|
|
97
|
+
constructor(threshold?: number, strength?: number, radius?: number);
|
|
98
|
+
set threshold(newThreshold: number);
|
|
99
|
+
get threshold(): number;
|
|
100
|
+
set strength(newStrength: number);
|
|
101
|
+
get strength(): number;
|
|
102
|
+
set radius(newRadius: number);
|
|
103
|
+
get radius(): number;
|
|
104
|
+
apply(buffer: OptimizedBuffer): void;
|
|
105
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { RenderableOptions } from "../Renderable";
|
|
2
|
+
import { Selection } from "../lib/selection";
|
|
3
|
+
import { type fonts, type ASCIIFontName } from "../lib/ascii.font";
|
|
4
|
+
import { RGBA } from "../lib/RGBA";
|
|
5
|
+
import { FrameBufferRenderable } from "./FrameBuffer";
|
|
6
|
+
import type { RenderContext } from "../types";
|
|
7
|
+
export interface ASCIIFontOptions extends RenderableOptions<ASCIIFontRenderable> {
|
|
8
|
+
text?: string;
|
|
9
|
+
font?: ASCIIFontName;
|
|
10
|
+
fg?: RGBA | RGBA[];
|
|
11
|
+
bg?: RGBA;
|
|
12
|
+
selectionBg?: string | RGBA;
|
|
13
|
+
selectionFg?: string | RGBA;
|
|
14
|
+
selectable?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class ASCIIFontRenderable extends FrameBufferRenderable {
|
|
17
|
+
selectable: boolean;
|
|
18
|
+
private _text;
|
|
19
|
+
private _font;
|
|
20
|
+
private _fg;
|
|
21
|
+
private _bg;
|
|
22
|
+
private _selectionBg;
|
|
23
|
+
private _selectionFg;
|
|
24
|
+
private lastLocalSelection;
|
|
25
|
+
private selectionHelper;
|
|
26
|
+
constructor(ctx: RenderContext, options: ASCIIFontOptions);
|
|
27
|
+
get text(): string;
|
|
28
|
+
set text(value: string);
|
|
29
|
+
get font(): keyof typeof fonts;
|
|
30
|
+
set font(value: keyof typeof fonts);
|
|
31
|
+
get fg(): RGBA[];
|
|
32
|
+
set fg(value: RGBA | RGBA[] | string | string[]);
|
|
33
|
+
get bg(): RGBA;
|
|
34
|
+
set bg(value: RGBA | string);
|
|
35
|
+
private updateDimensions;
|
|
36
|
+
shouldStartSelection(x: number, y: number): boolean;
|
|
37
|
+
onSelectionChanged(selection: Selection | null): boolean;
|
|
38
|
+
getSelectedText(): string;
|
|
39
|
+
hasSelection(): boolean;
|
|
40
|
+
protected onResize(width: number, height: number): void;
|
|
41
|
+
private renderFontToBuffer;
|
|
42
|
+
private renderSelectionHighlight;
|
|
43
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type RenderableOptions, Renderable } from "../Renderable";
|
|
2
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
3
|
+
import { type BorderCharacters, type BorderSides, type BorderSidesConfig, type BorderStyle } from "../lib";
|
|
4
|
+
import { type ColorInput, RGBA } from "../lib/RGBA";
|
|
5
|
+
import type { RenderContext } from "../types";
|
|
6
|
+
export interface BoxOptions<TRenderable extends Renderable = BoxRenderable> extends RenderableOptions<TRenderable> {
|
|
7
|
+
backgroundColor?: string | RGBA;
|
|
8
|
+
borderStyle?: BorderStyle;
|
|
9
|
+
border?: boolean | BorderSides[];
|
|
10
|
+
borderColor?: string | RGBA;
|
|
11
|
+
customBorderChars?: BorderCharacters;
|
|
12
|
+
shouldFill?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
titleAlignment?: "left" | "center" | "right";
|
|
15
|
+
focusedBorderColor?: ColorInput;
|
|
16
|
+
gap?: number | `${number}%`;
|
|
17
|
+
rowGap?: number | `${number}%`;
|
|
18
|
+
columnGap?: number | `${number}%`;
|
|
19
|
+
}
|
|
20
|
+
export declare class BoxRenderable extends Renderable {
|
|
21
|
+
protected _backgroundColor: RGBA;
|
|
22
|
+
protected _border: boolean | BorderSides[];
|
|
23
|
+
protected _borderStyle: BorderStyle;
|
|
24
|
+
protected _borderColor: RGBA;
|
|
25
|
+
protected _focusedBorderColor: RGBA;
|
|
26
|
+
private _customBorderCharsObj;
|
|
27
|
+
protected _customBorderChars?: Uint32Array;
|
|
28
|
+
protected borderSides: BorderSidesConfig;
|
|
29
|
+
shouldFill: boolean;
|
|
30
|
+
protected _title?: string;
|
|
31
|
+
protected _titleAlignment: "left" | "center" | "right";
|
|
32
|
+
protected _defaultOptions: {
|
|
33
|
+
backgroundColor: string;
|
|
34
|
+
borderStyle: "single";
|
|
35
|
+
border: false;
|
|
36
|
+
borderColor: string;
|
|
37
|
+
shouldFill: true;
|
|
38
|
+
titleAlignment: "left";
|
|
39
|
+
focusedBorderColor: string;
|
|
40
|
+
};
|
|
41
|
+
constructor(ctx: RenderContext, options: BoxOptions);
|
|
42
|
+
get customBorderChars(): BorderCharacters | undefined;
|
|
43
|
+
set customBorderChars(value: BorderCharacters | undefined);
|
|
44
|
+
get backgroundColor(): RGBA;
|
|
45
|
+
set backgroundColor(value: RGBA | string | undefined);
|
|
46
|
+
get border(): boolean | BorderSides[];
|
|
47
|
+
set border(value: boolean | BorderSides[]);
|
|
48
|
+
get borderStyle(): BorderStyle;
|
|
49
|
+
set borderStyle(value: BorderStyle);
|
|
50
|
+
get borderColor(): RGBA;
|
|
51
|
+
set borderColor(value: RGBA | string);
|
|
52
|
+
get focusedBorderColor(): RGBA;
|
|
53
|
+
set focusedBorderColor(value: RGBA | string);
|
|
54
|
+
get title(): string | undefined;
|
|
55
|
+
set title(value: string | undefined);
|
|
56
|
+
get titleAlignment(): "left" | "center" | "right";
|
|
57
|
+
set titleAlignment(value: "left" | "center" | "right");
|
|
58
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
59
|
+
protected getScissorRect(): {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
};
|
|
65
|
+
private applyYogaBorders;
|
|
66
|
+
private applyYogaGap;
|
|
67
|
+
set gap(gap: number | `${number}%` | undefined);
|
|
68
|
+
set rowGap(rowGap: number | `${number}%` | undefined);
|
|
69
|
+
set columnGap(columnGap: number | `${number}%` | undefined);
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RenderableOptions, Renderable } from "../Renderable";
|
|
2
|
+
import { OptimizedBuffer } from "../buffer";
|
|
3
|
+
import type { RenderContext } from "../types";
|
|
4
|
+
export interface FrameBufferOptions extends RenderableOptions<FrameBufferRenderable> {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
respectAlpha?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class FrameBufferRenderable extends Renderable {
|
|
10
|
+
frameBuffer: OptimizedBuffer;
|
|
11
|
+
protected respectAlpha: boolean;
|
|
12
|
+
constructor(ctx: RenderContext, options: FrameBufferOptions);
|
|
13
|
+
protected onResize(width: number, height: number): void;
|
|
14
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
15
|
+
protected destroySelf(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { OptimizedBuffer } from "../buffer";
|
|
2
|
+
import type { ParsedKey } from "../lib/parse.keypress";
|
|
3
|
+
import { type ColorInput } from "../lib/RGBA";
|
|
4
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
5
|
+
import type { RenderContext } from "../types";
|
|
6
|
+
export interface InputRenderableOptions extends RenderableOptions<InputRenderable> {
|
|
7
|
+
backgroundColor?: ColorInput;
|
|
8
|
+
textColor?: ColorInput;
|
|
9
|
+
focusedBackgroundColor?: ColorInput;
|
|
10
|
+
focusedTextColor?: ColorInput;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
placeholderColor?: ColorInput;
|
|
13
|
+
cursorColor?: ColorInput;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
value?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare enum InputRenderableEvents {
|
|
18
|
+
INPUT = "input",
|
|
19
|
+
CHANGE = "change",
|
|
20
|
+
ENTER = "enter"
|
|
21
|
+
}
|
|
22
|
+
export declare class InputRenderable extends Renderable {
|
|
23
|
+
protected focusable: boolean;
|
|
24
|
+
private _value;
|
|
25
|
+
private _cursorPosition;
|
|
26
|
+
private _placeholder;
|
|
27
|
+
private _backgroundColor;
|
|
28
|
+
private _textColor;
|
|
29
|
+
private _focusedBackgroundColor;
|
|
30
|
+
private _focusedTextColor;
|
|
31
|
+
private _placeholderColor;
|
|
32
|
+
private _cursorColor;
|
|
33
|
+
private _maxLength;
|
|
34
|
+
private _lastCommittedValue;
|
|
35
|
+
protected _defaultOptions: {
|
|
36
|
+
backgroundColor: string;
|
|
37
|
+
textColor: string;
|
|
38
|
+
focusedBackgroundColor: string;
|
|
39
|
+
focusedTextColor: string;
|
|
40
|
+
placeholder: string;
|
|
41
|
+
placeholderColor: string;
|
|
42
|
+
cursorColor: string;
|
|
43
|
+
maxLength: number;
|
|
44
|
+
value: string;
|
|
45
|
+
};
|
|
46
|
+
constructor(ctx: RenderContext, options: InputRenderableOptions);
|
|
47
|
+
private updateCursorPosition;
|
|
48
|
+
focus(): void;
|
|
49
|
+
blur(): void;
|
|
50
|
+
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
51
|
+
private refreshFrameBuffer;
|
|
52
|
+
get value(): string;
|
|
53
|
+
set value(value: string);
|
|
54
|
+
set placeholder(placeholder: string);
|
|
55
|
+
get cursorPosition(): number;
|
|
56
|
+
set cursorPosition(position: number);
|
|
57
|
+
private insertText;
|
|
58
|
+
private deleteCharacter;
|
|
59
|
+
handleKeyPress(key: ParsedKey | string): boolean;
|
|
60
|
+
set maxLength(maxLength: number);
|
|
61
|
+
set backgroundColor(value: ColorInput);
|
|
62
|
+
set textColor(value: ColorInput);
|
|
63
|
+
set focusedBackgroundColor(value: ColorInput);
|
|
64
|
+
set focusedTextColor(value: ColorInput);
|
|
65
|
+
set placeholderColor(value: ColorInput);
|
|
66
|
+
set cursorColor(value: ColorInput);
|
|
67
|
+
updateFromLayout(): void;
|
|
68
|
+
protected onResize(width: number, height: number): void;
|
|
69
|
+
protected onRemove(): void;
|
|
70
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
2
|
+
import { RGBA, type ColorInput } from "../lib";
|
|
3
|
+
import type { ParsedKey } from "../lib/parse.keypress";
|
|
4
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
5
|
+
import type { RenderContext } from "../types";
|
|
6
|
+
import { SliderRenderable, type SliderOptions } from "./Slider";
|
|
7
|
+
export interface ScrollBarOptions extends RenderableOptions<ScrollBarRenderable> {
|
|
8
|
+
orientation: "vertical" | "horizontal";
|
|
9
|
+
showArrows?: boolean;
|
|
10
|
+
arrowOptions?: Omit<ArrowOptions, "direction">;
|
|
11
|
+
trackOptions?: Partial<SliderOptions>;
|
|
12
|
+
onChange?: (position: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export type ScrollUnit = "absolute" | "viewport" | "content" | "step";
|
|
15
|
+
export declare class ScrollBarRenderable extends Renderable {
|
|
16
|
+
readonly slider: SliderRenderable;
|
|
17
|
+
readonly startArrow: ArrowRenderable;
|
|
18
|
+
readonly endArrow: ArrowRenderable;
|
|
19
|
+
readonly orientation: "vertical" | "horizontal";
|
|
20
|
+
protected focusable: boolean;
|
|
21
|
+
private _scrollSize;
|
|
22
|
+
private _scrollPosition;
|
|
23
|
+
private _viewportSize;
|
|
24
|
+
private _showArrows;
|
|
25
|
+
private _manualVisibility;
|
|
26
|
+
private _onChange;
|
|
27
|
+
scrollStep: number | undefined | null;
|
|
28
|
+
get visible(): boolean;
|
|
29
|
+
set visible(value: boolean);
|
|
30
|
+
resetVisibilityControl(): void;
|
|
31
|
+
get scrollSize(): number;
|
|
32
|
+
get scrollPosition(): number;
|
|
33
|
+
get viewportSize(): number;
|
|
34
|
+
set scrollSize(value: number);
|
|
35
|
+
set scrollPosition(value: number);
|
|
36
|
+
set viewportSize(value: number);
|
|
37
|
+
get showArrows(): boolean;
|
|
38
|
+
set showArrows(value: boolean);
|
|
39
|
+
constructor(ctx: RenderContext, { trackOptions, arrowOptions, orientation, showArrows, ...options }: ScrollBarOptions);
|
|
40
|
+
set arrowOptions(options: ScrollBarOptions["arrowOptions"]);
|
|
41
|
+
set trackOptions(options: ScrollBarOptions["trackOptions"]);
|
|
42
|
+
private updateSliderFromScrollState;
|
|
43
|
+
scrollBy(delta: number, unit?: ScrollUnit): void;
|
|
44
|
+
private recalculateVisibility;
|
|
45
|
+
handleKeyPress(key: ParsedKey | string): boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface ArrowOptions extends RenderableOptions<ArrowRenderable> {
|
|
48
|
+
direction: "up" | "down" | "left" | "right";
|
|
49
|
+
foregroundColor?: ColorInput;
|
|
50
|
+
backgroundColor?: ColorInput;
|
|
51
|
+
attributes?: number;
|
|
52
|
+
arrowChars?: {
|
|
53
|
+
up?: string;
|
|
54
|
+
down?: string;
|
|
55
|
+
left?: string;
|
|
56
|
+
right?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export declare class ArrowRenderable extends Renderable {
|
|
60
|
+
private _direction;
|
|
61
|
+
private _foregroundColor;
|
|
62
|
+
private _backgroundColor;
|
|
63
|
+
private _attributes;
|
|
64
|
+
private _arrowChars;
|
|
65
|
+
constructor(ctx: RenderContext, options: ArrowOptions);
|
|
66
|
+
get direction(): "up" | "down" | "left" | "right";
|
|
67
|
+
set direction(value: "up" | "down" | "left" | "right");
|
|
68
|
+
get foregroundColor(): RGBA;
|
|
69
|
+
set foregroundColor(value: ColorInput);
|
|
70
|
+
get backgroundColor(): RGBA;
|
|
71
|
+
set backgroundColor(value: ColorInput);
|
|
72
|
+
get attributes(): number;
|
|
73
|
+
set attributes(value: number);
|
|
74
|
+
set arrowChars(value: ArrowOptions["arrowChars"]);
|
|
75
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
76
|
+
private getArrowChar;
|
|
77
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ParsedKey } from "../lib";
|
|
2
|
+
import type { Renderable, RenderableOptions } from "../Renderable";
|
|
3
|
+
import type { MouseEvent } from "../renderer";
|
|
4
|
+
import type { RenderContext } from "../types";
|
|
5
|
+
import { BoxRenderable, type BoxOptions } from "./Box";
|
|
6
|
+
import type { VNode } from "./composition/vnode";
|
|
7
|
+
import { ScrollBarRenderable, type ScrollBarOptions, type ScrollUnit } from "./ScrollBar";
|
|
8
|
+
declare class ContentRenderable extends BoxRenderable {
|
|
9
|
+
private viewport;
|
|
10
|
+
constructor(ctx: RenderContext, viewport: BoxRenderable, options: RenderableOptions<BoxRenderable>);
|
|
11
|
+
protected _getChildren(): Renderable[];
|
|
12
|
+
}
|
|
13
|
+
export interface ScrollBoxOptions extends BoxOptions<ScrollBoxRenderable> {
|
|
14
|
+
rootOptions?: BoxOptions;
|
|
15
|
+
wrapperOptions?: BoxOptions;
|
|
16
|
+
viewportOptions?: BoxOptions;
|
|
17
|
+
contentOptions?: BoxOptions;
|
|
18
|
+
scrollbarOptions?: Omit<ScrollBarOptions, "orientation">;
|
|
19
|
+
verticalScrollbarOptions?: Omit<ScrollBarOptions, "orientation">;
|
|
20
|
+
horizontalScrollbarOptions?: Omit<ScrollBarOptions, "orientation">;
|
|
21
|
+
}
|
|
22
|
+
export declare class ScrollBoxRenderable extends BoxRenderable {
|
|
23
|
+
static idCounter: number;
|
|
24
|
+
private internalId;
|
|
25
|
+
readonly wrapper: BoxRenderable;
|
|
26
|
+
readonly viewport: BoxRenderable;
|
|
27
|
+
readonly content: ContentRenderable;
|
|
28
|
+
readonly horizontalScrollBar: ScrollBarRenderable;
|
|
29
|
+
readonly verticalScrollBar: ScrollBarRenderable;
|
|
30
|
+
protected focusable: boolean;
|
|
31
|
+
private selectionListener?;
|
|
32
|
+
private autoScrollMouseX;
|
|
33
|
+
private autoScrollMouseY;
|
|
34
|
+
private readonly autoScrollThresholdVertical;
|
|
35
|
+
private readonly autoScrollThresholdHorizontal;
|
|
36
|
+
private readonly autoScrollSpeedSlow;
|
|
37
|
+
private readonly autoScrollSpeedMedium;
|
|
38
|
+
private readonly autoScrollSpeedFast;
|
|
39
|
+
private isAutoScrolling;
|
|
40
|
+
private cachedAutoScrollSpeed;
|
|
41
|
+
private autoScrollAccumulatorX;
|
|
42
|
+
private autoScrollAccumulatorY;
|
|
43
|
+
get scrollTop(): number;
|
|
44
|
+
set scrollTop(value: number);
|
|
45
|
+
get scrollLeft(): number;
|
|
46
|
+
set scrollLeft(value: number);
|
|
47
|
+
get scrollWidth(): number;
|
|
48
|
+
get scrollHeight(): number;
|
|
49
|
+
constructor(ctx: RenderContext, { wrapperOptions, viewportOptions, contentOptions, rootOptions, scrollbarOptions, verticalScrollbarOptions, horizontalScrollbarOptions, ...options }: ScrollBoxOptions);
|
|
50
|
+
protected onUpdate(deltaTime: number): void;
|
|
51
|
+
scrollBy(delta: number | {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
}, unit?: ScrollUnit): void;
|
|
55
|
+
scrollTo(position: number | {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
}): void;
|
|
59
|
+
add(obj: Renderable | VNode<any, any[]>, index?: number): number;
|
|
60
|
+
remove(id: string): void;
|
|
61
|
+
getChildren(): Renderable[];
|
|
62
|
+
protected onMouseEvent(event: MouseEvent): void;
|
|
63
|
+
handleKeyPress(key: ParsedKey | string): boolean;
|
|
64
|
+
startAutoScroll(mouseX: number, mouseY: number): void;
|
|
65
|
+
updateAutoScroll(mouseX: number, mouseY: number): void;
|
|
66
|
+
stopAutoScroll(): void;
|
|
67
|
+
private hasOtherLiveReasons;
|
|
68
|
+
private handleAutoScroll;
|
|
69
|
+
private getAutoScrollDirectionX;
|
|
70
|
+
private getAutoScrollDirectionY;
|
|
71
|
+
private getAutoScrollSpeed;
|
|
72
|
+
private recalculateBarProps;
|
|
73
|
+
set rootOptions(options: ScrollBoxOptions["rootOptions"]);
|
|
74
|
+
set wrapperOptions(options: ScrollBoxOptions["wrapperOptions"]);
|
|
75
|
+
set viewportOptions(options: ScrollBoxOptions["viewportOptions"]);
|
|
76
|
+
set contentOptions(options: ScrollBoxOptions["contentOptions"]);
|
|
77
|
+
set scrollbarOptions(options: ScrollBoxOptions["scrollbarOptions"]);
|
|
78
|
+
set verticalScrollbarOptions(options: ScrollBoxOptions["verticalScrollbarOptions"]);
|
|
79
|
+
set horizontalScrollbarOptions(options: ScrollBoxOptions["horizontalScrollbarOptions"]);
|
|
80
|
+
protected destroySelf(): void;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { OptimizedBuffer } from "../buffer";
|
|
2
|
+
import { fonts } from "../lib/ascii.font";
|
|
3
|
+
import type { ParsedKey } from "../lib/parse.keypress";
|
|
4
|
+
import { type ColorInput } from "../lib/RGBA";
|
|
5
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
6
|
+
import type { RenderContext } from "../types";
|
|
7
|
+
export interface SelectOption {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
value?: any;
|
|
11
|
+
}
|
|
12
|
+
export interface SelectRenderableOptions extends RenderableOptions<SelectRenderable> {
|
|
13
|
+
backgroundColor?: ColorInput;
|
|
14
|
+
textColor?: ColorInput;
|
|
15
|
+
focusedBackgroundColor?: ColorInput;
|
|
16
|
+
focusedTextColor?: ColorInput;
|
|
17
|
+
options?: SelectOption[];
|
|
18
|
+
selectedBackgroundColor?: ColorInput;
|
|
19
|
+
selectedTextColor?: ColorInput;
|
|
20
|
+
descriptionColor?: ColorInput;
|
|
21
|
+
selectedDescriptionColor?: ColorInput;
|
|
22
|
+
showScrollIndicator?: boolean;
|
|
23
|
+
wrapSelection?: boolean;
|
|
24
|
+
showDescription?: boolean;
|
|
25
|
+
font?: keyof typeof fonts;
|
|
26
|
+
itemSpacing?: number;
|
|
27
|
+
fastScrollStep?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare enum SelectRenderableEvents {
|
|
30
|
+
SELECTION_CHANGED = "selectionChanged",
|
|
31
|
+
ITEM_SELECTED = "itemSelected"
|
|
32
|
+
}
|
|
33
|
+
export declare class SelectRenderable extends Renderable {
|
|
34
|
+
protected focusable: boolean;
|
|
35
|
+
private _options;
|
|
36
|
+
private selectedIndex;
|
|
37
|
+
private scrollOffset;
|
|
38
|
+
private maxVisibleItems;
|
|
39
|
+
private _backgroundColor;
|
|
40
|
+
private _textColor;
|
|
41
|
+
private _focusedBackgroundColor;
|
|
42
|
+
private _focusedTextColor;
|
|
43
|
+
private _selectedBackgroundColor;
|
|
44
|
+
private _selectedTextColor;
|
|
45
|
+
private _descriptionColor;
|
|
46
|
+
private _selectedDescriptionColor;
|
|
47
|
+
private _showScrollIndicator;
|
|
48
|
+
private _wrapSelection;
|
|
49
|
+
private _showDescription;
|
|
50
|
+
private _font?;
|
|
51
|
+
private _itemSpacing;
|
|
52
|
+
private linesPerItem;
|
|
53
|
+
private fontHeight;
|
|
54
|
+
private _fastScrollStep;
|
|
55
|
+
protected _defaultOptions: {
|
|
56
|
+
backgroundColor: string;
|
|
57
|
+
textColor: string;
|
|
58
|
+
focusedBackgroundColor: string;
|
|
59
|
+
focusedTextColor: string;
|
|
60
|
+
selectedBackgroundColor: string;
|
|
61
|
+
selectedTextColor: string;
|
|
62
|
+
descriptionColor: string;
|
|
63
|
+
selectedDescriptionColor: string;
|
|
64
|
+
showScrollIndicator: false;
|
|
65
|
+
wrapSelection: false;
|
|
66
|
+
showDescription: true;
|
|
67
|
+
itemSpacing: number;
|
|
68
|
+
fastScrollStep: number;
|
|
69
|
+
};
|
|
70
|
+
constructor(ctx: RenderContext, options: SelectRenderableOptions);
|
|
71
|
+
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
72
|
+
private refreshFrameBuffer;
|
|
73
|
+
private renderScrollIndicatorToFrameBuffer;
|
|
74
|
+
get options(): SelectOption[];
|
|
75
|
+
set options(options: SelectOption[]);
|
|
76
|
+
getSelectedOption(): SelectOption | null;
|
|
77
|
+
getSelectedIndex(): number;
|
|
78
|
+
moveUp(steps?: number): void;
|
|
79
|
+
moveDown(steps?: number): void;
|
|
80
|
+
selectCurrent(): void;
|
|
81
|
+
setSelectedIndex(index: number): void;
|
|
82
|
+
private updateScrollOffset;
|
|
83
|
+
protected onResize(width: number, height: number): void;
|
|
84
|
+
handleKeyPress(key: ParsedKey | string): boolean;
|
|
85
|
+
get showScrollIndicator(): boolean;
|
|
86
|
+
set showScrollIndicator(show: boolean);
|
|
87
|
+
get showDescription(): boolean;
|
|
88
|
+
set showDescription(show: boolean);
|
|
89
|
+
get wrapSelection(): boolean;
|
|
90
|
+
set wrapSelection(wrap: boolean);
|
|
91
|
+
set backgroundColor(value: ColorInput);
|
|
92
|
+
set textColor(value: ColorInput);
|
|
93
|
+
set focusedBackgroundColor(value: ColorInput);
|
|
94
|
+
set focusedTextColor(value: ColorInput);
|
|
95
|
+
set selectedBackgroundColor(value: ColorInput);
|
|
96
|
+
set selectedTextColor(value: ColorInput);
|
|
97
|
+
set descriptionColor(value: ColorInput);
|
|
98
|
+
set selectedDescriptionColor(value: ColorInput);
|
|
99
|
+
set font(font: keyof typeof fonts);
|
|
100
|
+
set itemSpacing(spacing: number);
|
|
101
|
+
set fastScrollStep(step: number);
|
|
102
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ColorInput, OptimizedBuffer, Renderable, type RenderableOptions, type RenderContext, RGBA } from "../index";
|
|
2
|
+
export interface SliderOptions extends RenderableOptions<SliderRenderable> {
|
|
3
|
+
orientation: "vertical" | "horizontal";
|
|
4
|
+
thumbSize?: number;
|
|
5
|
+
thumbPosition?: number;
|
|
6
|
+
backgroundColor?: ColorInput;
|
|
7
|
+
foregroundColor?: ColorInput;
|
|
8
|
+
onChange?: (position: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class SliderRenderable extends Renderable {
|
|
11
|
+
readonly orientation: "vertical" | "horizontal";
|
|
12
|
+
private _thumbSize;
|
|
13
|
+
private _thumbPosition;
|
|
14
|
+
private _backgroundColor;
|
|
15
|
+
private _foregroundColor;
|
|
16
|
+
private _onChange?;
|
|
17
|
+
constructor(ctx: RenderContext, options: SliderOptions);
|
|
18
|
+
get thumbSize(): number;
|
|
19
|
+
set thumbSize(value: number);
|
|
20
|
+
get thumbPosition(): number;
|
|
21
|
+
set thumbPosition(value: number);
|
|
22
|
+
get backgroundColor(): RGBA;
|
|
23
|
+
set backgroundColor(value: ColorInput);
|
|
24
|
+
get foregroundColor(): RGBA;
|
|
25
|
+
set foregroundColor(value: ColorInput);
|
|
26
|
+
private setupMouseHandling;
|
|
27
|
+
private updatePositionFromMouse;
|
|
28
|
+
private getThumbPosition;
|
|
29
|
+
private getThumbRect;
|
|
30
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
31
|
+
}
|