Commit 340d123
authored
Add terminal integration via ANSI OSC 9;4 sequences (#14615)
### What does this PR try to resolve?
A few terminal emulators support progress output to Windows taskbar.
`winget` uses this to show install progress.
Notably, Windows Terminal [recently (2020) added
support](microsoft/terminal#8055) for ANSI codes
[specified](https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC)
in ConEmu (another terminal emulator for Windows) documentation. Also,
in "[Learn
Windows](https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences)".
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 supported terminal
emulators.**
Fixes #11432
FCP:
#14615 (comment)
### How should we test and review this PR?
Run `cargo build` in Windows Terminal with configuration option
`term.progress.taskbar` set to `true`.
### Not sure
- [x] Should all the code be `#[cfg(windows)]`? Probably no, because the
feature is also usable in WSL.
> Solved by introducing heuristic based on environment variable set by
terminal
- [ ] If Ctrl+C is pressed, a progressbar will stay in a last state
forever (shown in the ConEmu video). `winget` is also behaves like
alike. I've experimented with `ctrl_c handler` and it's totally fixable.
- [x] `Enabled` is a sensible default for WSL because it works on linux
builds in Windows Terminal too
> Solved by introducing heuristic based on environment variable set by
terminal
- [x] Downloading stage may produce unpleasant blinking due to a rapid
0-100 changes
> Solved by not displaying bar when downloading and using indeterminate
state in other cases so amination don't reset
### TLDR
* An `term.progress.taskbar` option with bool type is added
* On Windows Terminal and ConEmu is enabled by default
* If enabled reports build progress to taskbar icon and/or tab header
### Videos
https://github.com/user-attachments/assets/48bb648a-e819-490e-b3ac-3502bc5f2f3a
https://github.com/user-attachments/assets/1d7ddf7a-34dd-4db1-b654-e64d7170798eFile tree
5 files changed
+225
-17
lines changed- src
- cargo
- core
- compiler/job_queue
- util
- context
- doc/src/reference
5 files changed
+225
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
857 | | - | |
| 857 | + | |
858 | 858 | | |
859 | 859 | | |
860 | 860 | | |
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| 866 | + | |
866 | 867 | | |
867 | 868 | | |
868 | 869 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
125 | 138 | | |
126 | 139 | | |
127 | 140 | | |
| |||
426 | 439 | | |
427 | 440 | | |
428 | 441 | | |
| 442 | + | |
429 | 443 | | |
430 | 444 | | |
431 | 445 | | |
| |||
575 | 589 | | |
576 | 590 | | |
577 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
578 | 602 | | |
579 | 603 | | |
580 | 604 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2833 | 2833 | | |
2834 | 2834 | | |
2835 | 2835 | | |
| 2836 | + | |
| 2837 | + | |
2836 | 2838 | | |
2837 | 2839 | | |
2838 | 2840 | | |
| |||
2865 | 2867 | | |
2866 | 2868 | | |
2867 | 2869 | | |
| 2870 | + | |
2868 | 2871 | | |
2869 | 2872 | | |
2870 | 2873 | | |
2871 | 2874 | | |
| 2875 | + | |
2872 | 2876 | | |
2873 | 2877 | | |
2874 | 2878 | | |
| |||
2890 | 2894 | | |
2891 | 2895 | | |
2892 | 2896 | | |
| 2897 | + | |
2893 | 2898 | | |
2894 | 2899 | | |
2895 | 2900 | | |
| |||
0 commit comments