GeezerVison is showing github.com — Supporting the OSC 9;4 codes · Issue #14208 · PowerShell/PowerShell
Supporting the OSC 9;4 codes #14208DescriptionSummary of the new feature/enhancement
As a user I want PowerShell to integrate with terminal features where it makes sense, especially when the terminal is providing integration with the host operating system. One such feature supported by ConEmu and Windows Terminal (as of 2020-11-18) is OS integration for visual progress indicators via OSC9;4 ANSI codes.
The Write-Progress cmdlet should optionally emit a ConEmu-style OSC 9;4 progress ANSI code, controlled by a switch parameter like -EmitAnsiProgress, and default to a global variable like $EmitAnsiProgressPreference so that it can be enabled profile-wide.
Proposed technical implementation details (optional)
When enabled via the switch parameter or the global preference variable, Write-Progress will emit the following OSC codes in the following circumstances:
`e]9;4;st;pr`e\
st |
Description |
Circumstance |
| 0 |
remove progress |
Write-Progress -Completed |
| 1 |
set progress value to pr |
Write-Progress -PercentComplete <pr> |
| 3 |
set taskbar to Indeterminate state |
Write-Progress when no -PercentCompleted has been set previously |
An example of this behavior can be emulated by running the following PowerShell command in a terminal supporting the OSC 9;4 code:
0..100 |% {
Write-Host -NoNewline "`e]9;4;1;$_`e\";
Write-Progress -Activity Demo -PercentComplete $_;
Start-Sleep 0.1
}; Write-Host -NoNewline "`e]9;4;0`e\"; Write-Progress -Activity Demo -Completed;Activitychanged the title [-]Feature Request[/-] [+]Supporting the OSC 9;4 codes[/+] on Nov 22, 2020SeeminglyScience commented on Nov 23, 2020 This would definitely be cool to see.
Something that should be worked out before an implementation is started is what to do about nested progress activities. That's something that always comes up as problematic whenever trying to integrate PowerShell progress into other progress systems. Sidneys1 commented on Nov 23, 2020 That's an excellent point. I suppose the options are:
- Don't do anything (show each record as it is generated). This is obviously not viable since it would cause terrible "flickering".
- Keep track of the parent-most and oldest progress indicator, and only show that in the taskbar.
- When multiple progress indicators are in play, either don't show any (disable taskbar progress), or show an indeterminate state in the taskbar progress (
"`e]9;4;3`e\").
Options 2 and 3 are tricky, since they'd require some additional tracking in the PowerShell host that I imagine doesn't currently exist. I'm not aware of the current host architecture for progress display - are these approaches viable? SeeminglyScience commented on Nov 23, 2020
- Keep track of the parent-most and oldest progress indicator, and only show that in the taskbar.
I think this one makes the most sense personally.
I'm not aware of the current host architecture for progress display - are these approaches viable?
Should be. ConsoleHost already keeps track of what progress messages are currently being displayed, so it should be able to keep track of what the top most is. I'm unsure how much overhead that would add, but probably minimal. Sidneys1 commented on Nov 23, 2020 I poked around in the ConsoleHost progress UI. It looks like this should be pretty easy to implement at a very basic level.
Some things that occurred to me:
- The system for display UI like the progress banner doesn't emit to a stream, it writes to the raw console buffer. This might interfere with OSC sequences.
- If there isn't already, there should be a central API in the ConsoleHost for emitting raw OSC sequences like this. I might have to investigate how
pwsh handles color codes on non-windows systems and see if something like this exists. I don't want to bury code emitting OSC to a stream in the actual progress UI code.
Sidneys1 commented on Nov 23, 2020 DHowett commented on Mar 12, 2021 Something similar to--or exactly matching--this just landed with #14927 Sidneys1 commented on Mar 12, 2021
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|