8000 Supporting the OSC 9;4 codes · Issue #14208 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Supporting the OSC 9;4 codes #14208

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

Closed
Sidneys1 opened this issue Nov 20, 2020 · 7 comments
Closed

Supporting the OSC 9;4 codes #14208

Sidneys1 opened this issue Nov 20, 2020 · 7 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug WG-Interactive-Console the console experience

Comments

@Sidneys1
Copy link
Sidneys1 commented Nov 20, 2020

Summary 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;
@Sidneys1 Sidneys1 added the Issue-Enhancement the issue is more of a feature request than a bug label Nov 20, 2020
@iSazonov iSazonov added the WG-Interactive-Console the console experience label Nov 22, 2020
@iSazonov iSazonov changed the title Feature Request Supporting the OSC 9;4 codes Nov 22, 2020
@SeeminglyScience
Copy link
Collaborator

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
Copy link
Author

That's an excellent point. I suppose the options are:

  1. Don't do anything (show each record as it is generated). This is obviously not viable since it would cause terrible "flickering".
  2. Keep track of the parent-most and oldest progress indicator, and only show that in the taskbar.
  3. 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
Copy link
Collaborator
  1. 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
Copy link
Author

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:

  1. 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.
  2. 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
Copy link
Author

For reference, the ProgressPane itself is here.

@DHowett
Copy link
DHowett commented Mar 12, 2021

Something similar to--or exactly matching--this just landed with #14927

@Sidneys1
Copy link
Author

I'd say this is adequately resolved, thanks for following up @DHowett!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug WG-Interactive-Console the console experience
Projects
None yet
Development

No branches or pull requests

4 participants
0