Advertisement
slipers

pe

Mar 21st, 2022
1,264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.93 KB | None | 0 0
  1. -- Get file to edit
  2. local tArgs = { ... }
  3. if #tArgs == 0 then
  4.     print( "Usage: "..fs.getName(shell.getRunningProgram()).." <path>" )
  5.     return
  6. end
  7.  
  8. -- Error checking
  9. local sPath = shell.resolve( tArgs[1] )
  10. local bReadOnly = fs.isReadOnly( sPath )
  11. if fs.exists( sPath ) and fs.isDir( sPath ) then
  12.     print( "Cannot edit a directory." )
  13.     return
  14. end
  15. if not settings then
  16.     _G.settings = {}
  17.     settings.get = function(s) return false end
  18. end
  19.  
  20. local x,y = 1,1
  21. local w,h = term.getSize()
  22. local scrollX, scrollY = 0,0
  23. local bRunOption = false --No python interpreter exists for CC (to the best of my knowledge)
  24.  
  25. local tLines = {}
  26. local bRunning = true
  27.  
  28. -- Colours
  29. local highlightColour, keywordColour, commentColour, textColour, bgColour, stringColour
  30. if term.isColour() then
  31.     bgColour = colours.black
  32.     textColour = colours.white
  33.     highlightColour = colours.yellow
  34.     keywordColour = colours.orange
  35.     commentColour = colours.green
  36.     stringColour = colours.red
  37. else
  38.     bgColour = colours.white
  39.     textColour = colours.black
  40.     highlightColour = colours.black
  41.     keywordColour = colours.black
  42.     commentColour = colours.black
  43.     stringColour = colours.black
  44. end
  45.  
  46. -- Menus
  47. local bMenu = false
  48. local nMenuItem = 1
  49. local tMenuItems = {}
  50. if not bReadOnly then
  51.     table.insert( tMenuItems, "Save" )
  52. end
  53. if shell.openTab and bRunOption then
  54.     table.insert( tMenuItems, "Run" )
  55. end
  56. if peripheral.find( "printer" ) then
  57.     table.insert( tMenuItems, "Print" )
  58. end
  59. table.insert( tMenuItems, "Exit" )
  60.  
  61. local sStatus = "Press Ctrl to access menu"
  62. if string.len( sStatus ) > w - 5 then
  63.     sStatus = "Press Ctrl for menu"
  64. end
  65.  
  66. local function load( _sPath )
  67.     tLines = {}
  68.     if fs.exists( _sPath ) then
  69.         local file = io.open( _sPath, "r" )
  70.         local sLine = file:read()
  71.         while sLine do
  72.             table.insert( tLines, sLine )
  73.             sLine = file:read()
  74.         end
  75.         file:close()
  76.     end
  77.    
  78.     if #tLines == 0 then
  79.         table.insert( tLines, "" )
  80.     end
  81. end
  82.  
  83. local function save( _sPath )
  84.     -- Create intervening folder
  85.     local sDir = _sPath:sub(1, _sPath:len() - fs.getName(_sPath):len() )
  86.     if not fs.exists( sDir ) then
  87.         fs.makeDir( sDir )
  88.     end
  89.  
  90.     -- Save
  91.     local file = nil
  92.     local function innerSave()
  93.         file = fs.open( _sPath, "w" )
  94.         if file then
  95.             for n, sLine in ipairs( tLines ) do
  96.                 file.write( sLine .. "\n" )
  97.             end
  98.         else
  99.             error( "Failed to open ".._sPath )
  100.         end
  101.     end
  102.    
  103.     local ok, err = pcall( innerSave )
  104.     if file then
  105.         file.close()
  106.     end
  107.     return ok, err
  108. end
  109.  
  110. local tKeywords = {}
  111. local function addKeywords(list)
  112.   for i=1,#list do
  113.     tKeywords[list[i]] = true
  114.   end
  115. end
  116. addKeywords({":","and","as","assert","break","class","continue","def","del","elif","else","except","exec","finally","for","from","global","if","import","in","is","lambda","not","or","pass","print","raise","return","try","while","with","yield"})
  117.  
  118. local function tryWrite( sLine, regex, colour )
  119.     local match = string.match( sLine, regex )
  120.     if match then
  121.         if type(colour) == "number" then
  122.             term.setTextColour( colour )
  123.         else
  124.             term.setTextColour( colour(match) )
  125.         end
  126.         term.write( match )
  127.         term.setTextColour( textColour )
  128.         return string.sub( sLine, string.len(match) + 1 )
  129.     end
  130.     return nil
  131. end
  132.  
  133. local function writeHighlighted( sLine )
  134.     while string.len(sLine) > 0 do 
  135.         sLine =
  136.             tryWrite( sLine, "^\"\"\".+\"\"\"", stringColour ) or
  137.    tryWrite( sLine, "^'''.+'''", stringColour) or
  138.             tryWrite( sLine, "^#.*", commentColour ) or
  139.             tryWrite( sLine, "^\"\"", stringColour ) or
  140.             tryWrite( sLine, "^\".-[^\\]\"", stringColour ) or
  141.             tryWrite( sLine, "^\'\'", stringColour ) or
  142.             tryWrite( sLine, "^\'.-[^\\]\'", stringColour ) or
  143.    tryWrite( sLine, "^:", keywordColour) or
  144.             tryWrite( sLine, "^[%w_]+", function( match )
  145.                 if tKeywords[ match ] then
  146.                     return keywordColour
  147.                 end
  148.                 return textColour
  149.             end ) or
  150.             tryWrite( sLine, "^[^%w_]", textColour )
  151.     end
  152. end
  153.  
  154. local tCompletions
  155. local nCompletion
  156.  
  157. local tCompleteEnv = {}
  158. for k,v in pairs(tKeywords) do table.insert(tCompleteEnv,k) end
  159. local function complete( sLine )
  160.     if settings.get( "edit.autocomplete" ) then
  161.         local nStartPos = string.find( sLine, "[a-zA-Z0-9_%.]+$" )
  162.         if nStartPos then
  163.             sLine = string.sub( sLine, nStartPos )
  164.         end
  165.         if #sLine > 0 then
  166.             return textutils.complete( sLine, tCompleteEnv )
  167.         end
  168.     end
  169.     return nil
  170. end
  171.  
  172. local function recomplete()
  173.     local sLine = tLines[y]
  174.     if not bMenu and not bReadOnly and x == string.len(sLine) + 1 then
  175.         tCompletions = complete( sLine )
  176.         if tCompletions and #tCompletions > 0 then
  177.             nCompletion = 1
  178.         else
  179.             nCompletion = nil
  180.         end
  181.     else
  182.         tCompletions = nil
  183.         nCompletion = nil
  184.     end
  185. end
  186.  
  187. local function writeCompletion( sLine )
  188.     if nCompletion then
  189.         local sCompletion = tCompletions[ nCompletion ]
  190.         term.setTextColor( colours.white )
  191.         term.setBackgroundColor( colours.grey )
  192.         term.write( sCompletion )
  193.         term.setTextColor( textColour )
  194.         term.setBackgroundColor( bgColour )
  195.     end
  196. end
  197.  
  198. local function redrawText()
  199.     local cursorX, cursorY = x, y
  200.     for y=1,h-1 do
  201.         term.setCursorPos( 1 - scrollX, y )
  202.         term.clearLine()
  203.  
  204.         local sLine = tLines[ y + scrollY ]
  205.         if sLine ~= nil then
  206.             writeHighlighted( sLine )
  207.             if cursorY == y and cursorX == #sLine + 1 then
  208.                 writeCompletion()
  209.             end
  210.         end
  211.     end
  212.     term.setCursorPos( x - scrollX, y - scrollY )
  213. end
  214.  
  215. local function redrawLine(_nY)
  216.     local sLine = tLines[_nY]
  217.     if sLine then
  218.         term.setCursorPos( 1 - scrollX, _nY - scrollY )
  219.         term.clearLine()
  220.         writeHighlighted( sLine )
  221.         if _nY == y and x == #sLine + 1 then
  222.             writeCompletion()
  223.         end
  224.         term.setCursorPos( x - scrollX, _nY - scrollY )
  225.     end
  226. end
  227.  
  228. local function redrawMenu()
  229.     -- Clear line
  230.     term.setCursorPos( 1, h )
  231.     term.clearLine()
  232.  
  233.     -- Draw line numbers
  234.     term.setCursorPos( w - string.len( "Ln "..y ) + 1, h )
  235.     term.setTextColour( highlightColour )
  236.     term.write( "Ln " )
  237.     term.setTextColour( textColour )
  238.     term.write( y )
  239.  
  240.     term.setCursorPos( 1, h )
  241.     if bMenu then
  242.         -- Draw menu
  243.         term.setTextColour( textColour )
  244.         for nItem,sItem in pairs( tMenuItems ) do
  245.             if nItem == nMenuItem then
  246.                 term.setTextColour( highlightColour )
  247.                 term.write( "[" )
  248.                 term.setTextColour( textColour )
  249.                 term.write( sItem )
  250.                 term.setTextColour( highlightColour )
  251.                 term.write( "]" )
  252.                 term.setTextColour( textColour )
  253.             else
  254.                 term.write( " "..sItem.." " )
  255.             end
  256.         end
  257.     else
  258.         -- Draw status
  259.         term.setTextColour( highlightColour )
  260.         term.write( sStatus )
  261.         term.setTextColour( textColour )
  262.     end
  263.  
  264.     -- Reset cursor
  265.     term.setCursorPos( x - scrollX, y - scrollY )
  266. end
  267.  
  268. local tMenuFuncs = {
  269.     Save = function()
  270.         if bReadOnly then
  271.             sStatus = "Access denied"
  272.         else
  273.             local ok, err = save( sPath )
  274.             if ok then
  275.                 sStatus="Saved to "..sPath
  276.             else
  277.                 sStatus="Error saving to "..sPath
  278.             end
  279.         end
  280.         redrawMenu()
  281.     end,
  282.     Print = function()
  283.         local printer = peripheral.find( "printer" )
  284.         if not printer then
  285.             sStatus = "No printer attached"
  286.             return
  287.         end
  288.  
  289.         local nPage = 0
  290.         local sName = fs.getName( sPath )
  291.         if printer.getInkLevel() < 1 then
  292.             sStatus = "Printer out of ink"
  293.             return
  294.         elseif printer.getPaperLevel() < 1 then
  295.             sStatus = "Printer out of paper"
  296.             return
  297.         end
  298.  
  299.         local screenTerminal = term.current()
  300.         local printerTerminal = {
  301.             getCursorPos = printer.getCursorPos,
  302.             setCursorPos = printer.setCursorPos,
  303.             getSize = printer.getPageSize,
  304.             write = printer.write,
  305.         }
  306.         printerTerminal.scroll = function()
  307.             if nPage == 1 then
  308.                 printer.setPageTitle( sName.." (page "..nPage..")" )           
  309.             end
  310.            
  311.             while not printer.newPage() do
  312.                 if printer.getInkLevel() < 1 then
  313.                     sStatus = "Printer out of ink, please refill"
  314.                 elseif printer.getPaperLevel() < 1 then
  315.                     sStatus = "Printer out of paper, please refill"
  316.                 else
  317.                     sStatus = "Printer output tray full, please empty"
  318.                 end
  319.    
  320.                 term.redirect( screenTerminal )
  321.                 redrawMenu()
  322.                 term.redirect( printerTerminal )
  323.                
  324.                 local timer = os.startTimer(0.5)
  325.                 sleep(0.5)
  326.             end
  327.  
  328.             nPage = nPage + 1
  329.             if nPage == 1 then
  330.                 printer.setPageTitle( sName )
  331.             else
  332.                 printer.setPageTitle( sName.." (page "..nPage..")" )
  333.             end
  334.         end
  335.        
  336.         bMenu = false
  337.         term.redirect( printerTerminal )
  338.         local ok, error = pcall( function()
  339.             term.scroll()
  340.             for n, sLine in ipairs( tLines ) do
  341.                 print( sLine )
  342.             end
  343.         end )
  344.         term.redirect( screenTerminal )
  345.         if not ok then
  346.             print( error )
  347.         end
  348.        
  349.         while not printer.endPage() do
  350.             sStatus = "Printer output tray full, please empty"
  351.             redrawMenu()
  352.             sleep( 0.5 )
  353.         end
  354.         bMenu = true
  355.            
  356.         if nPage > 1 then
  357.             sStatus = "Printed "..nPage.." Pages"
  358.         else
  359.             sStatus = "Printed 1 Page"
  360.         end
  361.         redrawMenu()
  362.     end,
  363.     Exit = function()
  364.         bRunning = false
  365.     end,
  366.     Run = function()
  367.         local sTempPath = "/.temp"
  368.         local ok, err = save( sTempPath )
  369.         if ok then
  370.             local nTask = shell.openTab( sTempPath )
  371.             if nTask then
  372.                 shell.switchTab( nTask )
  373.             else
  374.                 sStatus="Error starting Task"
  375.             end
  376.             fs.delete( sTempPath )
  377.         else
  378.             sStatus="Error saving to "..sTempPath
  379.         end
  380.         redrawMenu()
  381.     end
  382. }
  383.  
  384. local function doMenuItem( _n )
  385.     tMenuFuncs[tMenuItems[_n]]()
  386.     if bMenu then
  387.         bMenu = false
  388.         term.setCursorBlink( true )
  389.     end
  390.     redrawMenu()
  391. end
  392.  
  393. local function setCursor( newX, newY )
  394.     local oldX, oldY = x, y
  395.     x, y = newX, newY
  396.     local screenX = x - scrollX
  397.     local screenY = y - scrollY
  398.    
  399.     local bRedraw = false
  400.     if screenX < 1 then
  401.         scrollX = x - 1
  402.         screenX = 1
  403.         bRedraw = true
  404.     elseif screenX > w then
  405.         scrollX = x - w
  406.         screenX = w
  407.         bRedraw = true
  408.     end
  409.    
  410.     if screenY < 1 then
  411.         scrollY = y - 1
  412.         screenY = 1
  413.         bRedraw = true
  414.     elseif screenY > h-1 then
  415.         scrollY = y - (h-1)
  416.         screenY = h-1
  417.         bRedraw = true
  418.     end
  419.  
  420.     recomplete()
  421.     if bRedraw then
  422.         redrawText()
  423.     elseif y ~= oldY then
  424.         redrawLine( oldY )
  425.         redrawLine( y )
  426.     else
  427.         redrawLine( y )
  428.     end
  429.     term.setCursorPos( screenX, screenY )
  430.  
  431.     redrawMenu()
  432. end
  433.  
  434. -- Actual program functionality begins
  435. load(sPath)
  436.  
  437. term.setBackgroundColour( bgColour )
  438. term.clear()
  439. term.setCursorPos(x,y)
  440. term.setCursorBlink( true )
  441.  
  442. recomplete()
  443. redrawText()
  444. redrawMenu()
  445.  
  446. local function acceptCompletion()
  447.     if nCompletion then
  448.         -- Append the completion
  449.         local sCompletion = tCompletions[ nCompletion ]
  450.         tLines[y] = tLines[y] .. sCompletion
  451.         setCursor( x + string.len( sCompletion ), y )
  452.     end
  453. end
  454.  
  455. -- Handle input
  456. while bRunning do
  457.     local sEvent, param, param2, param3 = os.pullEvent()
  458.     if sEvent == "key" then
  459.         local oldX, oldY = x, y
  460.         if param == keys.up then
  461.             -- Up
  462.             if not bMenu then
  463.                 if nCompletion then
  464.                     -- Cycle completions
  465.                     nCompletion = nCompletion - 1
  466.                     if nCompletion < 1 then
  467.                         nCompletion = #tCompletions
  468.                     end
  469.                     redrawLine(y)
  470.  
  471.                 elseif y > 1 then
  472.                     -- Move cursor up
  473.                     setCursor(
  474.                         math.min( x, string.len( tLines[y - 1] ) + 1 ),
  475.                         y - 1
  476.                     )
  477.                 end
  478.             end
  479.  
  480.         elseif param == keys.down then
  481.             -- Down
  482.             if not bMenu then
  483.                 -- Move cursor down
  484.                 if nCompletion then
  485.                     -- Cycle completions
  486.                     nCompletion = nCompletion + 1
  487.                     if nCompletion > #tCompletions then
  488.                         nCompletion = 1
  489.                     end
  490.                     redrawLine(y)
  491.  
  492.                 elseif y < #tLines then
  493.                     -- Move cursor down
  494.                     setCursor(
  495.                         math.min( x, string.len( tLines[y + 1] ) + 1 ),
  496.                         y + 1
  497.                     )
  498.                 end
  499.             end
  500.  
  501.         elseif param == keys.tab then
  502.             -- Tab
  503.             if not bMenu and not bReadOnly then
  504.                 if nCompletion and x == string.len(tLines[y]) + 1 then
  505.                     -- Accept autocomplete
  506.                     acceptCompletion()
  507.                 else
  508.                     -- Indent line
  509.                     local sLine = tLines[y]
  510.                     tLines[y] = string.sub(sLine,1,x-1) .. "  " .. string.sub(sLine,x)
  511.                     setCursor( x + 2, y )
  512.                 end
  513.             end
  514.  
  515.         elseif param == keys.pageUp then
  516.             -- Page Up
  517.             if not bMenu then
  518.                 -- Move up a page
  519.                 local newY
  520.                 if y - (h - 1) >= 1 then
  521.                     newY = y - (h - 1)
  522.                 else
  523.                     newY = 1
  524.                 end
  525.                 setCursor(
  526.                     math.min( x, string.len( tLines[newY] ) + 1 ),
  527.                     newY
  528.                 )
  529.             end
  530.  
  531.         elseif param == keys.pageDown then
  532.             -- Page Down
  533.             if not bMenu then
  534.                 -- Move down a page
  535.                 local newY
  536.                 if y + (h - 1) <= #tLines then
  537.                     newY = y + (h - 1)
  538.                 else
  539.                     newY = #tLines
  540.                 end
  541.                 local newX = math.min( x, string.len( tLines[newY] ) + 1 )
  542.                 setCursor( newX, newY )
  543.             end
  544.  
  545.         elseif param == keys.home then
  546.             -- Home
  547.             if not bMenu then
  548.                 -- Move cursor to the beginning
  549.                 if x > 1 then
  550.                     setCursor(1,y)
  551.                 end
  552.             end
  553.  
  554.         elseif param == keys["end"] then
  555.             -- End
  556.             if not bMenu then
  557.                 -- Move cursor to the end
  558.                 local nLimit = string.len( tLines[y] ) + 1
  559.                 if x < nLimit then
  560.                     setCursor( nLimit, y )
  561.                 end
  562.             end
  563.  
  564.         elseif param == keys.left then
  565.             -- Left
  566.             if not bMenu then
  567.                 if x > 1 then
  568.                     -- Move cursor left
  569.                     setCursor( x - 1, y )
  570.                 elseif x==1 and y>1 then
  571.                     setCursor( string.len( tLines[y-1] ) + 1, y - 1 )
  572.                 end
  573.             else
  574.                 -- Move menu left
  575.                 nMenuItem = nMenuItem - 1
  576.                 if nMenuItem < 1 then
  577.                     nMenuItem = #tMenuItems
  578.                 end
  579.                 redrawMenu()
  580.             end
  581.  
  582.         elseif param == keys.right then
  583.             -- Right
  584.             if not bMenu then
  585.                 local nLimit = string.len( tLines[y] ) + 1
  586.                 if x < nLimit then
  587.                     -- Move cursor right
  588.                     setCursor( x + 1, y )
  589.                 elseif nCompletion and x == string.len(tLines[y]) + 1 then
  590.                     -- Accept autocomplete
  591.                     acceptCompletion()
  592.                 elseif x==nLimit and y<#tLines then
  593.                     -- Go to next line
  594.                     setCursor( 1, y + 1 )
  595.                 end
  596.             else
  597.                 -- Move menu right
  598.                 nMenuItem = nMenuItem + 1
  599.                 if nMenuItem > #tMenuItems then
  600.                     nMenuItem = 1
  601.                 end
  602.                 redrawMenu()
  603.             end
  604.  
  605.         elseif param == keys.delete then
  606.             -- Delete
  607.             if not bMenu and not bReadOnly then
  608.                 local nLimit = string.len( tLines[y] ) + 1
  609.                 if x < nLimit then
  610.                     local sLine = tLines[y]
  611.                     tLines[y] = string.sub(sLine,1,x-1) .. string.sub(sLine,x+1)
  612.                     recomplete()
  613.                     redrawLine(y)
  614.                 elseif y<#tLines then
  615.                     tLines[y] = tLines[y] .. tLines[y+1]
  616.                     table.remove( tLines, y+1 )
  617.                     recomplete()
  618.                     redrawText()
  619.                 end
  620.             end
  621.  
  622.         elseif param == keys.backspace then
  623.             -- Backspace
  624.             if not bMenu and not bReadOnly then
  625.                 if x > 1 then
  626.                     -- Remove character
  627.                     local sLine = tLines[y]
  628.                     tLines[y] = string.sub(sLine,1,x-2) .. string.sub(sLine,x)
  629.                     setCursor( x - 1, y )
  630.                 elseif y > 1 then
  631.                     -- Remove newline
  632.                     local sPrevLen = string.len( tLines[y-1] )
  633.                     tLines[y-1] = tLines[y-1] .. tLines[y]
  634.                     table.remove( tLines, y )
  635.                     setCursor( sPrevLen + 1, y - 1 )
  636.                     redrawText()
  637.                 end
  638.             end
  639.  
  640.         elseif param == keys.enter then
  641.             -- Enter
  642.             if not bMenu and not bReadOnly then
  643.                 -- Newline
  644.                 local sLine = tLines[y]
  645.                 local _,spaces=string.find(sLine,"^[ ]+")
  646.                 if not spaces then
  647.                     spaces=0
  648.                 end
  649.                 tLines[y] = string.sub(sLine,1,x-1)
  650.                 table.insert( tLines, y+1, string.rep(' ',spaces)..string.sub(sLine,x) )
  651.                 setCursor( spaces + 1, y + 1 )
  652.                 redrawText()
  653.  
  654.             elseif bMenu then
  655.                 -- Menu selection
  656.                 doMenuItem( nMenuItem )
  657.  
  658.             end
  659.  
  660.         elseif param == keys.leftCtrl or param == keys.rightCtrl or param == keys.rightAlt then
  661.             -- Menu toggle
  662.             bMenu = not bMenu
  663.             if bMenu then
  664.                 term.setCursorBlink( false )
  665.             else
  666.                 term.setCursorBlink( true )
  667.             end
  668.             redrawMenu()
  669.  
  670.         end
  671.        
  672.     elseif sEvent == "char" then
  673.         if not bMenu and not bReadOnly then
  674.             -- Input text
  675.             local sLine = tLines[y]
  676.             tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
  677.             setCursor( x + 1, y )
  678.  
  679.         elseif bMenu then
  680.             -- Select menu items
  681.             for n,sMenuItem in ipairs( tMenuItems ) do
  682.                 if string.lower(string.sub(sMenuItem,1,1)) == string.lower(param) then
  683.                     doMenuItem( n )
  684.                     break
  685.                 end
  686.             end
  687.         end
  688.  
  689.     elseif sEvent == "paste" then
  690.         if not bMenu and not bReadOnly then
  691.             -- Input text
  692.             local sLine = tLines[y]
  693.             tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
  694.             setCursor( x + string.len( param ), y )
  695.         end
  696.        
  697.     elseif sEvent == "mouse_click" then
  698.         if not bMenu then
  699.             if param == 1 then
  700.                 -- Left click
  701.                 local cx,cy = param2, param3
  702.                 if cy < h then
  703.                     local newY = math.min( math.max( scrollY + cy, 1 ), #tLines )
  704.                     local newX = math.min( math.max( scrollX + cx, 1 ), string.len( tLines[newY] ) + 1 )
  705.                     setCursor( newX, newY )
  706.                 end
  707.             end
  708.         end
  709.        
  710.     elseif sEvent == "mouse_scroll" then
  711.         if not bMenu then
  712.             if param == -1 then
  713.                 -- Scroll up
  714.                 if scrollY > 0 then
  715.                     -- Move cursor up
  716.                     scrollY = scrollY - 1
  717.                     redrawText()
  718.                 end
  719.            
  720.             elseif param == 1 then
  721.                 -- Scroll down
  722.                 local nMaxScroll = #tLines - (h-1)
  723.                 if scrollY < nMaxScroll then
  724.                     -- Move cursor down
  725.                     scrollY = scrollY + 1
  726.                     redrawText()
  727.                 end
  728.                
  729.             end
  730.         end
  731.  
  732.     elseif sEvent == "term_resize" then
  733.         w,h = term.getSize()
  734.         setCursor( x, y )
  735.         redrawMenu()
  736.         redrawText()
  737.  
  738.     end
  739. end
  740.  
  741. -- Cleanup
  742. term.setBackgroundColor(colors.black)
  743. term.clear()
  744. term.setCursorBlink( false )
  745. term.setCursorPos( 1, 1 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement