Advertisement
Redxone

[ComputerCraft] - Nova Explore

Jun 3rd, 2016
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 33.78 KB | None | 0 0
  1. --====================================================
  2. --]] Nova Explore and all file apis created by
  3. --]] Lewisk3 CEO of Nova, all rights reservered
  4. --]] DO NOT REDISTRIBUTE without the permission
  5. --]] of Nova, Editing and/or "rebranding" is prohibited.
  6. --]] Any copys found outside the permission of Nova
  7. --]] will be taken and money will be due to the rights
  8. --]] of Nova Technologys
  9. -------------------------------------------------------
  10. --=]      We have the rights to all the above       [=-      
  11. --=====================================================
  12. --]] Determine OS and load apis accordingly
  13. os.loadAPI(shell.resolveProgram("NovaAPI"))
  14. local w, h = term.getSize()
  15. local sbc = term.setBackgroundColor
  16. local stc = term.setTextColor
  17. local scp = term.setCursorPos
  18. local clr = term.clear
  19. local clrln = term.clearLine
  20. local actionkeydown = false
  21. local actionkey = keys.leftCtrl
  22. local multiselecting = false
  23. local diskside = "right"
  24. files_selected = {}
  25. local archiver = ""
  26. local pa = paintutils
  27. local pinnednames = {}
  28. local innova = true
  29. local iscrossbow = false
  30.  
  31. --]] Define variables
  32. local file_selected = 0
  33. local files = {}
  34. -- Path isnt locked
  35. local path = NovaAPI.newpath("/")
  36. NovaAPI.setActive(false)
  37. NovaAPI.setInput(path:getraw())
  38. local fileoffs = 0
  39. local sideoffs = 0
  40. local sidemax = h-1
  41. local filemax = h
  42. local searching = false
  43. local selectedside = 0
  44. local search = ""
  45. local pathsearch = "/"
  46. local clipboard = {}
  47. local inmenu = false
  48. local inmenutype = {}
  49. local drawingmenu = {}
  50. local inmenux, inmenuy = 1, 4
  51. local sideitems = {}
  52. local pinslocation = ".novapins"
  53. local icons = {
  54.     folder = "&e[=]",
  55.     file = "&7-~-",
  56.     executable = "&8:&7=&8:",
  57.     game = "&4-&7=&8]",
  58.     zip = "&5[&1=&2]",
  59.     paint = "&2~&4* ",
  60.     pin = "&7<&8 ",
  61.     disk= "&8:&4^&8:"
  62. }
  63. --]] Menus
  64. filemenu = {
  65.      {n="Open    ",func=function(file) openHref(path:getraw() .. file.n) end},
  66.      {n="Edit    ",func=function(file)
  67.         editfile(path:getraw() .. file.n)
  68.      end},
  69.      {n="Open as ",func=function(file)
  70.         local ans = NovaAPI.openYesNo("Open File As. ","Select open option.*",novaex_redraw,"With", "Args")
  71.         if(ans == 1)then -- open with file
  72.             local openfile = NovaAPI.openReadDialog("Open with another file. ",novaex_redraw)
  73.             if(file ~= "")then
  74.                 runFile(openfile,path:getraw() .. file.n,true)
  75.             end
  76.         elseif(ans == 2)then -- open with arguments
  77.             local args = NovaAPI.openReadDialog("Open with arguments. ",novaex_redraw)
  78.             runFile(path:getraw() .. file.n,args,true)
  79.         end
  80.      end},
  81.      {n="Rename  ",relies=function(file)
  82.         return file.t ~= "disk"
  83.      end,
  84.      func=function(file)
  85.             local sid = getSelectedFile()
  86.             sbc(colors.lightGray)
  87.             scp(23,(sid-fileoffs)+4)
  88.             write(string.rep(" ",17))
  89.             scp(23,(sid-fileoffs)+4)
  90.             local newname = NovaAPI.readEx(17,false,file.n)
  91.             renameFile(path:getraw(),file.n,newname)
  92.      end},
  93.      {n="Extract ",relies=function(file) return file.t == "zip" end,
  94.      func=function(file)
  95.          local eto = NovaAPI.openReadDialog("Extract to: ",novaex_redraw)
  96.          local ans = NovaAPI.openYesNo("Extract ", "Extract contents of * " .. file.n .. " to: " .. eto .. "? ",novaex_redraw)
  97.          if(ans == 1)then
  98.              NovaAPI.extract(path:getraw() .. file.n,eto)
  99.              ans = NovaAPI.openYesNo("Extract ", "Extracted to: " .. eto .. "* Open location?",novaex_redraw)
  100.              if(ans == 1)then
  101.                  path:set(eto)
  102.                  getfiles()
  103.                  undrawFiles()
  104.                  drawFiles()
  105.              end
  106.          end
  107.      end},
  108.      {n="Archive ",relies=function(file) return file.t ~= "zip" end,
  109.      func=function(file)
  110.          local eto = NovaAPI.openReadDialog("Export archive to: ",novaex_redraw)
  111.          if(NovaAPI.archive(path:getraw() .. file.n,eto))then
  112.              NovaAPI.notify("Archive","Folder/file successfully * archived. ",novaex_redraw)
  113.          else
  114.              NovaAPI.notify("Archive","Failed to archive folder/file. ",novaex_redraw)
  115.          end
  116.      end},
  117.      {n="Cut     ",relies=function(file)
  118.         return not fs.isReadOnly(path:getraw() .. file.n)
  119.      end,func=function(file)
  120.         setClipboard(path:getraw() .. file.n, file.n, "cut")
  121.      end},
  122.      {n="Copy    ",func=function(file)
  123.         setClipboard(path:getraw() .. file.n, file.n, "copy")
  124.      end},
  125.      {n="Paste   ",relies=function(file)
  126.         return clipboard.name ~= nil and
  127.             not fs.isReadOnly(path:getraw() .. file.n)
  128.      end,
  129.      func=function(file)
  130.         pasteFile(path:getraw())
  131.      end},
  132.      {n="Pin item",relies=function(file)
  133.         return not isPinnedItem(path:getraw() .. file.n) end,
  134.      func=function(file)
  135.          addPinnedFile(
  136.             icons[file.t] .. " &r" .. file.n,file.t,path:getraw() .. file.n
  137.          )
  138.      end},
  139.      {n="Unpin   ",relies=function(file)
  140.         return isPinnedItem(path:getraw() .. file.n) end,
  141.      func=function(file)
  142.          removePinnedFile(path:getraw() .. file.n)
  143.      end},
  144.      {n="Delete  ",relies=function(file)
  145.          return not fs.isReadOnly(path:getraw() .. file.n) and
  146.             not (file.t == "disk" and peripheral.find("drive"))
  147.      end,func=function(file)
  148.             local ans = NovaAPI.openYesNo("File deletion. ","Confirm &4deletion&r of *" .. file.n,novaex_redraw)
  149.             if(ans == 1)then
  150.                 deleteFile(path:getraw() .. file.n)
  151.             end
  152.      end},
  153. }
  154. sidemenu = {
  155.      {n="Open   ",func=function() openHref(getSelectedSideItem().href) end},
  156.      {n="Rename ",
  157.      func=function(file)
  158.             local sid = getSelectedSide()
  159.             scp(5,(sid-sideoffs)+4)
  160.             sbc(colors.lightGray)
  161.             write(string.rep(" ",11))
  162.             scp(5,(sid-sideoffs)+4)
  163.             local newname = NovaAPI.readEx(9,false)
  164.             renameSideItem(getSelectedSide(),newname)
  165.      end},
  166.      {n="Unpin  ",relies=function() return getSelectedSide() >= 8 end,
  167.      func=function(file)
  168.         removePinnedFile(getSelectedSideItem().href)
  169.      end},
  170.      {n="Up     ",relies=function()
  171.             return getSideItem(getSelectedSide()-1).t ~= nil and  
  172.                    getSideItem(getSelectedSide()-1).t ~= "text"
  173.             end,
  174.      func=function(file)
  175.             moveSideItem(getSelectedSide(),-1)
  176.      end},
  177.      {n="Down   ",relies=function()
  178.         return (getSelectedSide() < getSideAmmount()) and
  179.                (getSideItem(getSelectedSide()+1).n ~= nil) and
  180.                (getSideItem(getSelectedSide()+1).t ~= "text")
  181.      end,
  182.      func=function(file)
  183.         moveSideItem(getSelectedSide(),1)
  184.      end},
  185. }
  186. emptymenu = {
  187.     {n="New Folder ",func=function()
  188.         local file = NovaAPI.openReadDialog("New Folder",novaex_redraw)
  189.         newFileFolder("folder",path:getraw(),file)
  190.     end},
  191.     {n="New File   ",func=function()
  192.         local file = NovaAPI.openReadDialog("New File",novaex_redraw)
  193.         newFileFolder("file",path:getraw(),file)
  194.     end},
  195.      {n="Paste      ",relies=function()
  196.         return clipboard.name ~= nil and
  197.             not fs.isReadOnly(path:getraw())
  198.      end,
  199.      func=function()
  200.         pasteFile(path:getraw())
  201.      end},
  202.      {n="Test Crash ",func=function() error("Lol get rekt!") end},
  203. }
  204. foldermenu = {
  205.      filemenu[1],
  206.      filemenu[4],
  207.      filemenu[6],
  208.      filemenu[7],
  209.      filemenu[8],
  210.      filemenu[9],
  211.      {n="Pin item",relies=function(file)
  212.         return not isPinnedItem(path:getraw() .. file.n) end,
  213.      func=function(file)
  214.          addPinnedFile(
  215.             icons[file.t] .. " &r" .. file.n,file.t,path:getraw() .. file.n
  216.          )
  217.      end},
  218.      filemenu[11],
  219.      {n="Eject   ",relies=function(file)
  220.          return (file.t == "disk" and peripheral.find("drive"))
  221.      end,func=function(file)
  222.             disk.eject(getDiskside())
  223.      end},
  224.      filemenu[12],
  225. }
  226. if(iscrossbow)then
  227.     sideitems = {
  228.         {n='&5* &rQuick Access',t='text'},
  229.         {n=' ',t='text'},
  230.         {n=icons.folder..' &rPrograms',t='folder',href="CrossBow/programs"},
  231.         {n=icons.folder..' &rGames',t='folder',href="CrossBow/games"},
  232.         {n=' ',t='text'},
  233.         {n=' ',t='text'},
  234.         {n=icons.pin .. "&rPinned Items",t='text'},
  235.         {n=' ',t='text'},
  236.         {n=icons.game..' &rGameOfLife',t='game',href="CrossBow/games/GameOfLife"},
  237.         {n=icons.game..' &r2048',t='game',href="CrossBow/games/2048"},
  238.         {n=icons.folder..' &5Apis',t='folder',href="CrossBow/apis"},
  239.     }
  240. else
  241.     sideitems = {
  242.         {n='&5* &rQuick Access',t='text'},
  243.         {n=' ',t='text'},
  244.         {n=icons.folder..' &rPrograms',t='folder',href="rom/programs"},
  245.         {n=icons.folder..' &rGames',t='folder',href="rom/programs/fun"},
  246.         {n=' ',t='text'},
  247.         {n=' ',t='text'},
  248.         {n=icons.pin .. "&rPinned Items",t='text'},
  249.         {n=' ',t='text'},
  250.         {n=icons.game..' &2Worm',t='game',href="rom/programs/fun/worm"},
  251.         {n=icons.game..' &8Redirection',t='game',href="rom/programs/fun/advanced/redirection"},
  252.     }
  253. end
  254. --]] Get functions and file definitions
  255. local pinnednames = {}
  256. if(iscrossbow)then
  257.     pinslocation = "configs/novapins"
  258. end
  259.  
  260. function writexy(text,x,y)
  261.   term.setCursorPos(x,y)
  262.   term.write(text)
  263. end
  264.  
  265. function writec(text)
  266.   local w, h = term.getSize()
  267.   term.setCursorPos(w/2 - #text/2, (h/2)- 1)
  268.   term.write(text)
  269. end
  270.  
  271. function writecy(text,y)
  272.     local w,_ = term.getSize()
  273.     term.setCursorPos(w/2 - #text/2, y)
  274.     term.write(text)
  275. end
  276.  
  277. function getDiskside() return diskside end
  278. function getWorkingDir()
  279.     return fs.getDir(shell.getRunningProgram()) .. "/"
  280. end
  281. function getConfigPinnedItems()
  282.     if(fs.exists(getWorkingDir() .. pinslocation))then
  283.         local pfile = (getWorkingDir() .. pinslocation)
  284.         local itemspinned = textutils.unserialize(NovaAPI.file_readAll(pfile))
  285.         for i = 1, #itemspinned do
  286.             sideitems[8+(i-1)] = itemspinned[i]
  287.         end
  288.         getPinnedNames()
  289.     else
  290.         local writeitems = {}
  291.         for i = 8, #sideitems do
  292.             writeitems[#writeitems+1] = sideitems[i]
  293.         end
  294.         NovaAPI.file_write(getWorkingDir() .. pinslocation,textutils.serialize(writeitems))
  295.         getConfigPinnedItems()
  296.     end
  297. end
  298. function saveConfigPinnedItems()
  299.     local writeitems = {}
  300.     for i = 8, #sideitems do
  301.         writeitems[#writeitems+1] = sideitems[i]
  302.     end
  303.     if(fs.exists(getWorkingDir() .. pinslocation))then
  304.         NovaAPI.file_write(getWorkingDir() .. pinslocation,textutils.serialize(writeitems))
  305.     end
  306. end
  307.  
  308. function isPinnedItem(path)
  309.     return pinnednames[formatPinPath(path)]
  310. end
  311.  
  312. -- Icon drawing
  313.  
  314.  
  315. function formatPinPath(path)
  316.     local npath  = NovaAPI.newpath(path)
  317.     local pathtbl={}
  318.     for str in string.gmatch(path, "([^/]+)") do
  319.         pathtbl[#pathtbl+1] = str  
  320.     end
  321.     fname = pathtbl[#pathtbl]
  322.     npath:goback(1)
  323.  
  324.     if(path:sub(1,1) == "/" and #npath:getraw() > 1)then path = path:sub(2,#path) end
  325.     if(#npath:getraw() <= 1)then path = "/" .. fname end
  326.     return path
  327. end
  328.  
  329. function novaex_redraw()
  330.     undrawFiles()
  331.     getfiles()
  332.     drawMain()
  333.     drawFiles()
  334. end
  335.  
  336. function moveSideItem(id,to)
  337.     local moveitem = sideitems[id]
  338.     local toitem = sideitems[id+to]
  339.  
  340.     sideitems[id+to] = moveitem
  341.     sideitems[id] = toitem
  342.     selectedside = selectedside + to
  343.     drawSideBar()
  344. end
  345. function deleteFile(file)
  346.     file_selected = 0
  347.     fs.delete(file)
  348.     undrawFiles()
  349.     getfiles()
  350.     drawFiles()
  351. end
  352. function newFileFolder(forf,path,file)
  353.     if(file == "" or file:find(" "))then return false end
  354.     if(not fs.exists(path .. file))then
  355.         if(forf == "folder")then
  356.             if(file:sub(1,4) == "disk")then
  357.                 NovaAPI.notify("Creation Error.","Cannot create disk directory!",novaex_redraw)
  358.                 return false
  359.             end
  360.             fs.makeDir(path .. file)
  361.         elseif(forf == "file")then
  362.             local f = fs.open(path .. file,"w")
  363.             f.write("")
  364.             f.close()
  365.         end
  366.         getfiles()
  367.         drawFiles()
  368.     else
  369.         NovaAPI.notify("Creation Error.","File or folder already exists.",novaex_redraw)
  370.     end
  371. end
  372. function drawPathSearch()
  373.     sbc(colors.white)
  374.     writexy(string.rep(" ",w-24),12,2)
  375.     sbc(colors.white)
  376.     stc(colors.black)
  377.     scp(13,2)
  378.     if(#path:getraw() > 25)then
  379.         local dif = #path:getraw() - 25
  380.         write(pathsearch:sub(dif,#path:getraw()))
  381.     else
  382.         write(pathsearch)
  383.     end
  384. end
  385.  
  386. function renameSideItem(id,nname)
  387.      if(nname ~= "")then
  388.          nname = icons[sideitems[id].t] .. "&r " .. nname
  389.          sideitems[id].n = nname
  390.          saveConfigPinnedItems()
  391.      end
  392.        drawSideBar()
  393. end
  394. function getSideItemType(id)
  395.     return sideitems[id].t
  396. end
  397. function getSideItem(id)
  398.     return sideitems[id]
  399. end
  400. function addPinnedFile(name,type,link)
  401.     sideitems[#sideitems+1] = {n=name,t=type,href=formatPinPath(link)}
  402.     pinnednames[formatPinPath(link)] = true
  403.     saveConfigPinnedItems()
  404.     drawFiles()
  405.     drawSideBar()
  406. end
  407. function setClipboard(p,n,t)
  408.     clipboard = {path=p,name=n,type=t}
  409.     if(t == "cut")then
  410.         drawFiles()
  411.     end
  412. end
  413. function getSelectedSideItem()
  414.     return sideitems[selectedside]
  415. end
  416. function getSelectedSide()
  417.     return selectedside
  418. end
  419. function getSideAmmount()
  420.     return #sideitems
  421. end
  422. function getSelectedFile()
  423.     return file_selected
  424. end
  425. function getnamedpins()
  426.     return pinnednames
  427. end
  428. function getClipboard()
  429.     return clipboard
  430. end
  431. function removePinnedFile(link)
  432.     for i = 8, #sideitems do
  433.         if(sideitems[i].href == formatPinPath(link))then
  434.             table.remove(sideitems,i)
  435.             getPinnedNames()
  436.             saveConfigPinnedItems()
  437.             break
  438.         end
  439.     end
  440.     selectedside = 0
  441.     drawFiles()
  442.     drawSideBar()
  443. end
  444. function getPinnedNames()
  445.     pinnednames = {}
  446.     for i = 1, #sideitems do
  447.         if(sideitems[i].t ~= "text")then
  448.             pinnednames[sideitems[i].href] = true
  449.         end
  450.     end
  451. end
  452.  
  453. --]] Get files in directory
  454.  
  455. function getfiles()
  456.     files = {}
  457.     local folders = {}
  458.     for k , v in pairs(fs.list(path:getraw())) do
  459.         if(fs.isDir(path:getraw() .. v) and (path:getraw() .. v):find(search) )then
  460.             local spt = 'folder'
  461.             if(v:sub(1,4) == "disk")then
  462.                 if(#v > 4)then
  463.                     if(tonumber(v:sub(5,#v)) ~= nil)then
  464.                         spt = "disk"
  465.                     end
  466.                 else
  467.                     spt = "disk"
  468.                 end
  469.             end
  470.             folders[#folders+1] = {n=v,t=spt}
  471.         else if( v:find(search) )then
  472.             local nt = 'file'
  473.             if(v:sub(#v-3,#v) == '.zip')then nt = 'zip' end
  474.             if(v:sub(#v-3,#v) == '.exe')then nt = 'exe' end
  475.             if(path:getraw():find("CrossBow/games") or
  476.                 path:getraw():find("rom/programs/fun"))then nt = "game" end
  477.             if(path:getraw():find("CrossBow/programs"))then nt = "executable" end
  478.             if(NovaAPI.isFileImage(path:getraw() .. v))then nt = "paint" end
  479.             files[#files+1] = {n=v,t=nt}
  480.         end
  481.         end
  482.     end
  483.     -- Sort folders before files
  484.     for k,v in pairs(files) do
  485.         table.insert(folders, v)
  486.     end
  487.     files = folders
  488. end
  489.  
  490. --]] Draw program layout
  491. function drawSideBar()
  492.     term.current().setVisible(false)
  493.     sbc(colors.white)
  494.     pa.drawFilledBox(0,4,17,h,colors.white)
  495.     sbc(1,1)
  496.     local loopam = #sideitems
  497.     if(#sideitems > h-5)then
  498.         loopam = (h-5)+sideoffs
  499.     end
  500.     for i = 1+sideoffs, loopam do
  501.         if(i-sideoffs < sidemax)then
  502.             if(sideitems[i] ~= nil)then
  503.                 scp(1,(i-sideoffs)+4)
  504.                 write(string.rep(" ",16))
  505.                 if(selectedside == i)then
  506.                     sbc(colors.lightGray)
  507.                 else
  508.                     sbc(colors.white)
  509.                 end
  510.                 NovaAPI.colorwrite(sideitems[i].n,12,1,(i-sideoffs)+4)
  511.             end
  512.         end
  513.     end
  514.     pa.drawBox(17,4,17,h,colors.gray)
  515.     pa.drawBox(1,h,17,h,colors.gray)
  516.     pa.drawBox(16,4,16,h-1,colors.lightGray)
  517.     stc(colors.gray)
  518.     writexy("^",16,4)
  519.     writexy("v",16,h-1)
  520.     term.current().setVisible(true)
  521. end
  522. -- Deprecidated
  523. function drawFile(ind)
  524.      -- Draw selected files
  525.     term.current().setVisible(false)
  526.     sbc(colors.white)
  527.     stc(colors.black)
  528.       if(ind <= filemax)then
  529.             scp(19,ind+fileoffs)
  530.             write(string.rep(" ",30))
  531.             NovaAPI.colorwrite(icons[files[ind].t] .. " &r" .. files[ind].n ,12,19,ind,file_selected == ind)
  532.             scp(40,ind+fileoffs)
  533.          if(not fs.isDir(path:getraw() .. files[ind].n))then
  534.                 write(tostring(fs.getSize(path:getraw() .. files[ind].n) / 1000):sub(1,4) .. "KB")
  535.          end
  536.       end
  537.       term.current().setVisible(true)
  538.       drawPathSearch()
  539. end
  540. function undrawFiles()
  541.     pa.drawFilledBox(18,4,w-1,h,colors.white)
  542. end
  543. function drawFilePath()
  544.     sbc(colors.white)
  545.     writexy(string.rep(" ",w-24),12,2)
  546.     sbc(colors.white)
  547.     stc(colors.black)
  548.     scp(13,2)
  549.     if(#path:getraw() > 25)then
  550.         local dif = #path:getraw() - 25
  551.         write(path:getraw():sub(dif,#path:getraw()))
  552.     else
  553.         write(path:getraw())
  554.     end
  555.  
  556. end
  557. function drawFiles()
  558.     term.current().setVisible(false)
  559.     sbc(colors.white)
  560.     stc(colors.black)
  561.     drawFilePath()
  562.      scp(23,4)
  563.      stc(colors.lightGray)
  564.      write("Name")
  565.      scp(40,4)
  566.      write("Size")
  567.     if(#files == 0)then
  568.         scp(25,5)
  569.         stc(colors.lightGray)
  570.         if(search ~= "")then
  571.             scp(20,5)
  572.             write("No items matched your search. ")
  573.         else
  574.             write("This folder is empty. ")
  575.         end
  576.     end
  577.     local loopam = #files
  578.     if(#files > h-4)then
  579.         loopam = (h-4)+fileoffs
  580.     end
  581.      for i = 1+fileoffs, loopam do
  582.           if(i-fileoffs <= filemax)then
  583.             if(files[i].n ~= nil)then
  584.              scp(19,(i-fileoffs)+4)
  585.              write(string.rep(" ",30))
  586.              local namecolor = " &r"
  587.              local drawname = files[i].n
  588.              if(path:getraw() .. files[i].n == clipboard.path and clipboard.type == "cut")then
  589.                 namecolor = " &7"
  590.             end
  591.              if(isPinnedItem(path:getraw() .. files[i].n))then
  592.                  namecolor = " &b"
  593.                 if(path:getraw() .. files[i].n == clipboard.path and clipboard.type == "cut")then
  594.                     namecolor = " &e"
  595.                 end
  596.              end
  597.              local selected = (file_selected == i)
  598.              if(multiselecting)then
  599.                 for s = 1, #files_selected do
  600.                     if(files_selected[s].n == files[i].n and
  601.                         path:getraw() == files_selected[s].p)then
  602.                         if(clipboard.type == "cut")then
  603.                             namecolor = " &7"
  604.                             if(isPinnedItem(path:getraw() .. files[i].n))then
  605.                                 namecolor = " &e"
  606.                             end
  607.                         end
  608.                         selected = true
  609.                     end
  610.                 end
  611.              end
  612.  
  613.              local bcol = colors.white
  614.              if(selected)then bcol = colors.lightBlue end
  615.              NovaAPI.colorwrite(icons[files[i].t] .. namecolor .. drawname .."&r",12,19,(i-fileoffs)+4,bcol)
  616.              if(search ~= "" )then
  617.                 local foundletters = ""
  618.                  for x = 1, #files[i].n do
  619.                      if(search:find(files[i].n:sub(x,x)) and not foundletters:find(files[i].n:sub(x,x)) )then
  620.                          foundletters = foundletters .. files[i].n:sub(x,x)
  621.                          scp( (22)+x, (i-fileoffs)+4) -- hardcoded for 3 wide icons
  622.                          sbc(colors.yellow)
  623.                          write(files[i].n:sub(x,x))
  624.                          sbc(colors.white)
  625.                      end
  626.                  end
  627.              end
  628.              scp(40,(i-fileoffs)+4)
  629.              if(not fs.isDir(path:getraw() .. files[i].n))then
  630.                 write(tostring(fs.getSize(path:getraw() .. files[i].n) / 1000):sub(1,4) .. "KB")
  631.              end
  632.           end
  633.          end
  634.      end
  635.      term.current().setVisible(true)
  636. end
  637. function renameFile(path,name,nname)
  638.     local odir = shell.dir()
  639.     shell.setDir("")
  640.     if(not fs.exists(path .. nname) and nname ~= "" and not nname:find(" "))then
  641.         if(nname:sub(1,4) == "disk" and fs.isDir(path .. name))then
  642.             shell.setDir(odir)
  643.             NovaAPI.notify("Rename Error.","Cannot rename directory to * disk!",novaex_redraw)
  644.             return false
  645.         end
  646.         fs.move(path .. name, path .. nname)
  647.         getfiles()
  648.     elseif(nname ~= "" and not nname:find(" "))then
  649.         NovaAPI.notify("Couldn't rename file.","File with name:  * ".. nname .. ", already exists.",novaex_redraw)
  650.     end
  651.     drawFiles()
  652.     shell.setDir(odir)
  653. end
  654. function runFile(fpath,args,noclick)
  655.     local odir = shell.dir()
  656.     sbc(colors.black)
  657.     stc(colors.white)
  658.     clr()
  659.     scp(1,1)
  660.     shell.setDir("")
  661.     if(NovaAPI.isFileImage(fpath))then
  662.         args = fpath
  663.         fpath = "paint"
  664.         noclick = true
  665.     end
  666.     if(shell.resolveProgram(fpath))then
  667.         if(fs.exists(shell.resolveProgram(fpath)))then
  668.             shell.run(fpath,args)
  669.             if(not noclick)then
  670.                 writecy("Click any where to return to NovaBrowse. ",9)
  671.                 os.pullEvent("mouse_click")
  672.             end
  673.         else
  674.             NovaAPI.notify("Open file.", "&4File not found. ",novaex_redraw)
  675.         end
  676.     end
  677.     search = ""
  678.     shell.setDir(odir)
  679.     drawMain()
  680.     getfiles()
  681.     drawFiles()
  682.     drawPathSearch()
  683. end
  684. function setDir(name)
  685.     if(fs.isDir(name))then
  686.         clearSearch()
  687.         file_selected = 0
  688.         if(name:sub(#name,#name) ~= "/")then name = name .. "/" end
  689.         fileoffs = 0
  690.         path:set(name)
  691.         getfiles()
  692.         undrawFiles()
  693.         drawFiles()
  694.         return true
  695.     else
  696.         drawFilePath()
  697.         return false
  698.     end
  699.     NovaAPI.setInput(path:getraw())
  700.     pathsearch = path:getraw()
  701. end
  702. function addDir(name)
  703.     selectedside = 0
  704.     drawSideBar()
  705.     clearSearch()
  706.     file_selected = 0
  707.     fileoffs = 0
  708.     path:add(name)
  709.     getfiles()
  710.     undrawFiles()
  711.     drawFiles()
  712.     NovaAPI.setInput(path:getraw())
  713.     pathsearch = path:getraw()
  714. end
  715. function clearSearch()
  716.     search = ""
  717.     scp(40,2)
  718.     sbc(colors.lightGray)
  719.     write(string.rep(" ",11))
  720. end
  721. function searchDir(val)
  722.     file_selected = 0
  723.     fileoffs = 0
  724.     local nfiles = {}
  725.     undrawFiles()
  726.     if(val == "" or val == " ")then
  727.         getfiles()
  728.     else
  729.         --for i = 1, #files do
  730.         --  if(files[i])then
  731.         --      if(not files[i].n:find(val))then
  732.             --      table.remove(files,i)
  733.         --      end
  734.         --  end
  735.     --  end
  736.         --files = nfiles
  737.     end
  738.     drawFiles()
  739. end
  740. function openHref(href)
  741.  if(fs.isDir(href))then
  742.     setDir(href)
  743.  elseif(fs.exists(href))then
  744.     return runFile(href)
  745.  end
  746. end
  747. function editfile(filepath)
  748.     runFile("edit",filepath,true)
  749. end
  750. function pasteMultiFile(to)
  751.     if(multiselecting)then
  752.         for i = 1, #files_selected do
  753.             clipboard.path = files_selected[i].p .. files_selected[i].n
  754.             clipboard.name = files_selected[i].n
  755.             pasteFile(to)
  756.         end
  757.     end
  758. end
  759. function pasteFile(to)
  760.     local odir = shell.dir()
  761.     if(fs.isReadOnly(to))then
  762.         NovaAPI.notify("Paste file ", "Access Denied. ",novaex_redraw)
  763.         return
  764.     end
  765.     if(not fs.exists(to .. clipboard.name))then
  766.         fs.copy(clipboard.path,path:getraw() .. clipboard.name)
  767.         if(clipboard.type == "cut")then fs.delete(clipboard.path) clipboard = {} end
  768.         getfiles()
  769.         drawFiles()
  770.     else
  771.         if(to .. clipboard.name == clipboard.path)then
  772.             clipboard = {}
  773.             drawFiles()
  774.             return
  775.         end
  776.         local ans = NovaAPI.openYesNo("File transfer","File exists, Rename file? ",novaex_redraw)
  777.         if(ans == 1)then
  778.             local newname = NovaAPI.openReadDialog("Rename paste file. ",novaex_redraw,clipboard.name)
  779.             if(newname:find(" "))then
  780.                 NovaAPI.notify("File rename ", "Invalid file name. ",novaex_redraw)
  781.             else
  782.                 clipboard.name = newname
  783.             end
  784.             return pasteFile(to)
  785.         end
  786.     end
  787.  
  788.     shell.setDir(odir)
  789. end
  790. function prevDir(ind)
  791.     selectedside = 0
  792.     drawSideBar()
  793.     scp(2,2)
  794.     sbc(colors.gray)
  795.     stc(colors.black)
  796.     write("<-")
  797.     sleep(0.1)
  798.     scp(2,2)
  799.     sbc(colors.lightGray)
  800.     stc(colors.gray)
  801.     write("<-")
  802.     clearSearch()
  803.     file_selected = 0
  804.     fileoffs = 0
  805.     path:goback(ind)
  806.     getfiles()
  807.     undrawFiles()
  808.     drawFiles()
  809.     NovaAPI.setInput(path:getraw())
  810.     pathsearch = path:getraw()
  811. end
  812. function refreshDir()
  813.     scp(6,2)
  814.     sbc(colors.gray)
  815.     stc(colors.black)
  816.     write("<>")
  817.     sleep(0.1)
  818.     scp(6,2)
  819.     sbc(colors.lightGray)
  820.     stc(colors.gray)
  821.     write("<>")
  822.     clearSearch()
  823.     file_selected = 0
  824.     fileoffs = 0
  825.     drawMain()
  826.     getConfigPinnedItems()
  827.     getPinnedNames()
  828.     drawSideBar()
  829.     getfiles()
  830.     drawFiles()
  831.     checkUpdate()
  832.     NovaAPI.setInput(path:getraw())
  833.     pathsearch = path:getraw()
  834. end
  835. function drawfilemenu(menu,sx,sy)
  836.     local finalmenu = {}
  837.     for i = 1, #menu do
  838.         if(menu[i].relies == nil)then
  839.             finalmenu[#finalmenu+1] = menu[i]
  840.         elseif(menu[i].relies(files[file_selected],pinnednames))then
  841.             finalmenu[#finalmenu+1] = menu[i]
  842.         end
  843.     end
  844.     if(sy+#finalmenu > h)then
  845.         sy = sy - ((sy+#finalmenu)-h)
  846.     end
  847.     if(sx+#finalmenu[1].n >= w-1)then
  848.         sx = sx - ((sx+#finalmenu[1].n)-(w-1))
  849.     end
  850.     pa.drawBox(sx,sy+2,sx+#finalmenu[1].n,sy+#finalmenu+1,colors.black)
  851.     for i = 1, #finalmenu do
  852.         if(sy+i <= h)then
  853.             scp(sx-1,sy+i)
  854.             sbc(colors.lightGray)
  855.             stc(colors.white)
  856.             write(string.rep(" ",#finalmenu[i].n+1))
  857.             scp(sx,sy+i)
  858.             write(finalmenu[i].n)
  859.         end
  860.     end
  861.     return finalmenu, sx, sy
  862. end
  863. function drawMenuClick(mop)
  864.     local _, dny = term.getCursorPos()
  865.     local dnx = inmenux+1
  866.     sbc(colors.gray)
  867.     stc(colors.black)
  868.     write(mop.n)
  869.     sleep(0.2)
  870.     scp(dnx,dny)
  871.     sbc(colors.lightGray)
  872.     stc(colors.white)
  873.     write(mop.n)
  874. end
  875. function updatemenu(e,menu,sx,sy,clrfunc)
  876.     if(e[1] == "mouse_click")then
  877.         local x, y = e[3], e[4]
  878.         local mlen = #menu[1].n-1
  879.         if(x >= sx and x <= sx+mlen and y >= sy+1 and y <= sy+#menu)then
  880.              local clicked = menu[(y-sy)]
  881.              scp(sx,y)
  882.              drawMenuClick(clicked)
  883.              clrfunc()
  884.              e[1] = nil
  885.              inmenu = false
  886.              return clicked.func(files[file_selected])
  887.         else
  888.             clrfunc()
  889.             inmenu = false
  890.         end
  891.     end
  892. end
  893. function opencloseMenu(type,x,y,yind)
  894.     if(inmenu)then
  895.         undrawFiles()
  896.         drawFiles()
  897.         drawSideBar()
  898.         inmenu = false
  899.     elseif(type=="reg")then
  900.         local mtodraw = filemenu
  901.         if(fs.isDir(path:getraw() .. files[file_selected].n))then
  902.             mtodraw = foldermenu
  903.         end
  904.         drawingmenu = mtodraw
  905.         inmenutype, inmenux, inmenuy = drawfilemenu(mtodraw,x,y)
  906.         inmenu = true
  907.     elseif(type=="sidebar")then
  908.         drawingmenu = sidemenu
  909.         inmenutype, _, inmenuy = drawfilemenu(sidemenu,5,y)
  910.         inmenux = 5
  911.         inmenu = true
  912.     elseif(type=="new" and not fs.isReadOnly(path:getraw()) )then
  913.         drawingmenu = emptymenu
  914.         inmenutype,inmenux,inmenuy = drawfilemenu(emptymenu,x,y)
  915.         inmenu = true
  916.     end
  917. end
  918. local function update(e)
  919.     if(inmenu)then
  920.         updatemenu(e,inmenutype,inmenux,inmenuy,novaex_redraw)
  921.     end
  922.  
  923.     if(e[1] == "disk")then
  924.         getfiles()
  925.         drawFiles()
  926.         diskside = e[2]
  927.         if(fs.exists("disk/autorun"))then
  928.             local ans = NovaAPI.openYesNo("Disk detected ","A software disk has been * detected. ",novaex_redraw,"Run","Cancel")
  929.             if(ans == 1)then
  930.                 runFile("disk/autorun")
  931.             end
  932.         elseif(disk.hasAudio(e[2]))then
  933.             local ans = NovaAPI.openYesNo("Music detected ","A music disk has been * inserted. ",novaex_redraw,"Play","Cancel")
  934.             if(ans == 1)then
  935.                 disk.playAudio(e[2])
  936.             end
  937.         else
  938.             local ans = NovaAPI.openYesNo("Disk detected ","A floppy disk has been * inserted. ",novaex_redraw,"Open","Cancel")
  939.             if(ans == 1)then
  940.                 setDir("disk/")
  941.             end
  942.         end
  943.     elseif(e[1] == "disk_eject")then
  944.         if(path:getraw():find("disk/"))then
  945.             path:set("/")
  946.         end
  947.         undrawFiles()
  948.         getfiles()
  949.         drawFiles()
  950.     end
  951.     if(e[1] == "paste")then
  952.         if(clipboard.name ~= nil)then
  953.             if(multiselecting)then
  954.                 pasteMultiFile(path:getraw())
  955.             else
  956.                 pasteFile(path:getraw())
  957.             end
  958.         end
  959.     end
  960.     if(e[1] == "key")then
  961.         local key = e[2]
  962.         if(key == actionkey and not actionkeydown)then
  963.             actionkeydown = true
  964.         elseif(actionkeydown)then
  965.             local opper = "copy"
  966.             if(key == keys.c or key == keys.x)then
  967.                 if(key == keys.x)then opper = "cut" end
  968.                 if(file_selected ~= 0)then
  969.                     setClipboard(path:getraw() .. files[file_selected].n,
  970.                     files[file_selected].n, opper)
  971.                 end
  972.             end
  973.         end
  974.         if(file_selected > 0)then
  975.             if(key == keys.delete)then
  976.                 local ans = NovaAPI.openYesNo("File deletion. ","Confirm &4deletion&r of *" .. files[file_selected].n,novaex_redraw)
  977.                 if(ans == 1)then
  978.                     deleteFile(path:getraw() .. files[file_selected].n)
  979.                 end
  980.             end
  981.         end
  982.         if(selectedside > 0)then
  983.             if(key == keys.up and sideitems[selectedside-1].t ~= nil and  
  984.                sideitems[selectedside-1].t ~= "text" )then
  985.                 moveSideItem(selectedside,-1)
  986.             elseif(key == keys.down and (selectedside < #sideitems) and
  987.                (sideitems[selectedside+1].n ~= nil) and
  988.                 sideitems[selectedside+1].t ~= "text" )then
  989.                 moveSideItem(selectedside,1)
  990.             end
  991.         end
  992.     elseif(e[1] == "key_up")then
  993.             local key = e[2]
  994.         if(key == actionkey and actionkeydown )then
  995.             actionkeydown = false
  996.         end
  997.     end
  998.     if(e[1] == "mouse_click")then
  999.          local x,y = e[3], e[4]    
  1000.          -- Left clicked
  1001.         if(e[2] == 1)then
  1002.             if(x == w and y == 1)then
  1003.                 clickExit()
  1004.                 innova = false
  1005.                 sbc(colors.white)
  1006.                 clr()
  1007.                 stc(colors.gray)
  1008.                 writecy("Thank you for using Nova Explore. ",9)
  1009.                 writecy("Click the screen to exit. ",10)
  1010.                 os.pullEvent("mouse_click")
  1011.                 sbc(colors.black)
  1012.                 clr()
  1013.                 stc(colors.white)
  1014.                 scp(1,1)
  1015.                 return
  1016.             end
  1017.             if(x >= 11 and x <= 36 and y == 2)then
  1018.                 NovaAPI.setInput(pathsearch)
  1019.             end
  1020.             if(x >= 38 and x <= 51 and y == 2)then
  1021.                 NovaAPI.setInput(search)
  1022.                 searching = true
  1023.             elseif(searching)then
  1024.                 search = NovaAPI.getInput()
  1025.                 searching = false
  1026.             end
  1027.             if(x >= 2 and x <= 4 and y == 2)then
  1028.                 if(inmenu)then inmenu = false end
  1029.                 prevDir(1)
  1030.             end
  1031.             if(x >= 6 and x <= 8 and y == 2)then
  1032.                 refreshDir()
  1033.             end
  1034.         end
  1035.         -- Left or right clicked
  1036.             local yind = (y+fileoffs)-4
  1037.             local syind = (y+sideoffs)-4
  1038.             if(x < 18 and syind <= #sideitems and syind > 0)then
  1039.                  if(y > 4 and x >= 1 and x <= #(sideitems[syind].n:sub(1,14)) )then
  1040.                    if(e[2] == 1 and not inmenu and sideitems[syind].t ~= "text")then
  1041.                         if(fs.isDir(sideitems[syind].href))then
  1042.                             selectedside = syind
  1043.                             openHref(sideitems[syind].href)
  1044.                             drawSideBar()
  1045.                         elseif(sideitems[syind].t ~= "text")then
  1046.                             if(selectedside == syind)then
  1047.                                 openHref(sideitems[syind].href)
  1048.                             else
  1049.                                 selectedside = syind
  1050.                                 drawSideBar()
  1051.                             end
  1052.                         end
  1053.                    elseif(e[2] == 2)then
  1054.                         if(selectedside ~= 0  and sideitems[syind].t ~= "text" and yind == selectedside)then
  1055.                             opencloseMenu("sidebar",x,y)   
  1056.                         end
  1057.                    end
  1058.                  end
  1059.              elseif(yind <= #files and yind > 0)then
  1060.                 if(y > 4 and x >= 18 and x <= 22+#files[yind].n)then
  1061.                    if(e[2] == 1 and not inmenu)then
  1062.                       if(file_selected == yind)then
  1063.                             if(fs.isDir(path:getraw() .. files[file_selected].n))then
  1064.                                 if(inmenu)then inmenu = false end
  1065.                                 addDir(files[yind].n)
  1066.                              else
  1067.                                 runFile(path:getraw() .. files[file_selected].n)
  1068.                             end
  1069.                           else
  1070.                              file_selected = yind
  1071.                              drawFiles()
  1072.                              drawPathSearch()
  1073.                           end
  1074.                    elseif(e[2] == 2 )then
  1075.                        if(file_selected == yind)then
  1076.                             opencloseMenu("reg",x,y,yind)
  1077.                        else
  1078.                             opencloseMenu("new",x,y,yind)
  1079.                        end
  1080.                 end
  1081.          end
  1082.         end
  1083.         if(e[2] == 2 and not inmenu and x > 18)then
  1084.             opencloseMenu("new",x,y,1)
  1085.         end
  1086.     end
  1087.     if(e[1] == "mouse_scroll")then
  1088.         NovaAPI.setActive(false)
  1089.         local dir = e[2]
  1090.         local x,y = e[3], e[4]
  1091.         if(dir == -1)then
  1092.             if(x > 16 and fileoffs > 0 )then
  1093.                 fileoffs = fileoffs - 1
  1094.                 drawFiles()
  1095.             elseif(x <= 16 and sideoffs > 0)then
  1096.                 sideoffs = sideoffs - 1
  1097.                 drawSideBar()
  1098.             end
  1099.         elseif(dir == 1)then
  1100.             if(x > 16 and fileoffs < #files-(filemax-4))then
  1101.                 fileoffs = fileoffs + 1
  1102.                 drawFiles()
  1103.             elseif(x <= 16 and sideoffs < #sideitems-(sidemax-4))then
  1104.                 sideoffs = sideoffs + 1
  1105.                 drawSideBar()
  1106.             end
  1107.         end
  1108.     end
  1109.     if(pathsearch ~= "")then
  1110.         if(NovaAPI.getActive() == false)then
  1111.             drawPathSearch()
  1112.         end
  1113.         if(NovaAPI.getActive() == false and not searching)then
  1114.             if(NovaAPI.getInput() ~= pathsearch)then
  1115.                 --pathsearch = NovaAPI.getInput()
  1116.                 NovaAPI.setInput(pathsearch)
  1117.             end
  1118.         end
  1119.     end
  1120.  
  1121.         -- Searching files/commands
  1122.  
  1123.     if(not searching)then
  1124.         stc(colors.black)
  1125.         sbc(colors.white)
  1126.         local doneinp = NovaAPI.novaread(e,1000,25,13,2)
  1127.         if(doneinp)then
  1128.             NovaAPI.setActive(false)
  1129.             term.setCursorBlink(false)
  1130.             pathsearch = NovaAPI.getInput()
  1131.             if( fs.isDir(NovaAPI.getInput()) )then
  1132.                 if( setDir(NovaAPI.getInput()) )then
  1133.                     selectedside = 0
  1134.                     drawSideBar()
  1135.                 end
  1136.             else
  1137.                 --if(fs.exists(pathsearch))then
  1138.                     term.setBackgroundColor(colors.black)
  1139.                     term.setTextColor(colors.white)
  1140.                     term.clear()
  1141.                     term.setCursorPos(1, 1)
  1142.                     shell.run(pathsearch)
  1143.                     NovaAPI.setInput(pathsearch)
  1144.                     writecy("Click any where to return to NovaBrowse. ",9)
  1145.                     os.pullEvent("mouse_click")
  1146.                     NovaAPI.setInput(pathsearch)
  1147.                     drawMain()
  1148.                     getfiles()
  1149.                     drawFiles()
  1150.                 --end
  1151.    
  1152.             end
  1153.         end
  1154.     else
  1155.         stc(colors.black)
  1156.         sbc(colors.lightGray)
  1157.         local doneinp = NovaAPI.novaread(e,1000,10,40,2)
  1158.         if(doneinp)then
  1159.             searching = false
  1160.             NovaAPI.setActive(false)
  1161.             search = NovaAPI.getInput()
  1162.             --if(fs.isDir(NovaAPI.getInput()))then
  1163.                 getfiles() -- to prevent "nested" searches.
  1164.                 searchDir(NovaAPI.getInput())
  1165.                 --NovaAPI.setInput("")
  1166.             --end
  1167.  
  1168.         end
  1169.     end
  1170. end
  1171. function displayError(err)
  1172.     sbc(colors.white)
  1173.     clr()
  1174.     stc(colors.gray)
  1175.     writecy(" Well, thats not supposed to happen. ",1)
  1176.     scp(2,3)
  1177.     stc(colors.lightGray)
  1178.     write(err)
  1179.     writecy(" Why you do dis to me :(. ",16)
  1180.     stc(colors.black)
  1181.     writecy(" Press any key to end NovaExplore. ",17)
  1182.     writecy("  Click to restart NovaExplore. ",18)
  1183.     local e = {os.pullEvent()}
  1184.     if(e[1] == "key")then
  1185.         sbc(colors.black)
  1186.         clr()
  1187.         stc(colors.white)
  1188.         scp(1,1)
  1189.     elseif(e[1] == "mouse_click")then
  1190.         local odir = shell.dir()
  1191.         shell.setDir("")
  1192.         shell.run(shell.resolveProgram(shell.getRunningProgram()))
  1193.         shell.setDir(odir)
  1194.     end
  1195. end
  1196. function clickExit()
  1197.     scp(w,1)
  1198.     stc(colors.black)
  1199.     sbc(colors.pink)
  1200.     write("X")
  1201.     sleep(0.2)
  1202.     scp(w,1)
  1203.     stc(colors.white)
  1204.     sbc(colors.red)
  1205.     write("X")
  1206. end
  1207. function checkUpdate()
  1208.     if(http)then
  1209.         local upd = http.get("http://pastebin.com/raw/rpipr5pT")
  1210.         if(upd ~= nil)then
  1211.             local cont = upd.readAll()
  1212.             local f = fs.open(shell.getRunningProgram(),"r")
  1213.             local pcont = f.readAll()
  1214.             f.close()
  1215.             if(cont ~= pcont)then
  1216.                 local ans = NovaAPI.openYesNo("Auto update", "Update detected, would you * like to update?.",novaex_redraw)
  1217.                 if(ans == 1)then
  1218.                     local f = fs.open(shell.getRunningProgram(),"w")
  1219.                     f.write(cont)
  1220.                     f.close()
  1221.                     NovaAPI.notify("Auto update", "Updated, restart required.",novaex_redraw)
  1222.                     innova = false
  1223.                     return shell.run(shell.resolveProgram(shell.getRunningProgram()))
  1224.                 end
  1225.             end
  1226.         else
  1227.             NovaAPI.notify("Auto update", "Failed to connect to pastebin.",novaex_redraw)
  1228.         end
  1229.     else
  1230.         NovaAPI.notify("Auto update", "Http is disabled, Failed to * check for updates.",novaex_redraw)
  1231.         return
  1232.     end
  1233. end
  1234. function drawMain()
  1235.     sbc(colors.white)
  1236.     clr()
  1237.     scp(1,2)
  1238.     sbc(colors.lightGray)
  1239.     clrln()
  1240.     pa.drawBox(w-12,1,w,3,colors.gray)
  1241.     sbc(colors.white)
  1242.     writexy(string.rep(" ",w-12),1,2)
  1243.     pa.drawBox(10,1,w-12,3,colors.gray)
  1244.     drawSideBar()
  1245.     pa.drawFilledBox(1,1,9,3,colors.lightGray)
  1246.     scp(2,2)
  1247.     stc(colors.gray)
  1248.     write("<-  <>")
  1249.     --pa.drawBox(15,h,w,h,colors.lightGray)
  1250.     pa.drawBox(w,4,w,h,colors.lightGray)
  1251.     stc(colors.gray)
  1252.     writexy("^",w,4)
  1253.     writexy("v",w,h)
  1254.     scp(w,1)
  1255.     stc(colors.white)
  1256.     sbc(colors.red)
  1257.     write("X")
  1258.     sbc(colors.black)
  1259. end
  1260. drawMain()
  1261. getConfigPinnedItems()
  1262. getPinnedNames()
  1263. drawSideBar()
  1264. getfiles()
  1265. drawFiles()
  1266. checkUpdate()
  1267.  
  1268. local function loop()
  1269.     while innova do
  1270.         local e = {os.pullEvent()}
  1271.         update(e)
  1272.     end
  1273. end
  1274. local ok, err = pcall(loop)
  1275. if(not ok)then
  1276.     if(term.current().setVisible)then
  1277.         term.current().setVisible(true)
  1278.     end
  1279.     displayError(err)
  1280. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement