-
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?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @epage (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
src/cargo/util/context/mod.rs
Outdated
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.
Could you clean up the commits to represent how you want this reviewed and merged?
fn from_config(config: Option<bool>) -> Self { | ||
let show = match config { | ||
Some(v) => v, | ||
None => cfg!(target_os = "windows"), |
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 target_os
is sufficient. We should be checking the terminal as well.
// When st is 0: remove progress. | ||
// When st is 1: set progress value to pr (number, 0-100). | ||
// When st is 2: set error state in taskbar, pr is optional. | ||
// When st is 3: set indeterminate state. |
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.
Should we respect ProgressStyle::Indeterminate
and have a way of outputting this?
@@ -280,6 +353,7 @@ impl<'gctx> State<'gctx> { | |||
// return back to the beginning of the line for the next print. | |||
self.try_update_max_width(); | |||
if let Some(pbar) = self.format.progress(cur, max) { | |||
self.taskbar.percent = ((cur as f32) / (max as f32) * 100.0) as u8; |
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.
Format
has a progress
function to abstract things like this. I feel like self.taskbar
should as well.
// ESC ] 9 ; 4 ; st ; pr ST | ||
// When st is 0: remove progress. | ||
// When st is 1: set progress value to pr (number, 0-100). | ||
// When st is 2: set error state in taskbar, pr is optional. |
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.
Only slightly related to this PR: Any details on the error state? Wondering how we could use that.
What does this PR try to resolve?
A few traminal emulators support progress output to Windows taskbar.
winget
uses this to show install progress.Notably, Windows Terminal recently (2020) added support for ANSI codes specified in ConEmu (another terminal emulator for Windows) documentation. Also, in "Learn Windows".
I've found the previous attempt to add this feature: #11436
As per @weihanglo's request, I've added the config option to enable/disable this feature. It's enabled on Windows by default.
Fixes #11432
How should we test and review this PR?
Run
cargo build
in Windows Terminal with configuration optionterm.progress.taskbar
set totrue
.Not sure
#[cfg(windows)]
? Probably no, because feature is also usable in WSL.winget
is also behaves like alike. I've experimented withctrl_c handler
and it's totally fixable.Enabled
is a sensible default for WSL because it works on linux builds in Windows Terminal tooTLDR
term.progress.taskbar
option with bool type is addedVideos
Windows.PowerShell.2024-09-29.23-21-21.mp4
cmd.2024-09-29.23-36-25.mp4