Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ad3aUsVw
- args = {...}
- function renderProgram(name,cline,ccol,cdata,mon,linestoRender)
- -- render on advapi?
- program = split(cdata,"\n")
- l,w = mon.getSize()
- offsetrender = 0
- l = l-3; -- keep 3 for debug space.
- if(ccol > w-3) then
- offsetrender = ccol-w+3
- end
- start_line = math.max(0,cline+3-l-1);
- for current_line = 0,linestoRender do
- local c = current_line + start_line+1;
- if(program[c] ~= nil) then
- toDisplay = program[c]:sub(offsetrender,offsetrender+l);
- else
- toDisplay = "";
- end
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,c);
- mon.write(string.format("%02d", c));
- mon.write("|");
- if(c ~= cline) then
- mon.write(toDisplay);
- else
- for disp = 0,#toDisplay-1 do
- if(offsetrender + disp == ccol) then
- mon.setTextColor(colors.green)
- else
- mon.setTextColor(colors.white)
- end
- if(toDisplay:sub(disp+1,disp+1) ~= nil) then
- mon.write(toDisplay:sub(disp+1,disp+1))
- end
- end
- end
- end
- end
- function split(str, on)
- local ret = {};
- local s, e;
- while str:find(on) do
- s, e = str:find(on);
- table.insert(ret, str:sub(0, s - 1));
- str = str:sub(e + 1);
- end
- table.insert(ret, str);
- return ret;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement