Advertisement
Guest User

[Computer Craft] Mouse File Browser 0.2b by BigSHinyToys

a guest
Oct 30th, 2012
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.84 KB | None | 0 0
  1. --[[
  2.         file selection and dilog box API / lib / other
  3.         by BigSHinyToys
  4.         note: send link to nightin9ale on CC forums
  5. ]]--
  6.  
  7. local tArgs = {...}
  8. local ver = "0.2b"
  9.  
  10. local bugTest = false
  11.  
  12. if tArgs[1] and tArgs[1] == "-d" then
  13.     bugTest = true
  14. end
  15.  
  16. local function clear()
  17.     term.setBackgroundColor(colors.black)
  18.     term.setTextColor(colors.white)
  19.     term.clear()
  20.     term.setCursorBlink(false)
  21.     term.setCursorPos(1,1)
  22. end
  23.  
  24. local function dialogBox(title,message,options)
  25.     term.setCursorBlink(false)
  26.     local selected = 1
  27.     local boxW,boxH = 26,3
  28.     local termX,termY = term.getSize()
  29.     local ofsX,ofsY = math.ceil((termX/2) - (boxW/2)) , math.ceil((termY/2) - (boxH/2)) -- offset from top left
  30.    
  31.     local space = 0
  32.     local range = {}
  33.     for i = 1,#options do
  34.         range[i] = {s = space,f = space + string.len(options[i])}
  35.         space = space + string.len(options[i])+3
  36.     end
  37.     local ofC = (boxW/2) - (space/2)
  38.    
  39.     local function drawBox()
  40.         if term.isColor() then
  41.             term.setTextColor(colors.black)
  42.             term.setCursorPos(ofsX,ofsY) -- F*** YOU 3 hours to find out i forgot to round numbers before sending them to this Fing function
  43.             term.setBackgroundColor(colors.blue)
  44.             term.write(" "..title..string.rep(" ",boxW-#title-5).."_[]")
  45.             term.setBackgroundColor(colors.red)
  46.             term.setTextColor(colors.white)
  47.             term.write("X")
  48.             term.setCursorPos(ofsX,ofsY+1)
  49.             term.setBackgroundColor(colors.white)
  50.             term.setTextColor(colors.black)
  51.             term.write(" "..message..string.rep(" ",boxW-#message-1))
  52.             term.setCursorPos(ofsX,ofsY+2)
  53.             term.write(string.rep(" ",boxW))
  54.             term.setCursorPos(ofsX,ofsY+3)
  55.             term.write(string.rep(" ",boxW))
  56.            
  57.             for i = 1,#options do
  58.                 if i == selected then
  59.                     term.setBackgroundColor(colors.lightGray)
  60.                     term.setCursorPos(range[i].s + ofC + ofsX - 1,ofsY + 3)
  61.                     term.write("["..options[i].."]")
  62.                     term.setBackgroundColor(colors.white)
  63.                     term.write(" ")
  64.                 else
  65.                     term.setCursorPos(range[i].s + ofC + ofsX - 1,ofsY + 3)
  66.                     term.write(" "..options[i].." ")
  67.                 end
  68.             end
  69.             term.setCursorPos(ofsX + ofC + space,ofsY + 3)
  70.             term.write(string.rep(" ",boxW - (ofC + space)))
  71.             term.setBackgroundColor(colors.black)
  72.             term.setTextColor(colors.white)        
  73.         end
  74.     end
  75.     while true do
  76.         drawBox()
  77.         event = {os.pullEvent()}
  78.         if event[1] == "key" then
  79.             if event[2] == 203 then -- left
  80.                 selected = selected - 1
  81.                 if selected < 1 then
  82.                     selected = #options
  83.                 end
  84.             elseif event[2] == 205 then -- right
  85.                 selected = selected + 1
  86.                 if selected > #options then
  87.                     selected = 1
  88.                 end
  89.             elseif event[2] == 28 then -- enter
  90.                 return selected , options[selected]
  91.             end
  92.         elseif event[1] == "mouse_click" then
  93.             term.setCursorPos(1,1)
  94.             term.clearLine()
  95.            
  96.             if bugTest then term.write("M "..event[2].." X "..event[3].." Y "..event[4]) end
  97.            
  98.             if event[2] == 1 then
  99.                 if event[4] == ofsY + 3 then
  100.                     for i = 1,#options do
  101.                         if event[3] >= range[i].s + ofC + ofsX - 1 and event[3] <= range[i].f + ofC + ofsX then
  102.                             return i , options[i]
  103.                         end
  104.                     end
  105.                 end
  106.             end
  107.         end
  108.     end
  109. end
  110.  
  111. -- modified read made to play nice with coroutines
  112.  
  113. local sLine = ""
  114.  
  115. local function readMOD( _sReplaceChar, _tHistory,_wdth)
  116.     term.setCursorBlink( true )
  117.  
  118.     local nHistoryPos = nil
  119.     local nPos = 0
  120.     if _sReplaceChar then
  121.         _sReplaceChar = string.sub( _sReplaceChar, 1, 1 )
  122.     end
  123.    
  124.     local w, h = term.getSize()
  125.     if _wdth and type(_wdth) == "number" then
  126.         w = _wdth
  127.     end
  128.     local sx, sy = term.getCursorPos() 
  129.    
  130.     local function redraw( _sCustomReplaceChar )
  131.         local nScroll = 0
  132.         if sx + nPos >= w then
  133.             nScroll = (sx + nPos) - w
  134.         end
  135.            
  136.         term.setCursorPos( sx, sy )
  137.         local sReplace = _sCustomReplaceChar or _sReplaceChar
  138.         if sReplace then
  139.             term.write( string.rep(sReplace, string.len(sLine) - nScroll) )
  140.         else
  141.             term.write( string.sub( sLine, nScroll + 1 ) )
  142.         end
  143.         term.setCursorPos( sx + nPos - nScroll, sy )
  144.     end
  145.    
  146.     while true do
  147.         local sEvent, param = os.pullEvent()
  148.         if sEvent == "char" then
  149.             sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 )
  150.             nPos = nPos + 1
  151.             redraw()
  152.            
  153.         elseif sEvent == "key" then
  154.             if param == keys.enter then
  155.                 -- Enter
  156.                 -- break
  157.                
  158.             elseif param == keys.left then
  159.                 -- Left
  160.                 if nPos > 0 then
  161.                     nPos = nPos - 1
  162.                     redraw()
  163.                 end
  164.                
  165.             elseif param == keys.right then
  166.                 -- Right               
  167.                 if nPos < string.len(sLine) then
  168.                     nPos = nPos + 1
  169.                     redraw()
  170.                 end
  171.            
  172.             elseif param == keys.up or param == keys.down then
  173.                 -- Up or down
  174.                 if _tHistory then
  175.                     redraw(" ");
  176.                     if param == keys.up then
  177.                         -- Up
  178.                         if nHistoryPos == nil then
  179.                             if #_tHistory > 0 then
  180.                                 nHistoryPos = #_tHistory
  181.                             end
  182.                         elseif nHistoryPos > 1 then
  183.                             nHistoryPos = nHistoryPos - 1
  184.                         end
  185.                     else
  186.                         -- Down
  187.                         if nHistoryPos == #_tHistory then
  188.                             nHistoryPos = nil
  189.                         elseif nHistoryPos ~= nil then
  190.                             nHistoryPos = nHistoryPos + 1
  191.                         end                    
  192.                     end
  193.                    
  194.                     if nHistoryPos then
  195.                         sLine = _tHistory[nHistoryPos]
  196.                         nPos = string.len( sLine )
  197.                     else
  198.                         sLine = ""
  199.                         nPos = 0
  200.                     end
  201.                     redraw()
  202.                 end
  203.             elseif param == keys.backspace then
  204.                 -- Backspace
  205.                 if nPos > 0 then
  206.                     redraw(" ");
  207.                     sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 )
  208.                     nPos = nPos - 1                
  209.                     redraw()
  210.                 end
  211.             elseif param == keys.home then
  212.                 -- Home
  213.                 nPos = 0
  214.                 redraw()       
  215.             elseif param == keys.delete then
  216.                 if nPos < string.len(sLine) then
  217.                     redraw(" ");
  218.                     sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )              
  219.                     redraw()
  220.                 end
  221.             elseif param == keys["end"] then
  222.                 -- End
  223.                 nPos = string.len(sLine)
  224.                 redraw()
  225.             end
  226.         elseif sEvent == "redraw" then
  227.             redraw()
  228.         end
  229.     end
  230.    
  231.     term.setCursorBlink( false )
  232.     -- term.setCursorPos( w + 1, sy )
  233.     -- print()
  234.    
  235.     return sLine
  236. end
  237.  
  238. -- end modified read
  239.  
  240. local function printC(posX,posY,textCol,backCol,text)
  241.     term.setCursorPos(posX,posY)
  242.     term.setTextColor(textCol)
  243.     term.setBackgroundColor(backCol)
  244.     term.write(text)
  245. end
  246.  
  247. local function rClickMenu(title,tList,posX,posY)
  248.  
  249.     term.setCursorBlink(false)
  250.     local BoxTitle = title
  251.     local choices = tList
  252.     local termX,termY = term.getSize()
  253.     local offX,offY
  254.    
  255.     local width = #BoxTitle + 2
  256.     local hight = #choices + 1
  257.    
  258.     for i = 1,#choices do
  259.         if width < #choices[i] + 2 then
  260.             width = #choices[i] + 2
  261.         end
  262.     end
  263.    
  264.     offX,offY = math.ceil((termX/2) - (width/2)),math.ceil((termY/2) - (hight/2))
  265.    
  266.     if posX and posY then -- offX,offY = posX,posY
  267.         if posX >= termX - width - 1 then
  268.             offX = termX - width - 1
  269.         else
  270.             offX = posX
  271.         end
  272.         if posY >= termY - hight then
  273.             offY = termY - hight
  274.         else
  275.             offY = posY
  276.         end
  277.     end
  278.    
  279.     local function reDrawer()
  280.         printC(offX,offY,colors.black,colors.blue," "..BoxTitle..string.rep(" ",width - #BoxTitle - 1))
  281.         for i = 1,#choices do
  282.             printC(offX,offY + i,colors.black,colors.white," "..choices[i]..string.rep(" ",width - #choices[i] - 1))
  283.         end
  284.     end
  285.    
  286.     while true do
  287.         reDrawer()
  288.         local event = {os.pullEvent()}
  289.         if event[1] == "mouse_click" then
  290.             if event[2] == 1 then -- event[3] = x event[4] = y
  291.                 if event[4] > offY and event[4] < hight + offY and event[3] >= offX and event[3] < width + offX then
  292.                     return choices[event[4] - offY]
  293.                 else
  294.                     return
  295.                 end
  296.             elseif event[2] == 2 then
  297.                 return
  298.             end
  299.         end
  300.     end
  301.    
  302. end
  303.  
  304. local function fileSelect(mode) -- save_file open_file browse < not yet implemented
  305.    
  306.     local title = "File Browser "..ver
  307.     local bRun = true
  308.     local flag = true
  309.    
  310.     local termX,termY = term.getSize()
  311.     local offsetX,offsetY = 1,1
  312.     local hight,width = math.ceil(termY-2),math.ceil(termX-2)
  313.     local oldHight,oldWidth
  314.    
  315.     local boxOffX,boxOffY = offsetX,offsetY + 2
  316.     local boxH,boxW = hight - 3 ,width - 2
  317.    
  318.     local barX,barY = offsetX + 1,offsetY + 2
  319.     local barH,barW = 1,width - 1
  320.    
  321.     local tbarX,tbarY = offsetX + 1,offsetY + 1
  322.     local tbarH,tbarW = 1,width - 1
  323.    
  324.     local exitX,exitY = offsetX + width - 1 ,offsetY + 1
  325.    
  326.     local parth = {}
  327.     local list
  328.    
  329.     local fSlash = [[\]]
  330.     local listOff = 0
  331.    
  332.     local function stringParth()
  333.         local temp = fSlash
  334.         for i = 1,#parth do
  335.             if i == #parth then
  336.                 temp = temp..parth[i]
  337.             else
  338.                 temp = temp..parth[i]..fSlash
  339.             end
  340.         end
  341.         return temp
  342.     end
  343.    
  344.     local sParth = stringParth()
  345.     local files = {}
  346.     local folders = {}
  347.     local disks = {}
  348.  
  349.     local function NewList()
  350.         flag = true
  351.         listOff = 0
  352.         sParth = stringParth()
  353.         files = {}
  354.         folders = {}
  355.         disks = {}
  356.         test,list = pcall(fs.list,sParth)
  357.         for i = 1,#list do
  358.             if fs.isDir(sParth..fSlash..list[i]) then
  359.                 table.insert(folders,list[i])
  360.             else
  361.                 table.insert(files,list[i])
  362.             end
  363.         end
  364.         if #parth == 0 then
  365.             for i,v in pairs(rs.getSides()) do
  366.                 if disk.isPresent(v) and disk.hasData(v) then
  367.                     disks[disk.getMountPath(v)] = v
  368.                 end
  369.             end
  370.         end
  371.         table.sort(disks)
  372.         table.sort(folders)
  373.         table.sort(files)
  374.     end
  375.    
  376.     NewList()
  377.    
  378.     local function size(test)
  379.         if #test > boxW - 3 then
  380.             return string.sub(test,1,boxW-3)
  381.         end
  382.         return test
  383.     end
  384.    
  385.     local tRead = coroutine.create(function()
  386.         term.setCursorPos(boxOffX + 2,boxOffY + boxH + 1)
  387.         readMOD(nil,nil,boxOffX + boxW)
  388.     end)
  389.    
  390.     local function resume(...)
  391.         term.setTextColor(colors.black)
  392.         term.setBackgroundColor(colors.white)
  393.         term.setCursorPos(boxOffX + 1,boxOffY + boxH + 1)
  394.         term.write(string.rep(" ",boxW+1))
  395.         coroutine.resume(tRead,...)
  396.         term.setTextColor(colors.white)
  397.         term.setBackgroundColor(colors.black)
  398.     end
  399.    
  400.    
  401.     while bRun do
  402.         if flag then
  403.             flag = false
  404.             -- clear
  405.             if oldHight ~= hight and oldWidth ~= width then
  406.                 term.setBackgroundColor(colors.black)
  407.                 term.clear()
  408.                 oldHight,oldWidth = hight,width
  409.             end
  410.             -- draw top title bar
  411.             term.setCursorPos(tbarX,tbarY)
  412.             term.setTextColor(colors.black)
  413.             term.setBackgroundColor(colors.blue)
  414.             local b = tbarW - #title -2
  415.             if b < 0 then
  416.                 b = 0
  417.             end
  418.             term.write(string.sub(" "..title,1,tbarW)..string.rep(" ",b))
  419.             term.setTextColor(colors.white)
  420.             term.setBackgroundColor(colors.red)
  421.             term.write("X")
  422.            
  423.             -- draw location bar
  424.            
  425.             term.setCursorPos(barX,barY)
  426.             term.setTextColor(colors.black)
  427.             term.setBackgroundColor(colors.lightGray)
  428.             local a = barW - #sParth - 1
  429.             if a < 0 then
  430.                 a = 0
  431.             end
  432.             term.write(string.sub(" "..sParth,1,barW)..string.rep(" ",a))
  433.            
  434.             -- draw scroll bar
  435.            
  436.             if #folders + #files > boxH then
  437.                 term.setBackgroundColor(colors.lightGray)
  438.                 for i = 1,boxH do
  439.                     term.setCursorPos(boxOffX+boxW+1,i + boxOffY)
  440.                     local scroll = math.floor( boxH* (listOff/(#folders + #files-boxH+2)) )+1
  441.                     if i == scroll then
  442.                         term.setBackgroundColor(colors.gray)
  443.                         term.write(" ")
  444.                         term.setBackgroundColor(colors.lightGray)
  445.                     else
  446.                         term.write(" ")
  447.                     end
  448.                 end
  449.             else
  450.                 term.setBackgroundColor(colors.gray)
  451.                 for i = 1,boxH do
  452.                     term.setCursorPos(boxOffX+boxW+1,i + boxOffY)
  453.                     term.write(" ")
  454.                 end
  455.             end
  456.            
  457.             -- draw main section
  458.            
  459.             term.setTextColor(colors.black)
  460.             term.setBackgroundColor(colors.cyan)
  461.             for i = 1,boxH do
  462.                 term.setCursorPos(1+boxOffX,i+boxOffY)
  463.                 if folders[i+listOff] then
  464.                     if disks[folders[i+listOff]] then
  465.                         term.setTextColor(colors.orange)
  466.                         term.setBackgroundColor(colors.blue)
  467.                         term.write("D!")
  468.                     else
  469.                         term.setTextColor(colors.blue)
  470.                         term.setBackgroundColor(colors.lightBlue)
  471.                         term.write("[]")
  472.                     end
  473.                     term.setTextColor(colors.black)
  474.                     term.setBackgroundColor(colors.cyan)
  475.                     local repTimes = boxW - #folders[i+listOff] - 3
  476.                     if repTimes < 0 then
  477.                         repTimes = 0
  478.                     end
  479.                     term.write(" "..size(folders[i+listOff])..string.rep(" ",repTimes))
  480.                 elseif files[i-#folders+listOff] then
  481.                     local repTimes = boxW - #files[i-#folders+listOff] - 3
  482.                     if repTimes < 0 then
  483.                         repTimes = 0
  484.                     end
  485.                     term.write("   "..size(files[i-#folders+listOff])..string.rep(" ",repTimes))
  486.                 else
  487.                     term.write(string.rep(" ",boxW))
  488.                 end
  489.             end
  490.             term.setTextColor(colors.white)
  491.             term.setBackgroundColor(colors.black)
  492.            
  493.             if bugTest then
  494.                 term.setCursorPos(1,1)
  495.                 term.write(listOff.." "..boxOffY.." "..boxH)
  496.             end
  497.            
  498.             resume("redraw")
  499.         end
  500.         -- react to events
  501.        
  502.         local event = {os.pullEvent()}
  503.        
  504.         if event[1] == "mouse_click" then
  505.             if event[2] == 1 then -- left mouse
  506.                 local temp = nil
  507.                 if event[4] > boxOffY and event[4] <= boxH + boxOffY then
  508.                     temp = folders[event[4]+listOff-boxOffY] or files[event[4]-#folders+listOff-boxOffY]
  509.                 end
  510.                 if temp and event[3] > boxOffX and event[3] <= #temp + 3 + boxOffX and event[3] < boxOffX + boxW then
  511.                     if fs.isDir(stringParth()..fSlash..temp) then
  512.                         table.insert(parth,temp)
  513.                         NewList()
  514.                     else
  515.                         if fs.exists(stringParth()..fSlash..temp) then
  516.                             if dialogBox("Run file ?",temp,{"yes","no"}) == 1 then
  517.                                 local test,info = shell.run(stringParth()..fSlash..temp)
  518.                                 term.setCursorBlink(false)
  519.                                 if not test then
  520.                                     dialogBox("ERROR",tostring(info),{"ok"})
  521.                                 end
  522.                             end
  523.                             flag = true
  524.                         end
  525.                     end
  526.                 elseif event[3] == boxOffX+boxW+1 and event[4] > boxOffY and event[4] <= boxOffY+boxH then
  527.                     if #folders + #files > boxH then
  528.                         if event[4] == boxOffY + 1 then
  529.                             listOff = 0
  530.                         elseif event[4] == boxOffY+boxH then
  531.                             listOff = #folders + #files + 1 - boxH
  532.                         else
  533.                             listOff = math.ceil((event[4] - boxOffY - 1 )*(((#folders + #files - boxH+2)/boxH)))
  534.                         end
  535.                         flag = true
  536.                     end
  537.                 elseif event[3] == exitX and event[4] == exitY then
  538.                     if dialogBox("Confirm","Exit application",{"yes","no"}) == 1 then
  539.                         bRun = false
  540.                     end
  541.                     flag = true
  542.                 end
  543.             elseif event[2] == 2 then -- right mouse
  544.                 local temp = nil
  545.                 if event[4] > boxOffY and event[4] <= boxH + boxOffY then
  546.                     temp = folders[event[4]+listOff-boxOffY] or files[event[4]-#folders+listOff-boxOffY]
  547.                 end
  548.                 if temp and event[3] > boxOffX and event[3] <= #temp + 3 + boxOffX and event[3] < boxOffX + boxW then
  549.                     local sType = "File"
  550.                    
  551.                     if fs.isDir(stringParth()..fSlash..temp) then
  552.                         sType = "Folder"
  553.                     end
  554.                    
  555.                     local sChoice = nil
  556.                    
  557.                     if disks[temp] then
  558.                         sChoice = rClickMenu("Options",{"Open","Eject"},event[3]+1,event[4]+1)
  559.                     else
  560.                         if sType == "Folder" then
  561.                             sChoice = rClickMenu("Options",{"Open","Delete"},event[3]+1,event[4]+1)
  562.                         else
  563.                             if windowDimensions then
  564.                                 sChoice = rClickMenu("Options",{"Run","Run CMD","Run win","Edit","Paint","Delete"},event[3]+1,event[4]+1)
  565.                             else
  566.                                 sChoice = rClickMenu("Options",{"Run","Run CMD","Edit","Paint","Delete"},event[3]+1,event[4]+1)
  567.                             end
  568.                         end
  569.                     end
  570.                    
  571.                     if sChoice == "Run win" and windowDimensions then
  572.                         shell.run("start",stringParth()..fSlash..temp)
  573.                         flag = true
  574.                     elseif sChoice == "Open" then
  575.                         table.insert(parth,temp)
  576.                         NewList()
  577.                     elseif sChoice == "Run" then
  578.                         clear()
  579.                         local test,info = shell.run(stringParth()..fSlash..temp)
  580.                         term.setCursorBlink(false)
  581.                         if not test then
  582.                             dialogBox("ERROR",tostring(info),{"ok"})
  583.                         end
  584.                     elseif sChoice == "Run CMD" then
  585.                         clear()
  586.                         print("Enter Commands")
  587.                         local cmd = read()
  588.                         clear()
  589.                         local test,info = shell.run(stringParth()..fSlash..temp,cmd)
  590.                         term.setCursorBlink(false)
  591.                         if not test then
  592.                             dialogBox("ERROR",tostring(info),{"ok"})
  593.                         end
  594.                     elseif sChoice == "Edit" then
  595.                         if sType == "File" then
  596.                             shell.run("edit",stringParth()..fSlash..temp)
  597.                         else
  598.                             dialogBox("ERROR","Can't edit a Folder",{"ok"})
  599.                         end
  600.                     elseif sChoice == "Delete" then
  601.                         if dialogBox("Confirm","Delete "..sType.." "..temp,{"yes","no"}) == 1 then
  602.                             if fs.isReadOnly(stringParth()..fSlash..temp) then
  603.                                 dialogBox("ERROR",sType.." Is read Only",{"ok"})
  604.                             else
  605.                                 fs.delete(stringParth()..fSlash..temp)
  606.                                 NewList()
  607.                             end
  608.                         end
  609.                     elseif sChoice == "Paint" then
  610.                         if sType == "File" then
  611.                             shell.run("paint",stringParth()..fSlash..temp)
  612.                         else
  613.                             dialogBox("ERROR","Can't edit a Folder",{"ok"})
  614.                         end
  615.                     elseif sChoice == "Eject" then
  616.                         if dialogBox("Confirm","Eject disk "..disks[temp].." "..fSlash..temp,{"yes","no"}) == 1 then
  617.                             disk.eject(disks[temp])
  618.                             NewList()
  619.                         end
  620.                     end
  621.                     flag = true
  622.                 else
  623.                     table.remove(parth,#parth)
  624.                     NewList()
  625.                 end
  626.             end
  627.         elseif event[1] == "mouse_scroll" then -- flag
  628.             local old = listOff
  629.             listOff = listOff + event[2]
  630.             if listOff < 0 then
  631.                 listOff = 0
  632.             end
  633.             if #folders + #files + 1 - boxH > 0 and listOff > #folders + #files + 1 - boxH then
  634.                 listOff = #folders + #files + 1 - boxH
  635.             elseif listOff > 0 and #folders + #files + 1 - boxH < 0 then
  636.                 listOff = 0
  637.             end
  638.             if listOff ~= old then
  639.                 flag = true
  640.             end
  641.            
  642.         elseif event[1] == "key" then
  643.             resume(unpack(event))
  644.             flag = true
  645.            
  646.         elseif event[1] == "char" then
  647.             resume(unpack(event))
  648.             flag = true
  649.            
  650.         elseif event[1] == "disk" or event[1] == "disk_eject" then
  651.             NewList()
  652.         elseif event[1] == "window_resize" then
  653.             termX,termY = term.getSize()
  654.             offsetX,offsetY = 1,1
  655.             hight,width = math.ceil(termY-2),math.ceil(termX-2)
  656.            
  657.             boxOffX,boxOffY = offsetX,offsetY + 2
  658.             boxH,boxW = hight - 3 ,width - 2
  659.            
  660.             barX,barY = offsetX + 1,offsetY + 2
  661.             barH,barW = 1,width - 1
  662.            
  663.             tbarX,tbarY = offsetX + 1,offsetY + 1
  664.             tbarH,tbarW = 1,width - 1
  665.            
  666.             exitX,exitY = offsetX + width - 1 ,offsetY + 1
  667.            
  668.             flag = true
  669.         end
  670.     end
  671. end
  672.  
  673. clear()
  674. fileSelect()
  675. clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement