Posted 02 November 2016 - 09:43 AM
I am looking at my code on why its not working and i am blind X_X
term.clear()
xy,tc,bc = term.setCursorPos(),term.setTextColour(),term.setBackgroundColour()
local cut = function(t,l)
if string.len(t) > l then
return string.sub(t,1,l)
else
return t
end
end
local draw = function()
res = {term.getSize()}
paintutils.drawFilledBox(1,1,res[1],res[2],colours.white)
paintutils.drawFilledBox(1,1,res[1],3,colours.cyan)
xy(2,2)
bc(colours.cyan)
if path == "/" then
tc(colours.lightGrey)
else
tc(colours.white)
end
term.write("<")
xy(4,2)
tc(colours.white)
term.write(cut(path,res[1]-4))
end
while true do
if not path then path = "/" end
local offset = 0
local y = 4
local fileList = fs.list(path)
draw()
if #fileList > res[2]-3 then
local len = res[2]-3
else
local len = #fileList
end
for i=1,len,1 do
local filePath = fs.combine(path,fileList[i+offset])
if fs.isDir(filePath) then
paintutils.drawFilledBox(1,y,1,y,colours.blue)
elseif fs.isReadOnly(filePath) then
paintutils.drawFilledBox(1,y,1,y,colours.red)
else
paintutils.drawFilledBox(1,y,1,y,colours.yellow)
end
xy(3,y)
tc(colours.grey)
bc(colours.white)
term.write(fileList[i+offset])
y=y+1
end
local e,c,a,b = os.pullEvent()
if e == "mouse_up" then -- click
if c == 1 then
-- leftclick
elseif c == 2 then
local offset = 0
elseif c == 3 then
-- rightclick
end
elseif e == "mouse_scroll" then -- scroll
if a == "-1" and offset > 0 then
local offset = offset - 1
elseif a == "1" and offset < #fileList then
local offset = offset + 1
end
end
end
Edited on 02 November 2016 - 10:19 AM