Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. --ad3aUsVw
  2. args = {...}
  3. function renderProgram(name,cline,ccol,cdata,mon,linestoRender)
  4. -- render on advapi?
  5. program = split(cdata,"\n")
  6. l,w = mon.getSize()
  7. offsetrender = 0
  8. l = l-3; -- keep 3 for debug space.
  9. if(ccol > w-3) then
  10. offsetrender = ccol-w+3
  11. end
  12. start_line = math.max(0,cline+3-l-1);
  13.  
  14. for current_line = 0,linestoRender do
  15. local c = current_line + start_line+1;
  16. if(program[c] ~= nil) then
  17. toDisplay = program[c]:sub(offsetrender,offsetrender+l);
  18. else
  19. toDisplay = "";
  20. end
  21. mon.setTextColor(colors.white)
  22.  
  23. mon.setCursorPos(1,c);
  24. mon.write(string.format("%02d", c));
  25. mon.write("|");
  26. if(c ~= cline) then
  27. mon.write(toDisplay);
  28. else
  29. for disp = 0,#toDisplay-1 do
  30. if(offsetrender + disp == ccol) then
  31. mon.setTextColor(colors.green)
  32. else
  33. mon.setTextColor(colors.white)
  34. end
  35. if(toDisplay:sub(disp+1,disp+1) ~= nil) then
  36. mon.write(toDisplay:sub(disp+1,disp+1))
  37. end
  38.  
  39. end
  40. end
  41.  
  42. end
  43.  
  44.  
  45.  
  46. end
  47.  
  48. function split(str, on)
  49. local ret = {};
  50. local s, e;
  51. while str:find(on) do
  52. s, e = str:find(on);
  53. table.insert(ret, str:sub(0, s - 1));
  54. str = str:sub(e + 1);
  55. end
  56. table.insert(ret, str);
  57. return ret;
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement