-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Taskbar progress reporting via ANSI codes #14615
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ impl Shell { | |
stderr_tty: std::io::stderr().is_terminal(), | ||
stdout_unicode: supports_unicode(&std::io::stdout()), | ||
stderr_unicode: supports_unicode(&std::io::stderr()), | ||
progress_report: supports_progress_report(), | ||
}, | ||
verbosity: Verbosity::Verbose, | ||
needs_clear: false, | ||
|
@@ -286,6 +287,17 @@ impl Shell { | |
} | ||
} | ||
|
||
pub fn supports_osc9_4(&self) -> bool { | ||
match &self.output { | ||
ShellOut::Write(_) => false, | ||
ShellOut::Stream { | ||
progress_report, | ||
stderr_tty, | ||
.. | ||
} => *progress_report && *stderr_tty, | ||
} | ||
} | ||
|
||
/// Gets the current color choice. | ||
/// | ||
/// If we are not using a color stream, this will always return `Never`, even if the color | ||
|
@@ -426,6 +438,8 @@ enum ShellOut { | |
hyperlinks: bool, | ||
stdout_unicode: bool, | ||
stderr_unicode: bool, | ||
/// Whether the terminal supports progress notifications via OSC 9;4 sequences | ||
progress_report: bool, | ||
}, | ||
} | ||
|
||
|
@@ -565,6 +579,15 @@ fn supports_unicode(stream: &dyn IsTerminal) -> bool { | |
!stream.is_terminal() || supports_unicode::supports_unicode() | ||
} | ||
|
||
/// Detects if the terminal supports OSC 9;4 progress notifications. | ||
#[allow(clippy::disallowed_methods)] // ALLOWED: to read terminal app signature | ||
fn supports_progress_report() -> bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we rename this (and the variables) to from "progress report" is very generic and sounds like its talking about progress indicators in the terminal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From @joshtriplett:
Windows Terminal also displays progress in the tab. And here I also started to think about more generic term, because it's really more like a progress and status messaging to terminal. I'm fine to change it back to
epage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Windows Terminal session. | ||
std::env::var("WT_SESSION").is_ok() | ||
// Compatibility with ConEmu's ANSI support. | ||
|| std::env::var("ConEmuANSI").ok() == Some("ON".into()) | ||
} | ||
|
||
fn supports_hyperlinks() -> bool { | ||
#[allow(clippy::disallowed_methods)] // We are reading the state of the system, not config | ||
if std::env::var_os("TERM_PROGRAM").as_deref() == Some(std::ffi::OsStr::new("iTerm.app")) { | ||
|
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.
Generally this check is done in the
supports
functions, should we make that consistent?