Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Light weight mouse FB mini
- by BigSHinyToys
- ]]--
- local bRun = true
- local sSlash = [[\]]
- local path = {}
- local tItemList = {}
- local hight,width = term.getSize()
- local listPos = -1
- local function stringPath()
- local temp = sSlash..table.concat(path,sSlash)
- return temp
- end
- local function newList()
- listPos = -1
- tItemList = {{n = "..", id = "back"}} -- adds a back item at top of list
- sPath = stringPath()
- local folders = {}
- local files = {}
- local disks = {}
- local test,list = pcall(fs.list,sPath)
- if list == nil then
- list = {}
- end
- if #path == 0 then
- for i,v in pairs(rs.getSides()) do
- if disk.isPresent(v) then
- if disk.hasData(v) then
- table.insert(tItemList,{n = disk.getMountPath(v), id = "disk",s = v})
- disks[disk.getMountPath(v)] = true
- elseif disk.hasAudio(v) then
- table.insert(tItemList,{n = disk.getAudioTitle(v), id = "audio",s = v})
- end
- end
- end
- end
- for i,v in pairs(list) do
- if fs.isDir(sPath..sSlash..v) then
- table.insert(folders,v)
- else
- table.insert(files,v)
- end
- end
- table.sort(folders)
- table.sort(files)
- for i,v in pairs(folders) do
- if disks[v] == nil then
- table.insert(tItemList,{n = v, id = "folder"})
- end
- end
- for i,v in pairs(files) do
- table.insert(tItemList,{n = v, id = "file"})
- end
- end
- term.clear()
- newList()
- local tIcons = {
- back = {tCol = "lightGray",bCol = "blue",txt = " < "},
- disk = {tCol = "lightGray",bCol = "blue",txt = "[*]"},
- audio = {tCol = "yellow",bCol = "red",txt = "(o)"},
- folder = {tCol = "lightGray",bCol = "blue",txt = "[=]"},
- file = {tCol = "lime",bCol = "green",txt = " "}
- }
- while bRun do
- term.setBackgroundColor(colors.cyan)
- term.clear()
- for i = 1,hight do
- term.setCursorPos(1,i)
- local sel = i+listPos
- if tItemList[sel] then
- term.setBackgroundColor(colors[tIcons[tItemList[sel].id].bCol])
- term.setTextColor(colors[tIcons[tItemList[sel].id].tCol])
- term.write(tIcons[tItemList[sel].id].txt..tItemList[sel].n)
- end
- end
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.blue)
- term.setCursorPos(1,1)
- term.write(stringPath())
- local event = {os.pullEvent()}
- if event[1] == "mouse_scroll" then
- listPos = listPos + event[2]
- elseif event[1] == "mouse_click" then
- if event[2] == 1 then -- left click
- local itemNumber = event[4] + listPos -- to keep it neat
- if tItemList[itemNumber] then
- if tItemList[itemNumber].id == "folder" or tItemList[itemNumber].id == "disk" then
- table.insert(path,tItemList[itemNumber].n)
- newList()
- elseif tItemList[itemNumber].id == "file" then
- os.run(getfenv(),stringPath()..sSlash..tItemList[itemNumber].n)
- elseif tItemList[itemNumber].id == "back" then
- table.remove(path,#path)
- newList()
- end
- end
- else -- right click
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement