Created
August 23, 2014 18:51
-
-
Save timia2109/79fdd25922a692e4d461 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local tArgs = { ... } | |
local fileMans = {} | |
local edit = 'edit' --or luaide ;D | |
local popup,workPath,saveFile | |
local xLen,yLen = term.getSize() | |
local function getFileMenu(isDir) | |
local waysActs = { | |
['Delete'] = function(pFile) if --ask if the person is shure then fs.delete(fs.combine(shell.dir(),pFile)) end end, | |
['Rename'] = function(pFile) fs.move(pFile,--MUST GET THE NEW NAME) end, | |
['Copy'] = function(pFile) saveFile = '0'..fs.combine(shell.dir(),pFile) end, | |
['Cut'] = function(pFile) saveFile = '1'..fs.combine(shell.dir(),pFile) end, | |
['Back'] = function() end, | |
} | |
local ways = {} | |
if isDir then | |
waysActs['Open'] = function(pFile) shell.setDir(pFile) listFolder(pFile,1) end | |
ways[1] = 'Open' | |
else | |
waysActs['Run'] = function(pFile) shell.run(pFile) end | |
ways[1] = 'Run' | |
waysActs['Run with Args'] = function(pFile) shell.run(pFile,--ARGS INPUT) end | |
waysActs['Edit'] = function(pFile) shell.run(edit,pFile) end | |
waysActs['Upload to Pastebin'] = function(pFile) shell.run('pastebin','put',pFile) end | |
end | |
if saveFile then | |
waysActs['Paste'] = function() if saveFile:sub(1,1) == '0' then fs.copy(saveFile:sub(2,saveFile:len()),shell.dir()) end end | |
end | |
for i,v in pairs(waysActs) do | |
table.insert(ways,i) | |
end | |
ways[#ways+1] = 'Back' | |
return ways,waysActs | |
end | |
fileMans[true] = function() | |
function isDir(pWat) | |
return fs.isDir(workPath..'/'..pWat) | |
end | |
function changePath() | |
--YOU MUST GET nPath | |
--like local nPath = read() | |
if not nPath then | |
nPath = "/" | |
end | |
if fs.isDir(nPath) then | |
listFolder(nPath,1) | |
else | |
error("DIR DIDNT EXISTS!",0) | |
listFolder(workPath,1) | |
end | |
end | |
function rmenu(pFile) | |
local ways,waysActs = getFileMenu(fs.isDir(pFile)) | |
--The rClick Menu. Look in orgin for handling | |
end | |
function listFolder(pFolder,pSite) | |
if pFolder == '..' or pFolder == "/.." then | |
pFolder = '/' | |
end | |
shell.setDir(pFolder) | |
workPath = pFolder | |
workCount = pSite | |
local flist = fs.list(pFolder) | |
local dirs = {} | |
local files = {} | |
for _,v in ipairs(flist) do | |
if fs.isDir(pFolder..'/'..v) then | |
table.insert(dirs,v) | |
else | |
table.insert(files,v) | |
end | |
end | |
flist = {} | |
for _,v in ipairs(dirs) do | |
table.insert(flist,v) | |
end | |
for _,v in ipairs(files) do | |
table.insert(flist,v) | |
end | |
end | |
local openAtStart | |
if tArgs[1] then | |
openAtStart = tArgs[1] | |
else | |
openAtStart = shell.dir() | |
end | |
listFolder(openAtStart,1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment