add files filter to the editor
This commit is contained in:
parent
3a4b334d0b
commit
b9c2b0ba40
@ -25,8 +25,12 @@
|
||||
<splitbox id="editorRoot" pos="0,30" size-func="-1,gui.get_viewport()[2]-30"
|
||||
orientation="horizontal" split-pos="0.3">
|
||||
<splitbox split-pos="0.75">
|
||||
<panel id="filesList" color="#00000010" interval="6" padding="4">
|
||||
<!-- content is generated in script -->
|
||||
<panel interval="2" color="0" padding="2">
|
||||
<textbox pos="2" sub-consumer="filter_files"></textbox>
|
||||
<panel id="filesList" color="#00000010" interval="6" padding="4"
|
||||
size-func="-1,-45" pos="2,38">
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
</panel>
|
||||
<panel id="problemsLog"
|
||||
color="#00000010"
|
||||
@ -41,11 +45,19 @@
|
||||
interactive="true" onclick="unlock_access()"
|
||||
color="#FFFFFF80" size="16" pos="4,6"
|
||||
hover-color="#1080FF"></image>
|
||||
<image id="saveIcon" src="gui/save" tooltip="@Save"
|
||||
enabled="false" interactive="true"
|
||||
gravity="top-right" hover-color="#1080FF"
|
||||
onclick="save_current_file()"
|
||||
color="#FFFFFF80" size="16" margin="8"></image>
|
||||
<panel orientation="horizontal" gravity="top-right"
|
||||
size="36,16" padding="8" interval="8" color="0">
|
||||
<image id="saveIcon" src="gui/save" tooltip="@Save"
|
||||
enabled="false" interactive="true"
|
||||
hover-color="#1080FF"
|
||||
onclick="save_current_file()"
|
||||
color="#FFFFFF80" size="16"></image>
|
||||
<image id="syncIcon" src="gui/check_mark" tooltip="@Sync"
|
||||
enabled="true" interactive="true"
|
||||
hover-color="#1080FF"
|
||||
onclick="save_current_file()"
|
||||
color="#FFFFFF80" size="16"></image>
|
||||
</panel>
|
||||
<label id="title" pos="26,8"></label>
|
||||
</container>
|
||||
<textbox
|
||||
|
||||
@ -10,6 +10,7 @@ local warning_id = 0
|
||||
local error_id = 0
|
||||
|
||||
local writeables = {}
|
||||
local filenames = {}
|
||||
|
||||
local current_file = {
|
||||
filename = "",
|
||||
@ -81,6 +82,36 @@ local function refresh_file_title()
|
||||
..(edited and ' *' or '')
|
||||
end
|
||||
|
||||
function build_files_list(filenames, selected)
|
||||
local files_list = document.filesList
|
||||
files_list:clear()
|
||||
|
||||
for _, actual_filename in ipairs(filenames) do
|
||||
local filename = actual_filename
|
||||
if selected then
|
||||
filename = filename:gsub(selected, "**"..selected.."**")
|
||||
end
|
||||
local parent = file.parent(filename)
|
||||
local script_type = "file"
|
||||
files_list:add(gui.template("script_file", {
|
||||
path = parent .. (parent[#parent] == ':' and '' or '/'),
|
||||
name = file.name(filename),
|
||||
type = script_type,
|
||||
filename = actual_filename
|
||||
}))
|
||||
end
|
||||
end
|
||||
|
||||
function filter_files(text)
|
||||
local filtered = {}
|
||||
for _, filename in ipairs(filenames) do
|
||||
if filename:find(text) then
|
||||
table.insert(filtered, filename)
|
||||
end
|
||||
end
|
||||
build_files_list(filtered, text)
|
||||
end
|
||||
|
||||
function on_control_combination(keycode)
|
||||
if keycode == input.keycode("s") then
|
||||
save_current_file()
|
||||
@ -301,22 +332,12 @@ function on_open(mode)
|
||||
local files_list = document.filesList
|
||||
local packs = pack.get_installed()
|
||||
|
||||
local scripts = {}
|
||||
for _, packid in ipairs(packs) do
|
||||
collect_scripts(packid..":modules", scripts)
|
||||
collect_scripts(packid..":scripts", scripts)
|
||||
end
|
||||
table.sort(scripts)
|
||||
for _, filename in ipairs(scripts) do
|
||||
local parent = file.parent(filename)
|
||||
local script_type = "file"
|
||||
files_list:add(gui.template("script_file", {
|
||||
path = parent .. (parent[#parent] == ':' and '' or '/'),
|
||||
name = file.name(filename),
|
||||
type = script_type,
|
||||
filename = filename
|
||||
}))
|
||||
collect_scripts(packid..":modules", filenames)
|
||||
collect_scripts(packid..":scripts", filenames)
|
||||
end
|
||||
table.sort(filenames)
|
||||
build_files_list(filenames)
|
||||
|
||||
document.editorContainer:setInterval(200, refresh_file_title)
|
||||
elseif mode then
|
||||
|
||||
@ -306,8 +306,8 @@ void UINode::reposition() {
|
||||
defsize = parent->getSize();
|
||||
}
|
||||
setSize(
|
||||
{newSize.x < 0 ? defsize.x : newSize.x,
|
||||
newSize.y < 0 ? defsize.y : newSize.y}
|
||||
{newSize.x < 0 ? defsize.x + (newSize.x + 1) : newSize.x,
|
||||
newSize.y < 0 ? defsize.y + (newSize.y + 1) : newSize.y}
|
||||
);
|
||||
}
|
||||
if (positionfunc) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user