Advertisement
Alakazard12

CC OC Edit port

Jan 19th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.35 KB | None | 0 0
  1. -- Get file to edit
  2. local tArgs = { ... }
  3. if #tArgs == 0 then
  4.     print( "Usage: edit <path>" )
  5.     return
  6. end
  7.  
  8. local isColor = false
  9.  
  10. -- Error checking
  11. local sPath = shell.resolve( tArgs[1] )
  12. local bReadOnly = false --fs.isReadOnly( sPath )
  13. if fs.exists( sPath ) and fs.isDir( sPath ) then
  14.     print( "Cannot edit a directory." )
  15.     return
  16. end
  17.  
  18. local gpu = component.gpu
  19.  
  20. local x,y = 1,1
  21. local w,h = gpu.getResolution()
  22. local scrollX, scrollY = 0,0
  23.  
  24. local tLines = {}
  25. local bRunning = true
  26.  
  27. local mColors = {
  28.     black = 0x000000;
  29.     white = 0xFFFFFF;
  30.     yellow = 0xF2DD3A;
  31.     green = 0x1B6320;
  32.     red = 0xFF0000;
  33. }
  34.  
  35.  
  36. -- Minecraft key code bindings
  37. -- See http://www.minecraftwiki.net/wiki/Key_codes for more info
  38.  
  39. local nothing = 42
  40. local tKeys = {
  41.     nil,        "one",      "two",      "three",    "four",         -- 1
  42.     "five",     "six",      "seven",    "eight",    "nine",         -- 6
  43.     "zero",     "minus",    "equals",   "backspace","tab",          -- 11
  44.     "q",        "w",        "e",        "r",        "t",            -- 16
  45.     "y",        "u",        "i",        "o",        "p",            -- 21
  46.     "leftBracket","rightBracket","enter","leftCtrl","a",            -- 26
  47.     "s",        "d",        "f",        "g",        "h",            -- 31
  48.     "j",        "k",        "l",        "semiColon","apostrophe",   -- 36
  49.     "grave",    "leftShift","backslash","z",        "x",            -- 41
  50.     "c",        "v",        "b",        "n",        "m",            -- 46
  51.     "comma",    "period",   "slash",    "rightShift","multiply",    -- 51
  52.     "leftAlt",  "space",    "capsLock", "f1",       "f2",           -- 56
  53.     "f3",       "f4",       "f5",       "f6",       "f7",           -- 61
  54.     "f8",       "f9",       "f10",      "numLock",  "scollLock",    -- 66  
  55.     "numPad7",  "numPad8",  "numPad9",  "numPadSubtract","numPad4", -- 71
  56.     "numPad5",  "numPad6",  "numPadAdd","numPad1",  "numPad2",      -- 76
  57.     "numPad3",  "numPad0",  "numPadDecimal",nil,    nil,            -- 81
  58.     nil,        "f11",      "f12",      nil,        nil,            -- 86
  59.     nil,        nil,        nil,        nil,        nil,            -- 91
  60.     nil,        nil,        nil,        nil,        "f13",          -- 96
  61.     "f14",      "f15",      nil,        nil,        nil,            -- 101
  62.     nil,        nil,        nil,        nil,        nil,            -- 106
  63.     nil,        "kana",     nil,        nil,        nil,            -- 111
  64.     nil,        nil,        nil,        nil,        nil,            -- 116 
  65.     "convert",  nil,        "noconvert",nil,        "yen",          -- 121
  66.     nil,        nil,        nil,        nil,        nil,            -- 126
  67.     nil,        nil,        nil,        nil,        nil,            -- 131
  68.     nil,        nil,        nil,        nil,        nil,            -- 136
  69.     "numPadEquals",nil,     nil,        "cimcumflex","at",          -- 141
  70.     "colon",    "underscore","kanji",   "stop",     "ax",           -- 146
  71.     nil,        "numPadEnter","rightCtrl",nil,      nil,            -- 151
  72.     nil,        nil,        nil,        nil,        nil,            -- 156
  73.     nil,        nil,        nil,        nil,        nil,            -- 161
  74.     nil,        nil,        nil,        nil,        nil,            -- 166
  75.     nil,        nil,        nil,        nil,        nil,            -- 171
  76.     nil,        nil,        nil,        "numPadComma",nil,          -- 176
  77.     "numPadDivide",nil,     nil,        "rightAlt", nil,            -- 181
  78.     nil,        nil,        nil,        nil,        nil,            -- 186
  79.     nil,        nil,        nil,        nil,        nil,            -- 191
  80.     nil,        "pause",    nil,        "home",     "up",           -- 196
  81.     "pageUp",   nil,        "left",     nil,        "right",        -- 201
  82.     nil,        "end",      "down",     "pageDown", "insert",       -- 206
  83.     "delete"                                                        -- 211
  84. }
  85.  
  86. local keys = {}
  87. for nKey, sKey in pairs( tKeys ) do
  88.     keys[sKey] = nKey
  89. end
  90. keys["return"] = keys.enter
  91.  
  92.  
  93.  
  94. -- mColors
  95. local highlightColour, keywordColour, commentColour, textColour, bgColour
  96. if isColor then
  97.     bgColour = mColors.black
  98.     textColour = mColors.white
  99.     highlightColour = mColors.yellow
  100.     keywordColour = mColors.yellow
  101.     commentColour = mColors.green
  102.     stringColour = mColors.red
  103. else
  104.     bgColour = mColors.black
  105.     textColour = mColors.white
  106.     highlightColour = mColors.white
  107.     keywordColour = mColors.white
  108.     commentColour = mColors.white
  109.     stringColour = mColors.white
  110. end
  111.  
  112. -- Menus
  113. local bMenu = false
  114. local nMenuItem = 1
  115.  
  116. local tMenuItems
  117. if bReadOnly then
  118.     tMenuItems = { "Exit", "Print" }
  119. else
  120.     tMenuItems = { "Save", "Exit", "Print" }
  121. end
  122.    
  123. local sStatus = "Press Ctrl to access menu"
  124.  
  125. local function load( _sPath )
  126.     tLines = {}
  127.     if fs.exists( _sPath ) then
  128.         local file = io.open( _sPath, "r" )
  129.         local sLine = file:read()
  130.         while sLine do
  131.             table.insert( tLines, sLine )
  132.             sLine = file:read()
  133.         end
  134.         file:close()
  135.     end
  136.    
  137.     if #tLines == 0 then
  138.         table.insert( tLines, "" )
  139.     end
  140. end
  141.  
  142. local function save( _sPath )
  143.     -- Create intervening folder
  144.     local sDir = sPath:sub(1, sPath:len() - fs.name(sPath):len() )
  145.     if not fs.exists( sDir ) then
  146.         fs.makeDirectory( sDir )
  147.     end
  148.  
  149.     -- Save
  150.     local file = nil
  151.     local function innerSave()
  152.         file = io.open( _sPath, "w" )
  153.         if file then
  154.             for n, sLine in ipairs( tLines ) do
  155.                 file:write( sLine .. "\n" )
  156.             end
  157.         else
  158.             error( "Failed to open ".._sPath )
  159.         end
  160.     end
  161.    
  162.     local ok = pcall( innerSave )
  163.     if file then
  164.         file:close()
  165.     end
  166.     return ok
  167. end
  168.  
  169. local tKeywords = {
  170.     ["and"] = true,
  171.     ["break"] = true,
  172.     ["do"] = true,
  173.     ["else"] = true,
  174.     ["elseif"] = true,
  175.     ["end"] = true,
  176.     ["false"] = true,
  177.     ["for"] = true,
  178.     ["function"] = true,
  179.     ["if"] = true,
  180.     ["in"] = true,
  181.     ["local"] = true,
  182.     ["nil"] = true,
  183.     ["not"] = true,
  184.     ["or"] = true,
  185.     ["repeat"] = true,
  186.     ["return"] = true,
  187.     ["then"] = true,
  188.     ["true"] = true,
  189.     ["until"]= true,
  190.     ["while"] = true,
  191. }
  192.  
  193. local function tryWrite( sLine, regex, colour )
  194.     local match = string.match( sLine, regex )
  195.     if match then
  196.         if type(colour) == "number" then
  197.             gpu.setForeground( colour )
  198.         else
  199.             gpu.setForeground( colour(match) )
  200.         end
  201.         term.write( match )
  202.         gpu.setForeground( textColour )
  203.         return string.sub( sLine, string.len(match) + 1 )
  204.     end
  205.     return nil
  206. end
  207.  
  208. local function writeHighlighted( sLine )
  209.     while string.len(sLine) > 0 do 
  210.         sLine =
  211.             tryWrite( sLine, "^%-%-%[%[.-%]%]", commentColour ) or
  212.             tryWrite( sLine, "^%-%-.*", commentColour ) or
  213.             tryWrite( sLine, "^\".-[^\\]\"", stringColour ) or
  214.             tryWrite( sLine, "^\'.-[^\\]\'", stringColour ) or
  215.             tryWrite( sLine, "^%[%[.-%]%]", stringColour ) or
  216.             tryWrite( sLine, "^[%w_]+", function( match )
  217.                 if tKeywords[ match ] then
  218.                     return keywordColour
  219.                 end
  220.                 return textColour
  221.             end ) or
  222.             tryWrite( sLine, "^[^%w_]", textColour )
  223.     end
  224. end
  225.  
  226. local function redrawText()
  227.     for y=1,h-1 do
  228.         term.setCursor( 1 - scrollX, y )
  229.         term.clearLine()
  230.  
  231.         local sLine = tLines[ y + scrollY ]
  232.         if sLine ~= nil then
  233.             writeHighlighted( sLine )
  234.         end
  235.     end
  236.     term.setCursor( x - scrollX, y - scrollY )
  237. end
  238.  
  239. local function redrawLine(_nY)
  240.     local sLine = tLines[_nY]
  241.     term.setCursor( 1 - scrollX, _nY - scrollY )
  242.     term.clearLine()
  243.     writeHighlighted( sLine )
  244.     term.setCursor( x - scrollX, _nY - scrollY )
  245. end
  246.  
  247. local function redrawMenu()
  248.     term.setCursor( 1, h )
  249.     term.clearLine()
  250.  
  251.     local sLeft, sRight
  252.     local nLeftColour, nLeftHighlight1, nLeftHighlight2
  253.     if bMenu then
  254.         local sMenu = ""
  255.         for n,sItem in ipairs( tMenuItems ) do
  256.             if n == nMenuItem then
  257.                 nLeftHighlight1 = sMenu:len() + 1
  258.                 nLeftHighlight2 = sMenu:len() + sItem:len() + 2
  259.             end
  260.             sMenu = sMenu.." "..sItem.." "
  261.         end
  262.         sLeft = sMenu
  263.         nLeftColour = textColour
  264.     else
  265.         sLeft = sStatus
  266.         nLeftColour = highlightColour
  267.     end
  268.    
  269.     -- Left goes last so that it can overwrite the line numbers.
  270.     sRight = "Ln "..y
  271.     gpu.setForeground( highlightColour )
  272.     term.setCursor( w-sRight:len() + 1, h )
  273.     term.write(sRight)
  274.  
  275.     sRight = tostring(y)
  276.     gpu.setForeground( textColour )
  277.     term.setCursor( w-sRight:len() + 1, h )
  278.     term.write(sRight)
  279.  
  280.     if sLeft then
  281.         term.setCursor( 1, h )
  282.         gpu.setForeground( nLeftColour )
  283.         term.write(sLeft)      
  284.         if nLeftHighlight1 then
  285.             gpu.setForeground( highlightColour )
  286.             term.setCursor( nLeftHighlight1, h )
  287.             term.write( "[" )
  288.             term.setCursor( nLeftHighlight2, h )
  289.             term.write( "]" )
  290.         end
  291.         gpu.setForeground( textColour )
  292.     end
  293.    
  294.     -- Cursor highlights selection
  295.     term.setCursor( x - scrollX, y - scrollY )
  296. end
  297.  
  298. local tMenuFuncs = {
  299.     Save=function()
  300.         if bReadOnly then
  301.             sStatus = "Access denied"
  302.         else
  303.             local ok, err = save( sPath )
  304.             if ok then
  305.                 sStatus="Saved to "..sPath
  306.             else
  307.                 sStatus="Error saving to "..sPath
  308.             end
  309.         end
  310.         redrawMenu()
  311.     end,
  312.     Print=function()
  313.         --[[
  314.         local sPrinterSide = nil
  315.         for n,sName in ipairs(peripheral.getNames()) do
  316.             if peripheral.isPresent(sName) and peripheral.getType(sName) == "printer" then
  317.                 sPrinterSide = sName
  318.                 break
  319.             end
  320.         end
  321.        
  322.         if not sPrinterSide then
  323.             sStatus = "No printer attached"
  324.             return
  325.         end
  326.  
  327.         local nPage = 0
  328.         local sName = fs.getName( sPath )
  329.         local printer = peripheral.wrap(sPrinterSide)
  330.         if printer.getInkLevel() < 1 then
  331.             sStatus = "Printer out of ink"
  332.             return
  333.         elseif printer.getPaperLevel() < 1 then
  334.             sStatus = "Printer out of paper"
  335.             return
  336.         end
  337.        
  338.         local terminal = {
  339.             getCursorPos = printer.getCursorPos,
  340.             setCursorPos = printer.setCursorPos,
  341.             getSize = printer.getPageSize,
  342.             write = printer.write,
  343.         }
  344.         terminal.scroll = function()
  345.             if nPage == 1 then
  346.                 printer.setPageTitle( sName.." (page "..nPage..")" )           
  347.             end
  348.            
  349.             while not printer.newPage() do
  350.                 if printer.getInkLevel() < 1 then
  351.                     sStatus = "Printer out of ink, please refill"
  352.                 elseif printer.getPaperLevel() < 1 then
  353.                     sStatus = "Printer out of paper, please refill"
  354.                 else
  355.                     sStatus = "Printer output tray full, please empty"
  356.                 end
  357.    
  358.                 term.restore()
  359.                 redrawMenu()
  360.                 term.redirect( terminal )
  361.                
  362.                 local timer = os.startTimer(0.5)
  363.                 sleep(0.5)
  364.             end
  365.  
  366.             nPage = nPage + 1
  367.             if nPage == 1 then
  368.                 printer.setPageTitle( sName )
  369.             else
  370.                 printer.setPageTitle( sName.." (page "..nPage..")" )
  371.             end
  372.         end
  373.        
  374.         bMenu = false
  375.         term.redirect( terminal )
  376.         local ok, error = pcall( function()
  377.             term.scroll()
  378.             for n, sLine in ipairs( tLines ) do
  379.                 print( sLine )
  380.             end
  381.         end )
  382.         term.restore()
  383.         if not ok then
  384.             print( error )
  385.         end
  386.        
  387.         while not printer.endPage() do
  388.             sStatus = "Printer output tray full, please empty"
  389.             redrawMenu()
  390.             sleep( 0.5 )
  391.         end
  392.         bMenu = true
  393.            
  394.         if nPage > 1 then
  395.             sStatus = "Printed "..nPage.." Pages"
  396.         else
  397.             sStatus = "Printed 1 Page"
  398.         end]]
  399.         sStatus = "Printing disabled in OC port"
  400.         redrawMenu()
  401.     end,
  402.     Exit=function()
  403.         bRunning = false
  404.     end
  405. }
  406.  
  407. local function doMenuItem( _n )
  408.     tMenuFuncs[tMenuItems[_n]]()
  409.     if bMenu then
  410.         bMenu = false
  411.         term.setCursorBlink( true )
  412.     end
  413.     redrawMenu()
  414. end
  415.  
  416. local function setCursort( x, y )
  417.     local screenX = x - scrollX
  418.     local screenY = y - scrollY
  419.    
  420.     local bRedraw = false
  421.     if screenX < 1 then
  422.         scrollX = x - 1
  423.         screenX = 1
  424.         bRedraw = true
  425.     elseif screenX > w then
  426.         scrollX = x - w
  427.         screenX = w
  428.         bRedraw = true
  429.     end
  430.    
  431.     if screenY < 1 then
  432.         scrollY = y - 1
  433.         screenY = 1
  434.         bRedraw = true
  435.     elseif screenY > h-1 then
  436.         scrollY = y - (h-1)
  437.         screenY = h-1
  438.         bRedraw = true
  439.     end
  440.    
  441.     if bRedraw then
  442.         redrawText()
  443.     end
  444.     term.setCursor( screenX, screenY )
  445.    
  446.     -- Statusbar now pertains to menu, it would probably be safe to redraw the menu on every key event.
  447.     redrawMenu()
  448. end
  449.  
  450. -- Actual program functionality begins
  451. load(sPath)
  452.  
  453. gpu.setBackground( bgColour )
  454. term.clear()
  455. term.setCursor(x,y)
  456. term.setCursorBlink( true )
  457.  
  458. redrawText()
  459. redrawMenu()
  460.  
  461. -- Handle input
  462. while bRunning do
  463.     local sEvent, id, paramc, param, param1 = event.pull()
  464.     if sEvent == "key_down" then
  465.         if param == keys.up then
  466.             -- Up
  467.             if not bMenu then
  468.                 if y > 1 then
  469.                     -- Move cursor up
  470.                     y = y - 1
  471.                     x = math.min( x, string.len( tLines[y] ) + 1 )
  472.                     setCursort( x, y )
  473.                 end
  474.             end
  475.         elseif param == keys.down then
  476.             -- Down
  477.             if not bMenu then
  478.                 -- Move cursor down
  479.                 if y < #tLines then
  480.                     y = y + 1
  481.                     x = math.min( x, string.len( tLines[y] ) + 1 )
  482.                     setCursort( x, y )
  483.                 end
  484.             end
  485.         elseif param == keys.tab then
  486.             -- Tab
  487.             if not bMenu and not bReadOnly then
  488.                 -- Indent line
  489.                 tLines[y]="  "..tLines[y]
  490.                 x = x + 2
  491.                 setCursort( x, y )
  492.                 redrawLine(y)
  493.             end
  494.         elseif param == keys.pageUp then
  495.             -- Page Up
  496.             if not bMenu then
  497.                 -- Move up a page
  498.                 local sx,sy=term.getSize()
  499.                 y=y-sy-1
  500.                 if y<1 then y=1 end
  501.                 x = math.min( x, string.len( tLines[y] ) + 1 )
  502.                 setCursort( x, y )
  503.             end
  504.         elseif param == keys.pageDown then
  505.             -- Page Down
  506.             if not bMenu then
  507.                 -- Move down a page
  508.                 local sx,sy=term.getSize()
  509.                 if y<#tLines-sy-1 then
  510.                     y = y+sy-1
  511.                 else
  512.                     y = #tLines
  513.                 end
  514.                 x = math.min( x, string.len( tLines[y] ) + 1 )
  515.                 setCursort( x, y )
  516.             end
  517.         elseif param == keys.home then
  518.             -- Home
  519.             if not bMenu then
  520.                 -- Move cursor to the beginning
  521.                 x=1
  522.                 setCursort(x,y)
  523.             end
  524.         elseif param == keys["end"] then
  525.             -- End
  526.             if not bMenu then
  527.                 -- Move cursor to the end
  528.                 x = string.len( tLines[y] ) + 1
  529.                 setCursort(x,y)
  530.             end
  531.         elseif param == keys.left then
  532.             -- Left
  533.             if not bMenu then
  534.                 if x > 1 then
  535.                     -- Move cursor left
  536.                     x = x - 1
  537.                 elseif x==1 and y>1 then
  538.                     x = string.len( tLines[y-1] ) + 1
  539.                     y = y - 1
  540.                 end
  541.                 setCursort( x, y )
  542.             else
  543.                 -- Move menu left
  544.                 nMenuItem = nMenuItem - 1
  545.                 if nMenuItem < 1 then
  546.                     nMenuItem = #tMenuItems
  547.                 end
  548.                 redrawMenu()
  549.             end
  550.         elseif param == keys.right then
  551.             -- Right
  552.             if not bMenu then
  553.                 if x < string.len( tLines[y] ) + 1 then
  554.                     -- Move cursor right
  555.                     x = x + 1
  556.                 elseif x==string.len( tLines[y] ) + 1 and y<#tLines then
  557.                     x = 1
  558.                     y = y + 1
  559.                 end
  560.                 setCursort( x, y )
  561.             else
  562.                 -- Move menu right
  563.                 nMenuItem = nMenuItem + 1
  564.                 if nMenuItem > #tMenuItems then
  565.                     nMenuItem = 1
  566.                 end
  567.                 redrawMenu()
  568.             end
  569.         elseif param == keys.delete then
  570.             -- Delete
  571.             if not bMenu and not bReadOnly then
  572.                 if  x < string.len( tLines[y] ) + 1 then
  573.                     local sLine = tLines[y]
  574.                     tLines[y] = string.sub(sLine,1,x-1) .. string.sub(sLine,x+1)
  575.                     redrawLine(y)
  576.                 elseif y<#tLines then
  577.                     tLines[y] = tLines[y] .. tLines[y+1]
  578.                     table.remove( tLines, y+1 )
  579.                     redrawText()
  580.                     redrawMenu()
  581.                 end
  582.             end
  583.         elseif param == keys.backspace then
  584.             -- Backspace
  585.             if not bMenu and not bReadOnly then
  586.                 if x > 1 then
  587.                     -- Remove character
  588.                     local sLine = tLines[y]
  589.                     tLines[y] = string.sub(sLine,1,x-2) .. string.sub(sLine,x)
  590.                     redrawLine(y)
  591.            
  592.                     x = x - 1
  593.                     setCursort( x, y )
  594.                 elseif y > 1 then
  595.                     -- Remove newline
  596.                     local sPrevLen = string.len( tLines[y-1] )
  597.                     tLines[y-1] = tLines[y-1] .. tLines[y]
  598.                     table.remove( tLines, y )
  599.                     redrawText()
  600.                
  601.                     x = sPrevLen + 1
  602.                     y = y - 1
  603.                     setCursort( x, y )
  604.                 end
  605.             end
  606.         elseif param == keys.enter then
  607.             -- Enter
  608.             if not bMenu and not bReadOnly then
  609.                 -- Newline
  610.                 local sLine = tLines[y]
  611.                 local _,spaces=string.find(sLine,"^[ ]+")
  612.                 if not spaces then
  613.                     spaces=0
  614.                 end
  615.                 tLines[y] = string.sub(sLine,1,x-1)
  616.                 table.insert( tLines, y+1, string.rep(' ',spaces)..string.sub(sLine,x) )
  617.                 redrawText()
  618.            
  619.                 x = spaces+1
  620.                 y = y + 1
  621.                 setCursort( x, y )
  622.             elseif bMenu then
  623.                 -- Menu selection
  624.                 doMenuItem( nMenuItem )
  625.             end
  626.         elseif param == keys.leftCtrl or param == keys.rightCtrl then
  627.             -- Menu toggle
  628.             bMenu = not bMenu
  629.             if bMenu then
  630.                 term.setCursorBlink( false )
  631.                 nMenuItem = 1
  632.             else
  633.                 term.setCursorBlink( true )
  634.             end
  635.             redrawMenu()
  636.         elseif paramc and paramc ~= 0 then
  637.             param = string.char(paramc)
  638.             if param then
  639.                 if not bMenu and not bReadOnly then
  640.                     -- Input text
  641.                     local sLine = tLines[y]
  642.                     tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
  643.                     redrawLine(y)
  644.                
  645.                     x = x + string.len( param )
  646.                     setCursort( x, y )
  647.                 elseif bMenu then
  648.                     -- Select menu items
  649.                     for n,sMenuItem in ipairs( tMenuItems ) do
  650.                         if string.lower(string.sub(sMenuItem,1,1)) == string.lower(param) then
  651.                             doMenuItem( n )
  652.                             break
  653.                         end
  654.                     end
  655.                 end
  656.             end
  657.         end
  658.  
  659.         os.sleep(0.01)
  660.        
  661.     --[[elseif sEvent == "mouse_click" then
  662.         if not bMenu then
  663.             if param == 1 then
  664.                 -- Left click
  665.                 local cx,cy = param2, param3
  666.                 if cy < h then
  667.                     y = math.min( math.max( scrollY + cy, 1 ), #tLines )
  668.                     x = math.min( math.max( scrollX + cx, 1 ), string.len( tLines[y] ) + 1 )
  669.                     setCursort( x, y )
  670.                 end
  671.             end
  672.         end
  673.        
  674.     elseif sEvent == "mouse_scroll" then
  675.         if not bMenu then
  676.             if param == -1 then
  677.                 -- Scroll up
  678.                 if scrollY > 0 then
  679.                     -- Move cursor up
  680.                     scrollY = scrollY - 1
  681.                     redrawText()
  682.                 end
  683.            
  684.             elseif param == 1 then
  685.                 -- Scroll down
  686.                 local nMaxScroll = #tLines - (h-1)
  687.                 if scrollY < nMaxScroll then
  688.                     -- Move cursor down
  689.                     scrollY = scrollY + 1
  690.                     redrawText()
  691.                 end
  692.                
  693.             end
  694.         end]]
  695.     end
  696. end
  697.  
  698. -- Cleanup
  699. term.clear()
  700. term.setCursorBlink( false )
  701. term.setCursor( 1, 1 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement