Leverage ANSI escape sequences as the mechanism for rich formatting w/in Terminal.Gui apps
See original GitHub issueRight now we don’t parse ANSI escape sequences anywhere. Thus any text input that includes them gets drawn funky.
Ideally, any control that renders text should honor ANSI sequences, e.g. changing the color of the text (but also ignoring things like cursor movement).
See: https://github.com/PowerShell/GraphicalTools/issues/131
This could be fixed in ocgv
’s input parsing to at least strip out the sequences. But what users really want is for formatting (like color) to be honored and displayed.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Leverage ANSI escape sequences as the mechanism for ...
As a developer, I want to richly format output w/in terminal.gui apps. For example, within a ListView, I want some elements to be...
Read more >Write better looking console applications using ANSI escape ...
Write better looking console applications using ANSI escape codes · Figure 1: A simple GUI with a centered main menu and a custom...
Read more >Build your own Command Line with ANSI escape codes
Rich Text. The most basic Ansi escape codes are those involved in rendering text. These let you add decorations like Colors, Background Colors ......
Read more >Better terminal output from Ink with ANSI escape codes
ANSI escape codes are an in-band signaling mechanism, meaning the commands are sent as a part of the normal stream of text being...
Read more >Console Virtual Terminal Sequences
Virtual terminal sequences are control character sequences that can control cursor movement, color/font mode, and other operations when ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There are 2 seperate user stories being discussed here
Easily Add Color
The proposed solution for the story is to adopt the same markup as Spectre Console. It is a very simple markup which is easy to pick up, even for beginner programmers. Implementing it would be a big task but could start small (e.g. with
Label
). The feature should be ‘opt in’ so that it doesn’t break backwards compatibility. Finally we would need methods like EscapeMarkupHandling Process outputs that already contain ANSI
This is more complicated and would require writting a parser such as this one in teds-terminal. As highlighted by @migueldeicaza , this may not belong in Terminal.Gui itself and might be better as a standalone library.
@KieranDevvs given we don’t currently have an ANSI parser and are unlikely to soon. You might want to consider starting by stripping the ANSI codes? There is a post on Stack Overflow that contains some Regex that will do that (example is in Python but the regex patterns are the interesting bit).
Alternatively you could use the Regex to detect which bits of output have the color markups you are looking to parse and implement the highlighting using an approach similar to the syntax highlighting Scenario
https://github.com/gui-cs/Terminal.Gui/blob/d368215e0799b37c6e2b11d1770021cbe61bab2a/UICatalog/Scenarios/SyntaxHighlighting.cs#L153-L166
The pseudocode for that might be something like:
Then override the
ColorNormal
method to set the appropriate color.Renamed the issue to make this customer centric.
As a developer, I want to richly format output w/in terminal.gui apps. For example, within a ListView, I want some elements to be red and some to be blue.
That is not supported today. We could implement a new model for formatting, or, we could simply leverage ANSI escape sequences.