Advertisement
Guest User

ccfm

a guest
Oct 31st, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. --Chaos Console File Manager
  2. --By Metallist | Under GNU GPLv3
  3. --Version 1.0
  4. --Author's Skype : metalgamestudio
  5.  
  6. local dir
  7. local pos = 1
  8. local w,h = term.getSize()
  9. local filename = ""
  10. local screen = 0
  11.  
  12. local col = {
  13.   ["bg"] = colours.red,
  14.   ["bar"] = colours.gray,
  15.   ["btn"] = colours.black,
  16.   ["txt"] = colours.black,
  17.   ["bt"] = colours.white
  18. }
  19.  
  20. local ucc = {
  21.   ["bg"] = colours.white,
  22.   ["bar"] = colours.white,
  23.   ["btn"] = colours.black,
  24.   ["txt"] = colours.black,
  25.   ["bt"] = colours.white
  26. }
  27. if not term.isColor() then col = ucc end
  28.  
  29. function redraw()
  30.   local tfiles = fs.list(dir)
  31.   term.setBackgroundColor(col["bg"])
  32.   term.clear()
  33.   term.setCursorPos(1,1)
  34.   term.setBackgroundColor(col["bar"])
  35.   write(dir.." ")
  36.   term.setCursorPos(w-5,1)
  37.   term.setBackgroundCol(col["btn"])
  38.   term.setTextColor(col["bt"])
  39.   write("X")
  40.   term.setTextColor(col["txt"])
  41.   if screen == 0 then
  42.     term.setCursorPos(w-1,1)
  43.     term.setBackgroundColor(col["btn"])
  44.     term.setTextColor(col["bt"])
  45.     term.write("^")
  46.     term.setTextColor(col["txt"])
  47.     term.setBackgroundColor(col["bg"])
  48.     for i = pos, h - 2 do
  49.       if tfiles[i] == nil then break end
  50.       term.setCursorPos(1,i+1)
  51.       write(tfiles[i])
  52.       local type = ""
  53.       if fs.isDir(tfiles[i]) then
  54.         type = "folder"
  55.       else
  56.         local sp = split(tfiles[i], ".")
  57.         if #sp == 1 then
  58.           type = "executable"
  59.         else
  60.           type = sp[#sp] .. " file"
  61.         end
  62.       end
  63.       term.setCursorPos(20,i+1)
  64.       write(type)
  65.     end
  66.     term.setCursorPos(w - 1, h)
  67.     term.setbackgroundColor(col["btn"])
  68.     write(" ")
  69.   elseif screen == 1 then
  70.    
  71.   end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement