@sayknow-cli/tui 0.4.1 → 0.4.3
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/dist/types/animation-scheduler.d.ts +13 -0
- package/dist/types/autocomplete.d.ts +84 -0
- package/dist/types/bracketed-paste.d.ts +20 -0
- package/dist/types/components/box.d.ts +20 -0
- package/dist/types/components/cancellable-loader.d.ts +21 -0
- package/dist/types/components/editor.d.ts +126 -0
- package/dist/types/components/image.d.ts +18 -0
- package/dist/types/components/input.d.ts +16 -0
- package/dist/types/components/loader.d.ts +23 -0
- package/dist/types/components/markdown.d.ts +87 -0
- package/dist/types/components/sayknow-pet.d.ts +128 -0
- package/dist/types/components/secret-input.d.ts +35 -0
- package/dist/types/components/select-list.d.ts +52 -0
- package/dist/types/components/settings-list.d.ts +39 -0
- package/dist/types/components/spacer.d.ts +11 -0
- package/dist/types/components/tab-bar.d.ts +56 -0
- package/dist/types/components/text.d.ts +22 -0
- package/dist/types/components/truncated-text.d.ts +10 -0
- package/dist/types/editor-component.d.ts +36 -0
- package/dist/types/fuzzy.d.ts +15 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/keybindings.d.ts +201 -0
- package/dist/types/keys.d.ts +208 -0
- package/dist/types/kill-ring.d.ts +27 -0
- package/dist/types/metrics.d.ts +85 -0
- package/dist/types/stdin-buffer.d.ts +52 -0
- package/dist/types/symbols.d.ts +23 -0
- package/dist/types/terminal-capabilities.d.ts +187 -0
- package/dist/types/terminal.d.ts +94 -0
- package/dist/types/ttyid.d.ts +9 -0
- package/dist/types/tui.d.ts +304 -0
- package/dist/types/utils.d.ts +110 -0
- package/package.json +9 -8
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import type { Terminal } from "./terminal";
|
|
2
|
+
import { visibleWidth } from "./utils";
|
|
3
|
+
type InputListenerResult = {
|
|
4
|
+
consume?: boolean;
|
|
5
|
+
data?: string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
type InputListener = (data: string) => InputListenerResult;
|
|
8
|
+
/**
|
|
9
|
+
* Component interface - all components must implement this
|
|
10
|
+
*/
|
|
11
|
+
export type MouseEvent = {
|
|
12
|
+
kind: "wheel" | "click";
|
|
13
|
+
direction?: -1 | 1;
|
|
14
|
+
button?: 0;
|
|
15
|
+
/** Terminal cell coordinates, one-based. */
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
/** Focused-overlay cell coordinates, one-based when dispatched to an overlay. */
|
|
19
|
+
localX?: number;
|
|
20
|
+
localY?: number;
|
|
21
|
+
};
|
|
22
|
+
type OverlayMouseBounds = {
|
|
23
|
+
row: number;
|
|
24
|
+
col: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
termWidth: number;
|
|
28
|
+
termHeight: number;
|
|
29
|
+
};
|
|
30
|
+
/** Parse xterm SGR mouse reports. Drag and button-release reports are ignored. */
|
|
31
|
+
export declare function parseSgrMouseEvent(data: string): MouseEvent | undefined;
|
|
32
|
+
export interface Component {
|
|
33
|
+
/**
|
|
34
|
+
* Render the component to lines for the given viewport width
|
|
35
|
+
* @param width - Current viewport width
|
|
36
|
+
* @returns Array of strings, each representing a line
|
|
37
|
+
*/
|
|
38
|
+
render(width: number): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Optional handler for keyboard input when component has focus
|
|
41
|
+
*/
|
|
42
|
+
handleInput?(data: string): void;
|
|
43
|
+
/** Optional handler for terminal mouse events when component has focus. */
|
|
44
|
+
handleMouse?(event: MouseEvent): void;
|
|
45
|
+
/**
|
|
46
|
+
* If true, component receives key release events (Kitty protocol).
|
|
47
|
+
* Default is false - release events are filtered out.
|
|
48
|
+
*/
|
|
49
|
+
wantsKeyRelease?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Invalidate any cached rendering state.
|
|
52
|
+
* Called when theme changes or when component needs to re-render from scratch.
|
|
53
|
+
*/
|
|
54
|
+
invalidate(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Optional cleanup hook. Called once when the component is permanently
|
|
57
|
+
* removed from the tree via removeChild/clear/dispose. Implementations MUST
|
|
58
|
+
* be idempotent. Components meant to be re-added should be detached, not
|
|
59
|
+
* removed/cleared.
|
|
60
|
+
*/
|
|
61
|
+
dispose?(): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Interface for components that can receive focus and display a hardware cursor.
|
|
65
|
+
* When focused, the component should emit CURSOR_MARKER at the cursor position
|
|
66
|
+
* in its render output. TUI will find this marker and position the hardware
|
|
67
|
+
* cursor there for proper IME candidate window positioning.
|
|
68
|
+
*/
|
|
69
|
+
export interface Focusable {
|
|
70
|
+
/** Set by TUI when focus changes. Component should emit CURSOR_MARKER when true. */
|
|
71
|
+
focused: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Type guard to check if a component implements Focusable */
|
|
74
|
+
export declare function isFocusable(component: Component | null): component is Component & Focusable;
|
|
75
|
+
/**
|
|
76
|
+
* Cursor position marker - APC (Application Program Command) sequence.
|
|
77
|
+
* This is a zero-width escape sequence that terminals ignore.
|
|
78
|
+
* Components emit this at the cursor position when focused.
|
|
79
|
+
* TUI finds and strips this marker, then positions the hardware cursor there.
|
|
80
|
+
*/
|
|
81
|
+
export declare const CURSOR_MARKER = "\u001B_pi:c\u0007";
|
|
82
|
+
export { visibleWidth };
|
|
83
|
+
/** Durable source identifier for a semantically anchored viewport row. */
|
|
84
|
+
export type ViewportAnchorId = string;
|
|
85
|
+
export interface ViewportAnchorRow {
|
|
86
|
+
id: ViewportAnchorId;
|
|
87
|
+
graphemeStart: number;
|
|
88
|
+
graphemeEnd: number;
|
|
89
|
+
cellStart: number;
|
|
90
|
+
cellEnd: number;
|
|
91
|
+
}
|
|
92
|
+
export interface ViewportAnchorRender {
|
|
93
|
+
lines: string[];
|
|
94
|
+
anchors: Array<ViewportAnchorRow | null>;
|
|
95
|
+
}
|
|
96
|
+
export interface ViewportAnchorProvider extends Component {
|
|
97
|
+
renderWithViewportAnchors(width: number): ViewportAnchorRender;
|
|
98
|
+
}
|
|
99
|
+
export interface ViewportAnchorSource {
|
|
100
|
+
id: ViewportAnchorId;
|
|
101
|
+
}
|
|
102
|
+
export interface ViewportAnchorSourceRenderer extends Component {
|
|
103
|
+
renderWithViewportAnchorSource(width: number, source: ViewportAnchorSource): ViewportAnchorRender;
|
|
104
|
+
}
|
|
105
|
+
export declare function isViewportAnchorProvider(component: Component): component is ViewportAnchorProvider;
|
|
106
|
+
export declare function isViewportAnchorSourceRenderer(component: Component): component is ViewportAnchorSourceRenderer;
|
|
107
|
+
export declare function renderComponentWithViewportAnchors(component: Component, width: number): ViewportAnchorRender;
|
|
108
|
+
export declare function renderComponentWithViewportAnchorSource(component: Component, width: number, source: ViewportAnchorSource): ViewportAnchorRender;
|
|
109
|
+
/**
|
|
110
|
+
* Anchor position for overlays
|
|
111
|
+
*/
|
|
112
|
+
export type OverlayAnchor = "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top-center" | "bottom-center" | "left-center" | "right-center";
|
|
113
|
+
/**
|
|
114
|
+
* Margin configuration for overlays
|
|
115
|
+
*/
|
|
116
|
+
export interface OverlayMargin {
|
|
117
|
+
top?: number;
|
|
118
|
+
right?: number;
|
|
119
|
+
bottom?: number;
|
|
120
|
+
left?: number;
|
|
121
|
+
}
|
|
122
|
+
/** Value that can be absolute (number) or percentage (string like "50%") */
|
|
123
|
+
export type SizeValue = number | `${number}%`;
|
|
124
|
+
/**
|
|
125
|
+
* Startup sixel capability probe policy (pure; exported for tests):
|
|
126
|
+
* - Never probe when PI_FORCE_IMAGE_PROTOCOL is set — an explicit
|
|
127
|
+
* configuration (including "off") is authoritative.
|
|
128
|
+
* - Never probe inside a terminal multiplexer: tmux advertises DA1 ";4"
|
|
129
|
+
* whenever it was compiled with sixel support, regardless of whether the
|
|
130
|
+
* attached client terminal can render sixel, so a positive reply is not
|
|
131
|
+
* end-to-end evidence. Graphics under a multiplexer are strictly opt-in
|
|
132
|
+
* via PI_FORCE_IMAGE_PROTOCOL=sixel.
|
|
133
|
+
* - Probe Windows Terminal (>=1.22 renders sixel but exposes no env marker).
|
|
134
|
+
*/
|
|
135
|
+
export declare function shouldProbeSixelCapability(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* True when repainting only the live viewport is safer than clearing/replaying
|
|
138
|
+
* the full transcript. Real process terminals are viewport-sensitive because
|
|
139
|
+
* their native scrollback position is not observable by the renderer. Native
|
|
140
|
+
* Windows console hosts are also recognized from platform identity when that
|
|
141
|
+
* process-terminal capability is unavailable.
|
|
142
|
+
*/
|
|
143
|
+
export declare function shouldUseViewportRepaintForHost(env?: Record<string, string | undefined>, platform?: NodeJS.Platform, options?: {
|
|
144
|
+
includeNativeWindows?: boolean;
|
|
145
|
+
includeProcessTerminal?: boolean;
|
|
146
|
+
}): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Options for overlay positioning and sizing.
|
|
149
|
+
* Values can be absolute numbers or percentage strings (e.g., "50%").
|
|
150
|
+
*/
|
|
151
|
+
export interface OverlayOptions {
|
|
152
|
+
/** Width in columns, or percentage of terminal width (e.g., "50%") */
|
|
153
|
+
width?: SizeValue;
|
|
154
|
+
/** Minimum width in columns */
|
|
155
|
+
minWidth?: number;
|
|
156
|
+
/** Maximum height in rows, or percentage of terminal height (e.g., "50%") */
|
|
157
|
+
maxHeight?: SizeValue;
|
|
158
|
+
/** Anchor point for positioning (default: 'center') */
|
|
159
|
+
anchor?: OverlayAnchor;
|
|
160
|
+
/** Horizontal offset from anchor position (positive = right) */
|
|
161
|
+
offsetX?: number;
|
|
162
|
+
/** Vertical offset from anchor position (positive = down) */
|
|
163
|
+
offsetY?: number;
|
|
164
|
+
/** Row position: absolute number, or percentage (e.g., "25%" = 25% from top) */
|
|
165
|
+
row?: SizeValue;
|
|
166
|
+
/** Column position: absolute number, or percentage (e.g., "50%" = centered horizontally) */
|
|
167
|
+
col?: SizeValue;
|
|
168
|
+
/** Margin from terminal edges. Number applies to all sides. */
|
|
169
|
+
margin?: OverlayMargin | number;
|
|
170
|
+
/**
|
|
171
|
+
* Control overlay visibility based on terminal dimensions.
|
|
172
|
+
* If provided, overlay is only rendered when this returns true.
|
|
173
|
+
* Called each render cycle with current terminal dimensions.
|
|
174
|
+
*/
|
|
175
|
+
visible?: (termWidth: number, termHeight: number) => boolean;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Handle returned by showOverlay for controlling the overlay
|
|
179
|
+
*/
|
|
180
|
+
export interface OverlayHandle {
|
|
181
|
+
/** Permanently remove the overlay (cannot be shown again) */
|
|
182
|
+
hide(): void;
|
|
183
|
+
/** Temporarily hide or show the overlay */
|
|
184
|
+
setHidden(hidden: boolean): void;
|
|
185
|
+
/** Check if overlay is temporarily hidden */
|
|
186
|
+
isHidden(): boolean;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Container - a component that contains other components
|
|
190
|
+
*/
|
|
191
|
+
export declare class Container implements ViewportAnchorProvider {
|
|
192
|
+
#private;
|
|
193
|
+
children: Component[];
|
|
194
|
+
addChild(component: Component): void;
|
|
195
|
+
removeChild(component: Component): void;
|
|
196
|
+
/** Remove a child without disposing it (for detach-then-readd reuse). */
|
|
197
|
+
detachChild(component: Component): void;
|
|
198
|
+
clear(): void;
|
|
199
|
+
/** Remove all children without disposing them (for detach-then-readd reuse). */
|
|
200
|
+
detachAll(): void;
|
|
201
|
+
/** Registers a direct child as eligible for semantic viewport anchoring. */
|
|
202
|
+
setViewportAnchorSource(component: Component, source: ViewportAnchorSource | null): void;
|
|
203
|
+
dispose(): void;
|
|
204
|
+
invalidate(): void;
|
|
205
|
+
render(width: number): string[];
|
|
206
|
+
renderWithViewportAnchors(width: number): ViewportAnchorRender;
|
|
207
|
+
}
|
|
208
|
+
type TuiRenderCounterSnapshot = {
|
|
209
|
+
debugRedrawEnvReads: number;
|
|
210
|
+
debugRedrawAppendWrites: number;
|
|
211
|
+
differentialGuardVisibleWidthCalls: number;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* TUI - Main class for managing terminal UI with differential rendering
|
|
215
|
+
*/
|
|
216
|
+
export declare class TUI extends Container {
|
|
217
|
+
#private;
|
|
218
|
+
private readonly options;
|
|
219
|
+
terminal: Terminal;
|
|
220
|
+
/** Global callback for debug key (Shift+Ctrl+D). Called before input is forwarded to focused component. */
|
|
221
|
+
onDebug?: () => void;
|
|
222
|
+
static resetRenderCountersForTest(): void;
|
|
223
|
+
static getRenderCountersForTest(): TuiRenderCounterSnapshot;
|
|
224
|
+
overlayStack: {
|
|
225
|
+
component: Component;
|
|
226
|
+
options?: OverlayOptions;
|
|
227
|
+
preFocus: Component | null;
|
|
228
|
+
hidden: boolean;
|
|
229
|
+
mouseBounds?: OverlayMouseBounds;
|
|
230
|
+
}[];
|
|
231
|
+
constructor(terminal: Terminal, showHardwareCursor?: boolean, options?: {
|
|
232
|
+
enableMouse?: boolean;
|
|
233
|
+
});
|
|
234
|
+
dispose(): void;
|
|
235
|
+
get fullRedraws(): number;
|
|
236
|
+
getShowHardwareCursor(): boolean;
|
|
237
|
+
setShowHardwareCursor(enabled: boolean): void;
|
|
238
|
+
getClearOnShrink(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Set whether to trigger full re-render when content shrinks.
|
|
241
|
+
* When true (default), empty rows are cleared when content shrinks.
|
|
242
|
+
* When false, empty rows remain (reduces redraws on slower terminals).
|
|
243
|
+
*/
|
|
244
|
+
setClearOnShrink(enabled: boolean): void;
|
|
245
|
+
setFocus(component: Component | null): void;
|
|
246
|
+
setBottomPinnedComponent(component: Component | null): void;
|
|
247
|
+
/** Register the direct child whose rows are eligible for semantic viewport anchoring. */
|
|
248
|
+
setViewportAnchorComponent(component: Component | null): void;
|
|
249
|
+
/** Clear manual viewport ownership before replacing the transcript identity namespace. */
|
|
250
|
+
resetViewportAnchorIntent(): void;
|
|
251
|
+
/** Allow one semantic-neighbor reconciliation after a definitive same-transcript rebuild. */
|
|
252
|
+
prepareViewportAnchorForTranscriptRebuild(): void;
|
|
253
|
+
/** Reveal a semantic viewport anchor without changing the rendered content width. */
|
|
254
|
+
revealViewportAnchor(id: ViewportAnchorId, alignment: "top" | "center" | "bottom"): boolean;
|
|
255
|
+
scrollViewportPages(direction: -1 | 1): boolean;
|
|
256
|
+
followLiveViewport(): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Show an overlay component with configurable positioning and sizing.
|
|
259
|
+
* Returns a handle to control the overlay's visibility.
|
|
260
|
+
*/
|
|
261
|
+
showOverlay(component: Component, options?: OverlayOptions): OverlayHandle;
|
|
262
|
+
/** Hide the topmost overlay and restore previous focus. */
|
|
263
|
+
hideOverlay(): void;
|
|
264
|
+
/** Check if there are any visible overlays */
|
|
265
|
+
hasOverlay(): boolean;
|
|
266
|
+
invalidate(): void;
|
|
267
|
+
start(): void;
|
|
268
|
+
get terminalAvailable(): boolean;
|
|
269
|
+
addInputListener(listener: InputListener): () => void;
|
|
270
|
+
removeInputListener(listener: InputListener): void;
|
|
271
|
+
stop(): void;
|
|
272
|
+
/**
|
|
273
|
+
* Viewport-repaint-aware resize render request.
|
|
274
|
+
*
|
|
275
|
+
* A forced full redraw (`requestRender(true)`) resets `#previousWidth`/`#previousHeight`
|
|
276
|
+
* to -1, which makes `#doRender` treat the frame as a width change and fall into the
|
|
277
|
+
* `fullRender` path. In terminal multiplexers that path skips the scrollback-clearing
|
|
278
|
+
* `3J` escape (users navigate scrollback history), so replaying every transcript line
|
|
279
|
+
* piles it back on top of scrollback — the "top of screen scrolls down to the prompt at
|
|
280
|
+
* high speed" resize storm. Windows Terminal/ConPTY can also visibly jump to
|
|
281
|
+
* the transcript top during streaming redraws, so viewport-repaint sessions
|
|
282
|
+
* keep force off and let `#doRender` repaint only the live viewport. Set
|
|
283
|
+
* `PI_TUI_LEGACY_MULTIPLEXER_FULL_RENDER=1` to restore the legacy tmux redraw.
|
|
284
|
+
*/
|
|
285
|
+
requestResizeRender(): void;
|
|
286
|
+
requestRender(force?: boolean, source?: string): void;
|
|
287
|
+
getLineRenderCacheStats(): {
|
|
288
|
+
normalizationSize: number;
|
|
289
|
+
truncationSize: number;
|
|
290
|
+
normalizationLimit: number;
|
|
291
|
+
truncationLimit: number;
|
|
292
|
+
};
|
|
293
|
+
/** Retain terminal cleanup until a write succeeds, even after its component is disposed. */
|
|
294
|
+
queueTerminalCleanup(payload: string, onDelivered?: () => void): void;
|
|
295
|
+
/** Retry queued terminal cleanup after terminal recovery or before shutdown. */
|
|
296
|
+
flushTerminalCleanup(): void;
|
|
297
|
+
/**
|
|
298
|
+
* Register an emitter whose escape payload is appended to every render
|
|
299
|
+
* write (inside its own synchronized-output block, cursor saved/restored).
|
|
300
|
+
* Used for absolute-positioned overlays such as pixel-image pets that live
|
|
301
|
+
* outside the line-based component model. Return null to emit nothing.
|
|
302
|
+
*/
|
|
303
|
+
setPostRenderEmitter(emitter: (() => string | null) | undefined): void;
|
|
304
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Ellipsis, type ExtractSegmentsResult, type SliceResult } from "@sayknow-cli/natives";
|
|
2
|
+
export { Ellipsis } from "@sayknow-cli/natives";
|
|
3
|
+
export { getDefaultTabWidth, getIndentation } from "@sayknow-cli/utils";
|
|
4
|
+
/** Test-only performance counters for advisory baseline tests. */
|
|
5
|
+
export declare const __textHelperPerfCounters: {
|
|
6
|
+
truncateToWidthCalls: number;
|
|
7
|
+
wrapTextWithAnsiCalls: number;
|
|
8
|
+
truncateLinesToWidthCalls: number;
|
|
9
|
+
visibleWidthsCalls: number;
|
|
10
|
+
reset(): void;
|
|
11
|
+
};
|
|
12
|
+
export declare function invalidateTabWidthCache(): void;
|
|
13
|
+
export declare function isPrintableAscii(text: string): boolean;
|
|
14
|
+
export declare function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean | null): SliceResult;
|
|
15
|
+
export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind?: Ellipsis | null, pad?: boolean | null): string;
|
|
16
|
+
export declare function truncateLinesToWidth(lines: readonly string[], maxWidth: number, ellipsisKind?: Ellipsis | null, pad?: boolean | null): string[];
|
|
17
|
+
export declare function wrapTextWithAnsi(text: string, width: number): string[];
|
|
18
|
+
export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean): ExtractSegmentsResult;
|
|
19
|
+
/**
|
|
20
|
+
* Tab width in columns for `file`, using `process.cwd()` as the project root for relative paths.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getIndentationNoescape(file?: string): number;
|
|
23
|
+
export declare function replaceTabs(text: string, file?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a string of n spaces. Uses a pre-allocated buffer for efficiency.
|
|
26
|
+
*/
|
|
27
|
+
export declare function padding(n: number): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get the shared grapheme segmenter instance.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSegmenter(): Intl.Segmenter;
|
|
32
|
+
export interface ViewportAnchorSpan {
|
|
33
|
+
graphemeStart: number;
|
|
34
|
+
graphemeEnd: number;
|
|
35
|
+
cellStart: number;
|
|
36
|
+
cellEnd: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ViewportAnchorAnnotation {
|
|
39
|
+
text: string;
|
|
40
|
+
nextGrapheme: number;
|
|
41
|
+
nextCell: number;
|
|
42
|
+
token: string;
|
|
43
|
+
}
|
|
44
|
+
export declare const VIEWPORT_ANCHOR_PREFIX = "\u001B_ASKC_ANCHOR:";
|
|
45
|
+
/**
|
|
46
|
+
* Tag every visible grapheme with an APC marker that survives ANSI-aware
|
|
47
|
+
* wrapping. The marker contains source grapheme and monotonic cell offsets.
|
|
48
|
+
*/
|
|
49
|
+
export declare function annotateViewportAnchorGraphemes(text: string, startGrapheme?: number, startCell?: number, token?: `${string}-${string}-${string}-${string}-${string}`): ViewportAnchorAnnotation;
|
|
50
|
+
/** Remove viewport anchor markers and return the exact marked span for each row. */
|
|
51
|
+
export declare function extractViewportAnchorRows(lines: readonly string[], token: string): {
|
|
52
|
+
lines: string[];
|
|
53
|
+
spans: Array<ViewportAnchorSpan | null>;
|
|
54
|
+
};
|
|
55
|
+
export declare function visibleWidthRaw(str: string): number;
|
|
56
|
+
/**
|
|
57
|
+
* Calculate the visible width of a string in terminal columns.
|
|
58
|
+
*/
|
|
59
|
+
export declare function visibleWidth(str: string): number;
|
|
60
|
+
export declare function visibleWidthsNative(lines: readonly string[]): number[];
|
|
61
|
+
export declare function visibleWidths(lines: readonly string[]): number[];
|
|
62
|
+
/**
|
|
63
|
+
* Normalize text for terminal output without changing logical editor content.
|
|
64
|
+
* Some terminals render canonically decomposed Hangul jamo or precomposed
|
|
65
|
+
* Thai/Lao AM vowels inconsistently during differential repaint. Emit a stable
|
|
66
|
+
* terminal form while keeping the component/source strings unchanged.
|
|
67
|
+
*/
|
|
68
|
+
export declare function normalizeTerminalOutput(str: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a character is whitespace.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isWhitespaceChar(char: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Check if a character is punctuation.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isPunctuationChar(char: string): boolean;
|
|
77
|
+
export type WordNavKind = "whitespace" | "delimiter" | "cjk" | "word" | "other";
|
|
78
|
+
/**
|
|
79
|
+
* Coarse Unicode-aware character classification for word navigation (Option/Alt + Left/Right).
|
|
80
|
+
* This intentionally avoids language-specific word segmentation for predictability across scripts.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getWordNavKind(grapheme: string): WordNavKind;
|
|
83
|
+
export declare function isWordNavJoiner(grapheme: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Move the cursor one "word" to the left using Unicode-aware coarse navigation.
|
|
86
|
+
*
|
|
87
|
+
* Returns a new cursor index in the range [0, text.length].
|
|
88
|
+
*/
|
|
89
|
+
export declare function moveWordLeft(text: string, cursor: number): number;
|
|
90
|
+
/**
|
|
91
|
+
* Move the cursor one "word" to the right using Unicode-aware coarse navigation.
|
|
92
|
+
*
|
|
93
|
+
* Returns a new cursor index in the range [0, text.length].
|
|
94
|
+
*/
|
|
95
|
+
export declare function moveWordRight(text: string, cursor: number): number;
|
|
96
|
+
/**
|
|
97
|
+
* Apply background color to a line, padding to full width.
|
|
98
|
+
*
|
|
99
|
+
* @param line - Line of text (may contain ANSI codes)
|
|
100
|
+
* @param width - Total width to pad to
|
|
101
|
+
* @param bgFn - Background color function
|
|
102
|
+
* @returns Line with background applied and padded to width
|
|
103
|
+
*/
|
|
104
|
+
export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Extract a range of visible columns from a line. Handles ANSI codes and wide chars.
|
|
107
|
+
*
|
|
108
|
+
* @param strict - If true, exclude wide chars at boundary that would extend past the range
|
|
109
|
+
*/
|
|
110
|
+
export declare function sliceByColumn(line: string, startCol: number, length: number, strict?: boolean): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@sayknow-cli/tui",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"description": "Terminal User Interface library with differential rendering for efficient text-based applications",
|
|
6
6
|
"homepage": "https://sayknow-cli.com",
|
|
7
7
|
"author": "jaybeyond",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"cli"
|
|
28
28
|
],
|
|
29
29
|
"main": "./src/index.ts",
|
|
30
|
-
"types": "./
|
|
30
|
+
"types": "./dist/types/index.d.ts",
|
|
31
31
|
"scripts": {
|
|
32
32
|
"check": "biome check . && bun run check:types",
|
|
33
33
|
"check:types": "tsgo -p tsconfig.json --noEmit",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"fmt": "biome format --write ."
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@sayknow-cli/natives": "0.4.
|
|
42
|
-
"@sayknow-cli/utils": "0.4.
|
|
41
|
+
"@sayknow-cli/natives": "0.4.3",
|
|
42
|
+
"@sayknow-cli/utils": "0.4.3",
|
|
43
43
|
"lru-cache": "11.3.6",
|
|
44
44
|
"marked": "^18.0.3"
|
|
45
45
|
},
|
|
@@ -53,19 +53,20 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"src",
|
|
55
55
|
"README.md",
|
|
56
|
-
"CHANGELOG.md"
|
|
56
|
+
"CHANGELOG.md",
|
|
57
|
+
"dist/types"
|
|
57
58
|
],
|
|
58
59
|
"exports": {
|
|
59
60
|
".": {
|
|
60
|
-
"types": "./
|
|
61
|
+
"types": "./dist/types/index.d.ts",
|
|
61
62
|
"import": "./src/index.ts"
|
|
62
63
|
},
|
|
63
64
|
"./*": {
|
|
64
|
-
"types": "./
|
|
65
|
+
"types": "./dist/types/*.d.ts",
|
|
65
66
|
"import": "./src/*.ts"
|
|
66
67
|
},
|
|
67
68
|
"./components/*": {
|
|
68
|
-
"types": "./
|
|
69
|
+
"types": "./dist/types/components/*.d.ts",
|
|
69
70
|
"import": "./src/components/*.ts"
|
|
70
71
|
},
|
|
71
72
|
"./*.js": "./src/*.ts"
|