GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Supporting the OSC 9;4 codes · Issue #14208 · PowerShell/PowerShell

Supporting the OSC 9;4 codes #14208

New issue
Copy link
New issue
Copy link
Closed
Closed
Supporting the OSC 9;4 codes#14208
Copy link
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Interactive-Consolethe console experiencethe console experience

Description

@Sidneys1
Sidneys1 (Sidneys1)
opened on Nov 20, 2020
Issue body actions

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;

Activity

  1. Sidneys1 (Sidneys1)
    added
    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bug
    on Nov 20, 2020
  2. Ilya (iSazonov)
    added
    WG-Interactive-Consolethe console experiencethe console experience
    on Nov 22, 2020
  3. Ilya (iSazonov)
    changed the title [-]Feature Request[/-] [+]Supporting the OSC 9;4 codes[/+] on Nov 22, 2020
  4. SeeminglyScience commented on Nov 23, 2020

    @SeeminglyScience
    Patrick Meinecke (SeeminglyScience)
    on Nov 23, 2020
    Contributor
    More actions

    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.

  5. Sidneys1 commented on Nov 23, 2020

    @Sidneys1
    Sidneys1 (Sidneys1)
    on Nov 23, 2020
    Author
    More actions

    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?

  6. SeeminglyScience commented on Nov 23, 2020

    @SeeminglyScience
    Patrick Meinecke (SeeminglyScience)
    on Nov 23, 2020
    Contributor
    More actions
    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.

  7. Sidneys1 commented on Nov 23, 2020

    @Sidneys1
    Sidneys1 (Sidneys1)
    on Nov 23, 2020
    Author
    More actions

    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.
  8. Sidneys1 commented on Nov 23, 2020

    @Sidneys1
    Sidneys1 (Sidneys1)
    on Nov 23, 2020
    Author
    More actions

    For reference, the ProgressPane itself is here.

  9. DHowett commented on Mar 12, 2021

    @DHowett
    Dustin L. Howett (DHowett)
    on Mar 12, 2021
    More actions

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

    Reacted by Sidneys1
  10. Sidneys1 commented on Mar 12, 2021

    @Sidneys1
    Sidneys1 (Sidneys1)
    on Mar 12, 2021
    Author
    More actions

    I'd say this is adequately resolved, thanks for following up Dustin L. Howett (@DHowett)!

  11. Sidneys1 (Sidneys1)
    closed this as completedon Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Interactive-Consolethe console experiencethe console experience

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.