Advertisement
Pinkishu

writeHook

Aug 13th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. hookFuncs.write = function(str)
  2.  
  3.     local screen = getActiveScreen()
  4.     log("Writeing /"..str.."/ on /"..screen.screenName.."/")
  5.     local wLine = screen.screenData[screen.cursorPosY]
  6.     local sX = screen.cursorPosX
  7.     local pre = ""
  8.     if sX > 1 then
  9.         pre = string.sub(wLine,1,sX-1)
  10.     end
  11.     local post = ""
  12.     sX = screen.cursorPosX + string.len(str)
  13.     if sX <= screenSizeX then
  14.         post = string.sub(wLine,sX)
  15.     end
  16.     local newLine = string.sub(pre..str..post,1,screenSizeX)
  17.     screen.screenData[screen.cursorPosY] = newLine
  18.     if getDisplayScreen().screenName == screen.screenName then
  19.         screen:redraw(screen.cursorPosX,screen.cursorPosY,string.len(str),1)
  20.     end
  21.     screen.cursorPosX = math.min(screen.cursorPosX + string.len(str),screenSizeX)
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement