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