Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local FilePath = "os"
- local PastPaths = {"os"}
- local S = 3
- local w, h = term.getSize()
- local Icons = {"ImageFile.nfp","ProgramFile.nfp","TextFile.nfp","Shortcut.nfp","LuaFile.nfp","Folder.nfp"}
- local Return = false
- local Scroll = false
- local tArg = {...}
- settings.load(".settings")
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function ImageCUI(m) --declare function
- n=0
- local l = #m
- local Cords = {}
- local X = 2
- local Y = 5
- for i=1, #m, 1 do --traverse the table of options
- local W = fs.combine(FilePath,m[i])
- local Image
- if string.find(m[i],".nfp") then Image = Icons[1] end
- if string.find(m[i],".cpf") then Image = Icons[2] end
- if string.find(m[i],".txt") then Image = Icons[3] end
- if string.find(m[i],".lnk") then Image = Icons[4] end
- if string.find(m[i],".lua") then Image = Icons[5] end
- if Image == nil then Image = Icons[6] end
- Cords[i] = {X,Y,X + 6, Y + 2}
- Image = fs.combine("os/SystemFiles/FileNavigator.cpf/Images",Image)
- local Img = paintutils.loadImage(Image)
- paintutils.drawImage(Img,X,Y)
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(X - 1, Y + 3)
- term.write(string.sub(m[i],1,9))
- if X + 8 < w then
- X = X + 8
- else
- X = 2
- Y = Y + 5
- end
- end
- while true do
- term.setCursorPos(1,3)
- a, b, c, d = os.pullEvent() --wait for keypress
- for i = 1, #m do
- if a == "mouse_click" and c >= Cords[i][1] and c <= Cords[i][3] and d >= Cords[i][2] and d <= Cords[i][4] then n = i end
- end
- if n == 0 and Return == true and a == "mouse_click" and c == w and d == 3 then n = 50 end
- if Scroll == true and a == "key" and b == keys.w then term.scroll(-1) end
- if Scroll == true and a == "key" and b == keys.s then term.scroll(1) end
- if n > 0 then break end
- end
- return n, b --return the value
- end
- function Check(Items)
- if settings.get("AdminKey") == "Jta520" then
- else
- for i = 1, #Items do
- local RPath = fs.combine(FilePath,Items[i])
- for I = 1, #BlockedPaths do
- if RPath == BlockedPaths[I] then Items[i] = "blocked" end
- end
- end
- end
- local List = Items
- Items = {}
- for i = 1, #List do
- if List[i] ~= "blocked" then Items[#Items + 1] = List[i] end
- end
- return(Items)
- end
- function CreateFile()
- Clear()
- local FileType
- print("file type")
- local options = {"lua","txt"}
- local n = CUI(options)
- if options[n] == "lua" then
- FileType = ".lua"
- else
- FileType = ".txt"
- end
- print("enter name for file")
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- input = input..FileType
- local P = fs.combine(FilePath, input)
- local file = fs.open(P,"w")
- file.write("new file")
- file.close()
- if FileType == ".lua" then
- shell.run("edit",P)
- else
- shell.run("os/System/Programs/TextEditor","direct",P)
- end
- Display()
- end
- function CreateFolder()
- Clear()
- print("enter name for folder")
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- local P = fs.combine(FilePath, input)
- fs.makeDir(P)
- Display()
- end
- function SearchBar()
- term.setCursorPos(1,1)
- term.clearLine()
- paintutils.drawBox(1,1,w,1,colors.lightGray)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(1,1)
- local completion = require "cc.completion"
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read(nil, nil, function(text) return completion.choice(text, AllPaths) end)
- end
- if input == nil then
- else
- if fs.exists(input) then
- FilePath = input
- end
- end
- Display()
- end
- function Prompt()
- Clear()
- print("options")
- local options = {"run","edit properties","edit file","delete","close"}
- local n = CUI(options)
- return(options[n])
- end
- function ViewImage(file)
- Clear()
- local Image = paintutils.loadImage(file)
- paintutils.drawImage(Image,1,1)
- term.setCursorPos(1,h)
- term.write("press enter to exit")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- end
- function OpenProgram(file)
- local List = fs.list(file)
- local Loc
- local File
- for i = 1, #List do
- if string.find(List[n],"AppData.txt") then Loc = fs.combine(file,List[n]) end
- end
- if Loc == nil then
- else
- local F = fs.open(Loc,"r")
- local Content
- repeat
- Content = F.readLine()
- if string.find(Content,"StartFile = ") then File = string.sub(Content, 13, string.len(Content)) end
- until Content == nil
- if File ~= nil then shell.run(File) end
- end
- end
- function ViewTxt(file)
- end
- function Display(I)
- term.setBackgroundColor(colors.lightBlue)
- Clear()
- local Paths = fs.list(FilePath)
- Scroll = false
- Return = false
- local List = {}
- if #Paths > 14 and I == nil then
- Scroll = true
- end
- if FilePath ~= "os" then
- Return = true
- end
- paintutils.drawFilledBox(1,1,w,3,colors.lightGray)
- paintutils.drawFilledBox(1,1,3,3,colors.green)
- paintutils.drawFilledBox(4,1,7,3,colors.red)
- if Return == true then
- paintutils.drawBox(w,3,w,3,colors.red)
- end
- term.setBackgroundColor(colors.lightBlue)
- local options = Paths
- local n = ImageCUI(options)
- if string.find(options[n],".txt") then
- ViewTxt(fs.combine(FilePath,options[n]))
- elseif string.find(options[n],".lua") then
- shell.run(fs.combine(FilePath,options[n]))
- elseif string.find(options[n],".cpf") then
- OpenProgram(fs.combine(FilePath,options[n]))
- elseif string.find(options[n],".nfp") then
- ViewImage(fs.combine(FilePath,options[n]))
- else
- FilePath = fs.combine(FilePath,options[n])
- end
- Display()
- end
- if tArg[1] == "Show" then
- FilePath = tArg[2]
- end
- Display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement