@rbxts/centurion-ui 1.0.8 → 2.0.0-rc.1
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 +60 -15
- package/centurion.luau +10 -0
- package/package.json +13 -23
- package/src/analyse/cursor.luau +25 -0
- package/src/analyse/highlight.luau +91 -0
- package/src/analyse/init.luau +318 -0
- package/src/analyse/leventine.luau +298 -0
- package/src/analyse/match.luau +39 -0
- package/src/analyse/suggest.luau +41 -0
- package/src/app/header.luau +128 -0
- package/src/app/history.luau +258 -0
- package/src/app/init.luau +699 -0
- package/src/app/suggestions.luau +419 -0
- package/src/button.luau +13 -0
- package/src/components/background.luau +37 -0
- package/src/components/container.luau +33 -0
- package/src/components/corner.luau +11 -0
- package/src/components/divider.luau +28 -0
- package/src/components/flex.luau +108 -0
- package/src/components/gap.luau +25 -0
- package/src/components/image.luau +33 -0
- package/src/components/padding.luau +59 -0
- package/src/components/stroke.luau +20 -0
- package/src/components/text.luau +57 -0
- package/src/components/textbox.luau +186 -0
- package/src/fade.luau +23 -0
- package/src/init.luau +142 -0
- package/src/input.luau +16 -0
- package/src/px.luau +68 -0
- package/src/rich.luau +14 -0
- package/src/state.luau +33 -0
- package/src/theme.luau +70 -0
- package/src/ts/index.d.ts +60 -0
- package/src/ts/init.luau +5 -0
- package/src/types.luau +85 -0
- package/vide/init.luau +8 -0
- package/vide/src/action.luau +25 -0
- package/vide/src/apply.luau +162 -0
- package/vide/src/batch.luau +23 -0
- package/vide/src/branch.luau +40 -0
- package/vide/src/changed.luau +18 -0
- package/vide/src/cleanup.luau +43 -0
- package/vide/src/context.luau +74 -0
- package/vide/src/create.luau +107 -0
- package/vide/src/defaults.luau +113 -0
- package/vide/src/derive.luau +18 -0
- package/vide/src/effect.luau +12 -0
- package/vide/src/flags.luau +12 -0
- package/vide/src/graph.luau +321 -0
- package/vide/src/implicit_effect.luau +125 -0
- package/vide/src/indexes.luau +121 -0
- package/vide/src/init.luau +10 -0
- package/vide/src/lib.luau +120 -0
- package/vide/src/mount.luau +11 -0
- package/vide/src/read.luau +5 -0
- package/vide/src/root.luau +35 -0
- package/vide/src/show.luau +36 -0
- package/vide/src/source.luau +31 -0
- package/vide/src/spring.luau +328 -0
- package/vide/src/switch.luau +114 -0
- package/vide/src/timeout.luau +27 -0
- package/vide/src/untrack.luau +25 -0
- package/vide/src/values.luau +131 -0
- package/out/app/centurion-app.d.ts +0 -3
- package/out/app/centurion-app.luau +0 -86
- package/out/app/index.d.ts +0 -32
- package/out/app/init.luau +0 -105
- package/out/components/history/history-line.d.ts +0 -9
- package/out/components/history/history-line.luau +0 -88
- package/out/components/history/history-list.d.ts +0 -11
- package/out/components/history/history-list.luau +0 -67
- package/out/components/history/index.d.ts +0 -1
- package/out/components/history/init.luau +0 -7
- package/out/components/index.d.ts +0 -2
- package/out/components/init.luau +0 -10
- package/out/components/suggestions/badge.d.ts +0 -16
- package/out/components/suggestions/badge.luau +0 -40
- package/out/components/suggestions/index.d.ts +0 -1
- package/out/components/suggestions/init.luau +0 -7
- package/out/components/suggestions/main-suggestion.d.ts +0 -9
- package/out/components/suggestions/main-suggestion.luau +0 -232
- package/out/components/suggestions/suggestion-list.d.ts +0 -8
- package/out/components/suggestions/suggestion-list.luau +0 -96
- package/out/components/suggestions/suggestions.d.ts +0 -2
- package/out/components/suggestions/suggestions.luau +0 -64
- package/out/components/suggestions/types.d.ts +0 -6
- package/out/components/suggestions/types.luau +0 -2
- package/out/components/suggestions/util.d.ts +0 -1
- package/out/components/suggestions/util.luau +0 -22
- package/out/components/terminal/command.d.ts +0 -6
- package/out/components/terminal/command.luau +0 -74
- package/out/components/terminal/index.d.ts +0 -1
- package/out/components/terminal/init.luau +0 -7
- package/out/components/terminal/suggestion.d.ts +0 -26
- package/out/components/terminal/suggestion.luau +0 -205
- package/out/components/terminal/terminal-text-field/index.d.ts +0 -1
- package/out/components/terminal/terminal-text-field/init.luau +0 -7
- package/out/components/terminal/terminal-text-field/suggestion.d.ts +0 -5
- package/out/components/terminal/terminal-text-field/suggestion.luau +0 -124
- package/out/components/terminal/terminal-text-field/terminal-text-field.d.ts +0 -13
- package/out/components/terminal/terminal-text-field/terminal-text-field.luau +0 -278
- package/out/components/terminal/terminal.d.ts +0 -2
- package/out/components/terminal/terminal.luau +0 -304
- package/out/components/ui/frame.d.ts +0 -17
- package/out/components/ui/frame.luau +0 -32
- package/out/components/ui/group.d.ts +0 -15
- package/out/components/ui/group.luau +0 -29
- package/out/components/ui/layer.d.ts +0 -8
- package/out/components/ui/layer.luau +0 -26
- package/out/components/ui/outline.d.ts +0 -15
- package/out/components/ui/outline.luau +0 -116
- package/out/components/ui/padding.d.ts +0 -10
- package/out/components/ui/padding.luau +0 -19
- package/out/components/ui/scrolling-frame.d.ts +0 -14
- package/out/components/ui/scrolling-frame.luau +0 -44
- package/out/components/ui/text-field.d.ts +0 -12
- package/out/components/ui/text-field.luau +0 -60
- package/out/components/ui/text.d.ts +0 -17
- package/out/components/ui/text.luau +0 -61
- package/out/constants/options.d.ts +0 -2
- package/out/constants/options.luau +0 -27
- package/out/constants/text.d.ts +0 -3
- package/out/constants/text.luau +0 -9
- package/out/constants/util.d.ts +0 -1
- package/out/constants/util.luau +0 -7
- package/out/hooks/use-client.d.ts +0 -2
- package/out/hooks/use-client.luau +0 -17
- package/out/hooks/use-event.d.ts +0 -14
- package/out/hooks/use-event.luau +0 -58
- package/out/hooks/use-px.d.ts +0 -19
- package/out/hooks/use-px.luau +0 -78
- package/out/index.d.ts +0 -2
- package/out/init.luau +0 -10
- package/out/palette.d.ts +0 -47
- package/out/palette.luau +0 -42
- package/out/store.d.ts +0 -12
- package/out/store.luau +0 -26
- package/out/types.d.ts +0 -44
- package/out/types.luau +0 -2
- package/out/utils/string.d.ts +0 -5
- package/out/utils/string.luau +0 -25
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local _centurion = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out)
|
|
4
|
-
local ImmutableRegistryPath = _centurion.ImmutableRegistryPath
|
|
5
|
-
local RegistryPath = _centurion.RegistryPath
|
|
6
|
-
local IS_EDIT = TS.import(script, script.Parent.Parent.Parent, "constants", "util").IS_EDIT
|
|
7
|
-
local function formatPartsAsPath(parts)
|
|
8
|
-
return string.lower(table.concat(parts, "/"))
|
|
9
|
-
end
|
|
10
|
-
local function getValidPath(registry, text)
|
|
11
|
-
if #text == 0 then
|
|
12
|
-
return nil
|
|
13
|
-
end
|
|
14
|
-
local textPath = formatPartsAsPath(text)
|
|
15
|
-
if registry:getCommandByString(textPath) ~= nil or registry:getGroupByString(textPath) ~= nil then
|
|
16
|
-
return ImmutableRegistryPath:fromString(textPath)
|
|
17
|
-
end
|
|
18
|
-
local path = RegistryPath:empty()
|
|
19
|
-
for _, part in text do
|
|
20
|
-
path:append(string.lower(part))
|
|
21
|
-
if registry:getCommand(path) == nil and registry:getGroup(path) == nil and #registry:getChildPaths(path) == 0 then
|
|
22
|
-
path:remove(path:size() - 1)
|
|
23
|
-
break
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
if registry:getCommand(path) ~= nil or registry:getGroup(path) ~= nil then
|
|
27
|
-
return ImmutableRegistryPath:fromPath(path)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
local function getArgumentNames(registry, path)
|
|
31
|
-
if IS_EDIT then
|
|
32
|
-
return {}
|
|
33
|
-
end
|
|
34
|
-
local command = registry:getCommand(path)
|
|
35
|
-
if command == nil or command.options.arguments == nil then
|
|
36
|
-
return {}
|
|
37
|
-
end
|
|
38
|
-
local _exp = command.options.arguments
|
|
39
|
-
-- ▼ ReadonlyArray.map ▼
|
|
40
|
-
local _newValue = table.create(#_exp)
|
|
41
|
-
local _callback = function(arg)
|
|
42
|
-
return arg.name
|
|
43
|
-
end
|
|
44
|
-
for _k, _v in _exp do
|
|
45
|
-
_newValue[_k] = _callback(_v, _k - 1, _exp)
|
|
46
|
-
end
|
|
47
|
-
-- ▲ ReadonlyArray.map ▲
|
|
48
|
-
return _newValue
|
|
49
|
-
end
|
|
50
|
-
local function getMissingArgs(command, text)
|
|
51
|
-
if command.options.arguments == nil or #command.options.arguments == 0 then
|
|
52
|
-
return {}
|
|
53
|
-
end
|
|
54
|
-
local lastPartIndex = #text - command:getPath():size() - 1
|
|
55
|
-
local missingArgs = {}
|
|
56
|
-
local index = 0
|
|
57
|
-
for _, arg in command.options.arguments do
|
|
58
|
-
if arg.optional then
|
|
59
|
-
break
|
|
60
|
-
end
|
|
61
|
-
if index > lastPartIndex then
|
|
62
|
-
local _name = arg.name
|
|
63
|
-
table.insert(missingArgs, _name)
|
|
64
|
-
end
|
|
65
|
-
index += 1
|
|
66
|
-
end
|
|
67
|
-
return missingArgs
|
|
68
|
-
end
|
|
69
|
-
return {
|
|
70
|
-
formatPartsAsPath = formatPartsAsPath,
|
|
71
|
-
getValidPath = getValidPath,
|
|
72
|
-
getArgumentNames = getArgumentNames,
|
|
73
|
-
getMissingArgs = getMissingArgs,
|
|
74
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./terminal";
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ArgumentOptions, BaseRegistry, ListArgumentType, RegistryPath, SingleArgumentType } from "@rbxts/centurion";
|
|
2
|
-
import { ReadonlyDeep } from "@rbxts/centurion/out/shared/util/data";
|
|
3
|
-
import { CommandSuggestion } from "../../types";
|
|
4
|
-
export interface SingleArgument {
|
|
5
|
-
kind: "single";
|
|
6
|
-
options: ReadonlyDeep<ArgumentOptions>;
|
|
7
|
-
type: SingleArgumentType<unknown>;
|
|
8
|
-
input?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ListArgument {
|
|
11
|
-
kind: "list";
|
|
12
|
-
options: ReadonlyDeep<ArgumentOptions>;
|
|
13
|
-
type: ListArgumentType<unknown>;
|
|
14
|
-
input?: string[];
|
|
15
|
-
}
|
|
16
|
-
export type Argument = SingleArgument | ListArgument;
|
|
17
|
-
export declare function getArgumentSuggestion(arg: Argument, textPart?: string): {
|
|
18
|
-
type: "argument";
|
|
19
|
-
title: string;
|
|
20
|
-
others: string[];
|
|
21
|
-
description: string;
|
|
22
|
-
dataType: string;
|
|
23
|
-
optional: boolean;
|
|
24
|
-
error: string | undefined;
|
|
25
|
-
};
|
|
26
|
-
export declare function getCommandSuggestion(registry: BaseRegistry, parentPath?: RegistryPath, text?: string): CommandSuggestion | undefined;
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local Players = TS.import(script, TS.getModule(script, "@rbxts", "services")).Players
|
|
4
|
-
local _string = TS.import(script, script.Parent.Parent.Parent, "utils", "string")
|
|
5
|
-
local containsSpace = _string.containsSpace
|
|
6
|
-
local getQuoteChar = _string.getQuoteChar
|
|
7
|
-
local function getMatches(strings, text)
|
|
8
|
-
if text == nil then
|
|
9
|
-
table.sort(strings)
|
|
10
|
-
-- ▼ ReadonlyArray.map ▼
|
|
11
|
-
local _newValue = table.create(#strings)
|
|
12
|
-
local _callback = function(str, i)
|
|
13
|
-
local formatted = if containsSpace(str) then `"{str}"` else str
|
|
14
|
-
return { i, formatted, #formatted }
|
|
15
|
-
end
|
|
16
|
-
for _k, _v in strings do
|
|
17
|
-
_newValue[_k] = _callback(_v, _k - 1, strings)
|
|
18
|
-
end
|
|
19
|
-
-- ▲ ReadonlyArray.map ▲
|
|
20
|
-
return _newValue
|
|
21
|
-
end
|
|
22
|
-
local textLower = string.lower(text)
|
|
23
|
-
local textEndIndex = #text
|
|
24
|
-
local quoteChar = getQuoteChar(text)
|
|
25
|
-
local quoted = quoteChar ~= nil
|
|
26
|
-
local results = {}
|
|
27
|
-
for i = 0, #strings - 1 do
|
|
28
|
-
local str = strings[i + 1]
|
|
29
|
-
if quoted then
|
|
30
|
-
str = `{quoteChar}{str}{quoteChar}`
|
|
31
|
-
elseif containsSpace(str) then
|
|
32
|
-
str = `"{str}"`
|
|
33
|
-
end
|
|
34
|
-
local part = string.sub(string.lower(str), 0, textEndIndex)
|
|
35
|
-
if part == textLower then
|
|
36
|
-
local _arg0 = { i, str, #str }
|
|
37
|
-
table.insert(results, _arg0)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
table.sort(results, function(a, b)
|
|
41
|
-
return a[2] < b[2]
|
|
42
|
-
end)
|
|
43
|
-
return results
|
|
44
|
-
end
|
|
45
|
-
local function getArgumentSuggestion(arg, textPart)
|
|
46
|
-
local _result
|
|
47
|
-
if arg.options.suggestions ~= nil then
|
|
48
|
-
local _array = {}
|
|
49
|
-
local _length = #_array
|
|
50
|
-
local _array_1 = arg.options.suggestions
|
|
51
|
-
table.move(_array_1, 1, #_array_1, _length + 1, _array)
|
|
52
|
-
_result = _array
|
|
53
|
-
else
|
|
54
|
-
_result = {}
|
|
55
|
-
end
|
|
56
|
-
local suggestions = _result
|
|
57
|
-
local singleArg = arg.kind == "single"
|
|
58
|
-
local _result_1
|
|
59
|
-
if singleArg then
|
|
60
|
-
local _result_2 = arg.type.suggestions
|
|
61
|
-
if _result_2 ~= nil then
|
|
62
|
-
local _condition = arg.input
|
|
63
|
-
if _condition == nil then
|
|
64
|
-
_condition = ""
|
|
65
|
-
end
|
|
66
|
-
_result_2 = _result_2(_condition, Players.LocalPlayer)
|
|
67
|
-
end
|
|
68
|
-
_result_1 = _result_2
|
|
69
|
-
else
|
|
70
|
-
local _result_2 = arg.type.suggestions
|
|
71
|
-
if _result_2 ~= nil then
|
|
72
|
-
_result_2 = _result_2(arg.input or {}, Players.LocalPlayer)
|
|
73
|
-
end
|
|
74
|
-
_result_1 = _result_2
|
|
75
|
-
end
|
|
76
|
-
local typeSuggestions = _result_1
|
|
77
|
-
if typeSuggestions ~= nil then
|
|
78
|
-
for _, text in typeSuggestions do
|
|
79
|
-
table.insert(suggestions, text)
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
local errorText
|
|
83
|
-
local input = arg.input
|
|
84
|
-
if not arg.type.expensive and input ~= nil then
|
|
85
|
-
local success, err = pcall(function()
|
|
86
|
-
local transformResult = if singleArg then arg.type.transform(input, Players.LocalPlayer) else arg.type.transform(input, Players.LocalPlayer)
|
|
87
|
-
if transformResult.ok then
|
|
88
|
-
return nil
|
|
89
|
-
end
|
|
90
|
-
errorText = transformResult.value
|
|
91
|
-
end)
|
|
92
|
-
if not success then
|
|
93
|
-
errorText = "Failed to transform argument"
|
|
94
|
-
warn(err)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
local _object = {
|
|
98
|
-
type = "argument",
|
|
99
|
-
title = arg.options.name,
|
|
100
|
-
}
|
|
101
|
-
local _left = "others"
|
|
102
|
-
local _exp = getMatches(suggestions, textPart)
|
|
103
|
-
-- ▼ ReadonlyArray.map ▼
|
|
104
|
-
local _newValue = table.create(#_exp)
|
|
105
|
-
local _callback = function(_param)
|
|
106
|
-
local str = _param[2]
|
|
107
|
-
return str
|
|
108
|
-
end
|
|
109
|
-
for _k, _v in _exp do
|
|
110
|
-
_newValue[_k] = _callback(_v, _k - 1, _exp)
|
|
111
|
-
end
|
|
112
|
-
-- ▲ ReadonlyArray.map ▲
|
|
113
|
-
_object[_left] = _newValue
|
|
114
|
-
_object.description = arg.options.description
|
|
115
|
-
_object.dataType = arg.type.name
|
|
116
|
-
local _left_1 = "optional"
|
|
117
|
-
local _condition = arg.options.optional
|
|
118
|
-
if _condition == nil then
|
|
119
|
-
_condition = false
|
|
120
|
-
end
|
|
121
|
-
_object[_left_1] = _condition
|
|
122
|
-
_object.error = errorText
|
|
123
|
-
return _object
|
|
124
|
-
end
|
|
125
|
-
local getCommandName
|
|
126
|
-
local function getCommandSuggestion(registry, parentPath, text)
|
|
127
|
-
local paths = if parentPath ~= nil then registry:getChildPaths(parentPath) else registry:getRootPaths()
|
|
128
|
-
if #paths == 0 then
|
|
129
|
-
return nil
|
|
130
|
-
end
|
|
131
|
-
-- ▼ ReadonlyArray.map ▼
|
|
132
|
-
local _newValue = table.create(#paths)
|
|
133
|
-
local _callback = function(path)
|
|
134
|
-
return path:tail()
|
|
135
|
-
end
|
|
136
|
-
for _k, _v in paths do
|
|
137
|
-
_newValue[_k] = _callback(_v, _k - 1, paths)
|
|
138
|
-
end
|
|
139
|
-
-- ▲ ReadonlyArray.map ▲
|
|
140
|
-
local pathNames = _newValue
|
|
141
|
-
local sortedPaths = getMatches(pathNames, text)
|
|
142
|
-
local firstMatch = table.remove(sortedPaths, 1)
|
|
143
|
-
if firstMatch == nil then
|
|
144
|
-
return nil
|
|
145
|
-
end
|
|
146
|
-
local firstPath = paths[firstMatch[1] + 1]
|
|
147
|
-
local command = registry:getCommand(firstPath)
|
|
148
|
-
if command ~= nil then
|
|
149
|
-
local _object = {
|
|
150
|
-
type = "command",
|
|
151
|
-
title = getCommandName(command.options, firstPath:tail()),
|
|
152
|
-
description = command.options.description,
|
|
153
|
-
}
|
|
154
|
-
local _left = "others"
|
|
155
|
-
-- ▼ ReadonlyArray.map ▼
|
|
156
|
-
local _newValue_1 = table.create(#sortedPaths)
|
|
157
|
-
local _callback_1 = function(_param)
|
|
158
|
-
local str = _param[2]
|
|
159
|
-
return str
|
|
160
|
-
end
|
|
161
|
-
for _k, _v in sortedPaths do
|
|
162
|
-
_newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths)
|
|
163
|
-
end
|
|
164
|
-
-- ▲ ReadonlyArray.map ▲
|
|
165
|
-
_object[_left] = _newValue_1
|
|
166
|
-
_object.shortcuts = (command.options).shortcuts
|
|
167
|
-
return _object
|
|
168
|
-
end
|
|
169
|
-
local group = registry:getGroup(firstPath)
|
|
170
|
-
if group ~= nil then
|
|
171
|
-
local _object = {
|
|
172
|
-
type = "command",
|
|
173
|
-
title = group.options.name,
|
|
174
|
-
description = group.options.description,
|
|
175
|
-
}
|
|
176
|
-
local _left = "others"
|
|
177
|
-
-- ▼ ReadonlyArray.map ▼
|
|
178
|
-
local _newValue_1 = table.create(#sortedPaths)
|
|
179
|
-
local _callback_1 = function(_param)
|
|
180
|
-
local str = _param[2]
|
|
181
|
-
return str
|
|
182
|
-
end
|
|
183
|
-
for _k, _v in sortedPaths do
|
|
184
|
-
_newValue_1[_k] = _callback_1(_v, _k - 1, sortedPaths)
|
|
185
|
-
end
|
|
186
|
-
-- ▲ ReadonlyArray.map ▲
|
|
187
|
-
_object[_left] = _newValue_1
|
|
188
|
-
return _object
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
function getCommandName(options, input)
|
|
192
|
-
if input == string.lower(options.name) then
|
|
193
|
-
return options.name
|
|
194
|
-
end
|
|
195
|
-
for _, alias in options.aliases or {} do
|
|
196
|
-
if input == string.lower(alias) then
|
|
197
|
-
return alias
|
|
198
|
-
end
|
|
199
|
-
end
|
|
200
|
-
return input
|
|
201
|
-
end
|
|
202
|
-
return {
|
|
203
|
-
getArgumentSuggestion = getArgumentSuggestion,
|
|
204
|
-
getCommandSuggestion = getCommandSuggestion,
|
|
205
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./terminal-text-field";
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseRegistry } from "@rbxts/centurion";
|
|
2
|
-
import { Suggestion } from "../../../types";
|
|
3
|
-
export declare function completeCommand(registry: BaseRegistry, text: string, textParts: string[], suggestion: string): string;
|
|
4
|
-
export declare function completeArgument(text: string, suggestion: string, commandArgCount: number): string;
|
|
5
|
-
export declare function getSuggestedText(registry: BaseRegistry, text: string, textParts: string[], atNextPart: boolean, suggestion?: Suggestion): string;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local _store = TS.import(script, script.Parent.Parent.Parent.Parent, "store")
|
|
4
|
-
local commandArgIndex = _store.commandArgIndex
|
|
5
|
-
local currentCommandPath = _store.currentCommandPath
|
|
6
|
-
local currentTextPart = _store.currentTextPart
|
|
7
|
-
local terminalArgIndex = _store.terminalArgIndex
|
|
8
|
-
local _command = TS.import(script, script.Parent.Parent, "command")
|
|
9
|
-
local formatPartsAsPath = _command.formatPartsAsPath
|
|
10
|
-
local getArgumentNames = _command.getArgumentNames
|
|
11
|
-
local function replaceTextPart(text, ...)
|
|
12
|
-
local suggestions = { ... }
|
|
13
|
-
local currentPart = currentTextPart()
|
|
14
|
-
local _result = currentPart
|
|
15
|
-
if _result ~= nil then
|
|
16
|
-
_result = #_result
|
|
17
|
-
end
|
|
18
|
-
local _condition = _result
|
|
19
|
-
if _condition == nil then
|
|
20
|
-
_condition = 0
|
|
21
|
-
end
|
|
22
|
-
local currentPartSize = _condition
|
|
23
|
-
local _text = text
|
|
24
|
-
local _arg1 = #text - currentPartSize
|
|
25
|
-
local result = string.sub(_text, 0, _arg1)
|
|
26
|
-
result ..= table.concat(suggestions, " ")
|
|
27
|
-
return result
|
|
28
|
-
end
|
|
29
|
-
local function completeCommand(registry, text, textParts, suggestion)
|
|
30
|
-
local atNextPart = string.sub(text, -1) == " "
|
|
31
|
-
local _array = {}
|
|
32
|
-
local _length = #_array
|
|
33
|
-
table.move(textParts, 1, #textParts, _length + 1, _array)
|
|
34
|
-
local pathParts = _array
|
|
35
|
-
if not atNextPart then
|
|
36
|
-
local _arg0 = #textParts - 1
|
|
37
|
-
table.remove(pathParts, _arg0 + 1)
|
|
38
|
-
end
|
|
39
|
-
local _suggestion = suggestion
|
|
40
|
-
table.insert(pathParts, _suggestion)
|
|
41
|
-
local _command_1 = registry:getCommandByString(formatPartsAsPath(pathParts))
|
|
42
|
-
if _command_1 ~= nil then
|
|
43
|
-
_command_1 = _command_1.options
|
|
44
|
-
end
|
|
45
|
-
local command = _command_1
|
|
46
|
-
local result = replaceTextPart(text, suggestion)
|
|
47
|
-
-- Add a space if this path isn't a command (meaning it's a group) or is a command with arguments
|
|
48
|
-
local _condition = command == nil
|
|
49
|
-
if not _condition then
|
|
50
|
-
local _result = command.arguments
|
|
51
|
-
if _result ~= nil then
|
|
52
|
-
_result = #_result == 0
|
|
53
|
-
end
|
|
54
|
-
local _condition_1 = _result
|
|
55
|
-
if _condition_1 == nil then
|
|
56
|
-
_condition_1 = true
|
|
57
|
-
end
|
|
58
|
-
_condition = not _condition_1
|
|
59
|
-
end
|
|
60
|
-
if _condition then
|
|
61
|
-
result ..= " "
|
|
62
|
-
end
|
|
63
|
-
return result
|
|
64
|
-
end
|
|
65
|
-
local function completeArgument(text, suggestion, commandArgCount)
|
|
66
|
-
local argIndex = terminalArgIndex()
|
|
67
|
-
if argIndex == nil or commandArgCount == 0 then
|
|
68
|
-
return text
|
|
69
|
-
end
|
|
70
|
-
local result = replaceTextPart(text, suggestion)
|
|
71
|
-
if argIndex < commandArgCount - 1 then
|
|
72
|
-
result ..= " "
|
|
73
|
-
end
|
|
74
|
-
return result
|
|
75
|
-
end
|
|
76
|
-
local function getSuggestedText(registry, text, textParts, atNextPart, suggestion)
|
|
77
|
-
if suggestion == nil then
|
|
78
|
-
return ""
|
|
79
|
-
end
|
|
80
|
-
local suggestionText
|
|
81
|
-
if #textParts == 0 or suggestion.type == "command" then
|
|
82
|
-
suggestionText = suggestion.title
|
|
83
|
-
else
|
|
84
|
-
local command = currentCommandPath()
|
|
85
|
-
local argIndex = terminalArgIndex()
|
|
86
|
-
if command == nil or argIndex == nil then
|
|
87
|
-
return ""
|
|
88
|
-
end
|
|
89
|
-
if atNextPart and argIndex == commandArgIndex() then
|
|
90
|
-
suggestionText = suggestion.title
|
|
91
|
-
elseif not (#suggestion.others == 0) then
|
|
92
|
-
suggestionText = suggestion.others[1]
|
|
93
|
-
else
|
|
94
|
-
local _condition = currentTextPart()
|
|
95
|
-
if _condition == nil then
|
|
96
|
-
_condition = ""
|
|
97
|
-
end
|
|
98
|
-
suggestionText = _condition
|
|
99
|
-
end
|
|
100
|
-
local argNames = getArgumentNames(registry, command)
|
|
101
|
-
for i = argIndex + 1, #argNames - 1 do
|
|
102
|
-
suggestionText ..= ` {argNames[i + 1]}`
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
local _result = currentTextPart()
|
|
106
|
-
if _result ~= nil then
|
|
107
|
-
_result = #_result
|
|
108
|
-
end
|
|
109
|
-
local _condition = _result
|
|
110
|
-
if _condition == nil then
|
|
111
|
-
_condition = 0
|
|
112
|
-
end
|
|
113
|
-
local partSize = _condition
|
|
114
|
-
local result = text
|
|
115
|
-
local _suggestionText = suggestionText
|
|
116
|
-
local _arg0 = partSize + 1
|
|
117
|
-
result ..= string.sub(_suggestionText, _arg0)
|
|
118
|
-
return result
|
|
119
|
-
end
|
|
120
|
-
return {
|
|
121
|
-
completeCommand = completeCommand,
|
|
122
|
-
completeArgument = completeArgument,
|
|
123
|
-
getSuggestedText = getSuggestedText,
|
|
124
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import Vide, { Derivable } from "@rbxts/vide";
|
|
2
|
-
interface TerminalTextFieldProps {
|
|
3
|
-
anchor?: Derivable<Vector2>;
|
|
4
|
-
size?: Derivable<UDim2>;
|
|
5
|
-
position?: Derivable<UDim2>;
|
|
6
|
-
backgroundTransparency?: Derivable<number>;
|
|
7
|
-
onTextChange?: (text: string) => void;
|
|
8
|
-
onSubmit?: (text: string) => void;
|
|
9
|
-
textParts: () => string[];
|
|
10
|
-
atNextPart: () => boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare function TerminalTextField({ anchor, size, position, backgroundTransparency, onTextChange, onSubmit, textParts, atNextPart, }: TerminalTextFieldProps): Vide.Node;
|
|
13
|
-
export {};
|