-
-
Notifications
You must be signed in to change notification settings - Fork 422
feat(crossterm): allow multiple crossterm versions #1841
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
base: main
Are you sure you want to change the base?
Conversation
a5b5347
to
67d8a4a
Compare
This commit introduces feature flags to make it possible for widget library authors to depend on a specific version of crossterm without causing version conflicts. The available feature flags are `crossterm_0_28` and `crossterm_0_29`.
67d8a4a
to
f3d5e7c
Compare
## Enables crossterm 0.28.x | ||
crossterm_0_28 = ["dep:crossterm_0_28"] | ||
## Enables crossterm 0.29.x | ||
crossterm_0_29 = ["dep:crossterm_0_29"] |
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.
It might get a bit annoying to add a new feature flag for the each new version of crossterm, even the patches. Or are you thinking of only doing this for the minor versions?
Are we fine with that? If they decide to speed up their release cycle we might end up with so many feature flags. Maybe we can let the upstream know that we are doing this and hear what they think?
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.
It's only necessary for semver incompatible versions (0.x -> 0.x+1). Patch version doesn't matter.
It's also fairly unlikely that crossterm will speed up development IMO. Either way, we can roll with it as needed.
Perhaps we support last 2 versions or something like that. The rationale here is to make it possible for downstream widget crates to support several versions as needed.
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.
Yeah, supporting only the last 2-3 versions sound reasonable to me. We should then update these docs accordingly (we only support blah blah)
I still believe we should adjust this PR a bit to make it easier to add new versions (see my other comments)
//! version of Crossterm is compiled and used by the backend. Attempting to enable none or multiple | ||
//! `crossterm_xx` features will result in a compile-time error. | ||
//! | ||
//! To promote interoperability within the [Ratatui] ecosystem, the selected Crossterm crate is |
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.
//! To promote interoperability within the [Ratatui] ecosystem, the selected Crossterm crate is | |
//! To promote interoperability within the [Ratatui] ecosystem, the selected [Crossterm] crate is |
//! `ratatui-crossterm` requires you to specify a version of the [Crossterm] library to be used. | ||
//! This is managed via feature flags. You **must** enable one, and only one, of the available | ||
//! `crossterm_xx` features (e.g., `crossterm_28`, `crossterm_29`). These features determine which | ||
//! version of Crossterm is compiled and used by the backend. Attempting to enable none or multiple |
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.
//! version of Crossterm is compiled and used by the backend. Attempting to enable none or multiple | |
//! version of [Crossterm] is compiled and used by the backend. Attempting to enable none or multiple |
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.
We don't need to link every time this is mentioned. It's enough to link it in the first paragraph I think. Sound good?
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.
I'd link every time due to OCD... but sure :D
//! | ||
//! To promote interoperability within the [Ratatui] ecosystem, the selected Crossterm crate is | ||
//! re-exported as `ratatui_crossterm::crossterm`. This re-export is essential for authors of widget | ||
//! libraries or any applications that need to perform direct Crossterm operations while ensuring |
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.
//! libraries or any applications that need to perform direct Crossterm operations while ensuring | |
//! libraries or any applications that need to perform direct [Crossterm] operations while ensuring |
//! | ||
//! For example, if your application's `Cargo.toml` enables the `crossterm_0_29` feature for | ||
//! `ratatui-crossterm`, then any code using `ratatui_crossterm::crossterm` will refer to the | ||
//! 0.29 version of Crossterm. |
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.
//! 0.29 version of Crossterm. | |
//! 0.29 version of [Crossterm]. |
let common_features = [ | ||
"serde", | ||
"underline-color", | ||
"scrolling-regions", | ||
"unstable", | ||
"unstable-backend-writer", | ||
] | ||
.join(","); |
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.
I think #1820 might help here maybe... Just as a reminder that we should do that :D
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.
I don't think this scenario quite fits into cargo-hack. I may be wrong though. The problem is that the crossterm features are mutually exclusive.
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.
I see... I guess we need to play around with cargo-hack
a bit to see how that would work
.join(","); | ||
|
||
// Run `cargo check` on `ratatui-crossterm` with specific crossterm versions | ||
for crossterm_feature in ["crossterm_0_28", "crossterm_0_29"] { |
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.
I would define a separate constant or variable for the available versions. It makes it easier to just update the array whenever a new crossterm version is out.
Or maybe export it from somewhere such as ratatui_crossterm::AVAILABLE_VERSIONS
or something? I'm not sure.
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.
I'm mostly treating xtask as the place where this info is defined. Think of it as a makefile defined in rust. The available versions are not a runtime thing. It maybe makes sense to have a const in the xtask lib, but I think it's clear enough as-is on this. Put another way, you only have to look at this file to understand what the cargo xtask check command will do.
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.
Yup... then maybe let's do a const there? I really don't like the idea of modifying loops directly whenever a new version is out.
let clippy_options = ["--", "-D", "warnings"]; | ||
|
||
// Run Clippy on `ratatui-crossterm` with `crossterm_0_28` and `crossterm_0_29` | ||
for crossterm_feature in ["crossterm_0_28", "crossterm_0_29"] { |
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.
Same comment as above.
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.
Note: this is still a WIP (getting CI to be happy with it)
//! `ratatui-crossterm` requires you to specify a version of the [Crossterm] library to be used. | ||
//! This is managed via feature flags. You **must** enable one, and only one, of the available | ||
//! `crossterm_xx` features (e.g., `crossterm_28`, `crossterm_29`). These features determine which | ||
//! version of Crossterm is compiled and used by the backend. Attempting to enable none or multiple |
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.
We don't need to link every time this is mentioned. It's enough to link it in the first paragraph I think. Sound good?
Sorry, something went wrong.
All reactions
let common_features = [ | ||
"serde", | ||
"underline-color", | ||
"scrolling-regions", | ||
"unstable", | ||
"unstable-backend-writer", | ||
] | ||
.join(","); |
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.
I don't think this scenario quite fits into cargo-hack. I may be wrong though. The problem is that the crossterm features are mutually exclusive.
Sorry, something went wrong.
All reactions
.join(","); | ||
|
||
// Run `cargo check` on `ratatui-crossterm` with specific crossterm versions | ||
for crossterm_feature in ["crossterm_0_28", "crossterm_0_29"] { |
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.
I'm mostly treating xtask as the place where this info is defined. Think of it as a makefile defined in rust. The available versions are not a runtime thing. It maybe makes sense to have a const in the xtask lib, but I think it's clear enough as-is on this. Put another way, you only have to look at this file to understand what the cargo xtask check command will do.
Sorry, something went wrong.
All reactions
// Note that adding --tests or --benches causes clippy to pick up the default features. | ||
// I'm not sure why this is the case (JM 2025-05-10). |
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.
Any ideas on this?
Sorry, something went wrong.
All reactions
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.
Never ran into it... But intuitively I'd guess that using those flags will use default features...
Sorry, something went wrong.
All reactions
orhun
At least 1 approving review is required to merge this pull request.
Successfully merging this pull request may close these issues.
This commit introduces feature flags to make it possible for widget
library authors to depend on a specific version of crossterm without
causing version conflicts.
The available feature flags are
crossterm_0_28
andcrossterm_0_29
.