Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --filax
- local component=require("component")
- local gpu=component.gpu
- local shell=require"shell"
- local event=require"event"
- local unicode=require"unicode"
- local fs = require"filesystem"
- local width,height=gpu.getResolution()
- local buttons={}
- function addButton(x,y,callback)
- table.insert(buttons,{x=x,y=y,c=callback})
- end
- function clearScreen()
- gpu.fill(1,1,width,height," ")
- end
- function setbg(c) gpu.setBackground(c) end
- function setfg(c) gpu.setForeground(c) end
- function drawTopBar(color,title)
- setbg(color)
- setfg(0xFFFFFF)
- gpu.fill(1,1,width,1," ")
- gpu.set(width/2-string.len(title)/2,1,title)
- setbg(0xFF0000)
- gpu.set(width,1,"x")
- addButton(width,1,function()
- setbg(0x000000)
- clearScreen()
- os.exit()
- end)
- setbg(0x00FF00)
- gpu.set(width-1,1,"↻")
- addButton(width-1,1,function()
- shell.execute("pastebin get znAFQAdd "..shell.getWorkingDirectory().."/filax.lua -f")
- shell.execute("lua "..shell.getWorkingDirectory().."/filax.lua")
- setbg(0x000000)
- clearScreen()
- io.exit()
- end)
- end
- function rgbToHex(r, g, b)
- r = math.min(255, math.max(0, r))
- g = math.min(255, math.max(0, g))
- b = math.min(255, math.max(0, b))
- local hexR = string.format("%02X", r)
- local hexG = string.format("%02X", g)
- local hexB = string.format("%02X", b)
- return "#" .. hexR .. hexG .. hexB
- end
- setbg(0x584475)
- clearScreen()
- drawTopBar(0x7f8182,"Filax")
- setbg(0x423357)
- gpu.fill(5,3,4,4," ")
- setbg(0x584475)
- function folderSize(path)
- local count = 0
- for entry in fs.list(path) do
- count = count + 1
- end
- return count
- end
- gpu.set(5,5,"┌─root")
- local xindx=1
- local globalm=5
- local globalfamt=0
- function searchDir(path, indx,famt)
- if fs.isDirectory(path) then
- local numEntries = folderSize(path)
- local forIndex=0
- for e in fs.list(path) do
- forIndex=forIndex+1
- globalm = globalm + 1
- local concated=fs.concat(path,e)
- local len=unicode.wlen(famt)
- if fs.isDirectory(concated) then
- if forIndex == numEntries then
- if(folderSize(concated)==0) then
- gpu.set(4 + indx-len, globalm, famt.."└──" .. e)
- else
- gpu.set(4 + indx-len, globalm, famt.."└┬─" .. e)
- searchDir(fs.concat(path,e),indx+1,famt.." ")
- end
- else
- if(folderSize(concated)==0) then
- gpu.set(4 + indx-len, globalm, famt.."├──" .. e)
- else
- gpu.set(4 + indx-len, globalm, famt.."├┬─" .. e)
- searchDir(fs.concat(path,e),indx+1,famt.."│")
- end
- end
- else
- if forIndex == numEntries then
- gpu.set(4 + indx-len, globalm, famt.."└─"..e)
- else
- gpu.set(4 + indx-len, globalm, famt.."├─"..e)
- end
- end
- end
- end
- end
- searchDir("home/projects",1,"")
- setbg(0x51476e)
- while true do
- local eventType, _, x, y = event.pull("touch")
- if eventType == "touch" then
- for _, button in ipairs(buttons) do
- if x==button.x and y==button.y then
- button.c()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement