Add mouse wheel and keyboard scrolling support to REPL

- Add scroll_offset to REPLState (max 50 lines)
- Modify _render_repl() to use manual scroll position
- Add scroll_output(delta) method for scroll control
- Add PageUp/PageDown keyboard support (scroll 10 lines)
- Add mouse wheel support via SGR mouse tracking
- Update HUD to show scroll percentage (like vim) and position
- Reset scroll when new output arrives
- Add tests for scroll functionality
This commit is contained in:
2026-03-22 17:26:14 -07:00
parent e5799a346a
commit bfcad4963a
6 changed files with 257 additions and 21 deletions

View File

@@ -575,8 +575,21 @@ def run_pipeline_mode_direct():
repl_effect.navigate_history(-1)
elif key == "down":
repl_effect.navigate_history(1)
elif key == "page_up":
repl_effect.scroll_output(-10) # Scroll up 10 lines
elif key == "page_down":
repl_effect.scroll_output(10) # Scroll down 10 lines
elif key == "backspace":
repl_effect.backspace()
elif key.startswith("mouse:"):
# Mouse event format: mouse:button:x:y
parts = key.split(":")
if len(parts) >= 2:
button = int(parts[1])
if button == 64: # Wheel up
repl_effect.scroll_output(-3) # Scroll up 3 lines
elif button == 65: # Wheel down
repl_effect.scroll_output(3) # Scroll down 3 lines
elif len(key) == 1:
repl_effect.append_to_command(key)
# --- End REPL Input Handling ---