fixing docs
This commit is contained in:
parent
573caaa681
commit
fff43f1a78
1 changed files with 8 additions and 9 deletions
|
|
@ -112,7 +112,7 @@ class OutputBuffer:
|
||||||
|
|
||||||
# Check if cursor is at end (user hasn't scrolled up)
|
# Check if cursor is at end (user hasn't scrolled up)
|
||||||
old_text = self.buffer.text
|
old_text = self.buffer.text
|
||||||
was_at_end = self.buffer.cursor_position >= len(old_text)
|
was_at_end = self.is_at_bottom() # Use new method
|
||||||
|
|
||||||
# Update buffer text
|
# Update buffer text
|
||||||
text = "\n".join(self._lines)
|
text = "\n".join(self._lines)
|
||||||
|
|
@ -120,9 +120,10 @@ class OutputBuffer:
|
||||||
if was_at_end:
|
if was_at_end:
|
||||||
# Stay at bottom - auto-scroll
|
# Stay at bottom - auto-scroll
|
||||||
self.buffer.set_document(
|
self.buffer.set_document(
|
||||||
Document(text=text, cursor_position=len(text)),
|
Document(text=text), # Removed cursor_position
|
||||||
bypass_readonly=True
|
bypass_readonly=True
|
||||||
)
|
)
|
||||||
|
self.buffer.cursor_position = len(text) # Force bottom
|
||||||
else:
|
else:
|
||||||
# Preserve scroll position - silent append
|
# Preserve scroll position - silent append
|
||||||
old_pos = self.buffer.cursor_position
|
old_pos = self.buffer.cursor_position
|
||||||
|
|
@ -131,16 +132,14 @@ class OutputBuffer:
|
||||||
bypass_readonly=True
|
bypass_readonly=True
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_at_bottom(self) -> bool:
|
|
||||||
"""Check if output is scrolled to bottom (or near bottom)."""
|
|
||||||
doc = self.buffer.document
|
|
||||||
# Consider "at bottom" if on last 3 lines
|
|
||||||
return doc.cursor_position_row >= doc.line_count - 3
|
|
||||||
|
|
||||||
def scroll_to_bottom(self):
|
def scroll_to_bottom(self):
|
||||||
"""Scroll to the very bottom."""
|
"""Snap to bottom."""
|
||||||
self.buffer.cursor_position = len(self.buffer.text)
|
self.buffer.cursor_position = len(self.buffer.text)
|
||||||
|
|
||||||
|
def is_at_bottom(self) -> bool:
|
||||||
|
"""Cursor at/near end? (tolerance 1 line)."""
|
||||||
|
return self.buffer.cursor_position >= len(self.buffer.text) - len(self.buffer.text.split('\n', 1)[0]) - 1
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""Clear output."""
|
"""Clear output."""
|
||||||
self._lines.clear()
|
self._lines.clear()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue