Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local dir = "DevOS/SystemFiles"
- local w,h = term.getSize()
- local endat = 0
- if args[1] and fs.exists(args[1]) then
- dir = args[1]
- end
- local scrol = 0
- function scroll()
- while true do
- local e,d,x,y = os.pullEvent("mouse_scroll")
- if scrol ~= 0 or d ~= -1 then
- if endat >= h or d == -1 then
- scrol = scrol + d
- redraw()
- end
- end
- end
- end
- function redraw()
- buttonapis.clearButtons()
- buttonapis.clearFunctions()
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.white)
- term.clear()
- local dirs = {}
- local files = {}
- for ii,vv in pairs(fs.list(dir))do --SORT
- if fs.isDir(dir.."/"..vv)then
- table.insert(dirs,vv)
- end
- end
- for iii,vvv in pairs(fs.list(dir))do
- if not fs.isDir(dir.."/"..vvv)then
- table.insert(files,vvv)
- end
- end
- for iiii,vvvv in pairs(files)do
- table.insert(dirs,vvvv)
- end
- local list = dirs
- x = 5
- y = 2-scrol
- for i,v in pairs(list)do
- local image
- if fs.isDir(dir.."/"..v) then
- image = paintutils.loadImage("DevOS/Images/DFMFolder")
- bfunctions[v] = function(x,y,name)
- dir = dir.."/"..name
- redraw()
- end
- else
- image = paintutils.loadImage("DevOS/Images/DFMFile")
- bfunctions[v] = function(x,y,name)
- buttonapis.clearButtons()
- buttonapis.clearFunctions()
- redraw()
- end
- end
- paintutils.drawImage(image,x,y)
- local n = v
- if #v > 8 then
- n = v:sub(1,6)..".."
- end
- term.setCursorPos(x,y+4)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.white)
- term.write(n)
- buttonapis.addButton(x,y,x+5,y+5,v)
- x = x + 9
- if x + 9 >= w then
- x = 5
- y = y + 7
- end
- end
- endat = y+4
- term.setCursorPos(1,1)
- term.clearLine()
- term.write(":/"..dir.."/")
- end
- parallel.waitForAll(redraw,scroll)
Advertisement
Add Comment
Please, Sign In to add comment