Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[---------
- ufie Browser
- V 0.1
- --]]---------
- local size = {term.getSize()} --//Terminal Size
- local root = "/" --//...Root?
- local oldRoot = "/" --//..Old Root?
- local selected --//Selected File
- local clipboard --//..I guess Its not a clipboard.
- local optS = 10 --//Size of the Menu
- local txColor = colors.gray --//I dont know where this came from, ima check it out later
- local cp = --//SLightly unused text colors. Ill remove them. One Day.
- {
- ["bar"] = colors.gray;
- ["bar2"] = colors.lightGray;
- ["menu"] = colors.lightGray;
- ["suc"] = colors.cyan;
- ["tBar"] = colors.white;
- ["fail"] = colors.red;
- ["tFile"] = colors.lightGray;
- ["tDir"] = colors.lime;
- }
- local permOpt = --//The ol' options that stay. foreva.
- {
- "Copy";
- "Paste";
- }
- local fileOpt = --//Meh, Options for when A file is selected.
- {
- "Copy";
- "Delete";
- "Open";
- "Edit";
- "Rename";
- }
- local txtOpt = --//You guessed it.
- {
- "Copy";
- "Delete";
- "Open";
- "Rename";
- }
- function drawGUI()
- term.setBackgroundColor(colors.white)
- term.clear()
- paintutils.drawLine(1,1,size[1],1,cp.bar)
- paintutils.drawLine(1,2,size[1],2,cp.bar2)
- for x = size[1], size[1]-optS, -1 do
- paintutils.drawLine(x, 3, x, size[2], cp.bar2)
- end
- paintutils.drawLine(size[1]-(optS+1), 3, size[1]-(optS+1), size[2], cp.bar)
- term.setCursorPos(2, 1)
- term.setTextColor(cp.tBar)
- write("ufile")
- term.setCursorPos(size[1], 1)
- term.setTextColor(cp.fail)
- write("*")
- paintutils.drawLine(1, size[2], size[1]-optS-1, size[2], colors.lightGray)
- term.setCursorPos(2,size[2])
- term.setTextColor(cp.tBar)
- write("..")
- term.setTextColor(cp.tBar)
- term.setBackgroundColor(cp.bar)
- term.setCursorPos(1,2)
- write("@ ")
- term.setBackgroundColor(cp.bar2)
- if #root-2 > size[1] then
- for i = 1, size[1]-5 do
- local c = root:sub(i, i)
- write(c)
- end
- write("...")
- else
- write(root)
- end
- end
- while true do
- list = fs.list(root)
- drawGUI()
- for k, v in pairs(list) do
- if v == selected then
- txColor = cp.tBar
- paintutils.drawLine(1, k+2, size[1]-optS-1, k+2, cp.bar)
- else
- term.setBackgroundColor(colors.white)
- txColor = colors.gray
- end
- if fs.isDir(root.."/"..v) then
- term.setCursorPos(1, k+2)
- term.setTextColor(cp.tDir)
- write("* ")
- term.setTextColor(txColor)
- write(v)
- elseif not fs.isDir(root.."/"..v) then
- term.setCursorPos(1, k+2)
- term.setTextColor(cp.tFile)
- write("* ")
- term.setTextColor(txColor)
- write(v)
- end
- end
- local e, b, x, y = os.pullEvent()
- if e == "mouse_click" and x >= 2 and x <= 3 and y == size[2] then
- root = fs.getDir(root)
- elseif e == "mouse_click" and x >= 3 and y == 2 then
- term.setBackgroundColor(cp.bar2)
- term.setTextColor(colors.white)
- for x = 3, size[1] do --Doing this so I dont wipe off the whole line, parts are needed.
- term.setCursorPos(x, 2)
- write(" ")
- end
- term.setCursorPos(3,2)
- local newRoot = read()
- if fs.isDir(newRoot) then
- root = newRoot
- term.setBackgroundColor(cp.suc)
- term.setTextColor(cp.tBar)
- term.setCursorPos(1,2)
- write("@ ")
- sleep(0.1)
- elseif not fs.isDir(newRoot) or not fs.exsits(newRoot) then
- term.setBackgroundColor(cp.fail)
- term.setTextColor(colors.white)
- term.setCursorPos(1,2)
- write("@ ")
- sleep(0.1)
- end
- elseif e == "mouse_click" and x < size[1]-optS-1 and y-2 <= #list and selected == list[y-2] and fs.isDir(root.."/"..selected)then
- root = root.."/"..selected
- elseif e == "mouse_click" and b == 1 and x < size[1]-optS-1 and y-2 <= #list and selected == list[y-2] and not fs.isDir(root.."/"..selected) then
- shell.run(root.."/"..selected)
- elseif e == "mouse_click" and b == 2 and x < size[1]-optS-1 and y-2 <= #list and selected == list[y-2] and not fs.isDir(root.."/"..selected) then
- shell.run("edit "..root.."/"..selected)
- elseif e == "mouse_click" and x < size[1]-optS-1 and y-2 > #list then
- selected = nil
- elseif e == "mouse_click" and x < size[1]-optS-1 and y-2 <= #list and y ~= 1 and y ~= 2 then
- selected = list[y-2]
- elseif e == "mouse_click" and x == size[1] and y == 1 then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- break
- elseif e == "mouse_drag" then
- optS = size[1]-x
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement