rendering: clean a bit color attributes

This commit is contained in:
dece 2021-02-13 00:05:39 +01:00
parent e6686265d7
commit 20bcdf9df4

View file

@ -205,25 +205,20 @@ def render_lines(metalines, window, max_width):
line = line[:max_width - 1] line = line[:max_width - 1]
line_type = meta["type"] line_type = meta["type"]
if line_type == LineType.TITLE_1: if line_type == LineType.TITLE_1:
attributes = curses.color_pair(ColorPair.TITLE_1) | curses.A_BOLD attr = curses.color_pair(ColorPair.TITLE_1) | curses.A_BOLD
window.addstr(line, attributes)
elif line_type == LineType.TITLE_2: elif line_type == LineType.TITLE_2:
attributes = curses.color_pair(ColorPair.TITLE_2) | curses.A_BOLD attr = curses.color_pair(ColorPair.TITLE_2) | curses.A_BOLD
window.addstr(line, attributes)
elif line_type == LineType.TITLE_3: elif line_type == LineType.TITLE_3:
window.addstr(line, curses.color_pair(ColorPair.TITLE_3)) attr = curses.color_pair(ColorPair.TITLE_3)
elif line_type == LineType.LINK: elif line_type == LineType.LINK:
window.addstr(line, curses.color_pair(ColorPair.LINK)) attr = curses.color_pair(ColorPair.LINK)
elif line_type == LineType.PREFORMATTED: elif line_type == LineType.PREFORMATTED:
window.addstr(line, curses.color_pair(ColorPair.PREFORMATTED)) attr = curses.color_pair(ColorPair.PREFORMATTED)
elif line_type == LineType.BLOCKQUOTE: elif line_type == LineType.BLOCKQUOTE:
attributes = ( attr = curses.color_pair(ColorPair.BLOCKQUOTE) | curses.A_ITALIC
curses.color_pair(ColorPair.BLOCKQUOTE)
| curses.A_ITALIC
)
window.addstr(line, attributes)
else: # includes LineType.PARAGRAPH else: # includes LineType.PARAGRAPH
window.addstr(line) attr = curses.color_pair(ColorPair.NORMAL)
window.addstr(line, attr)
if line_index < num_lines - 1: if line_index < num_lines - 1:
window.addstr("\n") window.addstr("\n")
return num_lines, max_width return num_lines, max_width