29 lines
807 B
Python
29 lines
807 B
Python
|
|
||
|
def draw_horizontal_divider(window, y):
|
||
|
height, width = window.getmaxyx()
|
||
|
|
||
|
if y > height:
|
||
|
raise ValueError("y out of bounds")
|
||
|
|
||
|
line = '├' + '─' * (width - 2) + '┤'
|
||
|
window.addstr(y, 0, line)
|
||
|
|
||
|
|
||
|
def enumerate_lines(generator, default_color):
|
||
|
for y, item in enumerate(generator):
|
||
|
if isinstance(item, tuple) and len(item) == 2:
|
||
|
yield y, item[0], item[1]
|
||
|
elif isinstance(item, str):
|
||
|
yield y, item, default_color
|
||
|
elif item is None:
|
||
|
yield y, "", default_color
|
||
|
else:
|
||
|
raise ValueError("Wrong yield in generator")
|
||
|
|
||
|
|
||
|
def draw_lines(window, lines, x, y, default_color):
|
||
|
for dy, line, color in enumerate_lines(lines, default_color):
|
||
|
window.addstr(y + dy, x, line, color)
|
||
|
|
||
|
return y + dy + 1
|