diff --git a/briefing b/briefing index 0aa831d..fc9dee2 100755 --- a/briefing +++ b/briefing @@ -550,20 +550,34 @@ def tui_viewer(range_days, client): def split_lines(content): return content.split('\n') + ANSI_ESC = re.compile(r'\x1b\[[0-9;]*m') + + def visible_len(s): + """Length of string excluding ANSI escape codes.""" + return len(ANSI_ESC.sub('', s)) + def render(): rows, cols = get_terminal_size() view_height = rows - 1 # bottom row = status bar - # Move cursor to top-left, clear screen - out = '\033[H\033[2J' + # Move cursor to top-left + out = '\033[H' for i in range(view_height): line_idx = scroll + i + out += f'\033[{i+1};1H' if line_idx < len(lines): line = lines[line_idx] - out += f'\033[{i+1};1H{line}\033[K' + # Pad line to fill terminal width + pad = cols - visible_len(line) + if pad > 0: + out += line + ' ' * pad + else: + out += line else: - out += f'\033[{i+1};1H\033[K' + # Empty line — fill with spaces + out += ' ' * cols + out += '\033[0m' # Status bar (bottom row, reverse video) if input_mode: