Force output window to scroll to bottom
- Set vertical_scroll=999999 to always show newest content - Update scroll position on every invalidate - Reduced visible_lines to 20 for safety Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ce37278dcd
commit
e254ac7bf6
1 changed files with 10 additions and 6 deletions
|
|
@ -87,10 +87,10 @@ STYLE = Style.from_dict({
|
||||||
class OutputBuffer:
|
class OutputBuffer:
|
||||||
"""Manages scrolling output history."""
|
"""Manages scrolling output history."""
|
||||||
|
|
||||||
def __init__(self, max_lines: int = 1000, visible_lines: int = 50):
|
def __init__(self, max_lines: int = 1000, visible_lines: int = 20):
|
||||||
self.lines: List[tuple] = [] # (style_class, text)
|
self.lines: List[tuple] = [] # (style_class, text)
|
||||||
self.max_lines = max_lines
|
self.max_lines = max_lines
|
||||||
self.visible_lines = visible_lines # Lines to show on screen
|
self.visible_lines = visible_lines # Lines to show (fits most screens)
|
||||||
|
|
||||||
def append(self, text: str, style: str = "output"):
|
def append(self, text: str, style: str = "output"):
|
||||||
"""Add a line to output."""
|
"""Add a line to output."""
|
||||||
|
|
@ -194,12 +194,13 @@ class TUIConsole:
|
||||||
focusable=False,
|
focusable=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Output window - don't extend height, just show what we have
|
# Output window with scroll to bottom
|
||||||
output_window = Window(
|
self.output_window = Window(
|
||||||
content=output_control,
|
content=output_control,
|
||||||
wrap_lines=True,
|
wrap_lines=True,
|
||||||
dont_extend_height=True, # Only take space needed
|
|
||||||
)
|
)
|
||||||
|
# Force scroll to bottom (large number ensures we're at end)
|
||||||
|
self.output_window.vertical_scroll = 999999
|
||||||
|
|
||||||
# Empty filler that expands to push output to bottom
|
# Empty filler that expands to push output to bottom
|
||||||
filler = Window(height=Dimension(weight=1))
|
filler = Window(height=Dimension(weight=1))
|
||||||
|
|
@ -207,7 +208,7 @@ class TUIConsole:
|
||||||
# Upper area: filler on top, output at bottom
|
# Upper area: filler on top, output at bottom
|
||||||
upper_area = HSplit([
|
upper_area = HSplit([
|
||||||
filler,
|
filler,
|
||||||
output_window,
|
self.output_window,
|
||||||
])
|
])
|
||||||
|
|
||||||
# Separator line with status
|
# Separator line with status
|
||||||
|
|
@ -281,6 +282,9 @@ class TUIConsole:
|
||||||
"""Invalidate the app to trigger redraw."""
|
"""Invalidate the app to trigger redraw."""
|
||||||
if self.app:
|
if self.app:
|
||||||
try:
|
try:
|
||||||
|
# Keep output scrolled to bottom
|
||||||
|
if hasattr(self, 'output_window'):
|
||||||
|
self.output_window.vertical_scroll = 999999
|
||||||
self.app.invalidate()
|
self.app.invalidate()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue