Skip to content
Snippets Groups Projects
Commit cc0e2ff7 authored by rohieb's avatar rohieb
Browse files

python: make client.writeline() autoscroll as least surprise

parent ac6a6e56
No related branches found
No related tags found
No related merge requests found
......@@ -4,24 +4,8 @@ import sys
import client
# read lines from stdin and write them to the display.
# includes scrolling.
# FIXME: scrolling is slow. use a pixel buffer and blitting.
if __name__ == "__main__":
y = 0
lines = []
line = sys.stdin.readline()
while(line != ""):
client.writeline(line)
line = sys.stdin.readline()
while(line != ""):
client.write(0, y, line)
lines.append(line)
if(y == client.NUM_SEG_Y):
lines.reverse()
lines.pop()
lines.reverse()
y = 0
for l in lines:
client.write(0, y, l)
y += 1
else:
y += 1
line = sys.stdin.readline()
......@@ -111,10 +111,21 @@ def write(x, y, string):
if(x > NUM_SEG_X):
return False
# write text at beginning of line and clear remaining horizontal space
def writeline(y, string):
write(0, y, string)
write(len(string), y, ' ' * (NUM_SEG_X-len(string)))
# write line to screen as if on a terminal, scroll up if neccessary
cur_line = -1
def writeline(string):
global cur_line
cur_line += 1
if(cur_line >= NUM_SEG_Y):
scrollline()
cur_line -= 1
write(0, cur_line, string)
# clear remaining row
clear_chars = (NUM_SEG_X-len(string))
screenbuf_blit(len(string) * PWIDTH, cur_line * PHEIGHT,
clear_chars * PWIDTH, PHEIGHT,
[0] * clear_chars * PWIDTH * PHEIGHT)
# scroll the content y lines up and clear last line
def scrollline(y = 1):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment