1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-09-29 04:35:54 -04:00

Don't draw out of bounds

This commit is contained in:
Ivan Habunek 2018-01-13 13:03:45 +01:00
parent 5463e86d5d
commit e829ce2714
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95

View File

@ -1,10 +1,8 @@
def draw_horizontal_divider(window, y):
height, width = window.getmaxyx()
if y > height:
raise ValueError("y out of bounds")
# Don't draw out of bounds
if y < height - 1:
line = '' + '' * (width - 2) + ''
window.addstr(y, 0, line)
@ -22,7 +20,9 @@ def enumerate_lines(generator, default_color):
def draw_lines(window, lines, x, y, default_color):
height, _ = window.getmaxyx()
for dy, line, color in enumerate_lines(lines, default_color):
if y + dy < height - 1:
window.addstr(y + dy, x, line, color)
return y + dy + 1