fix: fill full terminal width — pad all lines to cols

Every line now pads to the full terminal width so there are
no gaps. Empty lines below content are filled with spaces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 13:35:31 +02:00
parent de98efde3c
commit b67cf4c1bd

View File

@@ -550,20 +550,34 @@ def tui_viewer(range_days, client):
def split_lines(content): def split_lines(content):
return content.split('\n') 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(): def render():
rows, cols = get_terminal_size() rows, cols = get_terminal_size()
view_height = rows - 1 # bottom row = status bar view_height = rows - 1 # bottom row = status bar
# Move cursor to top-left, clear screen # Move cursor to top-left
out = '\033[H\033[2J' out = '\033[H'
for i in range(view_height): for i in range(view_height):
line_idx = scroll + i line_idx = scroll + i
out += f'\033[{i+1};1H'
if line_idx < len(lines): if line_idx < len(lines):
line = lines[line_idx] 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: 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) # Status bar (bottom row, reverse video)
if input_mode: if input_mode: