@yaks/tui 0.0.0-stage → 0.2.36
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/Frame.js +52 -0
- package/Frame.js.map +1 -0
- package/Frame.ts +92 -0
- package/Image.js +10 -0
- package/Image.js.map +1 -0
- package/Image.ts +22 -0
- package/LICENSE +202 -0
- package/README.md +524 -2
- package/RenderedCursor.js +103 -0
- package/RenderedCursor.js.map +1 -0
- package/RenderedCursor.ts +127 -0
- package/Scroll.js +88 -0
- package/Scroll.js.map +1 -0
- package/Scroll.ts +155 -0
- package/Textarea.js +186 -0
- package/Textarea.js.map +1 -0
- package/Textarea.ts +234 -0
- package/VirtualList.js +729 -0
- package/VirtualList.js.map +1 -0
- package/VirtualList.ts +838 -0
- package/_dist/Frame.d.ts +25 -0
- package/_dist/Frame.d.ts.map +1 -0
- package/_dist/Image.d.ts +13 -0
- package/_dist/Image.d.ts.map +1 -0
- package/_dist/RenderedCursor.d.ts +9 -0
- package/_dist/RenderedCursor.d.ts.map +1 -0
- package/_dist/Scroll.d.ts +30 -0
- package/_dist/Scroll.d.ts.map +1 -0
- package/_dist/Textarea.d.ts +26 -0
- package/_dist/Textarea.d.ts.map +1 -0
- package/_dist/VirtualList.d.ts +103 -0
- package/_dist/VirtualList.d.ts.map +1 -0
- package/_dist/guide.d.ts +21 -0
- package/_dist/guide.d.ts.map +1 -0
- package/_dist/history.d.ts +12 -0
- package/_dist/history.d.ts.map +1 -0
- package/_dist/input.d.ts +47 -0
- package/_dist/input.d.ts.map +1 -0
- package/_dist/interaction.d.ts +15 -0
- package/_dist/interaction.d.ts.map +1 -0
- package/_dist/keymap.d.ts +4 -0
- package/_dist/keymap.d.ts.map +1 -0
- package/_dist/mod.d.ts +42 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/mouse.d.ts +15 -0
- package/_dist/mouse.d.ts.map +1 -0
- package/_dist/paint.d.ts +86 -0
- package/_dist/paint.d.ts.map +1 -0
- package/_dist/print.d.ts +20 -0
- package/_dist/print.d.ts.map +1 -0
- package/_dist/run.d.ts +19 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/screen.d.ts +22 -0
- package/_dist/screen.d.ts.map +1 -0
- package/_dist/scrollbar.d.ts +7 -0
- package/_dist/scrollbar.d.ts.map +1 -0
- package/_dist/testing.d.ts +19 -0
- package/_dist/testing.d.ts.map +1 -0
- package/_dist/theme.d.ts +11 -0
- package/_dist/theme.d.ts.map +1 -0
- package/_dist/visual.d.ts +28 -0
- package/_dist/visual.d.ts.map +1 -0
- package/deno.json +1 -0
- package/graphics.js +157 -0
- package/graphics.js.map +1 -0
- package/graphics.ts +191 -0
- package/grid.js +38 -0
- package/grid.js.map +1 -0
- package/grid.ts +46 -0
- package/guide.js +144 -0
- package/guide.js.map +1 -0
- package/guide.ts +169 -0
- package/history.js +58 -0
- package/history.js.map +1 -0
- package/history.ts +59 -0
- package/input.js +356 -0
- package/input.js.map +1 -0
- package/input.ts +324 -0
- package/interaction.js +180 -0
- package/interaction.js.map +1 -0
- package/interaction.ts +185 -0
- package/keymap.js +20 -0
- package/keymap.js.map +1 -0
- package/keymap.ts +23 -0
- package/mod.js +39 -0
- package/mod.js.map +1 -0
- package/mod.ts +92 -0
- package/mouse.js +65 -0
- package/mouse.js.map +1 -0
- package/mouse.ts +98 -0
- package/package.json +49 -4
- package/paint.js +1010 -0
- package/paint.js.map +1 -0
- package/paint.ts +1063 -0
- package/print.js +31 -0
- package/print.js.map +1 -0
- package/print.ts +40 -0
- package/run.js +220 -0
- package/run.js.map +1 -0
- package/run.ts +237 -0
- package/screen.js +97 -0
- package/screen.js.map +1 -0
- package/screen.ts +139 -0
- package/scrollbar.js +30 -0
- package/scrollbar.js.map +1 -0
- package/scrollbar.ts +33 -0
- package/table.js +134 -0
- package/table.js.map +1 -0
- package/table.ts +152 -0
- package/testing.js +86 -0
- package/testing.js.map +1 -0
- package/testing.ts +95 -0
- package/textRows.js +38 -0
- package/textRows.js.map +1 -0
- package/textRows.ts +31 -0
- package/theme.js +50 -0
- package/theme.js.map +1 -0
- package/theme.ts +39 -0
- package/visual.js +195 -0
- package/visual.js.map +1 -0
- package/visual.ts +209 -0
package/VirtualList.ts
ADDED
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clampPoint,
|
|
3
|
+
copyRendered,
|
|
4
|
+
cursorLine,
|
|
5
|
+
type RenderedCursor,
|
|
6
|
+
stepColumn,
|
|
7
|
+
} from './RenderedCursor.js'
|
|
8
|
+
import { useTextSurface } from './visual.js'
|
|
9
|
+
import { scrollbar as drawScrollbar, type ScrollPosition } from './scrollbar.js'
|
|
10
|
+
import type { MouseEvent } from './mouse.ts'
|
|
11
|
+
/** An identity-anchored, lazily measured viewport. No total-height pass. */
|
|
12
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import {
|
|
13
|
+
createElement as h,
|
|
14
|
+
type ReactElement,
|
|
15
|
+
type ReactNode,
|
|
16
|
+
useLayoutEffect,
|
|
17
|
+
useRef,
|
|
18
|
+
} from 'react'
|
|
19
|
+
import { render } from '@yaks/react/draw'
|
|
20
|
+
import { TElement, touch } from '@yaks/dom'
|
|
21
|
+
import { clip, lay, type Line, viewports } from './paint.js'
|
|
22
|
+
import type { Sheet, Style } from 'jsr:@yaks/ui@0.2.36/sheet'
|
|
23
|
+
import { terminalFocused, useKeys } from './screen.js'
|
|
24
|
+
import type { Key } from './input.ts'
|
|
25
|
+
import { type Anchor, rekey, type ViewportState, walk } from '@yaks/ux/anchor'
|
|
26
|
+
|
|
27
|
+
export type ListRange = {
|
|
28
|
+
before: boolean
|
|
29
|
+
after: boolean
|
|
30
|
+
/** Number of items in the whole list, not just the loaded page. */
|
|
31
|
+
total?: number
|
|
32
|
+
/** Logical index of the first loaded item. Supply together with total. */
|
|
33
|
+
offset?: number
|
|
34
|
+
}
|
|
35
|
+
export type RangeRequest = { anchor?: string; edge?: 'start' | 'end' }
|
|
36
|
+
|
|
37
|
+
export type VirtualItem = { id: string }
|
|
38
|
+
type Cached = { version: string; width: number; style: string; lines: Line[] }
|
|
39
|
+
export type { Anchor, ViewportState }
|
|
40
|
+
|
|
41
|
+
/** Also usable without Preact: measure is called only for visited items.
|
|
42
|
+
* Cache is bounded by item count; one very large item still costs its full size.
|
|
43
|
+
*/
|
|
44
|
+
export class VirtualWindow<T extends VirtualItem> {
|
|
45
|
+
anchor?: Anchor
|
|
46
|
+
cursor?: RenderedCursor
|
|
47
|
+
cursorStyle: Style = { inverse: true }
|
|
48
|
+
cursorVisible = true
|
|
49
|
+
private cursorStamp = ''
|
|
50
|
+
private reader?: (id: string) => Line[] | undefined
|
|
51
|
+
selected?: string
|
|
52
|
+
selectionVisible = true
|
|
53
|
+
selectionStyle: Style = { bg: '#343f44' }
|
|
54
|
+
follow: boolean
|
|
55
|
+
private items: readonly T[] = []
|
|
56
|
+
private indices = new Map<string, number>()
|
|
57
|
+
private retainedOrder: string[] = []
|
|
58
|
+
private cache = new Map<string, Cached>()
|
|
59
|
+
// Retain numeric heights independently of the bounded text/layout cache.
|
|
60
|
+
// Only the current width/style is kept; no extra layout is performed.
|
|
61
|
+
private heights = new Map<
|
|
62
|
+
string,
|
|
63
|
+
{ version: string; rows: number; index: number }
|
|
64
|
+
>()
|
|
65
|
+
private heightWidth = -1
|
|
66
|
+
private heightStyle = ''
|
|
67
|
+
private heightItems?: readonly T[]
|
|
68
|
+
private heightOffset = -1
|
|
69
|
+
private height = 0
|
|
70
|
+
private movement = 0
|
|
71
|
+
private start = false
|
|
72
|
+
private style = ''
|
|
73
|
+
private revealedSelection?: string
|
|
74
|
+
private revealedWidth = 0
|
|
75
|
+
private revealedHeight = 0
|
|
76
|
+
range: ListRange = { before: false, after: false }
|
|
77
|
+
visibleEnd = 0
|
|
78
|
+
stats = { measured: 0, hits: 0 }
|
|
79
|
+
constructor(
|
|
80
|
+
private measure: (item: T, width: number) => Line[],
|
|
81
|
+
private version: (item: T) => string,
|
|
82
|
+
follow = false,
|
|
83
|
+
private capacity = 256,
|
|
84
|
+
) {
|
|
85
|
+
this.follow = follow
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
update(items: readonly T[]) {
|
|
89
|
+
if (items === this.items) return
|
|
90
|
+
const was = this.items.map((item) => item.id)
|
|
91
|
+
// Keep bounded ordering metadata across overlapping loaded pages for selection.
|
|
92
|
+
// Membership is by Set: a list of thousands updates in linear time.
|
|
93
|
+
const nextIds = items.map((item) => item.id)
|
|
94
|
+
const next = new Set(nextIds)
|
|
95
|
+
const retained = new Set(this.retainedOrder)
|
|
96
|
+
const firstOverlap = nextIds.findIndex((id) => retained.has(id))
|
|
97
|
+
if (firstOverlap < 0) this.retainedOrder = nextIds
|
|
98
|
+
else {
|
|
99
|
+
const oldAt = this.retainedOrder.indexOf(nextIds[firstOverlap])
|
|
100
|
+
this.retainedOrder = [
|
|
101
|
+
...new Set([
|
|
102
|
+
...this.retainedOrder.slice(0, oldAt),
|
|
103
|
+
...nextIds,
|
|
104
|
+
...this.retainedOrder.slice(oldAt).filter((id) => !next.has(id)),
|
|
105
|
+
]),
|
|
106
|
+
]
|
|
107
|
+
if (this.retainedOrder.length > 512) {
|
|
108
|
+
this.retainedOrder = this.retainedOrder.slice(-512)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this.items = items
|
|
112
|
+
this.indices = new Map(items.map((item, i) => [item.id, i]))
|
|
113
|
+
// A removed anchor falls to its former successor (or its predecessor).
|
|
114
|
+
this.anchor = rekey(this.anchor, was, nextIds)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Item navigation uses only cached heights, never measures intervening history. */
|
|
118
|
+
selectionKey(key: Key, selected: string | undefined): string | undefined {
|
|
119
|
+
if (key.alt || key.shift) return undefined
|
|
120
|
+
let average = this.cache.size
|
|
121
|
+
? [...this.cache.values()].reduce((n, item) => n + item.lines.length, 0) /
|
|
122
|
+
this.cache.size
|
|
123
|
+
: 1
|
|
124
|
+
let page = Math.max(1, Math.floor(this.height / average))
|
|
125
|
+
let half = Math.max(1, Math.floor(this.height / average / 2))
|
|
126
|
+
let delta = key.ctrl
|
|
127
|
+
? key.text == 'u' ? -half : key.text == 'd' ? half : undefined
|
|
128
|
+
: key.name == 'up'
|
|
129
|
+
? -1
|
|
130
|
+
: key.name == 'down'
|
|
131
|
+
? 1
|
|
132
|
+
: key.name == 'pageup'
|
|
133
|
+
? -page
|
|
134
|
+
: key.name == 'pagedown'
|
|
135
|
+
? page
|
|
136
|
+
: undefined
|
|
137
|
+
let index = this.indices.get(selected ?? this.anchor?.id ?? '') ?? -1
|
|
138
|
+
if (key.name == 'home') {
|
|
139
|
+
index = 0
|
|
140
|
+
this.follow = false
|
|
141
|
+
} else if (key.name == 'end') {
|
|
142
|
+
index = this.items.length - 1
|
|
143
|
+
this.follow = true
|
|
144
|
+
} else if (delta !== undefined) index = index < 0 ? 0 : index + delta
|
|
145
|
+
else return undefined
|
|
146
|
+
return this.items[Math.max(0, Math.min(this.items.length - 1, index))]?.id
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
key(key: Key): boolean {
|
|
150
|
+
let page = Math.max(1, this.height - 1)
|
|
151
|
+
let delta = key.name == 'up'
|
|
152
|
+
? -1
|
|
153
|
+
: key.name == 'down'
|
|
154
|
+
? 1
|
|
155
|
+
: key.name == 'wheelup'
|
|
156
|
+
? -3
|
|
157
|
+
: key.name == 'wheeldown'
|
|
158
|
+
? 3
|
|
159
|
+
: key.name == 'pageup'
|
|
160
|
+
? -page
|
|
161
|
+
: key.name == 'pagedown'
|
|
162
|
+
? page
|
|
163
|
+
: null
|
|
164
|
+
if (key.ctrl && key.name == 'end') {
|
|
165
|
+
this.follow = true
|
|
166
|
+
this.movement = 0
|
|
167
|
+
return true
|
|
168
|
+
}
|
|
169
|
+
if (key.ctrl && key.name == 'home') {
|
|
170
|
+
this.follow = false
|
|
171
|
+
this.start = true
|
|
172
|
+
this.movement = 0
|
|
173
|
+
return true
|
|
174
|
+
}
|
|
175
|
+
if (delta == null) return false
|
|
176
|
+
// Wheel can bubble to an enclosing scroll region at a known boundary.
|
|
177
|
+
if (key.name == 'wheeldown' && this.follow) return false
|
|
178
|
+
if (
|
|
179
|
+
key.name == 'wheelup' && !this.follow && this.movement == 0 &&
|
|
180
|
+
this.anchor?.id == this.items[0]?.id && this.anchor?.offset == 0
|
|
181
|
+
) return false
|
|
182
|
+
if (delta < 0) this.follow = false
|
|
183
|
+
this.movement += delta
|
|
184
|
+
return true
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Move a rendered cursor; only visited items are measured. */
|
|
188
|
+
moveCursor(key: Key, point: RenderedCursor): RenderedCursor | undefined {
|
|
189
|
+
if (!this.reader) return
|
|
190
|
+
let index = this.indices.get(point.id)
|
|
191
|
+
if (index == null) return
|
|
192
|
+
let lines = this.reader(point.id)!, p = clampPoint(point, lines)
|
|
193
|
+
let row = p.row, col = p.col
|
|
194
|
+
if (key.name == 'left' || key.name == 'right') {
|
|
195
|
+
col = stepColumn(lines[row], col, key.name == 'left' ? -1 : 1)
|
|
196
|
+
} else if (key.name == 'up') row--
|
|
197
|
+
else if (key.name == 'down') row++
|
|
198
|
+
else if (key.name == 'pageup' || key.name == 'pagedown') {
|
|
199
|
+
row += (key.name == 'pageup' ? -1 : 1) * Math.max(1, this.height - 1)
|
|
200
|
+
} else if (key.ctrl && (key.text == 'u' || key.text == 'd')) {
|
|
201
|
+
row += (key.text == 'u' ? -1 : 1) *
|
|
202
|
+
Math.max(1, Math.floor(this.height / 2))
|
|
203
|
+
} else if (key.name == 'home' && !key.ctrl) col = 0
|
|
204
|
+
else if (key.name == 'end' && !key.ctrl) {
|
|
205
|
+
col = lines[row].reduce((n, s) => n + s.text.length, 0) - 1
|
|
206
|
+
} else return
|
|
207
|
+
while (row < 0 && index > 0) {
|
|
208
|
+
index--
|
|
209
|
+
lines = this.reader(this.items[index].id)!
|
|
210
|
+
row += lines.length
|
|
211
|
+
}
|
|
212
|
+
while (row >= lines.length && index < this.items.length - 1) {
|
|
213
|
+
row -= lines.length
|
|
214
|
+
index++
|
|
215
|
+
lines = this.reader(this.items[index].id)!
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
...point,
|
|
219
|
+
...clampPoint({ id: this.items[index].id, row, col }, lines),
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
copyCursor(point: RenderedCursor): string {
|
|
223
|
+
return copyRendered(
|
|
224
|
+
point,
|
|
225
|
+
this.retainedOrder,
|
|
226
|
+
(id) => this.reader?.(id) ?? this.cache.get(id)?.lines,
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Exact measured rows plus the observed average for unmeasured items.
|
|
231
|
+
* The estimate is presentation only: it never changes the scroll anchor.
|
|
232
|
+
*/
|
|
233
|
+
position(width: number): ScrollPosition {
|
|
234
|
+
const known = width == this.heightWidth && this.style == this.heightStyle
|
|
235
|
+
? [...this.heights.values()]
|
|
236
|
+
: []
|
|
237
|
+
const average = known.length
|
|
238
|
+
? known.reduce((sum, item) => sum + item.rows, 0) / known.length
|
|
239
|
+
: 1
|
|
240
|
+
const counted = this.range.total != null && this.range.offset != null
|
|
241
|
+
const offset = counted ? this.range.offset! : 0
|
|
242
|
+
const index = offset +
|
|
243
|
+
(this.anchor ? this.indices.get(this.anchor.id) ?? 0 : 0)
|
|
244
|
+
let total = (counted ? this.range.total! : this.items.length) * average
|
|
245
|
+
let top = index * average + (this.anchor?.offset ?? 0)
|
|
246
|
+
for (const item of known) {
|
|
247
|
+
if (!counted && (item.index < 0 || item.index >= this.items.length)) {
|
|
248
|
+
continue
|
|
249
|
+
}
|
|
250
|
+
const correction = item.rows - average
|
|
251
|
+
total += correction
|
|
252
|
+
if (item.index < index) top += correction
|
|
253
|
+
}
|
|
254
|
+
// Older callers may only know whether neighbors exist. Keep their fallback
|
|
255
|
+
// without pretending that those booleans describe the full item count.
|
|
256
|
+
if (!counted) {
|
|
257
|
+
const unknown = Math.max(this.height, this.items.length * average)
|
|
258
|
+
if (this.range.before) {
|
|
259
|
+
top += unknown
|
|
260
|
+
total += unknown
|
|
261
|
+
}
|
|
262
|
+
if (this.range.after) total += unknown
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
total,
|
|
266
|
+
top: Math.max(0, Math.min(top, Math.max(0, total - this.height))),
|
|
267
|
+
height: this.height,
|
|
268
|
+
bottom: this.follow && !this.range.after,
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
layout(width: number, height: number, style = ''): Line[] {
|
|
273
|
+
this.height = height
|
|
274
|
+
this.style = style
|
|
275
|
+
if (width != this.heightWidth || style != this.heightStyle) {
|
|
276
|
+
this.heights.clear()
|
|
277
|
+
this.heightWidth = width
|
|
278
|
+
this.heightStyle = style
|
|
279
|
+
}
|
|
280
|
+
const pageOffset = this.range.offset ?? 0
|
|
281
|
+
if (this.items !== this.heightItems || pageOffset != this.heightOffset) {
|
|
282
|
+
this.heightItems = this.items
|
|
283
|
+
this.heightOffset = pageOffset
|
|
284
|
+
const complete = !this.range.before && !this.range.after
|
|
285
|
+
// Loaded rows are authoritative for version and position; rows outside a
|
|
286
|
+
// partial page retain their last measurements until encountered again.
|
|
287
|
+
if (complete) {
|
|
288
|
+
for (const id of this.heights.keys()) {
|
|
289
|
+
if (!this.indices.has(id)) this.heights.delete(id)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
293
|
+
const item = this.items[i], known = this.heights.get(item.id)
|
|
294
|
+
if (known && known.version != this.version(item)) {
|
|
295
|
+
this.heights.delete(item.id)
|
|
296
|
+
} else if (known) known.index = pageOffset + i
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (!this.items.length || height <= 0 || width <= 0) return []
|
|
300
|
+
let get = (i: number): Line[] => {
|
|
301
|
+
let item = this.items[i], version = this.version(item)
|
|
302
|
+
let cached = this.cache.get(item.id)
|
|
303
|
+
if (
|
|
304
|
+
!cached || cached.version != version || cached.width != width ||
|
|
305
|
+
cached.style != this.style
|
|
306
|
+
) {
|
|
307
|
+
let lines = this.measure(item, width)
|
|
308
|
+
cached = {
|
|
309
|
+
version,
|
|
310
|
+
width,
|
|
311
|
+
style: this.style,
|
|
312
|
+
lines: lines.length ? lines : [[]],
|
|
313
|
+
}
|
|
314
|
+
this.stats.measured++
|
|
315
|
+
} else this.stats.hits++
|
|
316
|
+
this.heights.set(item.id, {
|
|
317
|
+
version,
|
|
318
|
+
rows: cached.lines.length,
|
|
319
|
+
index: pageOffset + i,
|
|
320
|
+
})
|
|
321
|
+
this.cache.delete(item.id)
|
|
322
|
+
this.cache.set(item.id, cached)
|
|
323
|
+
while (this.cache.size > this.capacity) {
|
|
324
|
+
this.cache.delete(this.cache.keys().next().value!)
|
|
325
|
+
}
|
|
326
|
+
return cached.lines
|
|
327
|
+
}
|
|
328
|
+
this.reader = (id) => {
|
|
329
|
+
const index = this.indices.get(id)
|
|
330
|
+
return index == null ? undefined : get(index)
|
|
331
|
+
}
|
|
332
|
+
if (this.cursor && this.indices.has(this.cursor.id)) {
|
|
333
|
+
this.cursor = {
|
|
334
|
+
...this.cursor,
|
|
335
|
+
...clampPoint(this.cursor, get(this.indices.get(this.cursor.id)!)),
|
|
336
|
+
}
|
|
337
|
+
this.selected = this.cursor.id
|
|
338
|
+
const stamp = JSON.stringify([
|
|
339
|
+
this.cursor.id,
|
|
340
|
+
this.cursor.row,
|
|
341
|
+
this.cursor.col,
|
|
342
|
+
width,
|
|
343
|
+
])
|
|
344
|
+
if (stamp != this.cursorStamp) {
|
|
345
|
+
this.cursorStamp = stamp
|
|
346
|
+
const startIndex = this.anchor
|
|
347
|
+
? this.indices.get(this.anchor.id)
|
|
348
|
+
: undefined
|
|
349
|
+
let distance = -(this.anchor?.offset ?? 0)
|
|
350
|
+
let index = startIndex ?? this.indices.get(this.cursor.id)!
|
|
351
|
+
const target = this.indices.get(this.cursor.id)!
|
|
352
|
+
let visible = target >= index
|
|
353
|
+
while (visible && index < target && distance < height) {
|
|
354
|
+
distance += get(index++).length
|
|
355
|
+
}
|
|
356
|
+
distance += this.cursor.row
|
|
357
|
+
visible = visible && index == target && distance >= 0 &&
|
|
358
|
+
distance < height
|
|
359
|
+
if (!visible) {
|
|
360
|
+
this.anchor = {
|
|
361
|
+
id: this.cursor.id,
|
|
362
|
+
offset: Math.max(0, this.cursor.row - height + 1),
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
this.revealedSelection = this.cursor.id
|
|
366
|
+
this.revealedWidth = width
|
|
367
|
+
this.revealedHeight = height
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
let i = this.anchor ? this.indices.get(this.anchor.id) ?? 0 : 0
|
|
371
|
+
let offset = this.anchor?.offset ?? 0
|
|
372
|
+
if (this.follow && !this.range.after) {
|
|
373
|
+
i = this.items.length - 1
|
|
374
|
+
let remaining = height
|
|
375
|
+
while (i > 0 && get(i).length < remaining) {
|
|
376
|
+
remaining -= get(i).length
|
|
377
|
+
i--
|
|
378
|
+
}
|
|
379
|
+
offset = Math.max(0, get(i).length - remaining)
|
|
380
|
+
} else {
|
|
381
|
+
if (this.start) {
|
|
382
|
+
i = 0
|
|
383
|
+
offset = 0
|
|
384
|
+
this.start = false
|
|
385
|
+
}
|
|
386
|
+
const walked = walk(
|
|
387
|
+
{ index: i, offset },
|
|
388
|
+
this.movement,
|
|
389
|
+
(index) => get(index).length,
|
|
390
|
+
this.items.length,
|
|
391
|
+
)
|
|
392
|
+
i = walked.index
|
|
393
|
+
offset = walked.offset
|
|
394
|
+
}
|
|
395
|
+
// Probe only the existing viewport. Jump directly to a distant selection,
|
|
396
|
+
// then measure at most one screen backwards to reveal its trailing edge.
|
|
397
|
+
let selected = this.selected === undefined
|
|
398
|
+
? undefined
|
|
399
|
+
: this.indices.get(this.selected)
|
|
400
|
+
const reveal = this.selected != this.revealedSelection ||
|
|
401
|
+
width != this.revealedWidth || height != this.revealedHeight
|
|
402
|
+
this.revealedSelection = this.selected
|
|
403
|
+
this.revealedWidth = width
|
|
404
|
+
this.revealedHeight = height
|
|
405
|
+
if (selected !== undefined && !this.follow && reveal) {
|
|
406
|
+
let end = i, remaining = height + offset, seen = false
|
|
407
|
+
while (end < this.items.length && remaining > 0) {
|
|
408
|
+
remaining -= get(end).length
|
|
409
|
+
if (end == selected) {
|
|
410
|
+
seen = true
|
|
411
|
+
break
|
|
412
|
+
}
|
|
413
|
+
end++
|
|
414
|
+
}
|
|
415
|
+
if (selected < i || (selected == i && offset > 0)) {
|
|
416
|
+
i = selected
|
|
417
|
+
offset = 0
|
|
418
|
+
this.follow = false
|
|
419
|
+
} else if (!seen || remaining < 0) {
|
|
420
|
+
i = selected
|
|
421
|
+
let room = height - get(i).length
|
|
422
|
+
while (i > 0 && room > 0) {
|
|
423
|
+
i--
|
|
424
|
+
room -= get(i).length
|
|
425
|
+
}
|
|
426
|
+
offset = Math.max(0, -room)
|
|
427
|
+
// Oversized entries show their beginning, not just their final lines.
|
|
428
|
+
if (i == selected) offset = 0
|
|
429
|
+
this.follow = false
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
let exhausted = false
|
|
433
|
+
let out: Line[] = [], end = i, local = offset
|
|
434
|
+
while (end < this.items.length && out.length < height) {
|
|
435
|
+
let lines = get(end)
|
|
436
|
+
exhausted = end == this.items.length - 1 &&
|
|
437
|
+
lines.length - local <= height - out.length
|
|
438
|
+
let visible = lines.slice(local, local + height - out.length)
|
|
439
|
+
if (this.cursor) {
|
|
440
|
+
visible = visible.map((line, row) =>
|
|
441
|
+
cursorLine(
|
|
442
|
+
line,
|
|
443
|
+
this.items[end].id,
|
|
444
|
+
row + local,
|
|
445
|
+
this.cursor!,
|
|
446
|
+
this.retainedOrder,
|
|
447
|
+
this.cursorVisible ? this.cursorStyle : {},
|
|
448
|
+
)
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
out.push(
|
|
452
|
+
...(this.selectionVisible && end == selected
|
|
453
|
+
? visible.map((line) =>
|
|
454
|
+
line.map((seg) => ({
|
|
455
|
+
...seg,
|
|
456
|
+
style: { ...seg.style, ...this.selectionStyle },
|
|
457
|
+
}))
|
|
458
|
+
)
|
|
459
|
+
: visible),
|
|
460
|
+
)
|
|
461
|
+
local = 0
|
|
462
|
+
end++
|
|
463
|
+
}
|
|
464
|
+
// Scrolling down into the end snaps; an append while detached never does.
|
|
465
|
+
if (
|
|
466
|
+
!this.range.after && !this.follow && this.movement > 0 && exhausted
|
|
467
|
+
) {
|
|
468
|
+
this.follow = true
|
|
469
|
+
this.movement = 0
|
|
470
|
+
return this.layout(width, height, style)
|
|
471
|
+
}
|
|
472
|
+
this.visibleEnd = end
|
|
473
|
+
this.movement = 0
|
|
474
|
+
this.anchor = { id: this.items[i].id, offset }
|
|
475
|
+
return out.concat(
|
|
476
|
+
Array.from({ length: Math.max(0, height - out.length) }, () => []),
|
|
477
|
+
)
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** The viewport owns a bounded line cache, not thousands of mounted components.
|
|
482
|
+
* Width/style changes invalidate lazily, so resize only measures visible items.
|
|
483
|
+
*/
|
|
484
|
+
export let VirtualList = <T extends VirtualItem>(
|
|
485
|
+
{
|
|
486
|
+
items,
|
|
487
|
+
renderItem,
|
|
488
|
+
textOf,
|
|
489
|
+
version = JSON.stringify,
|
|
490
|
+
follow = false,
|
|
491
|
+
pending = false,
|
|
492
|
+
value,
|
|
493
|
+
onViewportChange,
|
|
494
|
+
selected,
|
|
495
|
+
cursor,
|
|
496
|
+
onCursor,
|
|
497
|
+
onYank,
|
|
498
|
+
selectionVisible = true,
|
|
499
|
+
selectionClass = 'List_Selected',
|
|
500
|
+
onSelect,
|
|
501
|
+
range,
|
|
502
|
+
onRange,
|
|
503
|
+
...attrs
|
|
504
|
+
}: {
|
|
505
|
+
items: readonly T[]
|
|
506
|
+
/** Unloaded neighbors. Boundary requests never imply the data is empty. */
|
|
507
|
+
range?: ListRange
|
|
508
|
+
onRange?: (request: RangeRequest) => void
|
|
509
|
+
/** Controlled selected item; onSelect enables item-navigation keys. */
|
|
510
|
+
selected?: string
|
|
511
|
+
cursor?: RenderedCursor
|
|
512
|
+
onCursor?: (cursor: RenderedCursor) => void
|
|
513
|
+
onYank?: (text: string, error?: boolean) => void
|
|
514
|
+
/** Keep the logical selection while hiding its painted highlight. */
|
|
515
|
+
selectionClass?: string
|
|
516
|
+
selectionVisible?: boolean
|
|
517
|
+
onSelect?: (id: string) => void
|
|
518
|
+
textOf?: (item: T) => string
|
|
519
|
+
renderItem: (item: T) => ReactNode
|
|
520
|
+
version?: (item: T) => string
|
|
521
|
+
scrollbar?: boolean
|
|
522
|
+
follow?: boolean
|
|
523
|
+
/** Loading is not an authoritative empty item collection. */
|
|
524
|
+
pending?: boolean
|
|
525
|
+
/** Controlled logical position; measurements and caches remain internal. */
|
|
526
|
+
value?: ViewportState
|
|
527
|
+
onViewportChange?: (value: ViewportState) => void
|
|
528
|
+
id?: string
|
|
529
|
+
grow?: string
|
|
530
|
+
height?: string
|
|
531
|
+
},
|
|
532
|
+
): ReactElement<{
|
|
533
|
+
onWheel: (event: MouseEvent) => void
|
|
534
|
+
ref: (el: unknown) => void
|
|
535
|
+
scrollbar?: boolean
|
|
536
|
+
id?: string
|
|
537
|
+
grow?: string
|
|
538
|
+
}> => {
|
|
539
|
+
// The same range may be requested again only once the loaded ids change. If
|
|
540
|
+
// the caller returns the same page, it must not be asked again, or the list
|
|
541
|
+
// requests forever, stays pending, and drops every key.
|
|
542
|
+
let rangeRequest = useRef<string | undefined>(undefined)
|
|
543
|
+
let rangeIds = useRef<string | undefined>(undefined)
|
|
544
|
+
let ids = items.map((item) => item.id).join('\n')
|
|
545
|
+
if (rangeIds.current !== ids) {
|
|
546
|
+
rangeRequest.current = undefined
|
|
547
|
+
rangeIds.current = ids
|
|
548
|
+
}
|
|
549
|
+
let requestRange = (request: RangeRequest) => {
|
|
550
|
+
if (!onRange) return
|
|
551
|
+
let key = JSON.stringify(request)
|
|
552
|
+
if (rangeRequest.current === key) return
|
|
553
|
+
rangeRequest.current = key
|
|
554
|
+
queueMicrotask(() => onRange(request))
|
|
555
|
+
}
|
|
556
|
+
let props = useRef({ renderItem, version })
|
|
557
|
+
props.current = { renderItem, version }
|
|
558
|
+
let selectionWidth = useRef(80)
|
|
559
|
+
let selectedIndex = useRef<number | undefined>(undefined)
|
|
560
|
+
let env = useRef<{ style: Style; sheet: Sheet } | undefined>(undefined)
|
|
561
|
+
let state = useRef<VirtualWindow<T> | undefined>(undefined)
|
|
562
|
+
let trees = useRef(new Map<string, { version: string; root: TElement }>())
|
|
563
|
+
let clearTrees = () => {
|
|
564
|
+
for (let { root } of trees.current.values()) {
|
|
565
|
+
render(null, root as unknown as Element)
|
|
566
|
+
}
|
|
567
|
+
trees.current.clear()
|
|
568
|
+
}
|
|
569
|
+
useLayoutEffect(() => clearTrees, [])
|
|
570
|
+
// Keep the last accepted viewport while its replacement is in flight.
|
|
571
|
+
// This is a paint cache, not a second source of item or scroll state.
|
|
572
|
+
let frame = useRef<
|
|
573
|
+
{ lines: Line[]; position: ScrollPosition } | undefined
|
|
574
|
+
>(undefined)
|
|
575
|
+
let identity = useRef(attrs.id)
|
|
576
|
+
if (identity.current != attrs.id) {
|
|
577
|
+
frame.current = undefined
|
|
578
|
+
let old = [...trees.current.values()]
|
|
579
|
+
trees.current = new Map()
|
|
580
|
+
queueMicrotask(() => {
|
|
581
|
+
for (let { root } of old) render(null, root as unknown as Element)
|
|
582
|
+
})
|
|
583
|
+
state.current = undefined
|
|
584
|
+
identity.current = attrs.id
|
|
585
|
+
}
|
|
586
|
+
if (!state.current) {
|
|
587
|
+
state.current = new VirtualWindow<T>(
|
|
588
|
+
(item, width) => {
|
|
589
|
+
let version = props.current.version(item)
|
|
590
|
+
let cached = trees.current.get(item.id)
|
|
591
|
+
if (!cached || cached.version != version) {
|
|
592
|
+
if (cached) render(null, cached.root as unknown as Element)
|
|
593
|
+
let root = new TElement('div')
|
|
594
|
+
render(
|
|
595
|
+
h('div', null, props.current.renderItem(item)),
|
|
596
|
+
root as unknown as Element,
|
|
597
|
+
)
|
|
598
|
+
cached = { version, root }
|
|
599
|
+
}
|
|
600
|
+
trees.current.delete(item.id)
|
|
601
|
+
trees.current.set(item.id, cached)
|
|
602
|
+
while (trees.current.size > 256) {
|
|
603
|
+
let key = trees.current.keys().next().value!
|
|
604
|
+
render(null, trees.current.get(key)!.root as unknown as Element)
|
|
605
|
+
trees.current.delete(key)
|
|
606
|
+
}
|
|
607
|
+
let lines = lay(cached.root, env.current!.style, width, null, {
|
|
608
|
+
sheet: env.current!.sheet,
|
|
609
|
+
metrics: {},
|
|
610
|
+
})
|
|
611
|
+
return lines
|
|
612
|
+
},
|
|
613
|
+
(item) => props.current.version(item),
|
|
614
|
+
follow,
|
|
615
|
+
)
|
|
616
|
+
}
|
|
617
|
+
if (value) {
|
|
618
|
+
state.current.anchor = value.anchor
|
|
619
|
+
state.current.follow = value.follow
|
|
620
|
+
}
|
|
621
|
+
let publish = () => {
|
|
622
|
+
if (pending) return
|
|
623
|
+
let next = { anchor: state.current!.anchor, follow: state.current!.follow }
|
|
624
|
+
if (
|
|
625
|
+
next.follow != value?.follow || next.anchor?.id != value?.anchor?.id ||
|
|
626
|
+
next.anchor?.offset != value?.anchor?.offset
|
|
627
|
+
) onViewportChange?.(next)
|
|
628
|
+
}
|
|
629
|
+
if (!pending) state.current.update(items)
|
|
630
|
+
useTextSurface({
|
|
631
|
+
id: attrs.id ?? 'list',
|
|
632
|
+
enabled: Boolean(textOf) && !onCursor,
|
|
633
|
+
snapshot: () => {
|
|
634
|
+
selectedIndex.current = items.findIndex((i) =>
|
|
635
|
+
i.id == (selected ?? state.current!.anchor?.id)
|
|
636
|
+
)
|
|
637
|
+
let item = items[selectedIndex.current] ?? items.at(-1)
|
|
638
|
+
return { text: item && textOf ? textOf(item) : '' }
|
|
639
|
+
},
|
|
640
|
+
width: () => selectionWidth.current,
|
|
641
|
+
adjacent: (delta) => {
|
|
642
|
+
let index = Math.max(
|
|
643
|
+
0,
|
|
644
|
+
Math.min(items.length - 1, (selectedIndex.current ?? 0) + delta),
|
|
645
|
+
)
|
|
646
|
+
selectedIndex.current = index
|
|
647
|
+
let item = items[index]
|
|
648
|
+
return { text: item && textOf ? textOf(item) : '' }
|
|
649
|
+
},
|
|
650
|
+
})
|
|
651
|
+
state.current.selectionVisible = selectionVisible
|
|
652
|
+
state.current.range = range ?? { before: false, after: false }
|
|
653
|
+
state.current.selected = selected
|
|
654
|
+
state.current.cursor = cursor
|
|
655
|
+
useKeys((key) => {
|
|
656
|
+
if (pending) return false
|
|
657
|
+
const cursor = state.current!.cursor
|
|
658
|
+
if (cursor && onCursor) {
|
|
659
|
+
const text = key.name == 'char' && !key.ctrl && !key.alt
|
|
660
|
+
? key.text
|
|
661
|
+
: undefined
|
|
662
|
+
if (text == 'v') {
|
|
663
|
+
const next = {
|
|
664
|
+
...cursor,
|
|
665
|
+
anchor: { id: cursor.id, row: cursor.row, col: cursor.col },
|
|
666
|
+
}
|
|
667
|
+
state.current!.cursor = next
|
|
668
|
+
onCursor(next)
|
|
669
|
+
return true
|
|
670
|
+
}
|
|
671
|
+
if (key.name == 'escape') {
|
|
672
|
+
state.current!.cursor = { ...cursor, anchor: undefined }
|
|
673
|
+
onCursor(state.current!.cursor)
|
|
674
|
+
return true
|
|
675
|
+
}
|
|
676
|
+
if (text == 'y' && cursor.anchor) {
|
|
677
|
+
try {
|
|
678
|
+
onYank?.(state.current!.copyCursor(cursor))
|
|
679
|
+
state.current!.cursor = { ...cursor, anchor: undefined }
|
|
680
|
+
onCursor(state.current!.cursor)
|
|
681
|
+
} catch (error) {
|
|
682
|
+
onYank?.(String(error), true)
|
|
683
|
+
}
|
|
684
|
+
return true
|
|
685
|
+
}
|
|
686
|
+
const down = key.name == 'down' || key.name == 'pagedown' ||
|
|
687
|
+
key.ctrl && key.text == 'd'
|
|
688
|
+
const up = key.name == 'up' || key.name == 'pageup' ||
|
|
689
|
+
key.ctrl && key.text == 'u'
|
|
690
|
+
const index = items.findIndex((item) => item.id == cursor.id)
|
|
691
|
+
if (
|
|
692
|
+
range &&
|
|
693
|
+
(down && range.after && index >= items.length - 2 ||
|
|
694
|
+
up && range.before && index < 2)
|
|
695
|
+
) {
|
|
696
|
+
requestRange({ anchor: cursor.id })
|
|
697
|
+
}
|
|
698
|
+
const moved = state.current!.moveCursor(key, cursor)
|
|
699
|
+
if (moved) {
|
|
700
|
+
state.current!.follow = false
|
|
701
|
+
state.current!.cursor = moved
|
|
702
|
+
state.current!.selected = moved.id
|
|
703
|
+
onCursor(moved)
|
|
704
|
+
touch()
|
|
705
|
+
return true
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
if (
|
|
709
|
+
range && (key.name == 'home' || key.name == 'end') &&
|
|
710
|
+
(key.ctrl || onSelect)
|
|
711
|
+
) {
|
|
712
|
+
let edge: 'start' | 'end' = key.name == 'home' ? 'start' : 'end'
|
|
713
|
+
if (edge == 'start' ? range.before : range.after) {
|
|
714
|
+
requestRange({ edge })
|
|
715
|
+
return true
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
if (range && selected) {
|
|
719
|
+
let index = items.findIndex((item) => item.id == selected)
|
|
720
|
+
let up = key.name == 'up' || key.name == 'pageup' ||
|
|
721
|
+
key.ctrl && key.text == 'u'
|
|
722
|
+
let down = key.name == 'down' || key.name == 'pagedown' ||
|
|
723
|
+
key.ctrl && key.text == 'd'
|
|
724
|
+
if (
|
|
725
|
+
up && range.before && index <= 1 ||
|
|
726
|
+
down && range.after && index >= items.length - 2
|
|
727
|
+
) {
|
|
728
|
+
requestRange({ anchor: selected })
|
|
729
|
+
return true
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if (onSelect) {
|
|
733
|
+
let id = state.current!.selectionKey(key, selected)
|
|
734
|
+
if (id !== undefined) {
|
|
735
|
+
// Ordinary selection detaches; End explicitly resumes following.
|
|
736
|
+
if (key.name != 'end') state.current!.follow = false
|
|
737
|
+
publish()
|
|
738
|
+
onSelect(id)
|
|
739
|
+
if (cursor && onCursor) {
|
|
740
|
+
onCursor({
|
|
741
|
+
id,
|
|
742
|
+
row: key.name == 'end' ? Number.MAX_SAFE_INTEGER : 0,
|
|
743
|
+
col: key.name == 'end' ? Number.MAX_SAFE_INTEGER : 0,
|
|
744
|
+
anchor: cursor.anchor,
|
|
745
|
+
})
|
|
746
|
+
}
|
|
747
|
+
return true
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (!state.current!.key(key)) return false
|
|
751
|
+
touch()
|
|
752
|
+
return true
|
|
753
|
+
}, String(attrs.id))
|
|
754
|
+
useLayoutEffect(() => {
|
|
755
|
+
touch()
|
|
756
|
+
}, [items, renderItem, selected, selectionVisible, selectionClass, cursor])
|
|
757
|
+
return h('div', {
|
|
758
|
+
...attrs,
|
|
759
|
+
onWheel: (event: MouseEvent & { nativeEvent?: MouseEvent }) => {
|
|
760
|
+
let { release, ctrl, alt, shift } = event.nativeEvent ?? event
|
|
761
|
+
if (pending) return
|
|
762
|
+
if (
|
|
763
|
+
!event.deltaY || release || ctrl || alt || shift
|
|
764
|
+
) return
|
|
765
|
+
if (
|
|
766
|
+
state.current!.key({ name: event.deltaY < 0 ? 'wheelup' : 'wheeldown' })
|
|
767
|
+
) {
|
|
768
|
+
touch()
|
|
769
|
+
event.preventDefault()
|
|
770
|
+
event.stopPropagation()
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
ref: (el: unknown) => {
|
|
774
|
+
if (!el) return
|
|
775
|
+
viewports.set(el as TElement, (width, height, style, sheet) => {
|
|
776
|
+
selectionWidth.current = width
|
|
777
|
+
env.current = { style, sheet }
|
|
778
|
+
state.current!.cursorVisible = terminalFocused.value
|
|
779
|
+
state.current!.selectionStyle = sheet[selectionClass] ??
|
|
780
|
+
{ bg: '#343f44' }
|
|
781
|
+
let inner = attrs.scrollbar && width >= 2 ? width - 1 : width
|
|
782
|
+
if (pending) {
|
|
783
|
+
let saved = frame.current
|
|
784
|
+
let lines = saved?.lines.slice(0, height).map((line) =>
|
|
785
|
+
clip(line, inner)
|
|
786
|
+
) ??
|
|
787
|
+
[[{ text: 'Loading…', style: sheet.Muted ?? {} }]]
|
|
788
|
+
// Never normalize/publish an unloaded window or move its anchor.
|
|
789
|
+
// Keep the existing scrollbar position as well as its content.
|
|
790
|
+
let position = saved
|
|
791
|
+
? { ...saved.position, height }
|
|
792
|
+
: { height, total: height, top: 0, bottom: true }
|
|
793
|
+
return attrs.scrollbar
|
|
794
|
+
? drawScrollbar(lines, width, position, sheet)
|
|
795
|
+
: lines.slice(0, height)
|
|
796
|
+
}
|
|
797
|
+
let lines = state.current!.layout(
|
|
798
|
+
inner,
|
|
799
|
+
height,
|
|
800
|
+
JSON.stringify([style, sheet]),
|
|
801
|
+
)
|
|
802
|
+
publish()
|
|
803
|
+
const normalized = state.current!.cursor
|
|
804
|
+
if (
|
|
805
|
+
cursor && normalized &&
|
|
806
|
+
(selected !== normalized.id || cursor.row != normalized.row ||
|
|
807
|
+
cursor.col != normalized.col)
|
|
808
|
+
) {
|
|
809
|
+
onCursor?.(normalized)
|
|
810
|
+
}
|
|
811
|
+
if (range && items.length) {
|
|
812
|
+
let at = items.findIndex((item) =>
|
|
813
|
+
item.id == state.current!.anchor?.id
|
|
814
|
+
)
|
|
815
|
+
if (
|
|
816
|
+
range.before && at < 8 ||
|
|
817
|
+
range.after && state.current!.visibleEnd > items.length - 8
|
|
818
|
+
) {
|
|
819
|
+
requestRange({
|
|
820
|
+
anchor: range.before && at < 8
|
|
821
|
+
? state.current!.anchor?.id
|
|
822
|
+
: items[
|
|
823
|
+
Math.min(items.length - 1, state.current!.visibleEnd - 1)
|
|
824
|
+
].id,
|
|
825
|
+
})
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
frame.current = {
|
|
829
|
+
lines,
|
|
830
|
+
position: state.current!.position(inner),
|
|
831
|
+
}
|
|
832
|
+
return attrs.scrollbar
|
|
833
|
+
? drawScrollbar(lines, width, frame.current.position, sheet)
|
|
834
|
+
: lines
|
|
835
|
+
})
|
|
836
|
+
},
|
|
837
|
+
})
|
|
838
|
+
}
|