You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Developers using Console can employ VT/ANSI APIs (eg to use embedded color codes) #44513
Console Formatters introduced in .NET 5.0 allow for the built-in SimpleConsoleFormatter to embed color codes to each log message. But this implementation required knowledge about hardcoding a mapping between VT100 color codes and different background/foreground color changes.
Instead of typing colors to the formatter, we should decouple this by exposing a generic VT100 builder for colors (maybe even a parser) into System.Console. This way, we can simplify the architecture in Microsoft.Extensions.Logging.Console by making ConsoleFormatters's job purely about building up string of log messages structured in a specific format when having colors involved.
changed the title [-]ANSI Rendering support: Add general VT/ANSI APIs to the System.Console[/-][+]Add general VT/ANSI APIs to the System.Console[/+]on Nov 11, 2020
System.CommandLine.Rendering/Ansi.cs shows similar logic being duplicated in dotnet/command-line-api as well.
Another useful part of System.CommandLine.Rendering that we may want to pull into the BCL is the ConsoleFormatInfo class. This allows for ANSI control codes to be included or omitted dynamically depending on the current environment, or explicitly configured by a caller. (The design follows the same design as formatting a number or a date in the rest of .NET.)
See dotnet/command-line-api#966 for more info.
If we look not PowerShell itself but PowerShell module PSReadline - I believe we can find some other methods which could be great candidates for System.Console VT/ANSI APIs.
I hope @daxian-dbw could add more info.
changed the title [-]System.Console offers general VT/ANSI APIs [/-][+]Developers using Console can employ VT/ANSI APIs (eg to use embedded color codes)[/+]on Nov 29, 2020
Transparent support more terminals by utilizing TermInfo (on Windows too). This allows an application turn on/off coloring (and other feature) on the fly and to work on any terminal without recompile.
Maybe a rendering engine based on TermInfo entities. This could significantly reduce allocations in custom code, add formattings in resource strings and so on.
API for managing cursor position, getting info about a terminal sizing and resizing.
Activity
[-]ANSI Rendering support: Add general VT/ANSI APIs to the System.Console[/-][+]Add general VT/ANSI APIs to the System.Console[/+]eerhardt commentedon Nov 11, 2020
Another useful part of System.CommandLine.Rendering that we may want to pull into the BCL is the
ConsoleFormatInfoclass. This allows for ANSI control codes to be included or omitted dynamically depending on the current environment, or explicitly configured by a caller. (The design follows the same design as formatting a number or a date in the rest of .NET.)See dotnet/command-line-api#966 for more info.
[-]Add general VT/ANSI APIs to the System.Console[/-][+]System.Console offers general VT/ANSI APIs [/+]SteveL-MSFT commentedon Nov 24, 2020
I think the biggest help to PowerShell is a .NET API that returns the plain text version of a string (removing all ANSI decoration).
iSazonov commentedon Nov 24, 2020
If we look not PowerShell itself but PowerShell module PSReadline - I believe we can find some other methods which could be great candidates for System.Console VT/ANSI APIs.
I hope @daxian-dbw could add more info.
[-]System.Console offers general VT/ANSI APIs [/-][+]Developers using Console can employ VT/ANSI APIs (eg to use embedded color codes)[/+]iSazonov commentedon Dec 8, 2020
In short:
/cc @DHowett
1 remaining item
jeffhandley commentedon Jul 7, 2021
Moving this issue to .NET 7. We will consider this as part of a potential effort for a System.Console redesign as described in #52374.