Add mouse support for TUI interaction #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements mouse event support for the headless terminal, enabling programmatic interaction
with mouse-enabled TUI applications via the JSON STDIN API.
Addresses some of #2
Motivation
I need mouse support to use
htfor integration testing of TUI applications. Being able toprogrammatically send mouse events (clicks, drags, scrolling) is essential for comprehensive
testing of interactive terminal applications.
Changes
mousecommand to STDIN API supporting:press,release,drag, andclick(convenience shorthand)left,middle,right,wheel_up,wheel_downshift,alt,control\x1b[<format) for compatibility with modern TUIapps
Example Usage
{ "type": "mouse", "event": "click", "button": "left", "row": 10, "col": 25 } { "type": "mouse", "event": "drag", "button": "left", "row": 12, "col": 30 } { "type": "mouse", "event": "press", "button": "right", "row": 5, "col": 15, "control": true }Caveats
I should note that this PR is somewhat "vibe-coded" - I'm not deeply familiar with Rust, so
there may be idioms or patterns I've missed that would improve the implementation. I'd
appreciate any feedback on code quality, error handling, or areas that could be more
idiomatic. Happy to iterate on the implementation.
Testing
Manually tested
clickevents, using rlwrap with a mouse-enabled TUI application. All unittests pass.