blecsd 0.1.0
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/LICENSE +20 -0
- package/README.md +220 -0
- package/dist/3d/index.d.ts +5 -0
- package/dist/3d/index.js +1 -0
- package/dist/audio/index.d.ts +177 -0
- package/dist/audio/index.js +1 -0
- package/dist/border-D_Jb4ZJV.d.ts +257 -0
- package/dist/cell-DwIu2ryP.d.ts +505 -0
- package/dist/chunk-2UBBZFE4.js +1 -0
- package/dist/chunk-35LCBY6P.js +1 -0
- package/dist/chunk-3B7MIVW6.js +1 -0
- package/dist/chunk-3EGGGI5J.js +3 -0
- package/dist/chunk-4LWWONFK.js +1 -0
- package/dist/chunk-4X4N4HNQ.js +2 -0
- package/dist/chunk-5PELJRUQ.js +1 -0
- package/dist/chunk-AEJIX2MW.js +1 -0
- package/dist/chunk-AQ7LW75B.js +1 -0
- package/dist/chunk-AXZQAH4X.js +1 -0
- package/dist/chunk-B6Z2JFRY.js +1 -0
- package/dist/chunk-BCADUCOZ.js +1 -0
- package/dist/chunk-C5PCEQ6G.js +1 -0
- package/dist/chunk-CIK4AMUA.js +1 -0
- package/dist/chunk-DNRXW56C.js +1 -0
- package/dist/chunk-FC5FFAAC.js +12 -0
- package/dist/chunk-FGHEFXLK.js +1 -0
- package/dist/chunk-FYEBZAWN.js +1 -0
- package/dist/chunk-G7GIWWLE.js +1 -0
- package/dist/chunk-GYHI26UE.js +1 -0
- package/dist/chunk-H2YAOJDW.js +1 -0
- package/dist/chunk-J4JZ2NU2.js +1 -0
- package/dist/chunk-JKVHO4LH.js +1 -0
- package/dist/chunk-K2B2OXQ5.js +5 -0
- package/dist/chunk-K37L3G4Z.js +4 -0
- package/dist/chunk-KD55INV7.js +1 -0
- package/dist/chunk-KFAK4A3G.js +1 -0
- package/dist/chunk-LCN2ZITE.js +1 -0
- package/dist/chunk-LYSK5S63.js +1 -0
- package/dist/chunk-NZ55KBM6.js +1 -0
- package/dist/chunk-OMMJ7B5P.js +1 -0
- package/dist/chunk-OUXUPF3V.js +33 -0
- package/dist/chunk-OVT2PPGW.js +19 -0
- package/dist/chunk-P6CJO3BC.js +1 -0
- package/dist/chunk-PSXXMBVJ.js +1 -0
- package/dist/chunk-PXXGH3BV.js +1 -0
- package/dist/chunk-QIKIOVP2.js +1 -0
- package/dist/chunk-SHUC6JWA.js +1 -0
- package/dist/chunk-TDXJDLY6.js +6 -0
- package/dist/chunk-TWSWTBYL.js +1 -0
- package/dist/chunk-TYMY2TBR.js +3 -0
- package/dist/chunk-VNZ6CWJA.js +2 -0
- package/dist/chunk-VOCM5T2G.js +5 -0
- package/dist/chunk-W5OU7Z6J.js +1 -0
- package/dist/chunk-WNG4A3K7.js +4 -0
- package/dist/chunk-XQIGERNI.js +1 -0
- package/dist/chunk-XZA63ZPO.js +1 -0
- package/dist/chunk-YAMOSPWB.js +4 -0
- package/dist/chunk-YD6ULIUR.js +1 -0
- package/dist/chunk-Z4EZERNE.js +1 -0
- package/dist/cli/init.d.ts +86 -0
- package/dist/cli/init.js +179 -0
- package/dist/color-B78w3zH-.d.ts +79 -0
- package/dist/components/index.d.ts +10298 -0
- package/dist/components/index.js +1 -0
- package/dist/core/index.d.ts +6700 -0
- package/dist/core/index.js +1 -0
- package/dist/debug/index.d.ts +711 -0
- package/dist/debug/index.js +1 -0
- package/dist/doubleBuffer-CKQFmlPN.d.ts +95 -0
- package/dist/errors/index.d.ts +1110 -0
- package/dist/errors/index.js +1 -0
- package/dist/events-BbbxkgvX.d.ts +125 -0
- package/dist/game/index.d.ts +486 -0
- package/dist/game/index.js +1 -0
- package/dist/gameLoop-BIPW7-OY.d.ts +219 -0
- package/dist/index-zSGJ2eUk.d.ts +3156 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +1 -0
- package/dist/input/index.d.ts +158 -0
- package/dist/input/index.js +1 -0
- package/dist/inputActions-CefRUBuT.d.ts +2637 -0
- package/dist/keyParser-Bwm8-l7v.d.ts +229 -0
- package/dist/mouseParser-Cfrbn3AX.d.ts +177 -0
- package/dist/parser-iMHmQuUh.d.ts +265 -0
- package/dist/program-BZaKqDKH.d.ts +141 -0
- package/dist/renderable-jTMOA-GK.d.ts +302 -0
- package/dist/scheduler-DcfoFuum.d.ts +86 -0
- package/dist/schemas/index.d.ts +936 -0
- package/dist/schemas/index.js +1 -0
- package/dist/systems/index.d.ts +4036 -0
- package/dist/systems/index.js +1 -0
- package/dist/terminal/index.d.ts +7357 -0
- package/dist/terminal/index.js +1 -0
- package/dist/terminus-14-bold-HWSPRLJD.js +1 -0
- package/dist/terminus-14-normal-T3SWMH4D.js +1 -0
- package/dist/tilemap-D1HJvKy3.d.ts +1211 -0
- package/dist/types-BcsvoKzf.d.ts +68 -0
- package/dist/utils/index.d.ts +6104 -0
- package/dist/utils/index.js +1 -0
- package/dist/viewport3d-xI33-_wq.d.ts +182 -0
- package/dist/virtualScrollback-DvZTRU8a.d.ts +274 -0
- package/dist/virtualViewport-Dx2iJliO.d.ts +2334 -0
- package/dist/virtualizedLineStore-DwPEvPkk.d.ts +297 -0
- package/dist/widgets/bigText.d.ts +230 -0
- package/dist/widgets/bigText.js +1 -0
- package/dist/widgets/fonts/index.d.ts +211 -0
- package/dist/widgets/fonts/index.js +1 -0
- package/dist/widgets/index.d.ts +8591 -0
- package/dist/widgets/index.js +1 -0
- package/package.json +213 -0
|
@@ -0,0 +1,2334 @@
|
|
|
1
|
+
import { U as Unsubscribe, W as World, E as Entity } from './types-BcsvoKzf.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { A as Attribute } from './parser-iMHmQuUh.js';
|
|
4
|
+
import { S as ScreenBufferData, C as Cell } from './cell-DwIu2ryP.js';
|
|
5
|
+
import { S as ScrollbackBuffer } from './virtualScrollback-DvZTRU8a.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Configurable state machine framework
|
|
9
|
+
* @module core/stateMachine
|
|
10
|
+
* @internal This module is for internal use by widgets
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Action function executed on state transitions.
|
|
15
|
+
* Receives the state machine context for side effects.
|
|
16
|
+
*/
|
|
17
|
+
type Action<Context = unknown> = (context: Context) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Transition target with optional actions.
|
|
20
|
+
*/
|
|
21
|
+
interface TransitionConfig<S extends string, Context = unknown> {
|
|
22
|
+
target: S;
|
|
23
|
+
actions?: Action<Context>[];
|
|
24
|
+
guard?: (context: Context) => boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* State configuration with entry/exit actions and transitions.
|
|
28
|
+
*/
|
|
29
|
+
interface StateConfig<S extends string, E extends string, Context = unknown> {
|
|
30
|
+
/** Actions to run when entering this state */
|
|
31
|
+
entry?: Action<Context>[];
|
|
32
|
+
/** Actions to run when exiting this state */
|
|
33
|
+
exit?: Action<Context>[];
|
|
34
|
+
/** Event handlers mapping events to target states */
|
|
35
|
+
on?: Partial<Record<E, S | TransitionConfig<S, Context>>>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Full state machine configuration.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam S - Union type of all state names
|
|
41
|
+
* @typeParam E - Union type of all event names
|
|
42
|
+
* @typeParam Context - Optional context object passed to actions
|
|
43
|
+
*/
|
|
44
|
+
interface StateMachineConfig<S extends string, E extends string, Context = unknown> {
|
|
45
|
+
/** Initial state when machine starts */
|
|
46
|
+
initial: S;
|
|
47
|
+
/** State definitions */
|
|
48
|
+
states: Record<S, StateConfig<S, E, Context>>;
|
|
49
|
+
/** Optional initial context */
|
|
50
|
+
context?: Context;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* State change listener function.
|
|
54
|
+
*/
|
|
55
|
+
type StateListener<S extends string> = (current: S, previous: S) => void;
|
|
56
|
+
/**
|
|
57
|
+
* StateMachine interface for type-safe access.
|
|
58
|
+
*
|
|
59
|
+
* @typeParam S - Union type of all state names
|
|
60
|
+
* @typeParam E - Union type of all event names
|
|
61
|
+
* @typeParam Context - Optional context object passed to actions
|
|
62
|
+
*/
|
|
63
|
+
interface StateMachine<S extends string, E extends string, Context = unknown> {
|
|
64
|
+
readonly current: S;
|
|
65
|
+
readonly context: Context;
|
|
66
|
+
send(event: E): boolean;
|
|
67
|
+
can(event: E): boolean;
|
|
68
|
+
matches(state: S): boolean;
|
|
69
|
+
subscribe(listener: StateListener<S>): Unsubscribe;
|
|
70
|
+
validEvents(): E[];
|
|
71
|
+
reset(): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* List Component
|
|
76
|
+
*
|
|
77
|
+
* Provides list/item selection functionality with keyboard and mouse support.
|
|
78
|
+
*
|
|
79
|
+
* @module components/list
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* List state type.
|
|
84
|
+
*/
|
|
85
|
+
type ListState = 'idle' | 'focused' | 'selecting' | 'searching' | 'disabled';
|
|
86
|
+
/**
|
|
87
|
+
* List event type.
|
|
88
|
+
*/
|
|
89
|
+
type ListEvent = 'focus' | 'blur' | 'startSelect' | 'endSelect' | 'startSearch' | 'endSearch' | 'disable' | 'enable';
|
|
90
|
+
/**
|
|
91
|
+
* List item data.
|
|
92
|
+
*/
|
|
93
|
+
interface ListItem {
|
|
94
|
+
/** Display text */
|
|
95
|
+
readonly text: string;
|
|
96
|
+
/** Optional value associated with the item */
|
|
97
|
+
readonly value?: string;
|
|
98
|
+
/** Whether the item is disabled */
|
|
99
|
+
readonly disabled?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* List store for managing list-specific data.
|
|
103
|
+
*/
|
|
104
|
+
interface ListStore {
|
|
105
|
+
/** Whether entity is a list */
|
|
106
|
+
isList: Uint8Array;
|
|
107
|
+
/** Currently selected index (-1 if none) */
|
|
108
|
+
selectedIndex: Int32Array;
|
|
109
|
+
/** Number of items in the list */
|
|
110
|
+
itemCount: Uint32Array;
|
|
111
|
+
/** First visible item index (for virtualization) */
|
|
112
|
+
firstVisible: Uint32Array;
|
|
113
|
+
/** Number of visible items */
|
|
114
|
+
visibleCount: Uint32Array;
|
|
115
|
+
/** Whether list is interactive */
|
|
116
|
+
interactive: Uint8Array;
|
|
117
|
+
/** Whether list responds to mouse */
|
|
118
|
+
mouse: Uint8Array;
|
|
119
|
+
/** Whether list responds to keyboard */
|
|
120
|
+
keys: Uint8Array;
|
|
121
|
+
/** Whether search mode is enabled */
|
|
122
|
+
searchEnabled: Uint8Array;
|
|
123
|
+
/** Total item count for virtualized lists (may be > itemCount) */
|
|
124
|
+
totalCount: Uint32Array;
|
|
125
|
+
/** Whether items are currently loading */
|
|
126
|
+
isLoading: Uint8Array;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Lazy load callback for virtualized lists.
|
|
130
|
+
* Called when items need to be loaded for a range.
|
|
131
|
+
*
|
|
132
|
+
* @param startIndex - First item index to load
|
|
133
|
+
* @param count - Number of items to load
|
|
134
|
+
* @returns Promise that resolves when items are loaded
|
|
135
|
+
*/
|
|
136
|
+
type ListLazyLoadCallback = (startIndex: number, count: number) => Promise<ListItem[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Scroll event callback for infinite scroll detection.
|
|
139
|
+
*
|
|
140
|
+
* @param scrollInfo - Information about current scroll state
|
|
141
|
+
*/
|
|
142
|
+
type ListScrollCallback = (scrollInfo: ListScrollInfo) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Scroll information for infinite scroll.
|
|
145
|
+
*/
|
|
146
|
+
interface ListScrollInfo {
|
|
147
|
+
/** First visible item index */
|
|
148
|
+
readonly firstVisible: number;
|
|
149
|
+
/** Number of visible items */
|
|
150
|
+
readonly visibleCount: number;
|
|
151
|
+
/** Total loaded items */
|
|
152
|
+
readonly loadedCount: number;
|
|
153
|
+
/** Total items (may be larger than loaded for infinite scroll) */
|
|
154
|
+
readonly totalCount: number;
|
|
155
|
+
/** Whether we're near the end (within threshold) */
|
|
156
|
+
readonly nearEnd: boolean;
|
|
157
|
+
/** Whether we're near the start (within threshold) */
|
|
158
|
+
readonly nearStart: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* List display configuration.
|
|
162
|
+
*/
|
|
163
|
+
interface ListDisplay {
|
|
164
|
+
/** Character shown before selected item */
|
|
165
|
+
readonly selectedPrefix: string;
|
|
166
|
+
/** Character shown before unselected items */
|
|
167
|
+
readonly unselectedPrefix: string;
|
|
168
|
+
/** Selected item foreground color */
|
|
169
|
+
readonly selectedFg: number;
|
|
170
|
+
/** Selected item background color */
|
|
171
|
+
readonly selectedBg: number;
|
|
172
|
+
/** Item foreground color */
|
|
173
|
+
readonly itemFg: number;
|
|
174
|
+
/** Item background color */
|
|
175
|
+
readonly itemBg: number;
|
|
176
|
+
/** Disabled item foreground color */
|
|
177
|
+
readonly disabledFg: number;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* List display options for configuration.
|
|
181
|
+
*/
|
|
182
|
+
interface ListDisplayOptions {
|
|
183
|
+
selectedPrefix?: string;
|
|
184
|
+
unselectedPrefix?: string;
|
|
185
|
+
selectedFg?: number;
|
|
186
|
+
selectedBg?: number;
|
|
187
|
+
itemFg?: number;
|
|
188
|
+
itemBg?: number;
|
|
189
|
+
disabledFg?: number;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* List selection callback function type.
|
|
193
|
+
*/
|
|
194
|
+
type ListSelectCallback = (index: number, item: ListItem) => void;
|
|
195
|
+
/**
|
|
196
|
+
* List action returned from key press handling.
|
|
197
|
+
*/
|
|
198
|
+
type ListAction = {
|
|
199
|
+
type: 'selectPrev';
|
|
200
|
+
} | {
|
|
201
|
+
type: 'selectNext';
|
|
202
|
+
} | {
|
|
203
|
+
type: 'selectFirst';
|
|
204
|
+
} | {
|
|
205
|
+
type: 'selectLast';
|
|
206
|
+
} | {
|
|
207
|
+
type: 'pageUp';
|
|
208
|
+
} | {
|
|
209
|
+
type: 'pageDown';
|
|
210
|
+
} | {
|
|
211
|
+
type: 'confirm';
|
|
212
|
+
} | {
|
|
213
|
+
type: 'cancel';
|
|
214
|
+
} | {
|
|
215
|
+
type: 'startSearch';
|
|
216
|
+
} | {
|
|
217
|
+
type: 'endSearch';
|
|
218
|
+
} | {
|
|
219
|
+
type: 'searchChar';
|
|
220
|
+
char: string;
|
|
221
|
+
} | {
|
|
222
|
+
type: 'searchBackspace';
|
|
223
|
+
} | {
|
|
224
|
+
type: 'searchNextMatch';
|
|
225
|
+
};
|
|
226
|
+
/** Default selected prefix character */
|
|
227
|
+
declare const DEFAULT_SELECTED_PREFIX = "> ";
|
|
228
|
+
/** Default unselected prefix character */
|
|
229
|
+
declare const DEFAULT_UNSELECTED_PREFIX = " ";
|
|
230
|
+
/** Default selected foreground color */
|
|
231
|
+
declare const DEFAULT_SELECTED_FG = 4294967295;
|
|
232
|
+
/** Default selected background color */
|
|
233
|
+
declare const DEFAULT_SELECTED_BG = 6750207;
|
|
234
|
+
/** Default item foreground color */
|
|
235
|
+
declare const DEFAULT_ITEM_FG = 3435973887;
|
|
236
|
+
/** Default item background color */
|
|
237
|
+
declare const DEFAULT_ITEM_BG = 255;
|
|
238
|
+
/** Default disabled foreground color */
|
|
239
|
+
declare const DEFAULT_DISABLED_FG = 1717987071;
|
|
240
|
+
/**
|
|
241
|
+
* Store for list component data.
|
|
242
|
+
*/
|
|
243
|
+
declare const listStore: ListStore;
|
|
244
|
+
/**
|
|
245
|
+
* State machine configuration for list widgets.
|
|
246
|
+
*
|
|
247
|
+
* States:
|
|
248
|
+
* - idle: List is not focused
|
|
249
|
+
* - focused: List has focus, ready for navigation
|
|
250
|
+
* - selecting: User is actively selecting (e.g., during mouse drag)
|
|
251
|
+
* - searching: User is typing to search/filter items
|
|
252
|
+
* - disabled: List is disabled and cannot be interacted with
|
|
253
|
+
*/
|
|
254
|
+
declare const LIST_STATE_MACHINE_CONFIG: StateMachineConfig<ListState, ListEvent>;
|
|
255
|
+
/**
|
|
256
|
+
* Attaches list behavior to an entity.
|
|
257
|
+
*
|
|
258
|
+
* @param world - The ECS world
|
|
259
|
+
* @param eid - The entity ID
|
|
260
|
+
* @param items - Initial items
|
|
261
|
+
* @param options - List options
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* import { attachListBehavior } from 'blecsd';
|
|
266
|
+
*
|
|
267
|
+
* attachListBehavior(world, eid, [
|
|
268
|
+
* { text: 'Option 1', value: 'opt1' },
|
|
269
|
+
* { text: 'Option 2', value: 'opt2' },
|
|
270
|
+
* ], { interactive: true, keys: true });
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
declare function attachListBehavior(world: World, eid: Entity, items?: ListItem[], options?: {
|
|
274
|
+
interactive?: boolean;
|
|
275
|
+
mouse?: boolean;
|
|
276
|
+
keys?: boolean;
|
|
277
|
+
search?: boolean;
|
|
278
|
+
selectedIndex?: number;
|
|
279
|
+
visibleCount?: number;
|
|
280
|
+
}): void;
|
|
281
|
+
/**
|
|
282
|
+
* Checks if an entity is a list.
|
|
283
|
+
*
|
|
284
|
+
* @param world - The ECS world
|
|
285
|
+
* @param eid - The entity ID
|
|
286
|
+
* @returns true if entity is a list
|
|
287
|
+
*/
|
|
288
|
+
declare function isList(world: World, eid: Entity): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Gets the current state of a list.
|
|
291
|
+
*
|
|
292
|
+
* @param world - The ECS world
|
|
293
|
+
* @param eid - The entity ID
|
|
294
|
+
* @returns The current state
|
|
295
|
+
*/
|
|
296
|
+
declare function getListState(world: World, eid: Entity): ListState;
|
|
297
|
+
/**
|
|
298
|
+
* Checks if list is in a specific state.
|
|
299
|
+
*
|
|
300
|
+
* @param world - The ECS world
|
|
301
|
+
* @param eid - The entity ID
|
|
302
|
+
* @param state - The state to check
|
|
303
|
+
* @returns true if list is in the specified state
|
|
304
|
+
*/
|
|
305
|
+
declare function isListInState(world: World, eid: Entity, state: ListState): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Checks if list is focused.
|
|
308
|
+
*
|
|
309
|
+
* @param world - The ECS world
|
|
310
|
+
* @param eid - The entity ID
|
|
311
|
+
* @returns true if list is focused
|
|
312
|
+
*/
|
|
313
|
+
declare function isListFocused(world: World, eid: Entity): boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Checks if list is disabled.
|
|
316
|
+
*
|
|
317
|
+
* @param world - The ECS world
|
|
318
|
+
* @param eid - The entity ID
|
|
319
|
+
* @returns true if list is disabled
|
|
320
|
+
*/
|
|
321
|
+
declare function isListDisabled(world: World, eid: Entity): boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Sends an event to the list state machine.
|
|
324
|
+
*
|
|
325
|
+
* @param world - The ECS world
|
|
326
|
+
* @param eid - The entity ID
|
|
327
|
+
* @param event - The event to send
|
|
328
|
+
* @returns true if transition occurred
|
|
329
|
+
*/
|
|
330
|
+
declare function sendListEvent(world: World, eid: Entity, event: ListEvent): boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Focuses the list.
|
|
333
|
+
*
|
|
334
|
+
* @param world - The ECS world
|
|
335
|
+
* @param eid - The entity ID
|
|
336
|
+
* @returns true if focused successfully
|
|
337
|
+
*/
|
|
338
|
+
declare function focusList(world: World, eid: Entity): boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Blurs the list.
|
|
341
|
+
*
|
|
342
|
+
* @param world - The ECS world
|
|
343
|
+
* @param eid - The entity ID
|
|
344
|
+
* @returns true if blurred successfully
|
|
345
|
+
*/
|
|
346
|
+
declare function blurList(world: World, eid: Entity): boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Disables the list.
|
|
349
|
+
*
|
|
350
|
+
* @param world - The ECS world
|
|
351
|
+
* @param eid - The entity ID
|
|
352
|
+
* @returns true if disabled successfully
|
|
353
|
+
*/
|
|
354
|
+
declare function disableList(world: World, eid: Entity): boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Enables the list.
|
|
357
|
+
*
|
|
358
|
+
* @param world - The ECS world
|
|
359
|
+
* @param eid - The entity ID
|
|
360
|
+
* @returns true if enabled successfully
|
|
361
|
+
*/
|
|
362
|
+
declare function enableList(world: World, eid: Entity): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Gets all items from a list.
|
|
365
|
+
*
|
|
366
|
+
* @param eid - The entity ID
|
|
367
|
+
* @returns Array of list items
|
|
368
|
+
*/
|
|
369
|
+
declare function getItems(eid: Entity): readonly ListItem[];
|
|
370
|
+
/**
|
|
371
|
+
* Sets all items in a list.
|
|
372
|
+
*
|
|
373
|
+
* @param world - The ECS world
|
|
374
|
+
* @param eid - The entity ID
|
|
375
|
+
* @param items - The items to set
|
|
376
|
+
*/
|
|
377
|
+
declare function setItems(world: World, eid: Entity, items: ListItem[]): void;
|
|
378
|
+
/**
|
|
379
|
+
* Adds an item to the list.
|
|
380
|
+
*
|
|
381
|
+
* @param world - The ECS world
|
|
382
|
+
* @param eid - The entity ID
|
|
383
|
+
* @param item - The item to add
|
|
384
|
+
* @param index - Optional index to insert at (defaults to end)
|
|
385
|
+
*/
|
|
386
|
+
declare function addItem(world: World, eid: Entity, item: ListItem, index?: number): void;
|
|
387
|
+
/**
|
|
388
|
+
* Removes an item from the list.
|
|
389
|
+
*
|
|
390
|
+
* @param world - The ECS world
|
|
391
|
+
* @param eid - The entity ID
|
|
392
|
+
* @param index - The index to remove
|
|
393
|
+
* @returns The removed item or undefined
|
|
394
|
+
*/
|
|
395
|
+
declare function removeItem(world: World, eid: Entity, index: number): ListItem | undefined;
|
|
396
|
+
/**
|
|
397
|
+
* Gets an item by index.
|
|
398
|
+
*
|
|
399
|
+
* @param eid - The entity ID
|
|
400
|
+
* @param index - The item index
|
|
401
|
+
* @returns The item or undefined
|
|
402
|
+
*/
|
|
403
|
+
declare function getItem(eid: Entity, index: number): ListItem | undefined;
|
|
404
|
+
/**
|
|
405
|
+
* Updates an item at a specific index.
|
|
406
|
+
*
|
|
407
|
+
* @param world - The ECS world
|
|
408
|
+
* @param eid - The entity ID
|
|
409
|
+
* @param index - The item index
|
|
410
|
+
* @param item - The new item data
|
|
411
|
+
* @returns true if updated successfully
|
|
412
|
+
*/
|
|
413
|
+
declare function updateItem(world: World, eid: Entity, index: number, item: ListItem): boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Gets the number of items in the list.
|
|
416
|
+
*
|
|
417
|
+
* @param eid - The entity ID
|
|
418
|
+
* @returns Number of items
|
|
419
|
+
*/
|
|
420
|
+
declare function getItemCount(eid: Entity): number;
|
|
421
|
+
/**
|
|
422
|
+
* Clears all items from the list.
|
|
423
|
+
*
|
|
424
|
+
* @param world - The ECS world
|
|
425
|
+
* @param eid - The entity ID
|
|
426
|
+
*/
|
|
427
|
+
declare function clearItems(world: World, eid: Entity): void;
|
|
428
|
+
/**
|
|
429
|
+
* Gets the selected index.
|
|
430
|
+
*
|
|
431
|
+
* @param eid - The entity ID
|
|
432
|
+
* @returns Selected index or -1 if none
|
|
433
|
+
*/
|
|
434
|
+
declare function getSelectedIndex(eid: Entity): number;
|
|
435
|
+
/**
|
|
436
|
+
* Gets the selected item.
|
|
437
|
+
*
|
|
438
|
+
* @param eid - The entity ID
|
|
439
|
+
* @returns Selected item or undefined
|
|
440
|
+
*/
|
|
441
|
+
declare function getSelectedItem(eid: Entity): ListItem | undefined;
|
|
442
|
+
declare function setSelectedIndex(world: World, eid: Entity, index: number): boolean;
|
|
443
|
+
/**
|
|
444
|
+
* Selects the previous item.
|
|
445
|
+
*
|
|
446
|
+
* @param world - The ECS world
|
|
447
|
+
* @param eid - The entity ID
|
|
448
|
+
* @param wrap - Whether to wrap around (default: true)
|
|
449
|
+
* @returns true if selection changed
|
|
450
|
+
*/
|
|
451
|
+
declare function selectPrev(world: World, eid: Entity, wrap?: boolean): boolean;
|
|
452
|
+
/**
|
|
453
|
+
* Selects the next item.
|
|
454
|
+
*
|
|
455
|
+
* @param world - The ECS world
|
|
456
|
+
* @param eid - The entity ID
|
|
457
|
+
* @param wrap - Whether to wrap around (default: true)
|
|
458
|
+
* @returns true if selection changed
|
|
459
|
+
*/
|
|
460
|
+
declare function selectNext(world: World, eid: Entity, wrap?: boolean): boolean;
|
|
461
|
+
/**
|
|
462
|
+
* Selects the first item.
|
|
463
|
+
*
|
|
464
|
+
* @param world - The ECS world
|
|
465
|
+
* @param eid - The entity ID
|
|
466
|
+
* @returns true if selection changed
|
|
467
|
+
*/
|
|
468
|
+
declare function selectFirst(world: World, eid: Entity): boolean;
|
|
469
|
+
/**
|
|
470
|
+
* Selects the last item.
|
|
471
|
+
*
|
|
472
|
+
* @param world - The ECS world
|
|
473
|
+
* @param eid - The entity ID
|
|
474
|
+
* @returns true if selection changed
|
|
475
|
+
*/
|
|
476
|
+
declare function selectLast(world: World, eid: Entity): boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Selects an item by value.
|
|
479
|
+
*
|
|
480
|
+
* @param world - The ECS world
|
|
481
|
+
* @param eid - The entity ID
|
|
482
|
+
* @param value - The value to select
|
|
483
|
+
* @returns true if selection changed
|
|
484
|
+
*/
|
|
485
|
+
declare function selectByValue(world: World, eid: Entity, value: string): boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Clears the selection.
|
|
488
|
+
*
|
|
489
|
+
* @param world - The ECS world
|
|
490
|
+
* @param eid - The entity ID
|
|
491
|
+
*/
|
|
492
|
+
declare function clearSelection(world: World, eid: Entity): void;
|
|
493
|
+
/**
|
|
494
|
+
* Activates (confirms) the currently selected item.
|
|
495
|
+
*
|
|
496
|
+
* @param world - The ECS world
|
|
497
|
+
* @param eid - The entity ID
|
|
498
|
+
* @returns true if an item was activated
|
|
499
|
+
*/
|
|
500
|
+
declare function activateSelected(_world: World, eid: Entity): boolean;
|
|
501
|
+
/**
|
|
502
|
+
* Gets the first visible item index.
|
|
503
|
+
*
|
|
504
|
+
* @param eid - The entity ID
|
|
505
|
+
* @returns First visible index
|
|
506
|
+
*/
|
|
507
|
+
declare function getFirstVisible(eid: Entity): number;
|
|
508
|
+
/**
|
|
509
|
+
* Sets the first visible item index.
|
|
510
|
+
*
|
|
511
|
+
* @param world - The ECS world
|
|
512
|
+
* @param eid - The entity ID
|
|
513
|
+
* @param index - The first visible index
|
|
514
|
+
*/
|
|
515
|
+
declare function setFirstVisible(world: World, eid: Entity, index: number): void;
|
|
516
|
+
/**
|
|
517
|
+
* Gets the number of visible items.
|
|
518
|
+
*
|
|
519
|
+
* @param eid - The entity ID
|
|
520
|
+
* @returns Number of visible items
|
|
521
|
+
*/
|
|
522
|
+
declare function getVisibleCount(eid: Entity): number;
|
|
523
|
+
/**
|
|
524
|
+
* Sets the number of visible items.
|
|
525
|
+
*
|
|
526
|
+
* @param world - The ECS world
|
|
527
|
+
* @param eid - The entity ID
|
|
528
|
+
* @param count - The number of visible items
|
|
529
|
+
*/
|
|
530
|
+
declare function setVisibleCount(world: World, eid: Entity, count: number): void;
|
|
531
|
+
/**
|
|
532
|
+
* Ensures an index is visible by scrolling if necessary.
|
|
533
|
+
*
|
|
534
|
+
* @param world - The ECS world
|
|
535
|
+
* @param eid - The entity ID
|
|
536
|
+
* @param index - The index to make visible
|
|
537
|
+
*/
|
|
538
|
+
declare function ensureVisible(world: World, eid: Entity, index: number): void;
|
|
539
|
+
/**
|
|
540
|
+
* Scrolls the list by a page (visibleCount items).
|
|
541
|
+
*
|
|
542
|
+
* @param world - The ECS world
|
|
543
|
+
* @param eid - The entity ID
|
|
544
|
+
* @param direction - 1 for down, -1 for up
|
|
545
|
+
* @returns true if scrolled
|
|
546
|
+
*/
|
|
547
|
+
declare function scrollPage(world: World, eid: Entity, direction: 1 | -1): boolean;
|
|
548
|
+
/**
|
|
549
|
+
* Gets the visible items for rendering.
|
|
550
|
+
*
|
|
551
|
+
* @param eid - The entity ID
|
|
552
|
+
* @returns Array of visible items with their indices
|
|
553
|
+
*/
|
|
554
|
+
declare function getVisibleItems(eid: Entity): Array<{
|
|
555
|
+
index: number;
|
|
556
|
+
item: ListItem;
|
|
557
|
+
}>;
|
|
558
|
+
/**
|
|
559
|
+
* Sets the total item count for virtualized lists.
|
|
560
|
+
* This can be larger than the actual loaded items count for infinite scroll.
|
|
561
|
+
*
|
|
562
|
+
* @param world - The ECS world
|
|
563
|
+
* @param eid - The entity ID
|
|
564
|
+
* @param count - Total item count
|
|
565
|
+
*/
|
|
566
|
+
declare function setTotalCount(world: World, eid: Entity, count: number): void;
|
|
567
|
+
/**
|
|
568
|
+
* Gets the total item count (may be larger than loaded items).
|
|
569
|
+
*
|
|
570
|
+
* @param eid - The entity ID
|
|
571
|
+
* @returns Total item count
|
|
572
|
+
*/
|
|
573
|
+
declare function getTotalCount(eid: Entity): number;
|
|
574
|
+
/**
|
|
575
|
+
* Sets the lazy load callback for loading items on demand.
|
|
576
|
+
*
|
|
577
|
+
* @param eid - The entity ID
|
|
578
|
+
* @param callback - Callback function to load items
|
|
579
|
+
*/
|
|
580
|
+
declare function setLazyLoadCallback(eid: Entity, callback: ListLazyLoadCallback): void;
|
|
581
|
+
/**
|
|
582
|
+
* Gets the lazy load callback.
|
|
583
|
+
*
|
|
584
|
+
* @param eid - The entity ID
|
|
585
|
+
* @returns Lazy load callback or undefined
|
|
586
|
+
*/
|
|
587
|
+
declare function getLazyLoadCallback(eid: Entity): ListLazyLoadCallback | undefined;
|
|
588
|
+
/**
|
|
589
|
+
* Clears the lazy load callback.
|
|
590
|
+
*
|
|
591
|
+
* @param eid - The entity ID
|
|
592
|
+
*/
|
|
593
|
+
declare function clearLazyLoadCallback(eid: Entity): void;
|
|
594
|
+
/**
|
|
595
|
+
* Registers a scroll callback for detecting scroll events.
|
|
596
|
+
*
|
|
597
|
+
* @param eid - The entity ID
|
|
598
|
+
* @param callback - Callback function
|
|
599
|
+
* @returns Unsubscribe function
|
|
600
|
+
*/
|
|
601
|
+
declare function onListScroll(eid: Entity, callback: ListScrollCallback): () => void;
|
|
602
|
+
/**
|
|
603
|
+
* Sets the loading state for a list.
|
|
604
|
+
*
|
|
605
|
+
* @param world - The ECS world
|
|
606
|
+
* @param eid - The entity ID
|
|
607
|
+
* @param loading - Whether items are loading
|
|
608
|
+
*/
|
|
609
|
+
declare function setListLoading(world: World, eid: Entity, loading: boolean): void;
|
|
610
|
+
/**
|
|
611
|
+
* Checks if a list is currently loading items.
|
|
612
|
+
*
|
|
613
|
+
* @param eid - The entity ID
|
|
614
|
+
* @returns true if loading
|
|
615
|
+
*/
|
|
616
|
+
declare function isListLoading(eid: Entity): boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Sets the loading placeholder text.
|
|
619
|
+
*
|
|
620
|
+
* @param eid - The entity ID
|
|
621
|
+
* @param text - Placeholder text to show while loading
|
|
622
|
+
*/
|
|
623
|
+
declare function setLoadingPlaceholder(eid: Entity, text: string): void;
|
|
624
|
+
/**
|
|
625
|
+
* Gets the loading placeholder text.
|
|
626
|
+
*
|
|
627
|
+
* @param eid - The entity ID
|
|
628
|
+
* @returns Loading placeholder text
|
|
629
|
+
*/
|
|
630
|
+
declare function getLoadingPlaceholder(eid: Entity): string;
|
|
631
|
+
/**
|
|
632
|
+
* Loads items for a range using the lazy load callback.
|
|
633
|
+
* Returns immediately if no callback is set or already loading.
|
|
634
|
+
*
|
|
635
|
+
* @param world - The ECS world
|
|
636
|
+
* @param eid - The entity ID
|
|
637
|
+
* @param startIndex - First item to load
|
|
638
|
+
* @param count - Number of items to load
|
|
639
|
+
* @returns Promise that resolves when loading completes
|
|
640
|
+
*/
|
|
641
|
+
declare function loadItems(world: World, eid: Entity, startIndex: number, count: number): Promise<void>;
|
|
642
|
+
/**
|
|
643
|
+
* Checks if items need to be loaded for the current visible range.
|
|
644
|
+
*
|
|
645
|
+
* @param eid - The entity ID
|
|
646
|
+
* @returns Object with needsLoad flag and range to load
|
|
647
|
+
*/
|
|
648
|
+
declare function checkNeedsLoad(eid: Entity): {
|
|
649
|
+
needsLoad: boolean;
|
|
650
|
+
startIndex: number;
|
|
651
|
+
count: number;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Gets scroll info for the list.
|
|
655
|
+
*
|
|
656
|
+
* @param eid - The entity ID
|
|
657
|
+
* @param threshold - Items from end to trigger nearEnd (default: visibleCount)
|
|
658
|
+
* @returns Scroll information
|
|
659
|
+
*/
|
|
660
|
+
declare function getScrollInfo$1(eid: Entity, threshold?: number): ListScrollInfo;
|
|
661
|
+
/**
|
|
662
|
+
* Appends items to the list (useful for infinite scroll).
|
|
663
|
+
*
|
|
664
|
+
* @param world - The ECS world
|
|
665
|
+
* @param eid - The entity ID
|
|
666
|
+
* @param newItems - Items to append
|
|
667
|
+
*/
|
|
668
|
+
declare function appendItems(world: World, eid: Entity, newItems: readonly ListItem[]): void;
|
|
669
|
+
/**
|
|
670
|
+
* Sets the list display configuration.
|
|
671
|
+
*
|
|
672
|
+
* @param eid - The entity ID
|
|
673
|
+
* @param options - Display options
|
|
674
|
+
*/
|
|
675
|
+
declare function setListDisplay(eid: Entity, options: ListDisplayOptions): void;
|
|
676
|
+
/**
|
|
677
|
+
* Gets the list display configuration.
|
|
678
|
+
*
|
|
679
|
+
* @param eid - The entity ID
|
|
680
|
+
* @returns Display configuration
|
|
681
|
+
*/
|
|
682
|
+
declare function getListDisplay(eid: Entity): ListDisplay;
|
|
683
|
+
/**
|
|
684
|
+
* Clears the list display configuration.
|
|
685
|
+
*
|
|
686
|
+
* @param eid - The entity ID
|
|
687
|
+
*/
|
|
688
|
+
declare function clearListDisplay(eid: Entity): void;
|
|
689
|
+
/**
|
|
690
|
+
* Checks if list is interactive.
|
|
691
|
+
*
|
|
692
|
+
* @param eid - The entity ID
|
|
693
|
+
* @returns true if interactive
|
|
694
|
+
*/
|
|
695
|
+
declare function isListInteractive(eid: Entity): boolean;
|
|
696
|
+
/**
|
|
697
|
+
* Sets list interactive mode.
|
|
698
|
+
*
|
|
699
|
+
* @param world - The ECS world
|
|
700
|
+
* @param eid - The entity ID
|
|
701
|
+
* @param interactive - Whether list is interactive
|
|
702
|
+
*/
|
|
703
|
+
declare function setListInteractive(world: World, eid: Entity, interactive: boolean): void;
|
|
704
|
+
/**
|
|
705
|
+
* Checks if list responds to mouse.
|
|
706
|
+
*
|
|
707
|
+
* @param eid - The entity ID
|
|
708
|
+
* @returns true if mouse enabled
|
|
709
|
+
*/
|
|
710
|
+
declare function isListMouseEnabled(eid: Entity): boolean;
|
|
711
|
+
/**
|
|
712
|
+
* Sets list mouse mode.
|
|
713
|
+
*
|
|
714
|
+
* @param world - The ECS world
|
|
715
|
+
* @param eid - The entity ID
|
|
716
|
+
* @param mouse - Whether mouse is enabled
|
|
717
|
+
*/
|
|
718
|
+
declare function setListMouse(world: World, eid: Entity, mouse: boolean): void;
|
|
719
|
+
/**
|
|
720
|
+
* Checks if list responds to keyboard.
|
|
721
|
+
*
|
|
722
|
+
* @param eid - The entity ID
|
|
723
|
+
* @returns true if keys enabled
|
|
724
|
+
*/
|
|
725
|
+
declare function isListKeysEnabled(eid: Entity): boolean;
|
|
726
|
+
/**
|
|
727
|
+
* Sets list keys mode.
|
|
728
|
+
*
|
|
729
|
+
* @param world - The ECS world
|
|
730
|
+
* @param eid - The entity ID
|
|
731
|
+
* @param keys - Whether keys are enabled
|
|
732
|
+
*/
|
|
733
|
+
declare function setListKeys(world: World, eid: Entity, keys: boolean): void;
|
|
734
|
+
/**
|
|
735
|
+
* Checks if search mode is enabled for the list.
|
|
736
|
+
*
|
|
737
|
+
* @param eid - The entity ID
|
|
738
|
+
* @returns true if search is enabled
|
|
739
|
+
*/
|
|
740
|
+
declare function isListSearchEnabled(eid: Entity): boolean;
|
|
741
|
+
/**
|
|
742
|
+
* Sets whether search mode is enabled for the list.
|
|
743
|
+
*
|
|
744
|
+
* @param world - The ECS world
|
|
745
|
+
* @param eid - The entity ID
|
|
746
|
+
* @param enabled - Whether search is enabled
|
|
747
|
+
*/
|
|
748
|
+
declare function setListSearchEnabled(world: World, eid: Entity, enabled: boolean): void;
|
|
749
|
+
/**
|
|
750
|
+
* Checks if list is currently in search mode.
|
|
751
|
+
*
|
|
752
|
+
* @param world - The ECS world
|
|
753
|
+
* @param eid - The entity ID
|
|
754
|
+
* @returns true if list is in searching state
|
|
755
|
+
*/
|
|
756
|
+
declare function isListSearching(world: World, eid: Entity): boolean;
|
|
757
|
+
/**
|
|
758
|
+
* Starts search mode for the list.
|
|
759
|
+
*
|
|
760
|
+
* @param world - The ECS world
|
|
761
|
+
* @param eid - The entity ID
|
|
762
|
+
* @returns true if search mode was started
|
|
763
|
+
*/
|
|
764
|
+
declare function startListSearch(world: World, eid: Entity): boolean;
|
|
765
|
+
/**
|
|
766
|
+
* Ends search mode for the list.
|
|
767
|
+
*
|
|
768
|
+
* @param world - The ECS world
|
|
769
|
+
* @param eid - The entity ID
|
|
770
|
+
* @returns true if search mode was ended
|
|
771
|
+
*/
|
|
772
|
+
declare function endListSearch(world: World, eid: Entity): boolean;
|
|
773
|
+
/**
|
|
774
|
+
* Gets the current search query.
|
|
775
|
+
*
|
|
776
|
+
* @param eid - The entity ID
|
|
777
|
+
* @returns The current search query or empty string
|
|
778
|
+
*/
|
|
779
|
+
declare function getListSearchQuery(eid: Entity): string;
|
|
780
|
+
/**
|
|
781
|
+
* Sets the search query and finds matching items.
|
|
782
|
+
*
|
|
783
|
+
* @param world - The ECS world
|
|
784
|
+
* @param eid - The entity ID
|
|
785
|
+
* @param query - The search query
|
|
786
|
+
* @returns true if a match was found and selected
|
|
787
|
+
*/
|
|
788
|
+
declare function setListSearchQuery(world: World, eid: Entity, query: string): boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Appends a character to the search query.
|
|
791
|
+
*
|
|
792
|
+
* @param world - The ECS world
|
|
793
|
+
* @param eid - The entity ID
|
|
794
|
+
* @param char - The character to append
|
|
795
|
+
* @returns true if a match was found and selected
|
|
796
|
+
*/
|
|
797
|
+
declare function appendToSearchQuery(world: World, eid: Entity, char: string): boolean;
|
|
798
|
+
/**
|
|
799
|
+
* Removes the last character from the search query.
|
|
800
|
+
*
|
|
801
|
+
* @param world - The ECS world
|
|
802
|
+
* @param eid - The entity ID
|
|
803
|
+
* @returns true if a match was found and selected
|
|
804
|
+
*/
|
|
805
|
+
declare function backspaceSearchQuery(world: World, eid: Entity): boolean;
|
|
806
|
+
/**
|
|
807
|
+
* Clears the search query.
|
|
808
|
+
*
|
|
809
|
+
* @param world - The ECS world
|
|
810
|
+
* @param eid - The entity ID
|
|
811
|
+
*/
|
|
812
|
+
declare function clearSearchQuery(world: World, eid: Entity): void;
|
|
813
|
+
/**
|
|
814
|
+
* Finds and selects the first item matching the text (case-insensitive).
|
|
815
|
+
*
|
|
816
|
+
* @param world - The ECS world
|
|
817
|
+
* @param eid - The entity ID
|
|
818
|
+
* @param text - The text to search for
|
|
819
|
+
* @returns true if a match was found and selected
|
|
820
|
+
*/
|
|
821
|
+
declare function findAndSelectByText(world: World, eid: Entity, text: string): boolean;
|
|
822
|
+
/**
|
|
823
|
+
* Finds the next item matching the current search query.
|
|
824
|
+
*
|
|
825
|
+
* @param world - The ECS world
|
|
826
|
+
* @param eid - The entity ID
|
|
827
|
+
* @returns true if a match was found and selected
|
|
828
|
+
*/
|
|
829
|
+
declare function findNextMatch(world: World, eid: Entity): boolean;
|
|
830
|
+
/**
|
|
831
|
+
* Registers a callback for when search query changes.
|
|
832
|
+
*
|
|
833
|
+
* @param eid - The entity ID
|
|
834
|
+
* @param callback - The callback function
|
|
835
|
+
* @returns Unsubscribe function
|
|
836
|
+
*
|
|
837
|
+
* @example
|
|
838
|
+
* ```typescript
|
|
839
|
+
* const unsubscribe = onListSearchChange(eid, (query) => {
|
|
840
|
+
* console.log(`Search: ${query}`);
|
|
841
|
+
* });
|
|
842
|
+
* ```
|
|
843
|
+
*/
|
|
844
|
+
declare function onListSearchChange(eid: Entity, callback: (query: string) => void): () => void;
|
|
845
|
+
/**
|
|
846
|
+
* Registers a callback for when selection changes.
|
|
847
|
+
*
|
|
848
|
+
* @param eid - The entity ID
|
|
849
|
+
* @param callback - The callback function
|
|
850
|
+
* @returns Unsubscribe function
|
|
851
|
+
*
|
|
852
|
+
* @example
|
|
853
|
+
* ```typescript
|
|
854
|
+
* const unsubscribe = onListSelect(eid, (index, item) => {
|
|
855
|
+
* console.log(`Selected: ${item.text}`);
|
|
856
|
+
* });
|
|
857
|
+
* ```
|
|
858
|
+
*/
|
|
859
|
+
declare function onListSelect(eid: Entity, callback: ListSelectCallback): () => void;
|
|
860
|
+
/**
|
|
861
|
+
* Registers a callback for when an item is activated (confirmed).
|
|
862
|
+
*
|
|
863
|
+
* @param eid - The entity ID
|
|
864
|
+
* @param callback - The callback function
|
|
865
|
+
* @returns Unsubscribe function
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* ```typescript
|
|
869
|
+
* const unsubscribe = onListActivate(eid, (index, item) => {
|
|
870
|
+
* console.log(`Activated: ${item.text}`);
|
|
871
|
+
* });
|
|
872
|
+
* ```
|
|
873
|
+
*/
|
|
874
|
+
declare function onListActivate(eid: Entity, callback: ListSelectCallback): () => void;
|
|
875
|
+
/**
|
|
876
|
+
* Clears all callbacks for a list.
|
|
877
|
+
*
|
|
878
|
+
* @param eid - The entity ID
|
|
879
|
+
*/
|
|
880
|
+
declare function clearListCallbacks(eid: Entity): void;
|
|
881
|
+
/**
|
|
882
|
+
* Handles key press for list widget.
|
|
883
|
+
*
|
|
884
|
+
* @param world - The ECS world
|
|
885
|
+
* @param eid - The entity ID
|
|
886
|
+
* @param key - The key name
|
|
887
|
+
* @returns Action to perform or null
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* ```typescript
|
|
891
|
+
* const action = handleListKeyPress(world, eid, 'down');
|
|
892
|
+
* if (action?.type === 'selectNext') {
|
|
893
|
+
* selectNext(world, eid);
|
|
894
|
+
* }
|
|
895
|
+
* ```
|
|
896
|
+
*/
|
|
897
|
+
declare function handleListKeyPress(world: World, eid: Entity, key: string): ListAction | null;
|
|
898
|
+
/**
|
|
899
|
+
* Renders list items as strings for display.
|
|
900
|
+
*
|
|
901
|
+
* @param eid - The entity ID
|
|
902
|
+
* @param width - Available width
|
|
903
|
+
* @returns Array of rendered line strings
|
|
904
|
+
*/
|
|
905
|
+
declare function renderListItems(eid: Entity, width: number): string[];
|
|
906
|
+
/**
|
|
907
|
+
* Resets the list store. Used for testing.
|
|
908
|
+
*/
|
|
909
|
+
declare function resetListStore(): void;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Scrollable component for scrolling support.
|
|
913
|
+
* @module components/scrollable
|
|
914
|
+
*/
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Scrollbar visibility mode.
|
|
918
|
+
*/
|
|
919
|
+
declare enum ScrollbarVisibility {
|
|
920
|
+
/** Always hidden */
|
|
921
|
+
Hidden = 0,
|
|
922
|
+
/** Always visible */
|
|
923
|
+
Visible = 1,
|
|
924
|
+
/** Visible only when content overflows */
|
|
925
|
+
Auto = 2
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Scrollable component store using SoA (Structure of Arrays) for performance.
|
|
929
|
+
*
|
|
930
|
+
* - `scrollX`, `scrollY`: Current scroll offset
|
|
931
|
+
* - `scrollWidth`, `scrollHeight`: Total scrollable content size
|
|
932
|
+
* - `scrollbarVisible`: Scrollbar visibility mode
|
|
933
|
+
* - `trackVisible`: Whether scroll track is visible
|
|
934
|
+
* - `alwaysScroll`: Always show scrollbar even when not needed
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* ```typescript
|
|
938
|
+
* import { Scrollable, setScroll, getScroll, scrollBy } from 'blecsd';
|
|
939
|
+
*
|
|
940
|
+
* setScroll(world, entity, 0, 100);
|
|
941
|
+
* scrollBy(world, entity, 0, 50);
|
|
942
|
+
*
|
|
943
|
+
* const scroll = getScroll(world, entity);
|
|
944
|
+
* console.log(scroll.y); // 150
|
|
945
|
+
* ```
|
|
946
|
+
*/
|
|
947
|
+
declare const Scrollable: {
|
|
948
|
+
/** Horizontal scroll offset */
|
|
949
|
+
scrollX: Float32Array<ArrayBuffer>;
|
|
950
|
+
/** Vertical scroll offset */
|
|
951
|
+
scrollY: Float32Array<ArrayBuffer>;
|
|
952
|
+
/** Total scrollable width */
|
|
953
|
+
scrollWidth: Float32Array<ArrayBuffer>;
|
|
954
|
+
/** Total scrollable height */
|
|
955
|
+
scrollHeight: Float32Array<ArrayBuffer>;
|
|
956
|
+
/** Viewport width (visible area) - used for clamping */
|
|
957
|
+
viewportWidth: Float32Array<ArrayBuffer>;
|
|
958
|
+
/** Viewport height (visible area) - used for clamping */
|
|
959
|
+
viewportHeight: Float32Array<ArrayBuffer>;
|
|
960
|
+
/** Scrollbar visibility mode (0=hidden, 1=visible, 2=auto) */
|
|
961
|
+
scrollbarVisible: Uint8Array<ArrayBuffer>;
|
|
962
|
+
/** Whether scroll track is visible */
|
|
963
|
+
trackVisible: Uint8Array<ArrayBuffer>;
|
|
964
|
+
/** Always show scrollbar (0=no, 1=yes) */
|
|
965
|
+
alwaysScroll: Uint8Array<ArrayBuffer>;
|
|
966
|
+
/** Whether clamping is enabled (0=no, 1=yes) - default yes */
|
|
967
|
+
clampEnabled: Uint8Array<ArrayBuffer>;
|
|
968
|
+
};
|
|
969
|
+
/**
|
|
970
|
+
* Scrollable configuration options.
|
|
971
|
+
*/
|
|
972
|
+
interface ScrollableOptions {
|
|
973
|
+
/** Initial horizontal scroll offset */
|
|
974
|
+
scrollX?: number;
|
|
975
|
+
/** Initial vertical scroll offset */
|
|
976
|
+
scrollY?: number;
|
|
977
|
+
/** Total scrollable width */
|
|
978
|
+
scrollWidth?: number;
|
|
979
|
+
/** Total scrollable height */
|
|
980
|
+
scrollHeight?: number;
|
|
981
|
+
/** Viewport width (visible area) */
|
|
982
|
+
viewportWidth?: number;
|
|
983
|
+
/** Viewport height (visible area) */
|
|
984
|
+
viewportHeight?: number;
|
|
985
|
+
/** Scrollbar visibility mode */
|
|
986
|
+
scrollbarVisible?: ScrollbarVisibility;
|
|
987
|
+
/** Whether scroll track is visible */
|
|
988
|
+
trackVisible?: boolean;
|
|
989
|
+
/** Always show scrollbar */
|
|
990
|
+
alwaysScroll?: boolean;
|
|
991
|
+
/** Whether scroll clamping is enabled (default: true) */
|
|
992
|
+
clampEnabled?: boolean;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Scroll position data.
|
|
996
|
+
*/
|
|
997
|
+
interface ScrollPosition {
|
|
998
|
+
readonly x: number;
|
|
999
|
+
readonly y: number;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Scroll percentage data.
|
|
1003
|
+
*/
|
|
1004
|
+
interface ScrollPercentage {
|
|
1005
|
+
readonly x: number;
|
|
1006
|
+
readonly y: number;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Full scrollable data returned by getScrollable.
|
|
1010
|
+
*/
|
|
1011
|
+
interface ScrollableData {
|
|
1012
|
+
readonly scrollX: number;
|
|
1013
|
+
readonly scrollY: number;
|
|
1014
|
+
readonly scrollWidth: number;
|
|
1015
|
+
readonly scrollHeight: number;
|
|
1016
|
+
readonly viewportWidth: number;
|
|
1017
|
+
readonly viewportHeight: number;
|
|
1018
|
+
readonly scrollbarVisible: ScrollbarVisibility;
|
|
1019
|
+
readonly trackVisible: boolean;
|
|
1020
|
+
readonly alwaysScroll: boolean;
|
|
1021
|
+
readonly clampEnabled: boolean;
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Makes an entity scrollable with the given options.
|
|
1025
|
+
* Adds the Scrollable component if not already present.
|
|
1026
|
+
*
|
|
1027
|
+
* @param world - The ECS world
|
|
1028
|
+
* @param eid - The entity ID
|
|
1029
|
+
* @param options - Scrollable configuration options
|
|
1030
|
+
* @returns The entity ID for chaining
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* import { createWorld, addEntity } from '../core/ecs';
|
|
1035
|
+
* import { setScrollable, ScrollbarVisibility } from 'blecsd';
|
|
1036
|
+
*
|
|
1037
|
+
* const world = createWorld();
|
|
1038
|
+
* const entity = addEntity(world);
|
|
1039
|
+
*
|
|
1040
|
+
* setScrollable(world, entity, {
|
|
1041
|
+
* scrollHeight: 1000,
|
|
1042
|
+
* scrollbarVisible: ScrollbarVisibility.Auto,
|
|
1043
|
+
* });
|
|
1044
|
+
* ```
|
|
1045
|
+
*/
|
|
1046
|
+
declare function setScrollable(world: World, eid: Entity, options: ScrollableOptions): Entity;
|
|
1047
|
+
/**
|
|
1048
|
+
* Sets the scroll position of an entity.
|
|
1049
|
+
* Adds the Scrollable component if not already present.
|
|
1050
|
+
*
|
|
1051
|
+
* @param world - The ECS world
|
|
1052
|
+
* @param eid - The entity ID
|
|
1053
|
+
* @param x - Horizontal scroll offset
|
|
1054
|
+
* @param y - Vertical scroll offset
|
|
1055
|
+
* @returns The entity ID for chaining
|
|
1056
|
+
*
|
|
1057
|
+
* @example
|
|
1058
|
+
* ```typescript
|
|
1059
|
+
* import { setScroll } from 'blecsd';
|
|
1060
|
+
*
|
|
1061
|
+
* setScroll(world, entity, 0, 100);
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
declare function setScroll(world: World, eid: Entity, x: number, y: number): Entity;
|
|
1065
|
+
/**
|
|
1066
|
+
* Gets the scroll position of an entity.
|
|
1067
|
+
* Returns { x: 0, y: 0 } if no Scrollable component.
|
|
1068
|
+
*
|
|
1069
|
+
* @param world - The ECS world
|
|
1070
|
+
* @param eid - The entity ID
|
|
1071
|
+
* @returns Scroll position
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
* ```typescript
|
|
1075
|
+
* import { getScroll } from 'blecsd';
|
|
1076
|
+
*
|
|
1077
|
+
* const scroll = getScroll(world, entity);
|
|
1078
|
+
* console.log(`Scroll: ${scroll.x}, ${scroll.y}`);
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
declare function getScroll(world: World, eid: Entity): ScrollPosition;
|
|
1082
|
+
/**
|
|
1083
|
+
* Scrolls an entity by the given delta values.
|
|
1084
|
+
* Adds the Scrollable component if not already present.
|
|
1085
|
+
*
|
|
1086
|
+
* @param world - The ECS world
|
|
1087
|
+
* @param eid - The entity ID
|
|
1088
|
+
* @param dx - Horizontal scroll delta
|
|
1089
|
+
* @param dy - Vertical scroll delta
|
|
1090
|
+
* @returns The entity ID for chaining
|
|
1091
|
+
*
|
|
1092
|
+
* @example
|
|
1093
|
+
* ```typescript
|
|
1094
|
+
* import { scrollBy } from 'blecsd';
|
|
1095
|
+
*
|
|
1096
|
+
* // Scroll down by 50 pixels
|
|
1097
|
+
* scrollBy(world, entity, 0, 50);
|
|
1098
|
+
*
|
|
1099
|
+
* // Scroll right by 100 pixels
|
|
1100
|
+
* scrollBy(world, entity, 100, 0);
|
|
1101
|
+
* ```
|
|
1102
|
+
*/
|
|
1103
|
+
declare function scrollBy(world: World, eid: Entity, dx: number, dy: number): Entity;
|
|
1104
|
+
/**
|
|
1105
|
+
* Scrolls an entity to the given position.
|
|
1106
|
+
* Alias for setScroll for semantic clarity.
|
|
1107
|
+
*
|
|
1108
|
+
* @param world - The ECS world
|
|
1109
|
+
* @param eid - The entity ID
|
|
1110
|
+
* @param x - Target horizontal scroll offset
|
|
1111
|
+
* @param y - Target vertical scroll offset
|
|
1112
|
+
* @returns The entity ID for chaining
|
|
1113
|
+
*
|
|
1114
|
+
* @example
|
|
1115
|
+
* ```typescript
|
|
1116
|
+
* import { scrollTo } from 'blecsd';
|
|
1117
|
+
*
|
|
1118
|
+
* scrollTo(world, entity, 0, 0); // Scroll to top
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
declare function scrollTo(world: World, eid: Entity, x: number, y: number): Entity;
|
|
1122
|
+
/**
|
|
1123
|
+
* Gets the scroll percentage of an entity.
|
|
1124
|
+
* Takes viewport size into account: percentage is based on scrollable range
|
|
1125
|
+
* (scrollSize - viewportSize), not total content size.
|
|
1126
|
+
* Returns { x: 0, y: 0 } if no scrollable area or content fits in viewport.
|
|
1127
|
+
*
|
|
1128
|
+
* @param world - The ECS world
|
|
1129
|
+
* @param eid - The entity ID
|
|
1130
|
+
* @returns Scroll percentage (0-100 for each axis)
|
|
1131
|
+
*
|
|
1132
|
+
* @example
|
|
1133
|
+
* ```typescript
|
|
1134
|
+
* import { getScrollPercentage } from 'blecsd';
|
|
1135
|
+
*
|
|
1136
|
+
* const percent = getScrollPercentage(world, entity);
|
|
1137
|
+
* console.log(`Scrolled: ${percent.y}%`);
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
1140
|
+
declare function getScrollPercentage(world: World, eid: Entity): ScrollPercentage;
|
|
1141
|
+
/**
|
|
1142
|
+
* Gets the full scrollable data of an entity.
|
|
1143
|
+
* Returns undefined if no Scrollable component.
|
|
1144
|
+
*
|
|
1145
|
+
* @param world - The ECS world
|
|
1146
|
+
* @param eid - The entity ID
|
|
1147
|
+
* @returns Scrollable data or undefined
|
|
1148
|
+
*/
|
|
1149
|
+
declare function getScrollable(world: World, eid: Entity): ScrollableData | undefined;
|
|
1150
|
+
/**
|
|
1151
|
+
* Checks if an entity has a Scrollable component.
|
|
1152
|
+
*
|
|
1153
|
+
* @param world - The ECS world
|
|
1154
|
+
* @param eid - The entity ID
|
|
1155
|
+
* @returns true if entity has Scrollable component
|
|
1156
|
+
*/
|
|
1157
|
+
declare function hasScrollable(world: World, eid: Entity): boolean;
|
|
1158
|
+
/**
|
|
1159
|
+
* Sets the scrollable content size.
|
|
1160
|
+
*
|
|
1161
|
+
* @param world - The ECS world
|
|
1162
|
+
* @param eid - The entity ID
|
|
1163
|
+
* @param width - Total scrollable width
|
|
1164
|
+
* @param height - Total scrollable height
|
|
1165
|
+
* @returns The entity ID for chaining
|
|
1166
|
+
*/
|
|
1167
|
+
declare function setScrollSize(world: World, eid: Entity, width: number, height: number): Entity;
|
|
1168
|
+
/**
|
|
1169
|
+
* Sets the scrollbar visibility mode.
|
|
1170
|
+
*
|
|
1171
|
+
* @param world - The ECS world
|
|
1172
|
+
* @param eid - The entity ID
|
|
1173
|
+
* @param visibility - Scrollbar visibility mode
|
|
1174
|
+
* @returns The entity ID for chaining
|
|
1175
|
+
*/
|
|
1176
|
+
declare function setScrollbarVisibility(world: World, eid: Entity, visibility: ScrollbarVisibility): Entity;
|
|
1177
|
+
/**
|
|
1178
|
+
* Scrolls an entity to the top.
|
|
1179
|
+
*
|
|
1180
|
+
* @param world - The ECS world
|
|
1181
|
+
* @param eid - The entity ID
|
|
1182
|
+
* @returns The entity ID for chaining
|
|
1183
|
+
*/
|
|
1184
|
+
declare function scrollToTop$1(world: World, eid: Entity): Entity;
|
|
1185
|
+
/**
|
|
1186
|
+
* Scrolls an entity to the bottom.
|
|
1187
|
+
* Takes viewport height into account: scrollY = scrollHeight - viewportHeight.
|
|
1188
|
+
*
|
|
1189
|
+
* @param world - The ECS world
|
|
1190
|
+
* @param eid - The entity ID
|
|
1191
|
+
* @returns The entity ID for chaining
|
|
1192
|
+
*/
|
|
1193
|
+
declare function scrollToBottom$1(world: World, eid: Entity): Entity;
|
|
1194
|
+
/**
|
|
1195
|
+
* Checks if an entity can scroll (has content larger than visible area).
|
|
1196
|
+
* If viewport is set, checks if content exceeds viewport size.
|
|
1197
|
+
*
|
|
1198
|
+
* @param world - The ECS world
|
|
1199
|
+
* @param eid - The entity ID
|
|
1200
|
+
* @returns true if entity has scrollable content
|
|
1201
|
+
*/
|
|
1202
|
+
declare function canScroll(world: World, eid: Entity): boolean;
|
|
1203
|
+
/**
|
|
1204
|
+
* Checks if an entity is scrolled to the top.
|
|
1205
|
+
*
|
|
1206
|
+
* @param world - The ECS world
|
|
1207
|
+
* @param eid - The entity ID
|
|
1208
|
+
* @returns true if scrolled to top
|
|
1209
|
+
*/
|
|
1210
|
+
declare function isAtTop(world: World, eid: Entity): boolean;
|
|
1211
|
+
/**
|
|
1212
|
+
* Checks if an entity is scrolled to the bottom.
|
|
1213
|
+
* Takes viewport height into account: true when scrollY >= scrollHeight - viewportHeight.
|
|
1214
|
+
*
|
|
1215
|
+
* @param world - The ECS world
|
|
1216
|
+
* @param eid - The entity ID
|
|
1217
|
+
* @returns true if scrolled to bottom
|
|
1218
|
+
*/
|
|
1219
|
+
declare function isAtBottom(world: World, eid: Entity): boolean;
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* Table Component
|
|
1223
|
+
*
|
|
1224
|
+
* Provides table/grid data management functionality with cell-based data storage.
|
|
1225
|
+
*
|
|
1226
|
+
* @module components/table
|
|
1227
|
+
*/
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* Table cell alignment.
|
|
1231
|
+
*/
|
|
1232
|
+
type CellAlign = 'left' | 'center' | 'right';
|
|
1233
|
+
/**
|
|
1234
|
+
* Table cell data.
|
|
1235
|
+
*/
|
|
1236
|
+
interface TableCell {
|
|
1237
|
+
/** Cell text value */
|
|
1238
|
+
readonly value: string;
|
|
1239
|
+
/** Cell foreground color (optional) */
|
|
1240
|
+
readonly fg?: number;
|
|
1241
|
+
/** Cell background color (optional) */
|
|
1242
|
+
readonly bg?: number;
|
|
1243
|
+
/** Cell alignment (optional, defaults to left) */
|
|
1244
|
+
readonly align?: CellAlign;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Table row data.
|
|
1248
|
+
*/
|
|
1249
|
+
type TableRow = readonly TableCell[];
|
|
1250
|
+
/**
|
|
1251
|
+
* Table data (array of rows).
|
|
1252
|
+
*/
|
|
1253
|
+
type TableData = readonly TableRow[];
|
|
1254
|
+
/**
|
|
1255
|
+
* Table column configuration.
|
|
1256
|
+
*/
|
|
1257
|
+
interface TableColumn {
|
|
1258
|
+
/** Column header text */
|
|
1259
|
+
readonly header: string;
|
|
1260
|
+
/** Column width (characters) */
|
|
1261
|
+
readonly width?: number;
|
|
1262
|
+
/** Column minimum width */
|
|
1263
|
+
readonly minWidth?: number;
|
|
1264
|
+
/** Column maximum width */
|
|
1265
|
+
readonly maxWidth?: number;
|
|
1266
|
+
/** Column alignment */
|
|
1267
|
+
readonly align?: CellAlign;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Table store for managing table-specific data.
|
|
1271
|
+
*/
|
|
1272
|
+
interface TableStore {
|
|
1273
|
+
/** Whether entity is a table */
|
|
1274
|
+
isTable: Uint8Array;
|
|
1275
|
+
/** Number of rows in table */
|
|
1276
|
+
rowCount: Uint32Array;
|
|
1277
|
+
/** Number of columns in table */
|
|
1278
|
+
colCount: Uint16Array;
|
|
1279
|
+
/** Number of header rows */
|
|
1280
|
+
headerRows: Uint8Array;
|
|
1281
|
+
/** Cell padding */
|
|
1282
|
+
pad: Uint8Array;
|
|
1283
|
+
/** Whether to show cell borders */
|
|
1284
|
+
cellBorders: Uint8Array;
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Table display configuration.
|
|
1288
|
+
*/
|
|
1289
|
+
interface TableDisplay {
|
|
1290
|
+
/** Header foreground color */
|
|
1291
|
+
readonly headerFg: number;
|
|
1292
|
+
/** Header background color */
|
|
1293
|
+
readonly headerBg: number;
|
|
1294
|
+
/** Cell foreground color */
|
|
1295
|
+
readonly cellFg: number;
|
|
1296
|
+
/** Cell background color */
|
|
1297
|
+
readonly cellBg: number;
|
|
1298
|
+
/** Alternate row background color (for striping) */
|
|
1299
|
+
readonly altRowBg?: number;
|
|
1300
|
+
/** Border foreground color */
|
|
1301
|
+
readonly borderFg: number;
|
|
1302
|
+
/** Border background color */
|
|
1303
|
+
readonly borderBg: number;
|
|
1304
|
+
/** Selected row foreground color */
|
|
1305
|
+
readonly selectedFg?: number;
|
|
1306
|
+
/** Selected row background color */
|
|
1307
|
+
readonly selectedBg?: number;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Table display options for configuration.
|
|
1311
|
+
*/
|
|
1312
|
+
interface TableDisplayOptions {
|
|
1313
|
+
headerFg?: number;
|
|
1314
|
+
headerBg?: number;
|
|
1315
|
+
cellFg?: number;
|
|
1316
|
+
cellBg?: number;
|
|
1317
|
+
altRowBg?: number;
|
|
1318
|
+
borderFg?: number;
|
|
1319
|
+
borderBg?: number;
|
|
1320
|
+
selectedFg?: number;
|
|
1321
|
+
selectedBg?: number;
|
|
1322
|
+
}
|
|
1323
|
+
/** Default header foreground color */
|
|
1324
|
+
declare const DEFAULT_HEADER_FG = 4294967295;
|
|
1325
|
+
/** Default header background color */
|
|
1326
|
+
declare const DEFAULT_HEADER_BG = 858993663;
|
|
1327
|
+
/** Default cell foreground color */
|
|
1328
|
+
declare const DEFAULT_CELL_FG = 3435973887;
|
|
1329
|
+
/** Default cell background color */
|
|
1330
|
+
declare const DEFAULT_CELL_BG = 255;
|
|
1331
|
+
/** Default border foreground color */
|
|
1332
|
+
declare const DEFAULT_BORDER_FG = 1717987071;
|
|
1333
|
+
/** Default border background color */
|
|
1334
|
+
declare const DEFAULT_BORDER_BG = 255;
|
|
1335
|
+
/**
|
|
1336
|
+
* Table component store using SoA (Structure of Arrays) for performance.
|
|
1337
|
+
*
|
|
1338
|
+
* Stores table grid metadata.
|
|
1339
|
+
*
|
|
1340
|
+
* @example
|
|
1341
|
+
* ```typescript
|
|
1342
|
+
* import { Table, attachTableBehavior, setData } from 'blecsd';
|
|
1343
|
+
*
|
|
1344
|
+
* attachTableBehavior(world, eid);
|
|
1345
|
+
* setData(world, eid, [
|
|
1346
|
+
* ['Name', 'Age'],
|
|
1347
|
+
* ['Alice', '30'],
|
|
1348
|
+
* ]);
|
|
1349
|
+
* ```
|
|
1350
|
+
*/
|
|
1351
|
+
declare const Table: {
|
|
1352
|
+
/** Number of data rows (excluding headers) */
|
|
1353
|
+
rowCount: Uint32Array<ArrayBuffer>;
|
|
1354
|
+
/** Number of columns */
|
|
1355
|
+
colCount: Uint16Array<ArrayBuffer>;
|
|
1356
|
+
/** Number of header rows */
|
|
1357
|
+
headerRows: Uint8Array<ArrayBuffer>;
|
|
1358
|
+
/** Cell padding (spaces) */
|
|
1359
|
+
pad: Uint8Array<ArrayBuffer>;
|
|
1360
|
+
/** Whether to render cell borders (0 = no, 1 = yes) */
|
|
1361
|
+
cellBorders: Uint8Array<ArrayBuffer>;
|
|
1362
|
+
};
|
|
1363
|
+
/**
|
|
1364
|
+
* Store for table component data.
|
|
1365
|
+
*/
|
|
1366
|
+
declare const tableStore: TableStore;
|
|
1367
|
+
/**
|
|
1368
|
+
* Attaches table behavior to an entity.
|
|
1369
|
+
*
|
|
1370
|
+
* @param world - The ECS world
|
|
1371
|
+
* @param eid - The entity ID
|
|
1372
|
+
* @param options - Table options
|
|
1373
|
+
*
|
|
1374
|
+
* @example
|
|
1375
|
+
* ```typescript
|
|
1376
|
+
* import { attachTableBehavior } from 'blecsd';
|
|
1377
|
+
*
|
|
1378
|
+
* attachTableBehavior(world, eid, {
|
|
1379
|
+
* headerRows: 1,
|
|
1380
|
+
* pad: 1,
|
|
1381
|
+
* cellBorders: true,
|
|
1382
|
+
* });
|
|
1383
|
+
* ```
|
|
1384
|
+
*/
|
|
1385
|
+
declare function attachTableBehavior(_world: World, eid: Entity, options?: {
|
|
1386
|
+
headerRows?: number;
|
|
1387
|
+
pad?: number;
|
|
1388
|
+
cellBorders?: boolean;
|
|
1389
|
+
}): void;
|
|
1390
|
+
/**
|
|
1391
|
+
* Checks if an entity is a table.
|
|
1392
|
+
*
|
|
1393
|
+
* @param _world - The ECS world (unused, kept for API consistency)
|
|
1394
|
+
* @param eid - The entity ID
|
|
1395
|
+
* @returns true if entity is a table
|
|
1396
|
+
*/
|
|
1397
|
+
declare function isTable(_world: World, eid: Entity): boolean;
|
|
1398
|
+
/**
|
|
1399
|
+
* Detaches table behavior from an entity.
|
|
1400
|
+
*
|
|
1401
|
+
* @param _world - The ECS world
|
|
1402
|
+
* @param eid - The entity ID
|
|
1403
|
+
*/
|
|
1404
|
+
declare function detachTableBehavior(_world: World, eid: Entity): void;
|
|
1405
|
+
/**
|
|
1406
|
+
* Sets the table data.
|
|
1407
|
+
*
|
|
1408
|
+
* @param world - The ECS world
|
|
1409
|
+
* @param eid - The entity ID
|
|
1410
|
+
* @param rows - Array of row arrays (string[][] or TableCell[][])
|
|
1411
|
+
*
|
|
1412
|
+
* @example
|
|
1413
|
+
* ```typescript
|
|
1414
|
+
* // With string arrays
|
|
1415
|
+
* setData(world, eid, [
|
|
1416
|
+
* ['Name', 'Age', 'City'],
|
|
1417
|
+
* ['Alice', '30', 'NYC'],
|
|
1418
|
+
* ['Bob', '25', 'LA'],
|
|
1419
|
+
* ]);
|
|
1420
|
+
*
|
|
1421
|
+
* // With TableCell objects
|
|
1422
|
+
* setData(world, eid, [
|
|
1423
|
+
* [{ value: 'Name', fg: 0xffffffff }, { value: 'Age' }, { value: 'City' }],
|
|
1424
|
+
* [{ value: 'Alice' }, { value: '30' }, { value: 'NYC' }],
|
|
1425
|
+
* ]);
|
|
1426
|
+
* ```
|
|
1427
|
+
*/
|
|
1428
|
+
declare function setData(world: World, eid: Entity, rows: ReadonlyArray<ReadonlyArray<string | TableCell>>): void;
|
|
1429
|
+
/**
|
|
1430
|
+
* Gets the table data.
|
|
1431
|
+
*
|
|
1432
|
+
* @param eid - The entity ID
|
|
1433
|
+
* @returns Table data as array of rows
|
|
1434
|
+
*/
|
|
1435
|
+
declare function getData(eid: Entity): TableData;
|
|
1436
|
+
/**
|
|
1437
|
+
* Gets the table data as a string array.
|
|
1438
|
+
*
|
|
1439
|
+
* @param eid - The entity ID
|
|
1440
|
+
* @returns Table data as string[][]
|
|
1441
|
+
*/
|
|
1442
|
+
declare function getDataAsStrings(eid: Entity): string[][];
|
|
1443
|
+
/**
|
|
1444
|
+
* Sets a single cell value.
|
|
1445
|
+
*
|
|
1446
|
+
* @param world - The ECS world
|
|
1447
|
+
* @param eid - The entity ID
|
|
1448
|
+
* @param row - Row index (0-based)
|
|
1449
|
+
* @param col - Column index (0-based)
|
|
1450
|
+
* @param value - Cell value (string or TableCell)
|
|
1451
|
+
* @returns true if cell was set successfully
|
|
1452
|
+
*
|
|
1453
|
+
* @example
|
|
1454
|
+
* ```typescript
|
|
1455
|
+
* setCell(world, eid, 1, 2, 'Updated value');
|
|
1456
|
+
* setCell(world, eid, 1, 2, { value: 'Styled', fg: 0xff0000ff });
|
|
1457
|
+
* ```
|
|
1458
|
+
*/
|
|
1459
|
+
declare function setCell(world: World, eid: Entity, row: number, col: number, value: string | TableCell): boolean;
|
|
1460
|
+
/**
|
|
1461
|
+
* Gets a single cell value.
|
|
1462
|
+
*
|
|
1463
|
+
* @param eid - The entity ID
|
|
1464
|
+
* @param row - Row index (0-based)
|
|
1465
|
+
* @param col - Column index (0-based)
|
|
1466
|
+
* @returns Cell data or undefined if out of bounds
|
|
1467
|
+
*/
|
|
1468
|
+
declare function getCell(eid: Entity, row: number, col: number): TableCell | undefined;
|
|
1469
|
+
/**
|
|
1470
|
+
* Gets a cell's string value.
|
|
1471
|
+
*
|
|
1472
|
+
* @param eid - The entity ID
|
|
1473
|
+
* @param row - Row index (0-based)
|
|
1474
|
+
* @param col - Column index (0-based)
|
|
1475
|
+
* @returns Cell value string or undefined if out of bounds
|
|
1476
|
+
*/
|
|
1477
|
+
declare function getCellValue(eid: Entity, row: number, col: number): string | undefined;
|
|
1478
|
+
/**
|
|
1479
|
+
* Gets a specific row.
|
|
1480
|
+
*
|
|
1481
|
+
* @param eid - The entity ID
|
|
1482
|
+
* @param row - Row index (0-based)
|
|
1483
|
+
* @returns Row data or undefined if out of bounds
|
|
1484
|
+
*/
|
|
1485
|
+
declare function getRow(eid: Entity, row: number): TableRow | undefined;
|
|
1486
|
+
/**
|
|
1487
|
+
* Gets a specific column.
|
|
1488
|
+
*
|
|
1489
|
+
* @param eid - The entity ID
|
|
1490
|
+
* @param col - Column index (0-based)
|
|
1491
|
+
* @returns Column data as array of cells
|
|
1492
|
+
*/
|
|
1493
|
+
declare function getColumn(eid: Entity, col: number): readonly TableCell[];
|
|
1494
|
+
/**
|
|
1495
|
+
* Gets the number of rows.
|
|
1496
|
+
*
|
|
1497
|
+
* @param eid - The entity ID
|
|
1498
|
+
* @returns Number of rows
|
|
1499
|
+
*/
|
|
1500
|
+
declare function getRowCount(eid: Entity): number;
|
|
1501
|
+
/**
|
|
1502
|
+
* Gets the number of columns.
|
|
1503
|
+
*
|
|
1504
|
+
* @param eid - The entity ID
|
|
1505
|
+
* @returns Number of columns
|
|
1506
|
+
*/
|
|
1507
|
+
declare function getColCount(eid: Entity): number;
|
|
1508
|
+
/**
|
|
1509
|
+
* Appends a row to the table.
|
|
1510
|
+
*
|
|
1511
|
+
* @param world - The ECS world
|
|
1512
|
+
* @param eid - The entity ID
|
|
1513
|
+
* @param row - Row data
|
|
1514
|
+
*/
|
|
1515
|
+
declare function appendRow(world: World, eid: Entity, row: ReadonlyArray<string | TableCell>): void;
|
|
1516
|
+
/**
|
|
1517
|
+
* Inserts a row at a specific index.
|
|
1518
|
+
*
|
|
1519
|
+
* @param world - The ECS world
|
|
1520
|
+
* @param eid - The entity ID
|
|
1521
|
+
* @param index - Row index to insert at
|
|
1522
|
+
* @param row - Row data
|
|
1523
|
+
*/
|
|
1524
|
+
declare function insertRow(world: World, eid: Entity, index: number, row: ReadonlyArray<string | TableCell>): void;
|
|
1525
|
+
/**
|
|
1526
|
+
* Removes a row from the table.
|
|
1527
|
+
*
|
|
1528
|
+
* @param world - The ECS world
|
|
1529
|
+
* @param eid - The entity ID
|
|
1530
|
+
* @param index - Row index to remove
|
|
1531
|
+
* @returns The removed row or undefined
|
|
1532
|
+
*/
|
|
1533
|
+
declare function removeRow(world: World, eid: Entity, index: number): TableRow | undefined;
|
|
1534
|
+
/**
|
|
1535
|
+
* Clears all table data.
|
|
1536
|
+
*
|
|
1537
|
+
* @param world - The ECS world
|
|
1538
|
+
* @param eid - The entity ID
|
|
1539
|
+
*/
|
|
1540
|
+
declare function clearData(world: World, eid: Entity): void;
|
|
1541
|
+
/**
|
|
1542
|
+
* Sets table headers using column configuration.
|
|
1543
|
+
*
|
|
1544
|
+
* @param world - The ECS world
|
|
1545
|
+
* @param eid - The entity ID
|
|
1546
|
+
* @param columns - Column configuration
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```typescript
|
|
1550
|
+
* setHeaders(world, eid, [
|
|
1551
|
+
* { header: 'Name', width: 20, align: 'left' },
|
|
1552
|
+
* { header: 'Age', width: 5, align: 'right' },
|
|
1553
|
+
* { header: 'City', width: 15, align: 'left' },
|
|
1554
|
+
* ]);
|
|
1555
|
+
* ```
|
|
1556
|
+
*/
|
|
1557
|
+
declare function setHeaders(world: World, eid: Entity, columns: readonly TableColumn[]): void;
|
|
1558
|
+
/**
|
|
1559
|
+
* Gets the column configuration.
|
|
1560
|
+
*
|
|
1561
|
+
* @param eid - The entity ID
|
|
1562
|
+
* @returns Column configuration
|
|
1563
|
+
*/
|
|
1564
|
+
declare function getColumns(eid: Entity): readonly TableColumn[];
|
|
1565
|
+
/**
|
|
1566
|
+
* Gets the header row(s).
|
|
1567
|
+
*
|
|
1568
|
+
* @param eid - The entity ID
|
|
1569
|
+
* @returns Header row data
|
|
1570
|
+
*/
|
|
1571
|
+
declare function getHeaderRows(eid: Entity): readonly TableRow[];
|
|
1572
|
+
/**
|
|
1573
|
+
* Gets the data rows (excluding headers).
|
|
1574
|
+
*
|
|
1575
|
+
* @param eid - The entity ID
|
|
1576
|
+
* @returns Data rows
|
|
1577
|
+
*/
|
|
1578
|
+
declare function getDataRows(eid: Entity): readonly TableRow[];
|
|
1579
|
+
/**
|
|
1580
|
+
* Sets the number of header rows.
|
|
1581
|
+
*
|
|
1582
|
+
* @param world - The ECS world
|
|
1583
|
+
* @param eid - The entity ID
|
|
1584
|
+
* @param count - Number of header rows (0-255)
|
|
1585
|
+
*/
|
|
1586
|
+
declare function setHeaderRowCount(world: World, eid: Entity, count: number): void;
|
|
1587
|
+
/**
|
|
1588
|
+
* Gets the number of header rows.
|
|
1589
|
+
*
|
|
1590
|
+
* @param eid - The entity ID
|
|
1591
|
+
* @returns Number of header rows
|
|
1592
|
+
*/
|
|
1593
|
+
declare function getHeaderRowCount(eid: Entity): number;
|
|
1594
|
+
/**
|
|
1595
|
+
* Sets the table display configuration.
|
|
1596
|
+
*
|
|
1597
|
+
* @param eid - The entity ID
|
|
1598
|
+
* @param options - Display options
|
|
1599
|
+
*/
|
|
1600
|
+
declare function setTableDisplay(eid: Entity, options: TableDisplayOptions): void;
|
|
1601
|
+
/**
|
|
1602
|
+
* Gets the table display configuration.
|
|
1603
|
+
*
|
|
1604
|
+
* @param eid - The entity ID
|
|
1605
|
+
* @returns Display configuration
|
|
1606
|
+
*/
|
|
1607
|
+
declare function getTableDisplay(eid: Entity): TableDisplay;
|
|
1608
|
+
/**
|
|
1609
|
+
* Clears the table display configuration.
|
|
1610
|
+
*
|
|
1611
|
+
* @param eid - The entity ID
|
|
1612
|
+
*/
|
|
1613
|
+
declare function clearTableDisplay(eid: Entity): void;
|
|
1614
|
+
/**
|
|
1615
|
+
* Gets the cell padding.
|
|
1616
|
+
*
|
|
1617
|
+
* @param eid - The entity ID
|
|
1618
|
+
* @returns Cell padding (spaces)
|
|
1619
|
+
*/
|
|
1620
|
+
declare function getCellPadding(eid: Entity): number;
|
|
1621
|
+
/**
|
|
1622
|
+
* Sets the cell padding.
|
|
1623
|
+
*
|
|
1624
|
+
* @param world - The ECS world
|
|
1625
|
+
* @param eid - The entity ID
|
|
1626
|
+
* @param padding - Cell padding (0-255)
|
|
1627
|
+
*/
|
|
1628
|
+
declare function setCellPadding(world: World, eid: Entity, padding: number): void;
|
|
1629
|
+
/**
|
|
1630
|
+
* Checks if cell borders are enabled.
|
|
1631
|
+
*
|
|
1632
|
+
* @param eid - The entity ID
|
|
1633
|
+
* @returns true if cell borders are enabled
|
|
1634
|
+
*/
|
|
1635
|
+
declare function hasCellBorders(eid: Entity): boolean;
|
|
1636
|
+
/**
|
|
1637
|
+
* Sets whether cell borders are enabled.
|
|
1638
|
+
*
|
|
1639
|
+
* @param world - The ECS world
|
|
1640
|
+
* @param eid - The entity ID
|
|
1641
|
+
* @param enabled - Whether to show cell borders
|
|
1642
|
+
*/
|
|
1643
|
+
declare function setCellBorders(world: World, eid: Entity, enabled: boolean): void;
|
|
1644
|
+
declare function calculateColumnWidths(eid: Entity, maxTotalWidth?: number): number[];
|
|
1645
|
+
declare function renderTableLines(eid: Entity, width: number): string[];
|
|
1646
|
+
/**
|
|
1647
|
+
* Resets the table store. Used for testing.
|
|
1648
|
+
*/
|
|
1649
|
+
declare function resetTableStore(): void;
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* TerminalBuffer Component
|
|
1653
|
+
*
|
|
1654
|
+
* ECS component for terminal emulator buffers. Stores a 2D grid of cells
|
|
1655
|
+
* with per-cell styling, cursor state, and scrollback history.
|
|
1656
|
+
*
|
|
1657
|
+
* @module components/terminalBuffer
|
|
1658
|
+
*
|
|
1659
|
+
* @example
|
|
1660
|
+
* ```typescript
|
|
1661
|
+
* import { createWorld, addEntity } from 'blecsd';
|
|
1662
|
+
* import {
|
|
1663
|
+
* setTerminalBuffer,
|
|
1664
|
+
* writeToTerminal,
|
|
1665
|
+
* getTerminalState,
|
|
1666
|
+
* clearTerminal,
|
|
1667
|
+
* } from 'blecsd/components';
|
|
1668
|
+
*
|
|
1669
|
+
* const world = createWorld();
|
|
1670
|
+
* const eid = addEntity(world);
|
|
1671
|
+
*
|
|
1672
|
+
* // Initialize a terminal buffer
|
|
1673
|
+
* setTerminalBuffer(world, eid, { width: 80, height: 24 });
|
|
1674
|
+
*
|
|
1675
|
+
* // Write ANSI content
|
|
1676
|
+
* writeToTerminal(world, eid, '\x1b[31mHello\x1b[0m World');
|
|
1677
|
+
*
|
|
1678
|
+
* // Get current state
|
|
1679
|
+
* const state = getTerminalState(eid);
|
|
1680
|
+
* console.log(state?.cursorX, state?.cursorY);
|
|
1681
|
+
*
|
|
1682
|
+
* // Clear the terminal
|
|
1683
|
+
* clearTerminal(world, eid);
|
|
1684
|
+
* ```
|
|
1685
|
+
*/
|
|
1686
|
+
|
|
1687
|
+
/** Default terminal width in columns */
|
|
1688
|
+
declare const DEFAULT_TERMINAL_WIDTH = 80;
|
|
1689
|
+
/** Default terminal height in rows */
|
|
1690
|
+
declare const DEFAULT_TERMINAL_HEIGHT = 24;
|
|
1691
|
+
/** Default scrollback lines */
|
|
1692
|
+
declare const DEFAULT_SCROLLBACK_LINES = 1000;
|
|
1693
|
+
/**
|
|
1694
|
+
* TerminalBuffer component for scalar state.
|
|
1695
|
+
* Complex state (cells, scrollback, parser state) is stored in a Map.
|
|
1696
|
+
*/
|
|
1697
|
+
declare const TerminalBuffer: {
|
|
1698
|
+
/** Tag indicating this is a terminal buffer (1 = yes) */
|
|
1699
|
+
isTerminal: Uint8Array<ArrayBuffer>;
|
|
1700
|
+
/** Terminal width in columns */
|
|
1701
|
+
width: Uint16Array<ArrayBuffer>;
|
|
1702
|
+
/** Terminal height in rows */
|
|
1703
|
+
height: Uint16Array<ArrayBuffer>;
|
|
1704
|
+
/** Cursor X position (column) */
|
|
1705
|
+
cursorX: Uint16Array<ArrayBuffer>;
|
|
1706
|
+
/** Cursor Y position (row) */
|
|
1707
|
+
cursorY: Uint16Array<ArrayBuffer>;
|
|
1708
|
+
/** Cursor visible flag (1 = visible) */
|
|
1709
|
+
cursorVisible: Uint8Array<ArrayBuffer>;
|
|
1710
|
+
/** Scroll offset from top (for viewing history) */
|
|
1711
|
+
scrollOffset: Uint32Array<ArrayBuffer>;
|
|
1712
|
+
/** Alternate screen buffer active (1 = yes) */
|
|
1713
|
+
altScreenActive: Uint8Array<ArrayBuffer>;
|
|
1714
|
+
};
|
|
1715
|
+
/**
|
|
1716
|
+
* Terminal state stored in a Map for complex data.
|
|
1717
|
+
*/
|
|
1718
|
+
interface TerminalState {
|
|
1719
|
+
/** Cell buffer (2D grid in row-major order) */
|
|
1720
|
+
readonly buffer: ScreenBufferData;
|
|
1721
|
+
/** Scrollback history */
|
|
1722
|
+
readonly scrollback: ScrollbackBuffer;
|
|
1723
|
+
/** Current text attributes for new characters */
|
|
1724
|
+
currentAttr: Attribute;
|
|
1725
|
+
/** Partial escape sequence buffer */
|
|
1726
|
+
escapeBuffer: string;
|
|
1727
|
+
/** Whether we're in the middle of parsing an escape sequence */
|
|
1728
|
+
inEscape: boolean;
|
|
1729
|
+
/** Saved cursor position X */
|
|
1730
|
+
savedCursorX: number;
|
|
1731
|
+
/** Saved cursor position Y */
|
|
1732
|
+
savedCursorY: number;
|
|
1733
|
+
/** Saved attributes */
|
|
1734
|
+
savedAttr: Attribute;
|
|
1735
|
+
/** Alternate screen buffer (for full-screen apps) */
|
|
1736
|
+
altBuffer: ScreenBufferData | null;
|
|
1737
|
+
/** Cursor shape: 'block' | 'underline' | 'bar' */
|
|
1738
|
+
cursorShape: CursorShape;
|
|
1739
|
+
/** Cursor blink enabled */
|
|
1740
|
+
cursorBlink: boolean;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Cursor shape types.
|
|
1744
|
+
*/
|
|
1745
|
+
type CursorShape = 'block' | 'underline' | 'bar';
|
|
1746
|
+
/**
|
|
1747
|
+
* Terminal buffer configuration schema.
|
|
1748
|
+
*/
|
|
1749
|
+
declare const TerminalBufferConfigSchema: z.ZodObject<{
|
|
1750
|
+
width: z.ZodDefault<z.ZodNumber>;
|
|
1751
|
+
height: z.ZodDefault<z.ZodNumber>;
|
|
1752
|
+
scrollbackLines: z.ZodDefault<z.ZodNumber>;
|
|
1753
|
+
cursorVisible: z.ZodDefault<z.ZodBoolean>;
|
|
1754
|
+
cursorShape: z.ZodDefault<z.ZodEnum<{
|
|
1755
|
+
underline: "underline";
|
|
1756
|
+
block: "block";
|
|
1757
|
+
bar: "bar";
|
|
1758
|
+
}>>;
|
|
1759
|
+
cursorBlink: z.ZodDefault<z.ZodBoolean>;
|
|
1760
|
+
}, z.core.$strip>;
|
|
1761
|
+
/**
|
|
1762
|
+
* Terminal buffer configuration type.
|
|
1763
|
+
*/
|
|
1764
|
+
type TerminalBufferConfig = z.input<typeof TerminalBufferConfigSchema>;
|
|
1765
|
+
/**
|
|
1766
|
+
* Sets up a terminal buffer on an entity.
|
|
1767
|
+
*
|
|
1768
|
+
* @param world - The ECS world
|
|
1769
|
+
* @param eid - Entity ID
|
|
1770
|
+
* @param config - Terminal buffer configuration
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
* ```typescript
|
|
1774
|
+
* setTerminalBuffer(world, eid, {
|
|
1775
|
+
* width: 80,
|
|
1776
|
+
* height: 24,
|
|
1777
|
+
* scrollbackLines: 1000,
|
|
1778
|
+
* });
|
|
1779
|
+
* ```
|
|
1780
|
+
*/
|
|
1781
|
+
declare function setTerminalBuffer(world: World, eid: Entity, config?: TerminalBufferConfig): void;
|
|
1782
|
+
/**
|
|
1783
|
+
* Checks if an entity has a terminal buffer.
|
|
1784
|
+
*
|
|
1785
|
+
* @param eid - Entity ID
|
|
1786
|
+
* @returns true if the entity has a terminal buffer
|
|
1787
|
+
*/
|
|
1788
|
+
declare function hasTerminalBuffer(eid: Entity): boolean;
|
|
1789
|
+
/**
|
|
1790
|
+
* Gets the terminal state for an entity.
|
|
1791
|
+
*
|
|
1792
|
+
* @param eid - Entity ID
|
|
1793
|
+
* @returns Terminal state or undefined
|
|
1794
|
+
*/
|
|
1795
|
+
declare function getTerminalState(eid: Entity): TerminalState | undefined;
|
|
1796
|
+
/**
|
|
1797
|
+
* Gets terminal buffer data (scalar values).
|
|
1798
|
+
*
|
|
1799
|
+
* @param eid - Entity ID
|
|
1800
|
+
* @returns Terminal buffer data
|
|
1801
|
+
*/
|
|
1802
|
+
declare function getTerminalBuffer(eid: Entity): {
|
|
1803
|
+
width: number;
|
|
1804
|
+
height: number;
|
|
1805
|
+
cursorX: number;
|
|
1806
|
+
cursorY: number;
|
|
1807
|
+
cursorVisible: boolean;
|
|
1808
|
+
scrollOffset: number;
|
|
1809
|
+
} | undefined;
|
|
1810
|
+
/**
|
|
1811
|
+
* Writes a character to the terminal at the current cursor position.
|
|
1812
|
+
*
|
|
1813
|
+
* @param world - The ECS world
|
|
1814
|
+
* @param eid - Entity ID
|
|
1815
|
+
* @param char - Character to write
|
|
1816
|
+
*/
|
|
1817
|
+
declare function writeChar(world: World, eid: Entity, char: string): void;
|
|
1818
|
+
/**
|
|
1819
|
+
* Writes a string to the terminal (processes escape sequences).
|
|
1820
|
+
*
|
|
1821
|
+
* @param world - The ECS world
|
|
1822
|
+
* @param eid - Entity ID
|
|
1823
|
+
* @param data - String to write
|
|
1824
|
+
*/
|
|
1825
|
+
declare function writeToTerminal(world: World, eid: Entity, data: string): void;
|
|
1826
|
+
/**
|
|
1827
|
+
* Clears the terminal buffer.
|
|
1828
|
+
*
|
|
1829
|
+
* @param world - The ECS world
|
|
1830
|
+
* @param eid - Entity ID
|
|
1831
|
+
*/
|
|
1832
|
+
declare function clearTerminal(world: World, eid: Entity): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* Resets the terminal to initial state.
|
|
1835
|
+
*
|
|
1836
|
+
* @param world - The ECS world
|
|
1837
|
+
* @param eid - Entity ID
|
|
1838
|
+
*/
|
|
1839
|
+
declare function resetTerminal(world: World, eid: Entity): void;
|
|
1840
|
+
/**
|
|
1841
|
+
* Sets cursor position.
|
|
1842
|
+
*
|
|
1843
|
+
* @param world - The ECS world
|
|
1844
|
+
* @param eid - Entity ID
|
|
1845
|
+
* @param x - Column (0-indexed)
|
|
1846
|
+
* @param y - Row (0-indexed)
|
|
1847
|
+
*/
|
|
1848
|
+
declare function setCursorPosition(world: World, eid: Entity, x: number, y: number): void;
|
|
1849
|
+
/**
|
|
1850
|
+
* Sets cursor visibility.
|
|
1851
|
+
*
|
|
1852
|
+
* @param world - The ECS world
|
|
1853
|
+
* @param eid - Entity ID
|
|
1854
|
+
* @param visible - Cursor visibility
|
|
1855
|
+
*/
|
|
1856
|
+
declare function setCursorVisible(world: World, eid: Entity, visible: boolean): void;
|
|
1857
|
+
/**
|
|
1858
|
+
* Scrolls the terminal view up.
|
|
1859
|
+
*
|
|
1860
|
+
* @param world - The ECS world
|
|
1861
|
+
* @param eid - Entity ID
|
|
1862
|
+
* @param lines - Number of lines to scroll
|
|
1863
|
+
*/
|
|
1864
|
+
declare function scrollTerminalUp(world: World, eid: Entity, lines: number): void;
|
|
1865
|
+
/**
|
|
1866
|
+
* Scrolls the terminal view down.
|
|
1867
|
+
*
|
|
1868
|
+
* @param world - The ECS world
|
|
1869
|
+
* @param eid - Entity ID
|
|
1870
|
+
* @param lines - Number of lines to scroll
|
|
1871
|
+
*/
|
|
1872
|
+
declare function scrollTerminalDown(world: World, eid: Entity, lines: number): void;
|
|
1873
|
+
/**
|
|
1874
|
+
* Scrolls to the top of history.
|
|
1875
|
+
*
|
|
1876
|
+
* @param world - The ECS world
|
|
1877
|
+
* @param eid - Entity ID
|
|
1878
|
+
*/
|
|
1879
|
+
declare function scrollTerminalToTop(world: World, eid: Entity): void;
|
|
1880
|
+
/**
|
|
1881
|
+
* Scrolls to the bottom (current view).
|
|
1882
|
+
*
|
|
1883
|
+
* @param world - The ECS world
|
|
1884
|
+
* @param eid - Entity ID
|
|
1885
|
+
*/
|
|
1886
|
+
declare function scrollTerminalToBottom(world: World, eid: Entity): void;
|
|
1887
|
+
/**
|
|
1888
|
+
* Resizes the terminal buffer.
|
|
1889
|
+
*
|
|
1890
|
+
* @param world - The ECS world
|
|
1891
|
+
* @param eid - Entity ID
|
|
1892
|
+
* @param width - New width in columns
|
|
1893
|
+
* @param height - New height in rows
|
|
1894
|
+
*/
|
|
1895
|
+
declare function resizeTerminalBuffer(world: World, eid: Entity, width: number, height: number): void;
|
|
1896
|
+
/**
|
|
1897
|
+
* Removes a terminal buffer from an entity.
|
|
1898
|
+
*
|
|
1899
|
+
* @param eid - Entity ID
|
|
1900
|
+
*/
|
|
1901
|
+
declare function removeTerminalBuffer(eid: Entity): void;
|
|
1902
|
+
/**
|
|
1903
|
+
* Renders terminal buffer to an ANSI string (for display).
|
|
1904
|
+
*
|
|
1905
|
+
* @param eid - Entity ID
|
|
1906
|
+
* @returns ANSI string representation of the terminal
|
|
1907
|
+
*/
|
|
1908
|
+
declare function renderTerminalToAnsi(eid: Entity): string;
|
|
1909
|
+
/**
|
|
1910
|
+
* Gets the cells for rendering.
|
|
1911
|
+
*
|
|
1912
|
+
* @param eid - Entity ID
|
|
1913
|
+
* @returns Readonly array of cells
|
|
1914
|
+
*/
|
|
1915
|
+
declare function getTerminalCells(eid: Entity): readonly Cell[] | undefined;
|
|
1916
|
+
/**
|
|
1917
|
+
* Resets the terminal buffer store (for testing).
|
|
1918
|
+
* @internal
|
|
1919
|
+
*/
|
|
1920
|
+
declare function resetTerminalBufferStore(): void;
|
|
1921
|
+
|
|
1922
|
+
/**
|
|
1923
|
+
* VirtualViewport Component for Viewport Windowing
|
|
1924
|
+
*
|
|
1925
|
+
* ECS component that tracks which portion of a large dataset is currently visible.
|
|
1926
|
+
* Works with VirtualizedLineStore for text, or any other indexed content.
|
|
1927
|
+
*
|
|
1928
|
+
* @module components/virtualViewport
|
|
1929
|
+
*
|
|
1930
|
+
* @example
|
|
1931
|
+
* ```typescript
|
|
1932
|
+
* import { createWorld, addEntity } from '../core/ecs';
|
|
1933
|
+
* import { setVirtualViewport, scrollToLine, getVisibleRange } from 'blecsd';
|
|
1934
|
+
*
|
|
1935
|
+
* const world = createWorld();
|
|
1936
|
+
* const entity = addEntity(world);
|
|
1937
|
+
*
|
|
1938
|
+
* // Configure viewport for a list with 1000 items
|
|
1939
|
+
* setVirtualViewport(world, entity, {
|
|
1940
|
+
* totalLineCount: 1000,
|
|
1941
|
+
* visibleLineCount: 25,
|
|
1942
|
+
* overscanBefore: 5,
|
|
1943
|
+
* overscanAfter: 5,
|
|
1944
|
+
* });
|
|
1945
|
+
*
|
|
1946
|
+
* // Scroll to line 500
|
|
1947
|
+
* scrollToLine(world, entity, 500);
|
|
1948
|
+
*
|
|
1949
|
+
* // Get visible range (includes overscan)
|
|
1950
|
+
* const range = getVisibleRange(world, entity);
|
|
1951
|
+
* // range = { start: 495, end: 530 }
|
|
1952
|
+
* ```
|
|
1953
|
+
*/
|
|
1954
|
+
|
|
1955
|
+
/**
|
|
1956
|
+
* Schema for VirtualViewport configuration options.
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* ```typescript
|
|
1960
|
+
* import { VirtualViewportOptionsSchema } from 'blecsd';
|
|
1961
|
+
*
|
|
1962
|
+
* const options = VirtualViewportOptionsSchema.parse({
|
|
1963
|
+
* totalLineCount: 10000,
|
|
1964
|
+
* visibleLineCount: 25,
|
|
1965
|
+
* overscanBefore: 5,
|
|
1966
|
+
* });
|
|
1967
|
+
* ```
|
|
1968
|
+
*/
|
|
1969
|
+
declare const VirtualViewportOptionsSchema: z.ZodObject<{
|
|
1970
|
+
firstVisibleLine: z.ZodOptional<z.ZodNumber>;
|
|
1971
|
+
visibleLineCount: z.ZodOptional<z.ZodNumber>;
|
|
1972
|
+
totalLineCount: z.ZodOptional<z.ZodNumber>;
|
|
1973
|
+
overscanBefore: z.ZodOptional<z.ZodNumber>;
|
|
1974
|
+
overscanAfter: z.ZodOptional<z.ZodNumber>;
|
|
1975
|
+
estimatedLineHeight: z.ZodOptional<z.ZodNumber>;
|
|
1976
|
+
isVariableHeight: z.ZodOptional<z.ZodBoolean>;
|
|
1977
|
+
selectedLine: z.ZodOptional<z.ZodNumber>;
|
|
1978
|
+
cursorLine: z.ZodOptional<z.ZodNumber>;
|
|
1979
|
+
}, z.core.$strip>;
|
|
1980
|
+
/**
|
|
1981
|
+
* Schema for visible range output.
|
|
1982
|
+
*/
|
|
1983
|
+
declare const VisibleRangeSchema: z.ZodObject<{
|
|
1984
|
+
start: z.ZodNumber;
|
|
1985
|
+
end: z.ZodNumber;
|
|
1986
|
+
visibleStart: z.ZodNumber;
|
|
1987
|
+
visibleEnd: z.ZodNumber;
|
|
1988
|
+
count: z.ZodNumber;
|
|
1989
|
+
}, z.core.$strip>;
|
|
1990
|
+
/**
|
|
1991
|
+
* Schema for scroll info output.
|
|
1992
|
+
*/
|
|
1993
|
+
declare const ScrollInfoSchema: z.ZodObject<{
|
|
1994
|
+
currentLine: z.ZodNumber;
|
|
1995
|
+
totalLines: z.ZodNumber;
|
|
1996
|
+
viewportSize: z.ZodNumber;
|
|
1997
|
+
maxScrollLine: z.ZodNumber;
|
|
1998
|
+
scrollPercent: z.ZodNumber;
|
|
1999
|
+
atTop: z.ZodBoolean;
|
|
2000
|
+
atBottom: z.ZodBoolean;
|
|
2001
|
+
}, z.core.$strip>;
|
|
2002
|
+
/**
|
|
2003
|
+
* VirtualViewport component store using SoA (Structure of Arrays).
|
|
2004
|
+
*
|
|
2005
|
+
* Tracks viewport windowing for virtualized content rendering.
|
|
2006
|
+
* Only the visible portion (plus overscan) should be rendered.
|
|
2007
|
+
*/
|
|
2008
|
+
declare const VirtualViewport: {
|
|
2009
|
+
/** First visible line index in the viewport */
|
|
2010
|
+
firstVisibleLine: Uint32Array<ArrayBuffer>;
|
|
2011
|
+
/** Number of lines visible in the viewport */
|
|
2012
|
+
visibleLineCount: Uint32Array<ArrayBuffer>;
|
|
2013
|
+
/** Total number of lines in the content */
|
|
2014
|
+
totalLineCount: Uint32Array<ArrayBuffer>;
|
|
2015
|
+
/** Extra lines to render above viewport for smooth scrolling */
|
|
2016
|
+
overscanBefore: Uint8Array<ArrayBuffer>;
|
|
2017
|
+
/** Extra lines to render below viewport for smooth scrolling */
|
|
2018
|
+
overscanAfter: Uint8Array<ArrayBuffer>;
|
|
2019
|
+
/** Estimated height of each line in rows (for variable height estimation) */
|
|
2020
|
+
estimatedLineHeight: Uint8Array<ArrayBuffer>;
|
|
2021
|
+
/** Whether lines have variable height (0=fixed, 1=variable) */
|
|
2022
|
+
isVariableHeight: Uint8Array<ArrayBuffer>;
|
|
2023
|
+
/** Whether viewport needs re-render (dirty flag) */
|
|
2024
|
+
isDirty: Uint8Array<ArrayBuffer>;
|
|
2025
|
+
/** Selected line index (-1 = none) using Int32 to allow -1 */
|
|
2026
|
+
selectedLine: Int32Array<ArrayBuffer>;
|
|
2027
|
+
/** Cursor line for interactive lists (-1 = none) */
|
|
2028
|
+
cursorLine: Int32Array<ArrayBuffer>;
|
|
2029
|
+
};
|
|
2030
|
+
/**
|
|
2031
|
+
* Configuration options for VirtualViewport.
|
|
2032
|
+
*/
|
|
2033
|
+
interface VirtualViewportOptions {
|
|
2034
|
+
/** First visible line index */
|
|
2035
|
+
firstVisibleLine?: number;
|
|
2036
|
+
/** Number of visible lines */
|
|
2037
|
+
visibleLineCount?: number;
|
|
2038
|
+
/** Total line count in content */
|
|
2039
|
+
totalLineCount?: number;
|
|
2040
|
+
/** Overscan lines before viewport */
|
|
2041
|
+
overscanBefore?: number;
|
|
2042
|
+
/** Overscan lines after viewport */
|
|
2043
|
+
overscanAfter?: number;
|
|
2044
|
+
/** Estimated line height (for variable height) */
|
|
2045
|
+
estimatedLineHeight?: number;
|
|
2046
|
+
/** Whether lines have variable height */
|
|
2047
|
+
isVariableHeight?: boolean;
|
|
2048
|
+
/** Selected line index */
|
|
2049
|
+
selectedLine?: number;
|
|
2050
|
+
/** Cursor line index */
|
|
2051
|
+
cursorLine?: number;
|
|
2052
|
+
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Visible range including overscan.
|
|
2055
|
+
*/
|
|
2056
|
+
interface VisibleRange {
|
|
2057
|
+
/** Start line index (with overscan) */
|
|
2058
|
+
readonly start: number;
|
|
2059
|
+
/** End line index (exclusive, with overscan) */
|
|
2060
|
+
readonly end: number;
|
|
2061
|
+
/** First actually visible line (without overscan) */
|
|
2062
|
+
readonly visibleStart: number;
|
|
2063
|
+
/** Last actually visible line (exclusive, without overscan) */
|
|
2064
|
+
readonly visibleEnd: number;
|
|
2065
|
+
/** Total lines in range */
|
|
2066
|
+
readonly count: number;
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Full viewport data.
|
|
2070
|
+
*/
|
|
2071
|
+
interface VirtualViewportData {
|
|
2072
|
+
readonly firstVisibleLine: number;
|
|
2073
|
+
readonly visibleLineCount: number;
|
|
2074
|
+
readonly totalLineCount: number;
|
|
2075
|
+
readonly overscanBefore: number;
|
|
2076
|
+
readonly overscanAfter: number;
|
|
2077
|
+
readonly estimatedLineHeight: number;
|
|
2078
|
+
readonly isVariableHeight: boolean;
|
|
2079
|
+
readonly isDirty: boolean;
|
|
2080
|
+
readonly selectedLine: number;
|
|
2081
|
+
readonly cursorLine: number;
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* Scroll position info.
|
|
2085
|
+
*/
|
|
2086
|
+
interface ScrollInfo {
|
|
2087
|
+
/** Current line */
|
|
2088
|
+
readonly currentLine: number;
|
|
2089
|
+
/** Total lines */
|
|
2090
|
+
readonly totalLines: number;
|
|
2091
|
+
/** Viewport size */
|
|
2092
|
+
readonly viewportSize: number;
|
|
2093
|
+
/** Maximum scrollable line */
|
|
2094
|
+
readonly maxScrollLine: number;
|
|
2095
|
+
/** Scroll percentage (0-100) */
|
|
2096
|
+
readonly scrollPercent: number;
|
|
2097
|
+
/** Whether at top */
|
|
2098
|
+
readonly atTop: boolean;
|
|
2099
|
+
/** Whether at bottom */
|
|
2100
|
+
readonly atBottom: boolean;
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Sets up a VirtualViewport on an entity.
|
|
2104
|
+
* Input is validated against VirtualViewportOptionsSchema.
|
|
2105
|
+
*
|
|
2106
|
+
* @param world - The ECS world
|
|
2107
|
+
* @param eid - The entity ID
|
|
2108
|
+
* @param options - Viewport configuration
|
|
2109
|
+
* @returns The entity ID for chaining
|
|
2110
|
+
* @throws {z.ZodError} If options are invalid
|
|
2111
|
+
*
|
|
2112
|
+
* @example
|
|
2113
|
+
* ```typescript
|
|
2114
|
+
* setVirtualViewport(world, entity, {
|
|
2115
|
+
* totalLineCount: 10000,
|
|
2116
|
+
* visibleLineCount: 25,
|
|
2117
|
+
* });
|
|
2118
|
+
* ```
|
|
2119
|
+
*/
|
|
2120
|
+
declare function setVirtualViewport(world: World, eid: Entity, options: VirtualViewportOptions): Entity;
|
|
2121
|
+
/**
|
|
2122
|
+
* Gets VirtualViewport data for an entity.
|
|
2123
|
+
*
|
|
2124
|
+
* @param world - The ECS world
|
|
2125
|
+
* @param eid - The entity ID
|
|
2126
|
+
* @returns Viewport data or undefined if no component
|
|
2127
|
+
*/
|
|
2128
|
+
declare function getVirtualViewport(world: World, eid: Entity): VirtualViewportData | undefined;
|
|
2129
|
+
/**
|
|
2130
|
+
* Checks if entity has VirtualViewport.
|
|
2131
|
+
*
|
|
2132
|
+
* @param world - The ECS world
|
|
2133
|
+
* @param eid - The entity ID
|
|
2134
|
+
* @returns true if has component
|
|
2135
|
+
*/
|
|
2136
|
+
declare function hasVirtualViewport(world: World, eid: Entity): boolean;
|
|
2137
|
+
/**
|
|
2138
|
+
* Sets the first visible line (viewport start).
|
|
2139
|
+
*
|
|
2140
|
+
* @param world - The ECS world
|
|
2141
|
+
* @param eid - The entity ID
|
|
2142
|
+
* @param lineIndex - Line index to scroll to
|
|
2143
|
+
* @returns The entity ID for chaining
|
|
2144
|
+
*/
|
|
2145
|
+
declare function setViewportStart(world: World, eid: Entity, lineIndex: number): Entity;
|
|
2146
|
+
/**
|
|
2147
|
+
* Gets the visible range including overscan.
|
|
2148
|
+
*
|
|
2149
|
+
* @param world - The ECS world
|
|
2150
|
+
* @param eid - The entity ID
|
|
2151
|
+
* @returns Visible range or undefined if no component
|
|
2152
|
+
*
|
|
2153
|
+
* @example
|
|
2154
|
+
* ```typescript
|
|
2155
|
+
* const range = getVisibleRange(world, entity);
|
|
2156
|
+
* // Render lines from range.start to range.end
|
|
2157
|
+
* const lines = getLineRange(store, range.start, range.end);
|
|
2158
|
+
* ```
|
|
2159
|
+
*/
|
|
2160
|
+
declare function getVisibleRange(world: World, eid: Entity): VisibleRange | undefined;
|
|
2161
|
+
/**
|
|
2162
|
+
* Checks if a line is currently visible (in viewport, not just overscan).
|
|
2163
|
+
*
|
|
2164
|
+
* @param world - The ECS world
|
|
2165
|
+
* @param eid - The entity ID
|
|
2166
|
+
* @param lineIndex - Line index to check
|
|
2167
|
+
* @returns true if line is visible
|
|
2168
|
+
*/
|
|
2169
|
+
declare function isLineVisible(world: World, eid: Entity, lineIndex: number): boolean;
|
|
2170
|
+
/**
|
|
2171
|
+
* Checks if a line is in the render range (visible + overscan).
|
|
2172
|
+
*
|
|
2173
|
+
* @param world - The ECS world
|
|
2174
|
+
* @param eid - The entity ID
|
|
2175
|
+
* @param lineIndex - Line index to check
|
|
2176
|
+
* @returns true if line should be rendered
|
|
2177
|
+
*/
|
|
2178
|
+
declare function isLineInRenderRange(world: World, eid: Entity, lineIndex: number): boolean;
|
|
2179
|
+
/**
|
|
2180
|
+
* Scrolls to a specific line, centering it if possible.
|
|
2181
|
+
*
|
|
2182
|
+
* @param world - The ECS world
|
|
2183
|
+
* @param eid - The entity ID
|
|
2184
|
+
* @param lineIndex - Target line index
|
|
2185
|
+
* @returns The entity ID for chaining
|
|
2186
|
+
*/
|
|
2187
|
+
declare function scrollToLine(world: World, eid: Entity, lineIndex: number): Entity;
|
|
2188
|
+
/**
|
|
2189
|
+
* Scrolls by a number of lines.
|
|
2190
|
+
*
|
|
2191
|
+
* @param world - The ECS world
|
|
2192
|
+
* @param eid - The entity ID
|
|
2193
|
+
* @param delta - Lines to scroll (positive = down, negative = up)
|
|
2194
|
+
* @returns The entity ID for chaining
|
|
2195
|
+
*/
|
|
2196
|
+
declare function scrollByLines(world: World, eid: Entity, delta: number): Entity;
|
|
2197
|
+
/**
|
|
2198
|
+
* Scrolls by pages.
|
|
2199
|
+
*
|
|
2200
|
+
* @param world - The ECS world
|
|
2201
|
+
* @param eid - The entity ID
|
|
2202
|
+
* @param pages - Pages to scroll (positive = down, negative = up)
|
|
2203
|
+
* @returns The entity ID for chaining
|
|
2204
|
+
*/
|
|
2205
|
+
declare function scrollByPages(world: World, eid: Entity, pages: number): Entity;
|
|
2206
|
+
/**
|
|
2207
|
+
* Scrolls to the top.
|
|
2208
|
+
*
|
|
2209
|
+
* @param world - The ECS world
|
|
2210
|
+
* @param eid - The entity ID
|
|
2211
|
+
* @returns The entity ID for chaining
|
|
2212
|
+
*/
|
|
2213
|
+
declare function scrollToTop(world: World, eid: Entity): Entity;
|
|
2214
|
+
/**
|
|
2215
|
+
* Scrolls to the bottom.
|
|
2216
|
+
*
|
|
2217
|
+
* @param world - The ECS world
|
|
2218
|
+
* @param eid - The entity ID
|
|
2219
|
+
* @returns The entity ID for chaining
|
|
2220
|
+
*/
|
|
2221
|
+
declare function scrollToBottom(world: World, eid: Entity): Entity;
|
|
2222
|
+
/**
|
|
2223
|
+
* Gets scroll information.
|
|
2224
|
+
*
|
|
2225
|
+
* @param world - The ECS world
|
|
2226
|
+
* @param eid - The entity ID
|
|
2227
|
+
* @returns Scroll info or undefined if no component
|
|
2228
|
+
*/
|
|
2229
|
+
declare function getScrollInfo(world: World, eid: Entity): ScrollInfo | undefined;
|
|
2230
|
+
/**
|
|
2231
|
+
* Updates the total line count (when content changes).
|
|
2232
|
+
*
|
|
2233
|
+
* @param world - The ECS world
|
|
2234
|
+
* @param eid - The entity ID
|
|
2235
|
+
* @param totalLines - New total line count
|
|
2236
|
+
* @returns The entity ID for chaining
|
|
2237
|
+
*/
|
|
2238
|
+
declare function setTotalLineCount(world: World, eid: Entity, totalLines: number): Entity;
|
|
2239
|
+
/**
|
|
2240
|
+
* Updates the viewport size (when container resizes).
|
|
2241
|
+
*
|
|
2242
|
+
* @param world - The ECS world
|
|
2243
|
+
* @param eid - The entity ID
|
|
2244
|
+
* @param visibleLines - New visible line count
|
|
2245
|
+
* @returns The entity ID for chaining
|
|
2246
|
+
*/
|
|
2247
|
+
declare function setVisibleLineCount(world: World, eid: Entity, visibleLines: number): Entity;
|
|
2248
|
+
/**
|
|
2249
|
+
* Sets overscan values.
|
|
2250
|
+
*
|
|
2251
|
+
* @param world - The ECS world
|
|
2252
|
+
* @param eid - The entity ID
|
|
2253
|
+
* @param before - Lines to render before viewport
|
|
2254
|
+
* @param after - Lines to render after viewport
|
|
2255
|
+
* @returns The entity ID for chaining
|
|
2256
|
+
*/
|
|
2257
|
+
declare function setOverscan(world: World, eid: Entity, before: number, after: number): Entity;
|
|
2258
|
+
/**
|
|
2259
|
+
* Sets the selected line.
|
|
2260
|
+
*
|
|
2261
|
+
* @param world - The ECS world
|
|
2262
|
+
* @param eid - The entity ID
|
|
2263
|
+
* @param lineIndex - Selected line (-1 for none)
|
|
2264
|
+
* @returns The entity ID for chaining
|
|
2265
|
+
*/
|
|
2266
|
+
declare function setSelectedLine(world: World, eid: Entity, lineIndex: number): Entity;
|
|
2267
|
+
/**
|
|
2268
|
+
* Gets the selected line.
|
|
2269
|
+
*
|
|
2270
|
+
* @param world - The ECS world
|
|
2271
|
+
* @param eid - The entity ID
|
|
2272
|
+
* @returns Selected line index or -1 if none
|
|
2273
|
+
*/
|
|
2274
|
+
declare function getSelectedLine(world: World, eid: Entity): number;
|
|
2275
|
+
/**
|
|
2276
|
+
* Sets the cursor line (for keyboard navigation).
|
|
2277
|
+
*
|
|
2278
|
+
* @param world - The ECS world
|
|
2279
|
+
* @param eid - The entity ID
|
|
2280
|
+
* @param lineIndex - Cursor line (-1 for none)
|
|
2281
|
+
* @returns The entity ID for chaining
|
|
2282
|
+
*/
|
|
2283
|
+
declare function setCursorLine(world: World, eid: Entity, lineIndex: number): Entity;
|
|
2284
|
+
/**
|
|
2285
|
+
* Gets the cursor line.
|
|
2286
|
+
*
|
|
2287
|
+
* @param world - The ECS world
|
|
2288
|
+
* @param eid - The entity ID
|
|
2289
|
+
* @returns Cursor line index or -1 if none
|
|
2290
|
+
*/
|
|
2291
|
+
declare function getCursorLine(world: World, eid: Entity): number;
|
|
2292
|
+
/**
|
|
2293
|
+
* Moves cursor up/down and auto-scrolls to keep it visible.
|
|
2294
|
+
*
|
|
2295
|
+
* @param world - The ECS world
|
|
2296
|
+
* @param eid - The entity ID
|
|
2297
|
+
* @param delta - Lines to move (negative = up, positive = down)
|
|
2298
|
+
* @returns The entity ID for chaining
|
|
2299
|
+
*/
|
|
2300
|
+
declare function moveCursor(world: World, eid: Entity, delta: number): Entity;
|
|
2301
|
+
/**
|
|
2302
|
+
* Ensures the cursor is visible, scrolling if needed.
|
|
2303
|
+
*
|
|
2304
|
+
* @param world - The ECS world
|
|
2305
|
+
* @param eid - The entity ID
|
|
2306
|
+
* @returns The entity ID for chaining
|
|
2307
|
+
*/
|
|
2308
|
+
declare function ensureCursorVisible(world: World, eid: Entity): Entity;
|
|
2309
|
+
/**
|
|
2310
|
+
* Checks if viewport needs re-render.
|
|
2311
|
+
*
|
|
2312
|
+
* @param world - The ECS world
|
|
2313
|
+
* @param eid - The entity ID
|
|
2314
|
+
* @returns true if dirty
|
|
2315
|
+
*/
|
|
2316
|
+
declare function isViewportDirty(world: World, eid: Entity): boolean;
|
|
2317
|
+
/**
|
|
2318
|
+
* Clears the dirty flag after rendering.
|
|
2319
|
+
*
|
|
2320
|
+
* @param world - The ECS world
|
|
2321
|
+
* @param eid - The entity ID
|
|
2322
|
+
* @returns The entity ID for chaining
|
|
2323
|
+
*/
|
|
2324
|
+
declare function clearViewportDirty(world: World, eid: Entity): Entity;
|
|
2325
|
+
/**
|
|
2326
|
+
* Forces viewport to be dirty (triggers re-render).
|
|
2327
|
+
*
|
|
2328
|
+
* @param world - The ECS world
|
|
2329
|
+
* @param eid - The entity ID
|
|
2330
|
+
* @returns The entity ID for chaining
|
|
2331
|
+
*/
|
|
2332
|
+
declare function invalidateViewport(world: World, eid: Entity): Entity;
|
|
2333
|
+
|
|
2334
|
+
export { type ScrollInfo as $, type ScrollPercentage as A, type ScrollPosition as B, type CellAlign as C, DEFAULT_CELL_BG as D, Scrollable as E, type ScrollableData as F, type ScrollableOptions as G, ScrollbarVisibility as H, type TableCell as I, type TableColumn as J, type TableData as K, LIST_STATE_MACHINE_CONFIG as L, type TableDisplay as M, type TableDisplayOptions as N, type TableRow as O, type TableStore as P, TerminalBuffer as Q, type TerminalBufferConfig as R, ScrollInfoSchema as S, Table as T, TerminalBufferConfigSchema as U, type CursorShape as V, type TerminalState as W, VirtualViewport as X, type VirtualViewportData as Y, type VirtualViewportOptions as Z, VirtualViewportOptionsSchema as _, DEFAULT_CELL_FG as a, getTerminalBuffer as a$, type VisibleRange as a0, VisibleRangeSchema as a1, activateSelected as a2, addItem as a3, appendItems as a4, appendRow as a5, appendToSearchQuery as a6, attachListBehavior as a7, attachTableBehavior as a8, backspaceSearchQuery as a9, getColumn as aA, getColumns as aB, getCursorLine as aC, getData as aD, getDataAsStrings as aE, getDataRows as aF, getFirstVisible as aG, getHeaderRowCount as aH, getHeaderRows as aI, getItem as aJ, getItemCount as aK, getItems as aL, getLazyLoadCallback as aM, getListDisplay as aN, getListSearchQuery as aO, getSelectedIndex as aP, getListState as aQ, getLoadingPlaceholder as aR, getRow as aS, getRowCount as aT, getScroll as aU, getScrollInfo$1 as aV, getScrollPercentage as aW, getScrollable as aX, getSelectedItem as aY, getSelectedLine as aZ, getTableDisplay as a_, blurList as aa, calculateColumnWidths as ab, canScroll as ac, checkNeedsLoad as ad, clearData as ae, clearItems as af, clearLazyLoadCallback as ag, clearListCallbacks as ah, clearListDisplay as ai, clearSelection as aj, clearSearchQuery as ak, clearTableDisplay as al, clearTerminal as am, clearViewportDirty as an, detachTableBehavior as ao, disableList as ap, enableList as aq, endListSearch as ar, ensureCursorVisible as as, ensureVisible as at, findAndSelectByText as au, findNextMatch as av, focusList as aw, getCellPadding as ax, getCellValue as ay, getColCount as az, DEFAULT_DISABLED_FG as b, selectByValue as b$, getTerminalCells as b0, getTerminalState as b1, getTotalCount as b2, getScrollInfo as b3, getVirtualViewport as b4, getVisibleCount as b5, getVisibleItems as b6, getVisibleRange as b7, handleListKeyPress as b8, hasCellBorders as b9, onListSearchChange as bA, onListSelect as bB, removeItem as bC, removeRow as bD, removeTerminalBuffer as bE, renderListItems as bF, renderTableLines as bG, renderTerminalToAnsi as bH, resetListStore as bI, resetTableStore as bJ, resetTerminal as bK, resetTerminalBufferStore as bL, resizeTerminalBuffer as bM, scrollBy as bN, scrollByLines as bO, scrollByPages as bP, scrollPage as bQ, scrollTerminalDown as bR, scrollTerminalToBottom as bS, scrollTerminalToTop as bT, scrollTerminalUp as bU, scrollTo as bV, scrollToBottom$1 as bW, scrollToLine as bX, scrollToTop$1 as bY, scrollToBottom as bZ, scrollToTop as b_, hasScrollable as ba, hasTerminalBuffer as bb, hasVirtualViewport as bc, insertRow as bd, invalidateViewport as be, isAtBottom as bf, isAtTop as bg, isLineInRenderRange as bh, isLineVisible as bi, isList as bj, isListDisabled as bk, isListFocused as bl, isListInState as bm, isListInteractive as bn, isListKeysEnabled as bo, isListLoading as bp, isListMouseEnabled as bq, isListSearchEnabled as br, isListSearching as bs, isTable as bt, isViewportDirty as bu, listStore as bv, loadItems as bw, moveCursor as bx, onListActivate as by, onListScroll as bz, DEFAULT_HEADER_BG as c, selectFirst as c0, selectLast as c1, selectNext as c2, selectPrev as c3, sendListEvent as c4, setCellBorders as c5, setCellPadding as c6, setCursorLine as c7, setCursorPosition as c8, setData as c9, setVisibleCount as cA, setVisibleLineCount as cB, startListSearch as cC, tableStore as cD, updateItem as cE, writeToTerminal as cF, type StateMachineConfig as cG, type StateMachine as cH, getCell as cI, setCell as cJ, setCursorVisible as cK, writeChar as cL, setFirstVisible as ca, setHeaderRowCount as cb, setHeaders as cc, setItems as cd, setLazyLoadCallback as ce, setListDisplay as cf, setListInteractive as cg, setListKeys as ch, setListLoading as ci, setListMouse as cj, setListSearchEnabled as ck, setListSearchQuery as cl, setSelectedIndex as cm, setLoadingPlaceholder as cn, setOverscan as co, setScroll as cp, setScrollSize as cq, setScrollable as cr, setScrollbarVisibility as cs, setSelectedLine as ct, setTableDisplay as cu, setTerminalBuffer as cv, setTotalCount as cw, setTotalLineCount as cx, setViewportStart as cy, setVirtualViewport as cz, DEFAULT_HEADER_FG as d, DEFAULT_ITEM_BG as e, DEFAULT_ITEM_FG as f, DEFAULT_SCROLLBACK_LINES as g, DEFAULT_SELECTED_BG as h, DEFAULT_SELECTED_FG as i, DEFAULT_SELECTED_PREFIX as j, DEFAULT_BORDER_BG as k, DEFAULT_BORDER_FG as l, DEFAULT_TERMINAL_HEIGHT as m, DEFAULT_TERMINAL_WIDTH as n, DEFAULT_UNSELECTED_PREFIX as o, type ListAction as p, type ListDisplay as q, type ListDisplayOptions as r, type ListEvent as s, type ListItem as t, type ListLazyLoadCallback as u, type ListScrollCallback as v, type ListScrollInfo as w, type ListSelectCallback as x, type ListState as y, type ListStore as z };
|