@rbxts/centurion-ui 2.0.0-rc.2 → 2.0.0-rc.4
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/README.md +1 -1
- package/package.json +2 -2
- package/src/analyse/init.luau +11 -2
- package/src/analyse/suggest.luau +7 -3
- package/src/app/header.luau +1 -1
- package/src/app/init.luau +28 -9
- package/src/app/suggestions.luau +187 -6
- package/src/init.luau +3 -0
- package/src/state.luau +3 -1
- package/src/ts/index.d.ts +1 -0
- package/src/types.luau +6 -0
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
- 🧩 **Typed arguments.** Built-in types for players, teams, numbers, colors, durations, vectors and more, with optional, multi-value and rest arguments. Register your own types with custom suggestions.
|
|
33
33
|
|
|
34
|
-
- 🔐 **Guards and permissions.** Guard commands with reusable checks, and control access with
|
|
34
|
+
- 🔐 **Guards and permissions.** Guard commands with reusable checks, and control access with inheritable roles and permissions.
|
|
35
35
|
|
|
36
36
|
- 🔄 **Client-server sync.** Players only receive the commands they're allowed to run, and stay up to date as commands or roles change.
|
|
37
37
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/centurion-ui",
|
|
3
3
|
"description": "Terminal UI for the Centurion command framework",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.4",
|
|
5
5
|
"author": "paradoxuum",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/ts/init.luau",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@rbxts/centurion": "^2.0.0-rc.
|
|
36
|
+
"@rbxts/centurion": "^2.0.0-rc.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {}
|
|
39
39
|
}
|
package/src/analyse/init.luau
CHANGED
|
@@ -166,8 +166,10 @@ local function analyse(text: string, cursor_pos: number, max_suggestions: number
|
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
local suggestions = {}
|
|
169
|
+
local hidden = 0
|
|
169
170
|
if #arg_suggestions > 0 then
|
|
170
|
-
local matches = suggest(input_token.text, arg_suggestions, max_suggestions)
|
|
171
|
+
local matches, total = suggest(input_token.text, arg_suggestions, max_suggestions)
|
|
172
|
+
hidden = total - #matches
|
|
171
173
|
|
|
172
174
|
for _, suggestion_text in matches do
|
|
173
175
|
local replacement = ""
|
|
@@ -202,6 +204,7 @@ local function analyse(text: string, cursor_pos: number, max_suggestions: number
|
|
|
202
204
|
kind = arg_type.kind,
|
|
203
205
|
},
|
|
204
206
|
suggestions = suggestions,
|
|
207
|
+
hidden_suggestions = hidden,
|
|
205
208
|
} :: types.AnalysisResult
|
|
206
209
|
end
|
|
207
210
|
|
|
@@ -220,7 +223,8 @@ local function analyse(text: string, cursor_pos: number, max_suggestions: number
|
|
|
220
223
|
end
|
|
221
224
|
|
|
222
225
|
local query = table.concat(token_text, " ")
|
|
223
|
-
local matches = suggest(query, to_match, max_suggestions)
|
|
226
|
+
local matches, total = suggest(query, to_match, max_suggestions)
|
|
227
|
+
local hidden = total - #matches
|
|
224
228
|
if cmd_name then
|
|
225
229
|
table.insert(matches, 1, cmd_name)
|
|
226
230
|
end
|
|
@@ -255,6 +259,7 @@ local function analyse(text: string, cursor_pos: number, max_suggestions: number
|
|
|
255
259
|
return {
|
|
256
260
|
result = result,
|
|
257
261
|
suggestions = suggestions,
|
|
262
|
+
hidden_suggestions = hidden,
|
|
258
263
|
} :: types.AnalysisResult
|
|
259
264
|
end
|
|
260
265
|
|
|
@@ -276,8 +281,10 @@ local function analyse(text: string, cursor_pos: number, max_suggestions: number
|
|
|
276
281
|
end
|
|
277
282
|
|
|
278
283
|
local final_suggestions = cmd_result.suggestions
|
|
284
|
+
local hidden_suggestions = cmd_result.hidden_suggestions
|
|
279
285
|
if at_arg and arg_result then
|
|
280
286
|
final_suggestions = arg_result.suggestions
|
|
287
|
+
hidden_suggestions = arg_result.hidden_suggestions
|
|
281
288
|
|
|
282
289
|
-- a subcommand shares the position of its parent's first argument, so
|
|
283
290
|
-- both sets are offered there instead of the argument replacing them
|
|
@@ -299,6 +306,7 @@ local function analyse(text: string, cursor_pos: number, max_suggestions: number
|
|
|
299
306
|
if max_suggestions then
|
|
300
307
|
for i = #merged, max_suggestions + 1, -1 do
|
|
301
308
|
merged[i] = nil
|
|
309
|
+
hidden_suggestions = (hidden_suggestions or 0) + 1
|
|
302
310
|
end
|
|
303
311
|
end
|
|
304
312
|
|
|
@@ -312,6 +320,7 @@ local function analyse(text: string, cursor_pos: number, max_suggestions: number
|
|
|
312
320
|
command = cmd_name,
|
|
313
321
|
argument = arg_result and arg_result.argument or nil,
|
|
314
322
|
suggestions = final_suggestions,
|
|
323
|
+
hidden_suggestions = hidden_suggestions,
|
|
315
324
|
}
|
|
316
325
|
end
|
|
317
326
|
|
package/src/analyse/suggest.luau
CHANGED
|
@@ -2,9 +2,13 @@ local leventine = require("./leventine")
|
|
|
2
2
|
|
|
3
3
|
local MIN_SCORE = -math.huge
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
-- returns the best matches, and how many there were before being limited
|
|
6
|
+
local function suggest(input: string, candidates: { string }, max_suggestions: number?): ({ string }, number)
|
|
6
7
|
if #input == 0 then
|
|
7
|
-
|
|
8
|
+
if max_suggestions and #candidates > max_suggestions then
|
|
9
|
+
return { unpack(candidates, 1, max_suggestions) }, #candidates
|
|
10
|
+
end
|
|
11
|
+
return candidates, #candidates
|
|
8
12
|
end
|
|
9
13
|
|
|
10
14
|
local normalized = input:lower()
|
|
@@ -35,7 +39,7 @@ local function suggest(input: string, candidates: { string }, max_suggestions: n
|
|
|
35
39
|
for i = 1, math.min(max_suggestions or #scored, #scored) do
|
|
36
40
|
table.insert(mapped, scored[i].text)
|
|
37
41
|
end
|
|
38
|
-
return mapped
|
|
42
|
+
return mapped, #scored
|
|
39
43
|
end
|
|
40
44
|
|
|
41
45
|
return suggest
|
package/src/app/header.luau
CHANGED
|
@@ -172,7 +172,7 @@ local function header(props: Header)
|
|
|
172
172
|
if input() == Enum.PreferredInput.Gamepad then
|
|
173
173
|
return button_name(Enum.KeyCode.ButtonB)
|
|
174
174
|
end
|
|
175
|
-
return key_label(state.activation_keys()[1])
|
|
175
|
+
return #state.activation_keys() > 0 and key_label(state.activation_keys()[1]) or ""
|
|
176
176
|
end,
|
|
177
177
|
text_size = px(state.subtext_size),
|
|
178
178
|
weight = Enum.FontWeight.Bold,
|
package/src/app/init.luau
CHANGED
|
@@ -219,6 +219,14 @@ local function app()
|
|
|
219
219
|
display_analysis(analysis())
|
|
220
220
|
end)
|
|
221
221
|
|
|
222
|
+
-- the list can shrink while a later suggestion is selected
|
|
223
|
+
effect(function()
|
|
224
|
+
local count = #analysis().suggestions
|
|
225
|
+
if untrack(selected_suggestion) > count then
|
|
226
|
+
selected_suggestion(math.max(count, 1))
|
|
227
|
+
end
|
|
228
|
+
end)
|
|
229
|
+
|
|
222
230
|
cleanup(UserInputService.InputBegan:Connect(function(input)
|
|
223
231
|
if input.UserInputState ~= Enum.UserInputState.Begin then
|
|
224
232
|
return
|
|
@@ -315,9 +323,11 @@ local function app()
|
|
|
315
323
|
end)
|
|
316
324
|
|
|
317
325
|
local function submit(value: string)
|
|
326
|
+
local trimmed = value:gsub("^%s*(.-)%s*$", "%1")
|
|
327
|
+
|
|
318
328
|
-- resolve from the submitted text rather than the analysis, which only
|
|
319
329
|
-- carries arguments when the cursor happens to sit on one
|
|
320
|
-
local submitted = centurion.resolve_command(
|
|
330
|
+
local submitted = centurion.resolve_command(trimmed)
|
|
321
331
|
raw_text("")
|
|
322
332
|
analysis(default_analysis)
|
|
323
333
|
|
|
@@ -334,11 +344,16 @@ local function app()
|
|
|
334
344
|
end
|
|
335
345
|
|
|
336
346
|
cmd_history_index = 0
|
|
337
|
-
|
|
347
|
+
|
|
348
|
+
local history_index = table.find(cmd_history, trimmed)
|
|
349
|
+
if history_index ~= nil then
|
|
350
|
+
table.remove(cmd_history, history_index)
|
|
351
|
+
end
|
|
352
|
+
table.insert(cmd_history, 1, trimmed)
|
|
338
353
|
|
|
339
354
|
local cmd = submitted.name
|
|
340
355
|
if not cmd then
|
|
341
|
-
log(
|
|
356
|
+
log(trimmed, {
|
|
342
357
|
success = false,
|
|
343
358
|
message = "Unknown command",
|
|
344
359
|
timestamp = os.time(),
|
|
@@ -350,12 +365,12 @@ local function app()
|
|
|
350
365
|
executing(executing() + 1)
|
|
351
366
|
|
|
352
367
|
-- pass the submitted text so that ctx.input keeps its original quoting
|
|
353
|
-
local ok, result = pcall(centurion.execute_command, Players.LocalPlayer, cmd, submitted.args,
|
|
368
|
+
local ok, result = pcall(centurion.execute_command, Players.LocalPlayer, cmd, submitted.args, trimmed)
|
|
354
369
|
executing(executing() - 1)
|
|
355
370
|
|
|
356
371
|
if not ok then
|
|
357
|
-
warn(`Failed to execute '{
|
|
358
|
-
log(
|
|
372
|
+
warn(`Failed to execute '{trimmed}': {result}`)
|
|
373
|
+
log(trimmed, {
|
|
359
374
|
success = false,
|
|
360
375
|
message = "Failed to execute command",
|
|
361
376
|
timestamp = os.time(),
|
|
@@ -365,10 +380,10 @@ local function app()
|
|
|
365
380
|
|
|
366
381
|
if result.response then
|
|
367
382
|
if result.response.message ~= "" then
|
|
368
|
-
log(
|
|
383
|
+
log(trimmed, result.response)
|
|
369
384
|
end
|
|
370
385
|
else
|
|
371
|
-
log(
|
|
386
|
+
log(trimmed, {
|
|
372
387
|
success = true,
|
|
373
388
|
message = "Command executed",
|
|
374
389
|
timestamp = os.time(),
|
|
@@ -500,6 +515,10 @@ local function app()
|
|
|
500
515
|
end
|
|
501
516
|
|
|
502
517
|
local selected = analysis_suggestions[selected_suggestion()]
|
|
518
|
+
if selected == nil then
|
|
519
|
+
return ""
|
|
520
|
+
end
|
|
521
|
+
|
|
503
522
|
local suggested = autofill(raw_text(), selected, false)
|
|
504
523
|
if suggested:sub(1, #raw_text()) ~= raw_text() then
|
|
505
524
|
return ""
|
|
@@ -542,7 +561,7 @@ local function app()
|
|
|
542
561
|
|
|
543
562
|
local suggested = analysis().suggestions
|
|
544
563
|
if last_char == "\t" and suggested[1] then
|
|
545
|
-
local selected = suggested[selected_suggestion()]
|
|
564
|
+
local selected = suggested[selected_suggestion()] or suggested[1]
|
|
546
565
|
value = autofill(raw_text(), selected, true)
|
|
547
566
|
end
|
|
548
567
|
|
package/src/app/suggestions.luau
CHANGED
|
@@ -17,12 +17,17 @@ local theme = require("../theme")
|
|
|
17
17
|
local types = require("../types")
|
|
18
18
|
local vide = require("../../vide")
|
|
19
19
|
|
|
20
|
+
local action = vide.action
|
|
21
|
+
local changed = vide.changed
|
|
22
|
+
local cleanup = vide.cleanup
|
|
20
23
|
local create = vide.create
|
|
21
24
|
local derive = vide.derive
|
|
25
|
+
local effect = vide.effect
|
|
22
26
|
local indexes = vide.indexes
|
|
23
27
|
local show = vide.show
|
|
24
28
|
local source = vide.source
|
|
25
29
|
local spring = vide.spring
|
|
30
|
+
local untrack = vide.untrack
|
|
26
31
|
|
|
27
32
|
export type Suggestions = {
|
|
28
33
|
read analysis: () -> types.AnalysisResult,
|
|
@@ -67,12 +72,35 @@ local function pill(props: { text: () -> string, color: () -> Color3, order: num
|
|
|
67
72
|
}
|
|
68
73
|
end
|
|
69
74
|
|
|
70
|
-
local function suggestion_row(
|
|
75
|
+
local function suggestion_row(
|
|
76
|
+
value: () -> types.AnalysisSuggestion,
|
|
77
|
+
i: number,
|
|
78
|
+
props: Suggestions,
|
|
79
|
+
widths: vide.Source<{ [number]: number }>
|
|
80
|
+
)
|
|
71
81
|
local function selected()
|
|
72
82
|
return props.selected_suggestion() == i
|
|
73
83
|
end
|
|
74
84
|
local hovered = source(false)
|
|
75
85
|
|
|
86
|
+
-- the width the row needs without being stretched, so the list can fit the widest
|
|
87
|
+
local name_width = source(0)
|
|
88
|
+
local description_width = source(0)
|
|
89
|
+
|
|
90
|
+
effect(function()
|
|
91
|
+
local width = name_width() + description_width() + px.convert(10)
|
|
92
|
+
if untrack(widths)[i] ~= width then
|
|
93
|
+
local current = table.clone(untrack(widths))
|
|
94
|
+
current[i] = width
|
|
95
|
+
widths(current)
|
|
96
|
+
end
|
|
97
|
+
end)
|
|
98
|
+
cleanup(function()
|
|
99
|
+
local current = table.clone(untrack(widths))
|
|
100
|
+
current[i] = nil
|
|
101
|
+
widths(current)
|
|
102
|
+
end)
|
|
103
|
+
|
|
76
104
|
return create "TextButton" {
|
|
77
105
|
AutomaticSize = Enum.AutomaticSize.XY,
|
|
78
106
|
AutoButtonColor = false,
|
|
@@ -109,6 +137,9 @@ local function suggestion_row(value: () -> types.AnalysisSuggestion, i: number,
|
|
|
109
137
|
order = 1,
|
|
110
138
|
|
|
111
139
|
flex():column():vertical("center"),
|
|
140
|
+
changed("AbsoluteSize", function(size: Vector2)
|
|
141
|
+
name_width(size.X)
|
|
142
|
+
end),
|
|
112
143
|
|
|
113
144
|
-- marks the suggestion Tab will complete
|
|
114
145
|
text {
|
|
@@ -155,6 +186,10 @@ local function suggestion_row(value: () -> types.AnalysisSuggestion, i: number,
|
|
|
155
186
|
show(function()
|
|
156
187
|
return value().description ~= nil
|
|
157
188
|
end, function()
|
|
189
|
+
cleanup(function()
|
|
190
|
+
description_width(0)
|
|
191
|
+
end)
|
|
192
|
+
|
|
158
193
|
return text {
|
|
159
194
|
auto = "XY",
|
|
160
195
|
order = 2,
|
|
@@ -166,6 +201,9 @@ local function suggestion_row(value: () -> types.AnalysisSuggestion, i: number,
|
|
|
166
201
|
xalignment = Enum.TextXAlignment.Right,
|
|
167
202
|
|
|
168
203
|
padding { left = px(28) },
|
|
204
|
+
changed("AbsoluteSize", function(size: Vector2)
|
|
205
|
+
description_width(size.X)
|
|
206
|
+
end),
|
|
169
207
|
}
|
|
170
208
|
end),
|
|
171
209
|
}
|
|
@@ -211,6 +249,9 @@ local function suggestions(props: Suggestions)
|
|
|
211
249
|
return failed() or arg() ~= nil
|
|
212
250
|
end)
|
|
213
251
|
|
|
252
|
+
-- set by the list, which is also at the bottom when it's too short to scroll
|
|
253
|
+
local scrolled_to_bottom = source(true)
|
|
254
|
+
|
|
214
255
|
return background {
|
|
215
256
|
auto = "XY",
|
|
216
257
|
order = props.order,
|
|
@@ -353,17 +394,132 @@ local function suggestions(props: Suggestions)
|
|
|
353
394
|
},
|
|
354
395
|
|
|
355
396
|
show(has_suggestions, function()
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
397
|
+
local content_height = source(0)
|
|
398
|
+
local hovered = source(false)
|
|
399
|
+
local widths = source({} :: { [number]: number })
|
|
400
|
+
|
|
401
|
+
local canvas_y = source(0)
|
|
402
|
+
|
|
403
|
+
-- rows are all the same height, so one is the average of them
|
|
404
|
+
local function row_height()
|
|
405
|
+
return content_height() / math.max(#props.analysis().suggestions, 1)
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
local function visible_height()
|
|
409
|
+
return math.min(content_height(), row_height() * state.visible_suggestions())
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
effect(function()
|
|
413
|
+
scrolled_to_bottom(canvas_y() >= content_height() - visible_height() - 1)
|
|
414
|
+
end)
|
|
415
|
+
|
|
416
|
+
-- only the rows in view decide the width, so a long one further down
|
|
417
|
+
-- doesn't widen the list until it's scrolled to
|
|
418
|
+
local target_width = derive(function()
|
|
419
|
+
local height = row_height()
|
|
420
|
+
if height == 0 then
|
|
421
|
+
return 0
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
local current = widths()
|
|
425
|
+
local first = math.floor(canvas_y() / height) + 1
|
|
426
|
+
local last = math.ceil((canvas_y() + visible_height() - 0.5) / height)
|
|
427
|
+
|
|
428
|
+
local widest = 0
|
|
429
|
+
for i = first, last do
|
|
430
|
+
widest = math.max(widest, current[i] or 0)
|
|
431
|
+
end
|
|
432
|
+
return math.ceil(widest)
|
|
433
|
+
end)
|
|
434
|
+
local sprung_width = spring(target_width, 0.1, 0.8)
|
|
435
|
+
|
|
436
|
+
-- the list grows out from nothing when it first appears
|
|
437
|
+
local opening = source(true)
|
|
438
|
+
effect(function()
|
|
439
|
+
if untrack(opening) and target_width() > 0 and sprung_width() >= target_width() - 0.5 then
|
|
440
|
+
opening(false)
|
|
441
|
+
end
|
|
442
|
+
end)
|
|
443
|
+
|
|
444
|
+
-- after opening, grows instantly so rows are never clipped, and only eases when shrinking
|
|
445
|
+
local function content_width()
|
|
446
|
+
if opening() then
|
|
447
|
+
return sprung_width()
|
|
448
|
+
end
|
|
449
|
+
return math.max(target_width(), sprung_width())
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
return create "ScrollingFrame" {
|
|
453
|
+
AutomaticCanvasSize = Enum.AutomaticSize.Y,
|
|
454
|
+
BackgroundTransparency = 1,
|
|
455
|
+
BorderSizePixel = 0,
|
|
456
|
+
CanvasSize = UDim2.new(),
|
|
457
|
+
ScrollingDirection = Enum.ScrollingDirection.Y,
|
|
458
|
+
LayoutOrder = 4,
|
|
459
|
+
Size = function()
|
|
460
|
+
return UDim2.fromOffset(content_width() + px.convert(6), visible_height() + px.convert(6))
|
|
461
|
+
end,
|
|
462
|
+
|
|
463
|
+
-- the bar sits in the right padding rather than insetting the rows
|
|
464
|
+
ScrollBarThickness = px(3),
|
|
465
|
+
ScrollBarImageColor3 = function()
|
|
466
|
+
return state.theme().subtext
|
|
467
|
+
end,
|
|
468
|
+
ScrollBarImageTransparency = fade.fade(spring(function()
|
|
469
|
+
return if hovered() then 0 else 0.6
|
|
470
|
+
end, 0.2)),
|
|
471
|
+
VerticalScrollBarInset = Enum.ScrollBarInset.None,
|
|
472
|
+
|
|
473
|
+
MouseEnter = function()
|
|
474
|
+
hovered(true)
|
|
475
|
+
end,
|
|
476
|
+
MouseLeave = function()
|
|
477
|
+
hovered(false)
|
|
478
|
+
end,
|
|
479
|
+
|
|
480
|
+
changed("CanvasPosition", function(position: Vector2)
|
|
481
|
+
canvas_y(position.Y)
|
|
482
|
+
end),
|
|
359
483
|
|
|
360
484
|
padding(px(3)),
|
|
361
|
-
|
|
485
|
+
|
|
486
|
+
create "UIListLayout" {
|
|
487
|
+
HorizontalFlex = Enum.UIFlexAlignment.Fill,
|
|
488
|
+
SortOrder = Enum.SortOrder.LayoutOrder,
|
|
489
|
+
|
|
490
|
+
changed("AbsoluteContentSize", function(size: Vector2)
|
|
491
|
+
content_height(size.Y)
|
|
492
|
+
end),
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
-- keep the selected row in view when moving through the list
|
|
496
|
+
action(function(instance: ScrollingFrame)
|
|
497
|
+
effect(function()
|
|
498
|
+
local height = row_height()
|
|
499
|
+
if height == 0 then
|
|
500
|
+
return
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
-- AbsoluteWindowSize lags behind and is 0 when the list first appears,
|
|
504
|
+
-- which would scroll the first row out of view
|
|
505
|
+
local top = (props.selected_suggestion() - 1) * height
|
|
506
|
+
local window = visible_height()
|
|
507
|
+
local y = instance.CanvasPosition.Y
|
|
508
|
+
|
|
509
|
+
if top < y then
|
|
510
|
+
y = top
|
|
511
|
+
elseif top + height > y + window then
|
|
512
|
+
y = top + height - window
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
instance.CanvasPosition = Vector2.new(0, y)
|
|
516
|
+
end)
|
|
517
|
+
end),
|
|
362
518
|
|
|
363
519
|
indexes(function()
|
|
364
520
|
return props.analysis().suggestions
|
|
365
521
|
end, function(value: () -> types.AnalysisSuggestion, i)
|
|
366
|
-
return suggestion_row(value, i, props)
|
|
522
|
+
return suggestion_row(value, i, props, widths)
|
|
367
523
|
end),
|
|
368
524
|
}
|
|
369
525
|
end),
|
|
@@ -379,9 +535,11 @@ local function suggestions(props: Suggestions)
|
|
|
379
535
|
order = 6,
|
|
380
536
|
|
|
381
537
|
padding { x = px(8), y = px(4) },
|
|
538
|
+
flex():column():vertical("center"):between("horizontal"),
|
|
382
539
|
|
|
383
540
|
text {
|
|
384
541
|
auto = "XY",
|
|
542
|
+
order = 1,
|
|
385
543
|
text = function()
|
|
386
544
|
local key = rich.color("%s", state.theme().text)
|
|
387
545
|
if input() == Enum.PreferredInput.Touch then
|
|
@@ -408,6 +566,29 @@ local function suggestions(props: Suggestions)
|
|
|
408
566
|
text_style = "subtext",
|
|
409
567
|
xalignment = Enum.TextXAlignment.Left,
|
|
410
568
|
},
|
|
569
|
+
|
|
570
|
+
-- matches past the limit can't be scrolled to, so typing more is the only way to reach them.
|
|
571
|
+
-- only shown at the end of the list, where they would have been
|
|
572
|
+
show(function()
|
|
573
|
+
return (props.analysis().hidden_suggestions or 0) > 0
|
|
574
|
+
end, function()
|
|
575
|
+
return text {
|
|
576
|
+
auto = "XY",
|
|
577
|
+
order = 2,
|
|
578
|
+
text = function()
|
|
579
|
+
return `+{props.analysis().hidden_suggestions} more`
|
|
580
|
+
end,
|
|
581
|
+
text_size = px(state.subtext_size),
|
|
582
|
+
text_style = "subtext",
|
|
583
|
+
xalignment = Enum.TextXAlignment.Right,
|
|
584
|
+
-- faded rather than removed, so the footer doesn't change width while scrolling
|
|
585
|
+
transparency = spring(function()
|
|
586
|
+
return if scrolled_to_bottom() then 0 else 1
|
|
587
|
+
end, 0.1),
|
|
588
|
+
|
|
589
|
+
padding { left = px(16) },
|
|
590
|
+
}
|
|
591
|
+
end),
|
|
411
592
|
}
|
|
412
593
|
end),
|
|
413
594
|
|
package/src/init.luau
CHANGED
|
@@ -24,6 +24,7 @@ local function mount(keys: { Enum.KeyCode }?)
|
|
|
24
24
|
Name = "Centurion",
|
|
25
25
|
ResetOnSpawn = false,
|
|
26
26
|
ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
|
|
27
|
+
DisplayOrder = state.display_order,
|
|
27
28
|
|
|
28
29
|
app(),
|
|
29
30
|
}
|
|
@@ -51,7 +52,9 @@ local function configure(options: types.OptionsPartial)
|
|
|
51
52
|
set_opt(state.anchor, options.anchor)
|
|
52
53
|
set_opt(state.position, options.position)
|
|
53
54
|
set_opt(state.width, options.width)
|
|
55
|
+
set_opt(state.display_order, options.display_order)
|
|
54
56
|
|
|
57
|
+
set_opt(state.visible_suggestions, options.visible_suggestions)
|
|
55
58
|
set_opt(state.max_suggestions, options.max_suggestions)
|
|
56
59
|
set_opt(state.clear_button, options.clear_button)
|
|
57
60
|
set_opt(state.format_date, options.format_date)
|
package/src/state.luau
CHANGED
|
@@ -22,7 +22,8 @@ return {
|
|
|
22
22
|
local dateParts = dateTime:split(" ")
|
|
23
23
|
return `<b>{dateParts[1]}</b> {dateParts[2]}`
|
|
24
24
|
end),
|
|
25
|
-
|
|
25
|
+
visible_suggestions = source(5),
|
|
26
|
+
max_suggestions = source(50),
|
|
26
27
|
clear_button = source(false),
|
|
27
28
|
|
|
28
29
|
text_size = source(19),
|
|
@@ -31,4 +32,5 @@ return {
|
|
|
31
32
|
anchor = source(Vector2.new(0.5, 0)),
|
|
32
33
|
position = source(UDim2.new(0.5, 0, 0, 0)),
|
|
33
34
|
width = source(UDim.new(0, 1200)),
|
|
35
|
+
display_order = source(1000),
|
|
34
36
|
}
|
package/src/ts/index.d.ts
CHANGED
package/src/types.luau
CHANGED
|
@@ -13,6 +13,7 @@ export type Options = {
|
|
|
13
13
|
icon: string,
|
|
14
14
|
transparency: number,
|
|
15
15
|
format_date: (log: Log) -> string,
|
|
16
|
+
visible_suggestions: number,
|
|
16
17
|
max_suggestions: number,
|
|
17
18
|
clear_button: boolean,
|
|
18
19
|
|
|
@@ -22,6 +23,7 @@ export type Options = {
|
|
|
22
23
|
anchor: Vector2,
|
|
23
24
|
width: UDim,
|
|
24
25
|
position: UDim2,
|
|
26
|
+
display_order: number,
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export type OptionsPartial = {
|
|
@@ -32,6 +34,7 @@ export type OptionsPartial = {
|
|
|
32
34
|
icon: string?,
|
|
33
35
|
transparency: number?,
|
|
34
36
|
format_date: ((log: Log) -> string)?,
|
|
37
|
+
visible_suggestions: number?,
|
|
35
38
|
max_suggestions: number?,
|
|
36
39
|
clear_button: boolean?,
|
|
37
40
|
|
|
@@ -41,6 +44,7 @@ export type OptionsPartial = {
|
|
|
41
44
|
anchor: Vector2?,
|
|
42
45
|
width: UDim?,
|
|
43
46
|
position: UDim2?,
|
|
47
|
+
display_order: number?,
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export type Theme = {
|
|
@@ -75,6 +79,8 @@ export type AnalysisResult = {
|
|
|
75
79
|
command: string?,
|
|
76
80
|
argument: AnalysisArgument?,
|
|
77
81
|
suggestions: { AnalysisSuggestion },
|
|
82
|
+
-- matches left out by the suggestion limit
|
|
83
|
+
hidden_suggestions: number?,
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
export type Log = {
|