SHOW:
|
|
- or go back to the newest paste.
| 1 | local tArgs = { ... }
| |
| 2 | local home | |
| 3 | local root | |
| 4 | local clipboard | |
| 5 | if #tArgs > 0 then | |
| 6 | - | home = tArgs[1] |
| 6 | + | home = tArgs[1] |
| 7 | - | else |
| 7 | + | else |
| 8 | - | home = "" |
| 8 | + | home = "" |
| 9 | - | end |
| 9 | + | |
| 10 | - | if #tArgs > 1 then |
| 10 | + | if #tArgs > 1 then |
| 11 | - | root = tArgs[2] |
| 11 | + | root = tArgs[2] |
| 12 | - | else |
| 12 | + | else |
| 13 | - | root = "/" |
| 13 | + | root = "/" |
| 14 | - | end |
| 14 | + | |
| 15 | history = {}
| |
| 16 | history[1] = root .. home | |
| 17 | local w,h = term.getSize() | |
| 18 | local function split(inputstr, sep) | |
| 19 | - | if sep == nil then |
| 19 | + | if sep == nil then |
| 20 | - | sep = "%s" |
| 20 | + | sep = "%s" |
| 21 | - | end |
| 21 | + | end |
| 22 | - | local t={} ; i=1
|
| 22 | + | local t={} ; i=1
|
| 23 | - | for str in string.gmatch(inputstr, "([^"..sep.."]+)") do |
| 23 | + | for str in string.gmatch(inputstr, "([^"..sep.."]+)") do |
| 24 | - | t[i] = str |
| 24 | + | t[i] = str |
| 25 | - | i = i + 1 |
| 25 | + | i = i + 1 |
| 26 | - | end |
| 26 | + | end |
| 27 | - | return t |
| 27 | + | return t |
| 28 | end | |
| 29 | historyclear = function() | |
| 30 | - | history = {}
|
| 30 | + | history = {}
|
| 31 | - | history[1] = root..home |
| 31 | + | history[1] = root..home |
| 32 | end | |
| 33 | shellcom = {historyclear}
| |
| 34 | local function diabox(txt) | |
| 35 | - | term.setBackgroundColor(colors.white) |
| 35 | + | term.setBackgroundColor(colors.white) |
| 36 | - | term.setTextColor(colors.black) |
| 36 | + | term.setTextColor(colors.black) |
| 37 | - | paintutils.drawFilledBox(math.floor(w/2-(#txt+2)/2),math.floor(h/2)-2,math.floor(w/2+(#txt+2)/2),math.floor(h/2)+2,colors.white) |
| 37 | + | paintutils.drawFilledBox(math.floor(w/2-(#txt+2)/2),math.floor(h/2)-2,math.floor(w/2+(#txt+2)/2),math.floor(h/2)+2,colors.white) |
| 38 | - | term.setCursorPos(math.floor(w/2-(#txt+2)/2)+1,math.floor(h/2)-1) |
| 38 | + | term.setCursorPos(math.floor(w/2-(#txt+2)/2)+1,math.floor(h/2)-1) |
| 39 | - | term.write(txt) |
| 39 | + | term.write(txt) |
| 40 | - | term.setCursorPos(math.floor(w/2-(#txt+2)/2)+1,math.floor(h/2)+1) |
| 40 | + | term.setCursorPos(math.floor(w/2-(#txt+2)/2)+1,math.floor(h/2)+1) |
| 41 | end | |
| 42 | function readtextbox(txt) | |
| 43 | - | diabox(txt) |
| 43 | + | diabox(txt) |
| 44 | - | return read() |
| 44 | + | return read() |
| 45 | end | |
| 46 | function buttonbox(txt,buttons) | |
| 47 | - | if type(buttons) ~= "table" then |
| 47 | + | if type(buttons) ~= "table" then |
| 48 | - | buttons = {{" Yes ",colors.red,colors.white},{" No ",colors.gray,colors.white}}
|
| 48 | + | buttons = {{" Yes ",colors.red,colors.white},{" No ",colors.gray,colors.white}}
|
| 49 | - | end |
| 49 | + | end |
| 50 | - | if txt == "" or txt == nil then |
| 50 | + | if txt == "" or txt == nil then |
| 51 | - | txt = " Are you sure? " |
| 51 | + | txt = " Are you sure? " |
| 52 | - | end |
| 52 | + | end |
| 53 | - | local x,y |
| 53 | + | local x,y |
| 54 | - | diabox(txt) |
| 54 | + | diabox(txt) |
| 55 | - | for i=1,#buttons do |
| 55 | + | for i=1,#buttons do |
| 56 | - | x,y = term.getCursorPos() |
| 56 | + | x,y = term.getCursorPos() |
| 57 | - | x = math.floor((w/2-(#txt+2)/2)+((#txt+2)/i)*(i-1)) + 1 |
| 57 | + | x = math.floor((w/2-(#txt+2)/2)+((#txt+2)/i)*(i-1)) + 1 |
| 58 | - | term.setCursorPos(x,y) |
| 58 | + | term.setCursorPos(x,y) |
| 59 | - | term.setBackgroundColor(buttons[i][2]) |
| 59 | + | term.setBackgroundColor(buttons[i][2]) |
| 60 | - | term.setTextColor(buttons[i][3]) |
| 60 | + | term.setTextColor(buttons[i][3]) |
| 61 | - | term.write(buttons[i][1]) |
| 61 | + | term.write(buttons[i][1]) |
| 62 | - | end |
| 62 | + | end |
| 63 | - | while true do |
| 63 | + | while true do |
| 64 | - | local _,b,x2,y2 = os.pullEvent("mouse_click")
|
| 64 | + | local _,b,x2,y2 = os.pullEvent("mouse_click")
|
| 65 | - | if b == 1 and y == y2 then |
| 65 | + | if b == 1 and y == y2 then |
| 66 | - | for i=1,#buttons do |
| 66 | + | for i=1,#buttons do |
| 67 | - | local x = math.floor((w/2-(#txt+2)/2)+((#txt+2)/i)*(i-1)) + 1 |
| 67 | + | local x = math.floor((w/2-(#txt+2)/2)+((#txt+2)/i)*(i-1)) + 1 |
| 68 | - | if x2 > x - 1 and x2 < x + #buttons[i][1] then |
| 68 | + | if x2 > x - 1 and x2 < x + #buttons[i][1] then |
| 69 | - | return i |
| 69 | + | return i |
| 70 | - | end |
| 70 | + | end |
| 71 | - | end |
| 71 | + | end |
| 72 | - | end |
| 72 | + | end |
| 73 | - | end |
| 73 | + | end |
| 74 | end | |
| 75 | local function clear() | |
| 76 | - | term.setBackgroundColor(colors.lightBlue) |
| 76 | + | term.setBackgroundColor(colors.lightBlue) |
| 77 | - | term.setTextColor(colors.black) |
| 77 | + | term.setTextColor(colors.black) |
| 78 | - | term.clear() |
| 78 | + | term.clear() |
| 79 | - | term.setCursorPos(1,1) |
| 79 | + | term.setCursorPos(1,1) |
| 80 | end | |
| 81 | local function list(path,scroll,selected) | |
| 82 | - | clear() |
| 82 | + | clear() |
| 83 | - | local items = fs.list(path) |
| 83 | + | local items = fs.list(path) |
| 84 | - | for i=scroll+1,scroll+h-2 do |
| 84 | + | for i=scroll+1,scroll+h-2 do |
| 85 | - | if type(items[i]) == "string" then |
| 85 | + | if type(items[i]) == "string" then |
| 86 | - | if i ~= selected then |
| 86 | + | if i ~= selected then |
| 87 | - | if not fs.isDir(path..items[i]) then |
| 87 | + | if not fs.isDir(path..items[i]) then |
| 88 | - | term.setTextColor(colors.black) |
| 88 | + | term.setTextColor(colors.black) |
| 89 | - | else |
| 89 | + | else |
| 90 | - | term.setTextColor(colors.yellow) |
| 90 | + | term.setTextColor(colors.yellow) |
| 91 | - | end |
| 91 | + | end |
| 92 | - | else |
| 92 | + | else |
| 93 | - | term.setTextColor(colors.white) |
| 93 | + | term.setTextColor(colors.white) |
| 94 | - | end |
| 94 | + | end |
| 95 | - | |
| 95 | + | print(items[i]) |
| 96 | - | print(items[i]) |
| 96 | + | end |
| 97 | - | end |
| 97 | + | end |
| 98 | - | |
| 98 | + | return items |
| 99 | - | end |
| 99 | + | |
| 100 | - | return items |
| 100 | + | |
| 101 | term.setBackgroundColor(colors.blue) | |
| 102 | term.setTextColor(colors.white) | |
| 103 | - | term.setBackgroundColor(colors.blue) |
| 103 | + | term.setCursorPos(1,h-1) |
| 104 | - | term.setTextColor(colors.white) |
| 104 | + | term.clearLine() |
| 105 | - | term.setCursorPos(1,h-1) |
| 105 | + | term.setCursorPos(1,h-1) |
| 106 | - | term.clearLine() |
| 106 | + | term.write(path) |
| 107 | - | term.setCursorPos(1,h-1) |
| 107 | + | term.setCursorPos(1,h) |
| 108 | - | term.write(path) |
| 108 | + | term.clearLine() |
| 109 | - | term.setCursorPos(1,h) |
| 109 | + | term.setCursorPos(1,h) |
| 110 | - | term.clearLine() |
| 110 | + | term.write("| New | MkDir | More | Root | Home | Back | Exit |")
|
| 111 | - | term.setCursorPos(1,h) |
| 111 | + | |
| 112 | - | term.write("| New | MkDir | More | Root | Home | Back | Exit |")
|
| 112 | + | |
| 113 | if y == nil then _,y = term.getCursorPos() end | |
| 114 | term.setCursorPos(w-#txt,y) | |
| 115 | - | if y == nil then _,y = term.getCursorPos() end |
| 115 | + | term.write(txt) |
| 116 | - | term.setCursorPos(w-#txt,y) |
| 116 | + | term.setCursorPos(1,y+1) |
| 117 | - | term.write(txt) |
| 117 | + | |
| 118 | - | term.setCursorPos(1,y+1) |
| 118 | + | |
| 119 | paintutils.drawFilledBox(math.floor(w/2),1,w,h-1) | |
| 120 | if (isDir) then | |
| 121 | - | paintutils.drawFilledBox(math.floor(w/2),1,w,h-1) |
| 121 | + | rPrint("Open",2)
|
| 122 | - | if (isDir) then |
| 122 | + | rPrint("Unpack")
|
| 123 | - | rPrint("Open",2)
|
| 123 | + | else |
| 124 | - | rPrint("Unpack")
|
| 124 | + | rPrint("Edit",2)
|
| 125 | - | else |
| 125 | + | rPrint("Paint")
|
| 126 | - | rPrint("Edit",2)
|
| 126 | + | rPrint("Open with ...")
|
| 127 | - | rPrint("Paint")
|
| 127 | + | rPrint("Run")
|
| 128 | - | rPrint("Open with ...")
|
| 128 | + | rPrint("Run w/Args")
|
| 129 | - | rPrint("Run")
|
| 129 | + | end |
| 130 | - | rPrint("Run w/Args")
|
| 130 | + | rPrint("Rename",7)
|
| 131 | - | end |
| 131 | + | rPrint("Move")
|
| 132 | - | rPrint("Rename",7)
|
| 132 | + | rPrint("Copy")
|
| 133 | - | rPrint("Move")
|
| 133 | + | rPrint("Copy to clipboard")
|
| 134 | - | rPrint("Copy")
|
| 134 | + | rPrint("Delete")
|
| 135 | - | rPrint("Copy to clipboard")
|
| 135 | + | rPrint("Deselect")
|
| 136 | - | rPrint("Delete")
|
| 136 | + | |
| 137 | - | rPrint("Deselect")
|
| 137 | + | |
| 138 | - | end |
| 138 | + | if type == nil then type = 1 end |
| 139 | if type == 1 then return "Unpacked_" .. name end | |
| 140 | - | if type == nil then type = 1 end |
| 140 | + | if type == 2 then return name .. math.random(1,10000) end |
| 141 | - | if type == 1 then return "Unpacked_" .. name end |
| 141 | + | return name .. "_pasted" |
| 142 | - | if type == 2 then return name .. math.random(1,10000) end |
| 142 | + | |
| 143 | - | return name .. "_pasted" |
| 143 | + | |
| 144 | if type(col) == nil then col = colors.white end | |
| 145 | term.setCursorPos(1,y) | |
| 146 | - | if type(col) == nil then col = colors.white end |
| 146 | + | term.clearLine() |
| 147 | - | term.setCursorPos(1,y) |
| 147 | + | term.setCursorPos(math.floor(w/2-#txt/2),y) |
| 148 | - | term.clearLine() |
| 148 | + | term.write(txt) |
| 149 | - | term.setCursorPos(math.floor(w/2-#txt/2),y) |
| 149 | + | |
| 150 | - | term.write(txt) |
| 150 | + | |
| 151 | clear() | |
| 152 | while true do | |
| 153 | - | clear() |
| 153 | + | term.setCursorPos(1,h) |
| 154 | - | while true do |
| 154 | + | term.clearLine() |
| 155 | - | term.setCursorPos(1,h) |
| 155 | + | term.setCursorPos(1,h) |
| 156 | - | term.clearLine() |
| 156 | + | term.write("? ")
|
| 157 | - | term.setCursorPos(1,h) |
| 157 | + | local command = read() |
| 158 | - | term.write("? ")
|
| 158 | + | clear() |
| 159 | - | local command = read() |
| 159 | + | term.setCursorPos(1,1) |
| 160 | - | clear() |
| 160 | + | if command == "exit" then return end |
| 161 | - | term.setCursorPos(1,1) |
| 161 | + | if type(shellcom[command]) == "function" then |
| 162 | - | if command == "exit" then return end |
| 162 | + | shellcom[command]() |
| 163 | - | if type(shellcom[command]) == "function" then |
| 163 | + | else |
| 164 | - | shellcom[command]() |
| 164 | + | print("Not a command")
|
| 165 | - | else |
| 165 | + | end |
| 166 | - | print("Not a command")
|
| 166 | + | end |
| 167 | - | end |
| 167 | + | |
| 168 | - | end |
| 168 | + | |
| 169 | clear() | |
| 170 | local url = readtextbox(" Please enter url ")
| |
| 171 | - | clear() |
| 171 | + | clear() |
| 172 | - | local url = readtextbox(" Please enter url ")
|
| 172 | + | print("Progress:")
|
| 173 | - | clear() |
| 173 | + | print("Downloading...")
|
| 174 | - | print("Progress:")
|
| 174 | + | local httpgot = http.get(url) |
| 175 | - | print("Downloading...")
|
| 175 | + | print("Done")
|
| 176 | - | local httpgot = http.get(url) |
| 176 | + | local name = readtextbox("Please name the file")
|
| 177 | - | print("Done")
|
| 177 | + | while fs.exists(path..name) do name = createNewName(name,3) end |
| 178 | - | local name = readtextbox("Please name the file")
|
| 178 | + | local file = fs.open(path..name,"w") |
| 179 | - | while fs.exists(path..name) do name = createNewName(name,3) end |
| 179 | + | file.write(httpgot.readAll()) |
| 180 | - | local file = fs.open(path..name,"w") |
| 180 | + | file.close() |
| 181 | - | file.write(httpgot.readAll()) |
| 181 | + | httpgot.close() |
| 182 | - | file.close() |
| 182 | + | clear() |
| 183 | - | httpgot.close() |
| 183 | + | buttonbox("File downloaded",{{"OK",colors.gray,colors.white}})
|
| 184 | - | clear() |
| 184 | + | |
| 185 | - | buttonbox("File downloaded",{{"OK",colors.gray,colors.white}})
|
| 185 | + | local function more(path) --draw ui |
| 186 | while true do | |
| 187 | - | local function more(path) |
| 187 | + | clear() |
| 188 | - | while true do |
| 188 | + | print("More actions:")
|
| 189 | - | clear() |
| 189 | + | term.setTextColor(colors.black) |
| 190 | - | --draw ui |
| 190 | + | drawLine(3,"Shell") |
| 191 | - | print("More actions:")
|
| 191 | + | drawLine(5,"Download file") |
| 192 | - | term.setTextColor(colors.black) |
| 192 | + | drawLine(7,"Paste from clipboard") |
| 193 | - | drawLine(3,"Shell") |
| 193 | + | drawLine(9,"Paste from pastebin.com") |
| 194 | - | drawLine(5,"Download file") |
| 194 | + | drawLine(11,"Open webpage") |
| 195 | - | drawLine(7,"Paste from clipboard") |
| 195 | + | drawLine(13,"New file...") |
| 196 | - | drawLine(9,"Paste from pastebin.com") |
| 196 | + | drawLine(15,"Go back") |
| 197 | - | drawLine(11,"Open webpage") |
| 197 | + | --get event |
| 198 | - | drawLine(13,"New file...") |
| 198 | + | local _,_,_,y = os.pullEvent() |
| 199 | - | drawLine(15,"Go back") |
| 199 | + | if y == 3 then |
| 200 | - | --get event |
| 200 | + | customShell() |
| 201 | - | local _,_,_,y = os.pullEvent() |
| 201 | + | elseif y == 5 then |
| 202 | - | if y == 3 then |
| 202 | + | downloadfile(path) |
| 203 | - | customShell() |
| 203 | + | elseif y == 7 then |
| 204 | - | elseif y == 5 then |
| 204 | + | if fs.exists(clipboard) then |
| 205 | - | downloadfile(path) |
| 205 | + | if clipboard:sub(#clipboard,#clipboard) == "/" then clipboard = clipboard:sub(1,#clipboard-1) end |
| 206 | - | elseif y == 7 then |
| 206 | + | local splitted = split(clipboard,"/") |
| 207 | - | if fs.exists(clipboard) then |
| 207 | + | local name = splitted[#splitted] |
| 208 | - | if clipboard:sub(#clipboard,#clipboard) == "/" then clipboard = clipboard:sub(1,#clipboard-1) end |
| 208 | + | while fs.exists(path..name) do name = createNewName(name,3) end |
| 209 | - | local splitted = split(clipboard,"/") |
| 209 | + | fs.copy(clipboard,path..name) |
| 210 | - | local name = splitted[#splitted] |
| 210 | + | buttonbox("Pasted as "..name.." in directory "..path,{{"OK",colors.gray,colors.white}})
|
| 211 | - | while fs.exists(path..name) do name = createNewName(name,3) end |
| 211 | + | else |
| 212 | - | fs.copy(clipboard,path..name) |
| 212 | + | buttonbox("File not found: "..clipboard,{{"OK",colors.gray,colors.white}})
|
| 213 | - | buttonbox("Pasted as "..name.." in directory "..path,{{"OK",colors.gray,colors.white}})
|
| 213 | + | end |
| 214 | - | else |
| 214 | + | elseif y == 9 then |
| 215 | - | buttonbox("File not found: "..clipboard,{{"OK",colors.gray,colors.white}})
|
| 215 | + | --paste from pastebin |
| 216 | - | end |
| 216 | + | local name |
| 217 | - | elseif y == 9 then |
| 217 | + | repeat |
| 218 | - | --paste from pastebin |
| 218 | + | name = readtextbox("Please enter a filename")
|
| 219 | - | local name |
| 219 | + | until not fs.exists(path..name) |
| 220 | - | repeat |
| 220 | + | local url = readtextbox("Please enter the pastebin URL")
|
| 221 | - | name = readtextbox("Please enter a filename")
|
| 221 | + | term.setCursorPos(1,1) |
| 222 | - | until not fs.exists(path..name) |
| 222 | + | term.setBackgroundColor(colors.white) |
| 223 | - | local url = readtextbox("Please enter the pastebin URL")
|
| 223 | + | term.setTextColor(colors.gray) |
| 224 | - | term.setCursorPos(1,1) |
| 224 | + | term.clear() |
| 225 | - | term.setBackgroundColor(colors.white) |
| 225 | + | print("Downloading file: ")
|
| 226 | - | term.setTextColor(colors.gray) |
| 226 | + | shell.run("pastebin get "..url.." "..path..name)
|
| 227 | - | term.clear() |
| 227 | + | print("Ended. Press any key to continue")
|
| 228 | - | print("Downloading file: ")
|
| 228 | + | os.pullEvent() |
| 229 | - | shell.run("pastebin get "..url.." "..path..name)
|
| 229 | + | elseif y == 11 then |
| 230 | - | print("Ended. Press any key to continue")
|
| 230 | + | --open webpage: |
| 231 | - | os.pullEvent() |
| 231 | + | local url = readtextbox(" Please enter the url ")
|
| 232 | - | elseif y == 11 then |
| 232 | + | local httpsth = http.get(url) |
| 233 | - | --open webpage: |
| 233 | + | local cont = httpsth.readAll() |
| 234 | - | local url = readtextbox(" Please enter the url ")
|
| 234 | + | httpsth.close() |
| 235 | - | local httpsth = http.get(url) |
| 235 | + | clear() |
| 236 | - | local cont = httpsth.readAll() |
| 236 | + | print(cont) |
| 237 | - | httpsth.close() |
| 237 | + | os.pullEvent() |
| 238 | - | clear() |
| 238 | + | elseif y == 13 then |
| 239 | - | print(cont) |
| 239 | + | --new file options |
| 240 | - | os.pullEvent() |
| 240 | + | clear() |
| 241 | - | elseif y == 13 then |
| 241 | + | local exc = buttonbox("Please choose a program",{{"Paint",colors.yellow,colors.black},{"Custom",colors.yellow,colors.black}})
|
| 242 | - | --new file options |
| 242 | + | clear() |
| 243 | - | clear() |
| 243 | + | local filename = readtextbox("Please enter a filename")
|
| 244 | - | local exc = buttonbox("Please choose a program",{{"Paint",colors.yellow,colors.black},{"Custom",colors.yellow,colors.black}})
|
| 244 | + | if not fs.exists(path..filename) then |
| 245 | - | clear() |
| 245 | + | if exc == 1 then |
| 246 | - | local filename = readtextbox("Please enter a filename")
|
| 246 | + | shell.run("paint",path..filename)
|
| 247 | - | if not fs.exists(path..filename) then |
| 247 | + | else |
| 248 | - | if exc == 1 then |
| 248 | + | clear() |
| 249 | - | shell.run("paint",path..filename)
|
| 249 | + | local prog = readtextbox("Please choose a program "..root)
|
| 250 | - | else |
| 250 | + | shell.run(prog,path..filename) |
| 251 | - | clear() |
| 251 | + | end |
| 252 | - | local prog = readtextbox("Please choose a program "..root)
|
| 252 | + | end |
| 253 | - | shell.run(prog,path..filename) |
| 253 | + | elseif y == 15 then |
| 254 | - | end |
| 254 | + | return |
| 255 | - | end |
| 255 | + | end |
| 256 | - | elseif y == 15 then |
| 256 | + | end |
| 257 | - | return |
| 257 | + | |
| 258 | - | end |
| 258 | + | |
| 259 | local scroll = 0 | |
| 260 | local selected = 0 | |
| 261 | local items | |
| 262 | local endprogram = false | |
| 263 | while not endprogram do | |
| 264 | repeat | |
| 265 | items = list(path,scroll,selected) | |
| 266 | drawMenu(path) | |
| 267 | - | repeat |
| 267 | + | if items[selected] ~= nil then popupMenu(fs.isDir(path..items[selected])) end |
| 268 | - | items = list(path,scroll,selected) |
| 268 | + | local e,b,x,y = os.pullEvent() |
| 269 | - | drawMenu(path) |
| 269 | + | if e == "mouse_click" then |
| 270 | - | if items[selected] ~= nil then |
| 270 | + | if items[selected] ~= nil and x > math.floor(w/2) and y < h-1 then |
| 271 | - | popupMenu(fs.isDir(path..items[selected])) |
| 271 | + | if fs.isDir(path..items[selected]) then |
| 272 | - | end |
| 272 | + | --folder specific |
| 273 | - | local e,b,x,y = os.pullEvent() |
| 273 | + | if y == 2 then |
| 274 | - | if e == "mouse_click" then |
| 274 | + | path = path .. items[selected] .. "/" |
| 275 | - | if items[selected] ~= nil and x > math.floor(w/2) and y < h-1 then |
| 275 | + | selected = 0 |
| 276 | - | if fs.isDir(path..items[selected]) then |
| 276 | + | scroll = 0 |
| 277 | - | --folder specific |
| 277 | + | history[#history+1] = path |
| 278 | - | if y == 2 then |
| 278 | + | elseif y == 3 then |
| 279 | - | path = path .. items[selected] .. "/" |
| 279 | + | local con = fs.list(path..items[selected].."/") |
| 280 | - | selected = 0 |
| 280 | + | for i=1,#con do |
| 281 | - | scroll = 0 |
| 281 | + | local altname = con[i] |
| 282 | - | history[#history+1] = path |
| 282 | + | while fs.exists(path..altname) do |
| 283 | - | end |
| 283 | + | altname = createNewName(altname) |
| 284 | - | if y == 3 then |
| 284 | + | end |
| 285 | - | local con = fs.list(path..items[selected].."/") |
| 285 | + | fs.move(path..items[selected].."/"..con[i],path..altname) |
| 286 | - | for i=1,#con do |
| 286 | + | end |
| 287 | - | local altname = con[i] |
| 287 | + | fs.delete(path..items[selected]) |
| 288 | - | while fs.exists(path..altname) do altname = createNewName(altname) end |
| 288 | + | selected = 0 |
| 289 | - | fs.move(path..items[selected].."/"..con[i],path..altname) |
| 289 | + | end |
| 290 | - | end |
| 290 | + | else |
| 291 | - | fs.delete(path..items[selected]) |
| 291 | + | --file specific |
| 292 | - | selected = 0 |
| 292 | + | if y == 2 then |
| 293 | - | end |
| 293 | + | --edit |
| 294 | - | else |
| 294 | + | shell.run("edit",path.. items[selected])
|
| 295 | - | --file specific |
| 295 | + | elseif y == 3 then |
| 296 | - | if y == 2 then |
| 296 | + | --open with paint |
| 297 | - | --edit |
| 297 | + | shell.run("paint",path..items[selected])
|
| 298 | - | shell.run("edit",path.. items[selected])
|
| 298 | + | elseif y == 4 then |
| 299 | - | elseif y == 3 then |
| 299 | + | --open with... |
| 300 | - | --open with paint |
| 300 | + | local program = readtextbox("Please choose a program: "..root)
|
| 301 | - | shell.run("paint",path..items[selected])
|
| 301 | + | if program ~= nil or program ~= "" then |
| 302 | - | elseif y == 4 then |
| 302 | + | shell.run(root..program,path..items[selected]) |
| 303 | - | --open with... |
| 303 | + | end |
| 304 | - | local program = readtextbox("Please choose a program: "..root)
|
| 304 | + | elseif y == 5 then |
| 305 | - | if program ~= nil or program ~= "" then |
| 305 | + | term.setBackgroundColor(colors.black) |
| 306 | - | shell.run(root..program,path..items[selected]) |
| 306 | + | term.setTextColor(colors.white) |
| 307 | - | end |
| 307 | + | term.clear() |
| 308 | - | elseif y == 5 then |
| 308 | + | term.setCursorPos(1,1) |
| 309 | - | term.setBackgroundColor(colors.black) |
| 309 | + | os.pullEvent() |
| 310 | - | term.setTextColor(colors.white) |
| 310 | + | shell.run(path..items[selected]) |
| 311 | - | term.clear() |
| 311 | + | sleep(0) |
| 312 | - | term.setCursorPos(1,1) |
| 312 | + | print("Press any key to continue")
|
| 313 | - | os.pullEvent() |
| 313 | + | os.pullEvent("key")
|
| 314 | - | shell.run(path..items[selected]) |
| 314 | + | elseif y == 6 then |
| 315 | - | print("Press any key to continue")
|
| 315 | + | local args = readtextbox("Please enter all arguments to run with!")
|
| 316 | - | os.pullEvent() |
| 316 | + | term.setBackgroundColor(colors.black) |
| 317 | - | elseif y == 6 then |
| 317 | + | term.setTextColor(colors.white) |
| 318 | - | local args = readtextbox("Please enter all arguments to run with!")
|
| 318 | + | term.clear() |
| 319 | - | term.setBackgroundColor(colors.black) |
| 319 | + | term.setCursorPos(1,1) |
| 320 | - | term.setTextColor(colors.white) |
| 320 | + | os.pullEvent() |
| 321 | - | term.clear() |
| 321 | + | shell.run(path..items[selected] .. " " .. args) |
| 322 | - | term.setCursorPos(1,1) |
| 322 | + | sleep(0) |
| 323 | - | os.pullEvent() |
| 323 | + | print("Press any key to continue")
|
| 324 | - | shell.run(path..items[selected] .. " " .. args) |
| 324 | + | os.pullEvent("key")
|
| 325 | - | print("Press any key to continue")
|
| 325 | + | end |
| 326 | - | os.pullEvent() |
| 326 | + | end |
| 327 | - | end |
| 327 | + | --universal |
| 328 | - | |
| 328 | + | if y == 7 then |
| 329 | - | end |
| 329 | + | local nname = readtextbox("Please enter the new name (empty = cancel)")
|
| 330 | - | --universal |
| 330 | + | if nname ~= nil or nname ~= "" then |
| 331 | - | if y == 7 then |
| 331 | + | if not fs.exists(path..nname) then |
| 332 | - | local nname = readtextbox("Please enter the new name (empty = cancel)")
|
| 332 | + | fs.move(path..items[selected],path..nname) |
| 333 | - | if nname ~= nil or nname ~= "" then |
| 333 | + | clear() |
| 334 | - | if not fs.exists(path..nname) then |
| 334 | + | buttonbox("Success",{{"OK",colors.gray,colors.white}})
|
| 335 | - | fs.move(path..items[selected],path..nname) |
| 335 | + | selected = 0 |
| 336 | - | clear() |
| 336 | + | else |
| 337 | - | buttonbox("Success",{{"OK",colors.gray,colors.white}})
|
| 337 | + | clear() |
| 338 | - | selected = 0 |
| 338 | + | buttonbox("File already exists",{{"OK",colors.gray,colors.white}})
|
| 339 | - | else |
| 339 | + | end |
| 340 | - | clear() |
| 340 | + | end |
| 341 | - | buttonbox("File already exists",{{"OK",colors.gray,colors.white}})
|
| 341 | + | elseif y == 8 then |
| 342 | - | end |
| 342 | + | --move |
| 343 | - | end |
| 343 | + | local dest = readtextbox("Move to (empty=cancel) "..root)
|
| 344 | - | end |
| 344 | + | if dest ~= nil or dest ~= "" then |
| 345 | - | if y == 8 then |
| 345 | + | if not fs.exists(root..dest) then |
| 346 | - | --move |
| 346 | + | fs.move(path..items[selected],root..dest) |
| 347 | - | local dest = readtextbox("Move to (empty=cancel) "..root)
|
| 347 | + | clear() |
| 348 | - | if dest ~= nil or dest ~= "" then |
| 348 | + | buttonbox("Success",{{"OK",colors.gray,colors.white}})
|
| 349 | - | if not fs.exists(root..dest) then |
| 349 | + | else |
| 350 | - | fs.move(path..items[selected],root..dest) |
| 350 | + | clear() |
| 351 | - | clear() |
| 351 | + | buttonbox("File already exists",{{"OK",colors.gray,colors.white}})
|
| 352 | - | buttonbox("Success",{{"OK",colors.gray,colors.white}})
|
| 352 | + | end |
| 353 | - | else |
| 353 | + | end |
| 354 | - | clear() |
| 354 | + | elseif y == 9 then |
| 355 | - | buttonbox("File already exists",{{"OK",colors.gray,colors.white}})
|
| 355 | + | --copy |
| 356 | - | end |
| 356 | + | local destination = readtextbox("Copy to (emplty=cancel) "..root)
|
| 357 | - | end |
| 357 | + | if destination ~= nil or destination ~= "" then |
| 358 | - | end |
| 358 | + | if not fs.exists(root..destination) then |
| 359 | - | if y == 9 then |
| 359 | + | fs.copy(path..items[selected],root..destination) |
| 360 | - | --copy |
| 360 | + | clear() |
| 361 | - | local destination = readtextbox("Copy to (emplty=cancel) "..root)
|
| 361 | + | buttonbox("Success",{{"OK",colors.gray,colors.white}})
|
| 362 | - | if destination ~= nil or destination ~= "" then |
| 362 | + | else |
| 363 | - | if not fs.exists(root..destination) then |
| 363 | + | clear() |
| 364 | - | fs.copy(path..items[selected],root..destination) |
| 364 | + | buttonbox("File already exists",{{"OK",colors.gray,colors.white}})
|
| 365 | - | clear() |
| 365 | + | end |
| 366 | - | buttonbox("Success",{{"OK",colors.gray,colors.white}})
|
| 366 | + | end |
| 367 | - | else |
| 367 | + | elseif y == 10 then |
| 368 | - | clear() |
| 368 | + | --clipboard |
| 369 | - | buttonbox("File already exists",{{"OK",colors.gray,colors.white}})
|
| 369 | + | clipboard = path .. items[selected] |
| 370 | - | end |
| 370 | + | elseif y == 11 then |
| 371 | - | end |
| 371 | + | --delete |
| 372 | - | end |
| 372 | + | local bclicked = buttonbox() |
| 373 | - | if y == 10 then |
| 373 | + | if bclicked == 1 then |
| 374 | - | --clipboard |
| 374 | + | fs.delete(path..items[selected]) |
| 375 | - | clipboard = path .. items[selected] |
| 375 | + | clear() |
| 376 | - | end |
| 376 | + | buttonbox("File deleted",{{"OK",colors.gray,colors.white}})
|
| 377 | - | if y == 11 then |
| 377 | + | selected = 0 |
| 378 | - | --delete |
| 378 | + | end |
| 379 | - | local bclicked = buttonbox() |
| 379 | + | elseif y == 12 then |
| 380 | - | if bclicked == 1 then |
| 380 | + | selected = 0 |
| 381 | - | fs.delete(path..items[selected]) |
| 381 | + | end |
| 382 | - | clear() |
| 382 | + | break |
| 383 | - | buttonbox("File deleted",{{"OK",colors.gray,colors.white}})
|
| 383 | + | end |
| 384 | - | selected = 0 |
| 384 | + | if y == h-1 then |
| 385 | - | end |
| 385 | + | local npath = readtextbox("Enter new path: (empty=cancel) "..root)
|
| 386 | - | end |
| 386 | + | if npath ~= nil and npath ~= "" and fs.isDir(root..npath) then |
| 387 | - | if y == 12 then |
| 387 | + | path = root .. npath |
| 388 | - | selected = 0 |
| 388 | + | selected = 0 |
| 389 | - | end |
| 389 | + | scroll = 0 |
| 390 | - | break |
| 390 | + | end |
| 391 | - | end |
| 391 | + | history[#history+1] = path |
| 392 | - | if y == h-1 then |
| 392 | + | elseif y == h then |
| 393 | - | local npath = readtextbox("Enter new path: (empty=cancel) "..root)
|
| 393 | + | --new |
| 394 | - | |
| 394 | + | if x > 1 and x < 7 then |
| 395 | - | if npath ~= nil and npath ~= "" and fs.isDir(root..npath) then |
| 395 | + | local name = readtextbox("Filename: (empty=cancel) ")
|
| 396 | - | path = root .. npath |
| 396 | + | if name ~= nil or name ~= "" then |
| 397 | - | selected = 0 |
| 397 | + | if not fs.exists(path..name) then |
| 398 | - | scroll = 0 |
| 398 | + | shell.run("edit",path..name)
|
| 399 | - | end |
| 399 | + | end |
| 400 | - | history[#history+1] = path |
| 400 | + | end |
| 401 | - | elseif y == h then |
| 401 | + | end |
| 402 | - | --new |
| 402 | + | if x > 7 and x < 15 then |
| 403 | - | if x > 1 and x < 7 then |
| 403 | + | local name = readtextbox("Directory's name: (empty=cancel)")
|
| 404 | - | local name = readtextbox("Filename: (empty=cancel) ")
|
| 404 | + | if name ~= nil or name ~= "" then |
| 405 | - | if name ~= nil or name ~= "" then |
| 405 | + | if not fs.exists(path..name) then |
| 406 | - | if not fs.exists(path..name) then |
| 406 | + | fs.makeDir(path..name) |
| 407 | - | shell.run("edit",path..name)
|
| 407 | + | end |
| 408 | - | end |
| 408 | + | end |
| 409 | - | end |
| 409 | + | end |
| 410 | - | end |
| 410 | + | if x > 15 and x < 22 then |
| 411 | - | if x > 7 and x < 15 then |
| 411 | + | --more... |
| 412 | - | local name = readtextbox("Directory's name: (empty=cancel)")
|
| 412 | + | more(path) |
| 413 | - | if name ~= nil or name ~= "" then |
| 413 | + | end |
| 414 | - | if not fs.exists(path..name) then |
| 414 | + | if x > 22 and x < 29 then |
| 415 | - | fs.makeDir(path..name) |
| 415 | + | path = root |
| 416 | - | end |
| 416 | + | history[#history+1] = path |
| 417 | - | end |
| 417 | + | selected = 0 |
| 418 | - | end |
| 418 | + | scroll = 0 |
| 419 | - | if x > 15 and x < 22 then |
| 419 | + | end |
| 420 | - | --more... |
| 420 | + | if (x > 29 and x < 36) and fs.exists(root .. home) then |
| 421 | - | more(path) |
| 421 | + | path = root .. home |
| 422 | - | end |
| 422 | + | history[#history+1] = path |
| 423 | - | if x > 22 and x < 29 then |
| 423 | + | selected = 0 |
| 424 | - | path = root |
| 424 | + | scroll = 0 |
| 425 | - | history[#history+1] = path |
| 425 | + | end |
| 426 | - | selected = 0 |
| 426 | + | if x > 36 and x < 43 then |
| 427 | - | scroll = 0 |
| 427 | + | while true do |
| 428 | - | end |
| 428 | + | history[#history] = nil |
| 429 | - | if x > 29 and x < 36 then |
| 429 | + | if #history == 0 then |
| 430 | - | if fs.exists(root .. home) then |
| 430 | + | if fs.exists(root..home) then |
| 431 | - | path = root .. home |
| 431 | + | path = root..home |
| 432 | - | history[#history+1] = path |
| 432 | + | history[1] = path |
| 433 | - | selected = 0 |
| 433 | + | elseif fs.exists(root) then |
| 434 | - | scroll = 0 |
| 434 | + | path = root |
| 435 | - | end |
| 435 | + | history[1] = path |
| 436 | - | end |
| 436 | + | else |
| 437 | - | if x > 36 and x < 43 then |
| 437 | + | error("Root folder deleted",0)
|
| 438 | - | while true do |
| 438 | + | end |
| 439 | - | history[#history] = nil |
| 439 | + | end |
| 440 | - | if #history == 0 then |
| 440 | + | if fs.exists(history[#history]) then |
| 441 | - | if fs.exists(root..home) then |
| 441 | + | path = history[#history] |
| 442 | - | path = root..home |
| 442 | + | break |
| 443 | - | history[1] = path |
| 443 | + | end |
| 444 | - | elseif fs.exists(root) then |
| 444 | + | end |
| 445 | - | path = root |
| 445 | + | selected = 0 |
| 446 | - | history[1] = path |
| 446 | + | end |
| 447 | - | else |
| 447 | + | if x > 43 and x < 50 then |
| 448 | - | error("Root folder deleted",0)
|
| 448 | + | term.setBackgroundColor(colors.black) |
| 449 | - | end |
| 449 | + | term.setTextColor(colors.white) |
| 450 | - | end |
| 450 | + | term.setCursorPos(1,1) |
| 451 | - | if fs.exists(history[#history]) then |
| 451 | + | term.clear() |
| 452 | - | path = history[#history] |
| 452 | + | return |
| 453 | - | break |
| 453 | + | end |
| 454 | - | end |
| 454 | + | elseif e == "mouse_scroll" then |
| 455 | - | end |
| 455 | + | if b == 1 and #items - scroll > h-2 then |
| 456 | - | selected = 0 |
| 456 | + | scroll = scroll + 1 |
| 457 | - | end |
| 457 | + | end |
| 458 | - | if x > 43 and x < 50 then |
| 458 | + | if b == -1 and scroll > 0 then |
| 459 | - | term.setBackgroundColor(colors.black) |
| 459 | + | scroll = scroll - 1 |
| 460 | - | term.setTextColor(colors.white) |
| 460 | + | end |
| 461 | - | term.setCursorPos(1,1) |
| 461 | + | else |
| 462 | - | term.clear() |
| 462 | + | if y + scroll == selected then |
| 463 | - | return |
| 463 | + | if items[selected] ~= nil then |
| 464 | - | end |
| 464 | + | if fs.isDir(path..items[selected]) then |
| 465 | - | else |
| 465 | + | path = path .. items[selected] .. "/" |
| 466 | - | if y + scroll == selected then |
| 466 | + | history[#history+1] = path |
| 467 | - | if items[selected] ~= nil then |
| 467 | + | selected = 0 |
| 468 | - | if fs.isDir(path..items[selected]) then |
| 468 | + | scroll = 0 |
| 469 | - | path = path .. items[selected] .. "/" |
| 469 | + | else |
| 470 | - | history[#history+1] = path |
| 470 | + | term.setBackgroundColor(colors.black) |
| 471 | - | selected = 0 |
| 471 | + | term.setTextColor(colors.white) |
| 472 | - | scroll = 0 |
| 472 | + | term.setCursorPos(1,1) |
| 473 | - | else |
| 473 | + | term.clear() |
| 474 | - | term.setBackgroundColor(colors.black) |
| 474 | + | shell.run(path..items[selected]) |
| 475 | - | term.setTextColor(colors.white) |
| 475 | + | end |
| 476 | - | term.setCursorPos(1,1) |
| 476 | + | end |
| 477 | - | term.clear() |
| 477 | + | else |
| 478 | - | shell.run(path..items[selected]) |
| 478 | + | selected = y + scroll |
| 479 | - | end |
| 479 | + | end |
| 480 | - | end |
| 480 | + | end |
| 481 | - | else |
| 481 | + | end |
| 482 | - | selected = y + scroll |
| 482 | + | until true |
| 483 | - | end |
| 483 | + |