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):
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 += f'\033[{i+1};1H\033[K'
out += line
else:
# Empty line — fill with spaces
out += ' ' * cols
out += '\033[0m'
# Status bar (bottom row, reverse video)
if input_mode: