def _add_line(y, x, window, line):
# split but \033 which stands for a color change
color_split = line.split('\033')
# Print the first part of the line without color change
default_color_pair = _get_color(curses.COLOR_WHITE, curses.COLOR_BLACK)
window.addstr(y, x, color_split[0], curses.color_pair(default_color_pair))
x += len(color_split[0])
# Iterate over the rest of the line-parts and print them with their colors
for substring in color_split[1:]:
color_str = substring.split('m')[0]
substring = substring[len(color_str)+1:]
color_pair = _color_str_to_color_pair(color_str)
window.addstr(y, x, substring, curses.color_pair(color_pair))
x += len(substring)
评论列表
文章目录