Files
simplicitty/AmazonQ.md

42 lines
1.9 KiB
Markdown

# Text Scrolling Implementation in Simplicitty
This document outlines the implementation of text scrolling in the Simplicitty terminal emulator project.
## Overview
The implementation adds the ability to scroll through text content when it doesn't fit completely in the window. The scrolling is implemented on a line-by-line basis, allowing users to navigate through the content using keyboard shortcuts.
## Key Components
1. **Scroll State Management**:
- Added `scroll_offset` to track the current scroll position (in visual lines)
- Added `max_scroll_offset` to limit scrolling to available content
2. **Viewport Calculation**:
- Modified `get_visible_line_range()` to consider the scroll offset when determining visible lines
- Added `update_max_scroll_offset()` to recalculate the maximum scroll position based on content and viewport size
3. **Scrolling Methods**:
- `scroll_up(lines)`: Move viewport up by specified number of lines
- `scroll_down(lines)`: Move viewport down by specified number of lines
- `page_up()`: Scroll up by one page (viewport height)
- `page_down()`: Scroll down by one page (viewport height)
4. **Keyboard Controls**:
- Ctrl+Up/Down: Scroll one line up/down
- Page Up/Down: Scroll one page up/down
- Ctrl+Home/End: Scroll to top/bottom of content
## Implementation Details
The scrolling implementation works by adjusting the `scroll_offset` value, which determines which visual lines are rendered in the viewport. The `get_visible_line_range()` function uses this offset to calculate which logical lines should be rendered.
When the window is resized or content changes, the `max_scroll_offset` is recalculated to ensure scrolling remains within valid bounds.
## Future Improvements
1. Add mouse wheel support for scrolling
2. Implement smooth scrolling animations
3. Add a visual scrollbar indicator
4. Preserve horizontal scroll position when navigating vertically