2018-01-06 16:32:27 +00:00
|
|
|
def draw_horizontal_divider(window, y):
|
|
|
|
height, width = window.getmaxyx()
|
|
|
|
|
2018-01-13 12:03:45 +00:00
|
|
|
# Don't draw out of bounds
|
|
|
|
if y < height - 1:
|
|
|
|
line = '├' + '─' * (width - 2) + '┤'
|
|
|
|
window.addstr(y, 0, line)
|
2018-01-06 16:32:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
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):
|
2018-01-13 12:03:45 +00:00
|
|
|
height, _ = window.getmaxyx()
|
2018-01-06 16:32:27 +00:00
|
|
|
for dy, line, color in enumerate_lines(lines, default_color):
|
2018-01-13 12:03:45 +00:00
|
|
|
if y + dy < height - 1:
|
|
|
|
window.addstr(y + dy, x, line, color)
|
2018-01-06 16:32:27 +00:00
|
|
|
|
|
|
|
return y + dy + 1
|