這是 Scite 檔案瀏覽器的一個基本實作。控管透過輸出面板來完成。
local cmd, dir, pat, up, sep, begPos, endPos
if props['PLAT_WIN'] == '1' then
cmd = 'dir /b /o /a:-h '
sep = '\\'
pat = '\\[^\\]+$'
elseif props['PLAT_GTK'] == '1' then
cmd = 'ls -1v '
sep = '/'
pat = '/[^/]+$'
end
up = '[..]'
local function updateContent()
if begPos and endPos then
output:remove(begPos, endPos)
end
begPos = output.CurrentPos
local content = io.popen(cmd..'"'..dir..sep..'"')
print(dir..sep)
print(up)
print(content:read '*a')
content:close()
endPos = output.CurrentPos
end
function createContent()
dir = props['FileDir']
updateContent()
end
local oldOnDoubleClick = OnDoubleClick or function()end
function OnDoubleClick()
oldOnDoubleClick()
local name, path
name = output:GetCurLine():sub(1, -2)
if not dir
or not output.Focus
or name == '' or name == dir..sep
or endPos <= output.CurrentPos
or output.CurrentPos <= begPos then
return
end
if name == up then
path = dir:gsub(pat, '')
else
path = dir..sep..name
end
local file = io.open(path)
local x,err=file:read(1)
if io.type(file) and err==nil then
file:close()
scite.Open(path)
else
dir = path
updateContent()
end
end
要在 *.properties 檔案中設定它,輸入下列內容command.name.3.*=FileBrowser
command.mode.3.*=subsystem:lua,savebefore:no
command.3.*=dostring createContent()
最新變更 · 偏好設定
編輯 · 歷史
最後編輯於格林威治時間 2023 年 1 月 31 日 上午 1 點 50 分 (diff)