Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local path = ""
- local programs = {}
- function Paint()
- term.setTextColor(colors.white)
- term.setBackgroundColour(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- write("<")
- term.setCursorPos(3,1)
- write("+")
- term.setCursorPos(5,1)
- write(path)
- term.setTextColor(colors.black)
- term.setBackgroundColour(colors.white)
- programs = {}
- local files = fs.list(path)
- for i = 1, #files do
- term.setCursorPos(1,i+2)
- write(files[i])
- programs[i] = {files[i], i+2}
- end
- end
- function Click(x, y)
- if (x==1 and y == 1) then
- if (path == "") then return end
- path = fs.getDir(path)
- return
- elseif (x==3 and y == 1) then
- term.setCursorPos(6 + string.len(path),1)
- local fileName = read()
- if (fileName == "") then
- return
- elseif (string.find(fileName, "%.") == nil) then
- fs.makeDir(path .. "/" .. fileName)
- else
- local file = fs.open(path .. "/" .. fileName, "w")
- file.close()
- end
- return
- end
- for i = 1, #programs do
- if (y == programs[i][2]) then
- term.clear()
- term.setCursorPos(1,1)
- write(programs[i][1])
- if (string.find(programs[i][1], "%.") ~= nil) then
- local prog
- if (string.find(programs[i][1], ".nfp") ~= nil or string.find(programs[i][1], ".nft") ~= nil) then
- prog = shell.openTab("paint " .. path .. "/" .. programs[i][1])
- else
- prog = shell.openTab("edit " .. path .. "/" .. programs[i][1])
- end
- multishell.setFocus(prog)
- multishell.setTitle(prog, programs[i][1])
- else
- path = path .. "/" .. programs[i][1]
- end
- end
- end
- end
- while (true) do
- Paint()
- local event, button, x, y = os.pullEvent("mouse_click")
- Click(x, y)
- end
Advertisement
Add Comment
Please, Sign In to add comment