Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@altsem
Copy link
Owner

@altsem altsem commented Sep 22, 2025

Started a bit on going back to using crossterm. I reverted the commits, but might've missed a bunch of stuff. it's not compiling yet. All of this could be squashed to a single commit I think. It's in a messy state.

@altsem altsem force-pushed the feat/revert-to-crossterm branch from f1cf63b to f9105cf Compare September 28, 2025 19:25
@altsem altsem marked this pull request as ready for review September 28, 2025 20:04
@altsem
Copy link
Owner Author

altsem commented Sep 28, 2025

@jonathanj I did some progress, it appears to run great!

  • No longer need .saturating_sub(1) when dealing with mouse events, they're 0-indexed
  • Mouse capture/reporting is enabled by default in Crossterm. So I had to switch that.
  • I don't encounter the strange key inputs when mouse capture is on.
  • It seems to fix the issue of Ctrl+j being interpreted as enter (making hunk lines selectable again)
  • Rendering issues when background color touches end of screen is no longer present.
  • Achieved world peace

The tests are broken though D:

@jonathanj
Copy link
Contributor

That all sounds really positive. I'm happy to contribute fixes for the mouse tests.

The 1-indexed lines are annoying in the implementation, but when looking at the snapshot it's really convenient that the snapshot lines are the exact value for the mouse position. I was thinking that maybe the mouse_event helper could just be refactored to adjust the Y position (so subtract 1) and then use an internal enum instead of relying on MouseButtons from termwiz.

Should make it a bit more robust.

@jonathanj
Copy link
Contributor

jonathanj commented Sep 29, 2025

I see you already modified the mouse_event to accept the crossterm values, so all I did was adjust the Y-position inside mouse_event. I would advocate for this because of how much it helps the test+snapshot iteration loop, over the technical correctness of the underlying library.

Anyway, with this diff the test suite passes again!

diff --git a/src/tests/helpers/ui.rs b/src/tests/helpers/ui.rs
index 4a75008..76dc5cd 100644
--- a/src/tests/helpers/ui.rs
+++ b/src/tests/helpers/ui.rs
@@ -136,7 +136,7 @@ pub fn mouse_event(x: u16, y: u16, mouse_button: MouseButton) -> Event {
     Event::Mouse(crossterm::event::MouseEvent {
         kind: crossterm::event::MouseEventKind::Down(mouse_button),
         column: x,
-        row: y,
+        row: y.saturating_sub(1),
         modifiers: KeyModifiers::NONE,
     })
 }

@altsem
Copy link
Owner Author

altsem commented Sep 29, 2025

ah, I was looking at the x-value "It is zero, so it must be 0-indexed". 🤦 Thanks!

@altsem altsem force-pushed the feat/revert-to-crossterm branch from f3fd4e7 to 01b1e72 Compare September 29, 2025 15:34
@altsem altsem requested a review from Copilot September 29, 2025 15:35
@altsem altsem changed the title Feat/revert to crossterm feat: revert to using Crossterm as backend (fixes rendering/input bugs) Sep 29, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reverts the terminal backend from termwiz to crossterm, migrating input handling, event processing, and mouse operations to use crossterm's API instead. This represents a significant architectural change to restore crossterm as the primary terminal library.

  • Migration from termwiz to crossterm event handling and input processing
  • Replacement of custom prompt implementation with tui-prompts library
  • Updated mouse event handling and scroll wheel support

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/ui.rs Imports tui-prompts library and updates cursor position access
src/tests/mod.rs Replaces termwiz mouse types with crossterm equivalents in tests
src/tests/helpers/ui.rs Migrates test helpers from termwiz to crossterm event types
src/term.rs Complete rewrite of terminal backend to use crossterm instead of termwiz
src/prompt.rs Removes custom prompt implementation in favor of tui-prompts
src/main.rs Adds panic handler and restructures terminal initialization
src/lib.rs Updates event handling imports and structures
src/key_parser.rs Migrates key parsing from termwiz to crossterm types
src/error.rs Removes termwiz error handling
src/bindings.rs Updates key binding types for crossterm
src/app.rs Major refactor of event handling and input processing
Cargo.toml Adds crossterm and tui-prompts dependencies, removes termwiz

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 61.67401% with 87 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.75%. Comparing base (b69bdc8) to head (a7d7f82).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/term.rs 14.28% 54 Missing ⚠️
src/main.rs 0.00% 15 Missing ⚠️
src/lib.rs 0.00% 7 Missing ⚠️
src/app.rs 90.00% 5 Missing ⚠️
src/key_parser.rs 92.30% 4 Missing ⚠️
src/error.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #423      +/-   ##
==========================================
+ Coverage   86.62%   87.75%   +1.13%     
==========================================
  Files          71       71              
  Lines        7385     7188     -197     
==========================================
- Hits         6397     6308      -89     
+ Misses        988      880     -108     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@altsem altsem force-pushed the feat/revert-to-crossterm branch from 01b1e72 to a7d7f82 Compare September 29, 2025 15:57
@altsem altsem merged commit 1d468ae into master Sep 29, 2025
5 checks passed
@altsem altsem deleted the feat/revert-to-crossterm branch September 29, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants