-
Notifications
You must be signed in to change notification settings - Fork 132
feat: Switch terminal backend from Crossterm to Termwiz #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 switches the terminal backend from Crossterm to Termwiz to simplify UI code and unlock additional terminal features. Key changes include:
- Replacing Crossterm event and terminal APIs with Termwiz equivalents.
- Updating tests and key parsing logic to work with Termwiz types.
- Removing the now-unused crossterm dependency from Cargo.toml.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui.rs | Uses Termwiz for cursor positioning instead of function invocation |
| src/tests/helpers/ui.rs | Updates event mapping to use Termwiz input events |
| src/term.rs | Replaces Crossterm backend with Termwiz backend and related functions |
| src/state.rs | Updates event handling and pending key storage to Termwiz types |
| src/prompt.rs | Refactors prompt state and rendering with updated key handling |
| src/ops/* | Updates prompt state checks to property access instead of method calls |
| src/main.rs | Changes terminal initialization and raw mode handling |
| src/lib.rs | Adjusts event polling and key event construction for Termwiz |
| src/key_parser.rs | Updates parser to emit Termwiz input events and fixes key codes |
| src/error.rs | Adds Termwiz error variant |
| src/bindings.rs | Alters binding key types to use Termwiz modifiers and key codes |
| Cargo.toml | Removes Crossterm and enables Termwiz support in ratatui |
Comments suppressed due to low confidence (3)
src/state.rs:175
- [nitpick] The change from 'key.code' to 'key.key' might be confusing. Consider verifying that 'key.key' clearly represents the intended key value consistent with Termwiz conventions.
self.pending_keys.push((key.modifiers, key.key));
src/key_parser.rs:94
- [nitpick] Uppercase letters no longer apply a SHIFT modifier during parsing. If this behavior is intended, consider documenting it; otherwise, adjust the parsing logic to automatically add the SHIFT modifier for uppercase characters.
assert_eq!(parse_keys("A"), Ok(("", vec![(Modifiers::NONE, Char('A'))])));
src/ui.rs:78
- The change from invoking cursor as a function to accessing it as a field requires verification that state.prompt.state.cursor always holds an updated tuple (u16, u16). Please confirm that this change aligns with the new design.
let (cx, cy) = state.prompt.state.cursor;
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## refactor/remove-term-dep-in-state #352 +/- ##
=====================================================================
- Coverage 86.67% 85.65% -1.03%
=====================================================================
Files 66 66
Lines 6163 6356 +193
=====================================================================
+ Hits 5342 5444 +102
- Misses 821 912 +91 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@altsem Working well for me on a mac! |
|
@altsem I've just noticed that when I change the size of my terminal window, a redraw isn't triggered, and gitu doesn't respect the new size (in wezterm and alacritty). Resize events are logged, with correct size values. Is it working for you? If it's mac-specific, I'll try to debug it. |
|
@sbillig I didn't manage to figure out a fix for the rendering bug. One alternative is to rewrite the entire rendering code in Termwiz straight away. |
|
I think I'm willing to ignore that rendering bug i encountered for now, it only seems to apply if The terminal resize bug should be fixed, but I still haven't managed to figure it out. |
The goal is to inevitably switch from Ratatui, and start using Termwiz with Termwiz widgets. My hope is that this will clean up the UI code quite a bit, as well as allow more features like re-interpreting terminal codes, and perhaps using Termwiz's line editor with autocomplete for prompts.
The goal is to inevitably switch from Ratatui, and start using Termwiz
with Termwiz widgets.
My hope is that this will clean up the UI code quite a bit,
as well as allow more features like re-interpreting terminal codes,
and perhaps using Termwiz's line editor with autocomplete for prompts.
This merely switches the "backend" of Ratatui from Crossterm to Termwiz.
TODO: