Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- reverses cc terminal output left to right
- -- pastebin get rxSRAq2h rev
- local oldterm = {}
- local oldos = {}
- local oldio = {}
- local scr_x,scr_y = term.getSize()
- local revTable = {
- ["("] = ")",
- [")"] = "(",
- ["["] = "]",
- ["]"] = "[",
- ["{"] = "}",
- ["}"] = "{",
- ["<"] = ">",
- [">"] = "<",
- ["/"] = "\\",
- ["\\"] = "/",
- }
- local strReverse = function(str)
- local output = str:reverse()
- for k,v in pairs(revTable) do
- output = output:gsub(k,v)
- end
- return output
- end
- oldterm.getCursorPos = term.getCursorPos
- term.getCursorPos = function()
- local cx,cy = oldterm.getCursorPos()
- return scr_x-(cx-1),cy
- end
- oldterm.setCursorPos = term.setCursorPos
- term.setCursorPos = function(x,y)
- return oldterm.setCursorPos(scr_x-(x-1), y)
- end
- oldio.write = io.write
- io.write = function(txt)
- local cx,cy = term.getCursorPos()
- oldterm.setCursorPos(cx-(txt:len()-0),cy)
- oldio.write(strReverse(txt:reverse()))
- oldterm.setCursorPos(cx-(txt:len()-0),cy)
- end
- oldterm.write = term.write
- term.write = function(txt)
- local cx,cy = getCursorPos()
- oldterm.setCursorPos(cx-(txt:len()-0),cy)
- oldterm.write(strReverse(txt:reverse()))
- oldterm.setCursorPos(cx-(txt:len()-0),cy)
- end
- oldterm.blit = term.blit
- term.blit = function(text,txt,bg)
- if (#text == #txt) and (#txt == #bg) then
- local cx,cy = term.getCursorPos()
- oldterm.setCursorPos(cx-(text:len()-0),cy)
- oldterm.blit(strReverse(text:reverse()),txt:reverse(),bg:reverse())
- oldterm.setCursorPos(cx-(text:len()-0),cy)
- else
- error("Arguments must be the same length")
- end
- end
- oldos.pullEventRaw = os.pullEventRaw
- os.pullEventRaw = function(event)
- local evt = oldos.pullEventRaw(event)
- if (evt == "mouse_click") or (evt == "mouse_drag") then
- return evt[1], evt[2], scr_x-(evt[3]-1), evt[4]
- elseif evt == "mouse_up" then
- return evt[1],scr_x-(evt[2]-1),evt[3]
- else
- return table.unpack(evt)
- end
- end
- oldos.pullEvent = os.pullEvent
- os.pullEvent = function(event)
- local evt = oldos.pullEvent(event)
- if (evt == "mouse_click") or (evt == "mouse_drag") then
- return evt[1], evt[2], scr_x-(evt[3]-1), evt[4]
- elseif evt == "mouse_up" then
- return evt[1],scr_x-(evt[2]-1),evt[3]
- else
- return table.unpack(evt)
- end
- end
- local startShell = function(program)
- term.clear()
- term.setCursorPos(1,1)
- dofile(program or "/rom/programs/shell")
- end
- startShell()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement