-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Windows 7, crossterm, SetUnderlineColor error #555
Comments
Thanks for reporting! I'm using Ratatui on Windows and I'm surprised I didn't run into this yet. Does this happen for you when you style a cell a particular way or does it happen even if you apply no styling? |
No worries!
Looks like it fails even when applying Style::default() |
How is Windows 7 still a thing? LOL The colored underline behavior was added recently with a feature flag behind crossterm. We might have to replace that with a "colored-underline" flag or something like that instead. |
Haha, I know right? Some of our users are running Windows 7. I had to install it myself to troubleshoot.
That would be great, thanks! The less intrusive the fix the better - otherwise it's not worth the effort, considering the issue is only present on Win 7. It's that unconditional |
You'll also run into the issue if you manually set underline color, right? For example this line: @joshka What do you think about change the following: to something like this instead: if let Err(e) = queue!(self.writer, SetUnderlineColor(CColor::Reset)) {
log::error!("Unable to set underline color: {e}");
}
queue!(
self.writer,
SetForegroundColor(CColor::Reset),
SetBackgroundColor(CColor::Reset),
SetAttribute(CAttribute::Reset)
) |
That's going to spam logs hard - it's better to not do something when it can error than do it many times. |
I think you can raise issue/pr upstream (even though response will be slow) , usually unsupported apis are just ignored like here https://github.com/crossterm-rs/crossterm/blob/master/src/style.rs#L321 I think this case should be the same, it provably just wasn't noticed. |
@sigmaSd Thanks. Raised the issue crossterm-rs/crossterm#831. |
Windows 7 doesn't support the underline color attribute, so we need to make it optional. This commit adds a feature flag for the underline color attribute - it is enabled by default, but can be disabled by passing `--no-default-features` to cargo. We could specically check for Windows 7 and disable the feature flag automatically, but I think it's better for this check to be done by the crossterm crate, since it's the one that actually knows about the underlying terminal. To disable the feature flag in an application that supports Windows 7, add the following to your Cargo.toml: ```toml ratatui = { version = "0.24.0", default-features = false, features = ["crossterm"] } ``` Fixes #555
Windows 7 doesn't support the underline color attribute, so we need to make it optional. This commit adds a feature flag for the underline color attribute - it is enabled by default, but can be disabled by passing `--no-default-features` to cargo. We could specically check for Windows 7 and disable the feature flag automatically, but I think it's better for this check to be done by the crossterm crate, since it's the one that actually knows about the underlying terminal. To disable the feature flag in an application that supports Windows 7, add the following to your Cargo.toml: ```toml ratatui = { version = "0.24.0", default-features = false, features = ["crossterm"] } ``` Fixes #555
Windows 7 doesn't support the underline color attribute, so we need to make it optional. This commit adds a feature flag for the underline color attribute - it is enabled by default, but can be disabled by passing `--no-default-features` to cargo. We could specically check for Windows 7 and disable the feature flag automatically, but I think it's better for this check to be done by the crossterm crate, since it's the one that actually knows about the underlying terminal. To disable the feature flag in an application that supports Windows 7, add the following to your Cargo.toml: ```toml ratatui = { version = "0.24.0", default-features = false, features = ["crossterm"] } ``` Fixes ratatui#555
man, i'm using even Windows 8.1 and steel have the same problem, i just wanted to make a simple “Hello World” TUI app...
and then on the use std::io::{stdout, Result};
use ratatui::{
backend::CrosstermBackend,
crossterm::{
event::{self, KeyCode, KeyEventKind},
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
ExecutableCommand,
},
style::Stylize,
widgets::Paragraph,
Terminal,
};
fn main() -> Result<()> {
stdout().execute(EnterAlternateScreen)?;
enable_raw_mode()?;
let mut terminal = Terminal::new(CrosstermBackend::new(stdout()))?;
terminal.clear()?;
loop {
terminal.draw(|frame| {
let area = frame.size();
frame.render_widget(
Paragraph::new("Hello Ratatui! (press 'q' to quit)")
.white()
.on_blue(),
area,
);
})?;
if event::poll(std::time::Duration::from_millis(16))? {
if let event::Event::Key(key) = event::read()? {
if key.kind == KeyEventKind::Press && key.code == KeyCode::Char('q') {
break;
}
}
}
}
stdout().execute(LeaveAlternateScreen)?;
disable_raw_mode()?;
Ok(())
} whenever i run it on the cmd, it makes the design but gives an error:
there is no option to exit from the app, it's directly loged out with this error hope someone will find a solution for me)) |
QQ: do you have a full backtrace for the error? That would be helpful to understand how this is feature gated on winapi (and would enable us to perhaps do the same thing, either in Ratatui or crossterm. It's probably more crossterm than Ratatui that should ignore this. To disable underline colors in your app use the following in your Cargo.toml (basically don't enable the underline-color feature). This was fixed in #570 which is mentioned above in the "closed as completed" link. ratatui = { version = "0.27.0", default-features = false, features = ["crossterm"] } |
@joshka |
Hey, can you open another issue for any problems you're seeing with Windows 8 here. My guess for the borders is that your terminal is not using a font that has the symbols available. It's possible that Windows 8 works, but we don't really have any maintainers that regularly use Windows, so I wouldn't call it supported - merely tolerated ;) I'd recommend grabbing a Windows 11 VM for your development purposes. See https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/. Obviously you know your reasons for using really old software, but it's not something I want to invest much time into generally. I hope you can appreciate that. |
@joshka I also were trying to learn about ratatui for making a good TUI for my socks5 proxy project..its a Windows tool tunneling it over named pipes... |
Description
When using ratatui with crossterm backend on Windows 7, the application fails to render with an error
Custom { kind: Other, error: "SetUnderlineColor not supported by winapi." }
To Reproduce
Render UI with ratatui 0.23.0 on Windows 7
Expected behavior
The UI renders successfully
Environment
Additional context
The error originates here https://github.com/crossterm-rs/crossterm/blob/master/src/style.rs#L251.
SetUnderlineColor
command is called in ratatui here: https://github.com/ratatui-org/ratatui/blob/main/src/backend/crossterm.rs#L167 <-- commenting out this line fixes the issue.I'm not experiencing this problem with the original tui-rs as it doesn't call
SetUnderlineColor
.Is there a way to make the code call
SetUnderlineColor
only when the underline color functionality is used? I promise not to use on Win 7 😄The text was updated successfully, but these errors were encountered: