Skip to content

Attribute System Should honor terminal settings #2381

@tig

Description

@tig

Terminal.Gui apps should honor user terminal color settings, similar to how ls and other commands adapt to terminal configurations, rather than relying on our default color schemes. This ensures a consistent user experience across terminal-based applications.

To achieve this, we can model our approach on PowerShell’s $PSStyle (PowerShell 7.2+), which provides robust user-defined color settings for output styling. Proposed mappings for Terminal.Gui’s Scheme attributes include:

  • Normal: Map to $PSStyle.Foreground or $Host.UI.RawUI.ForegroundColor for the terminal’s default text color, used in views like Label or ListView.
  • Active: Map to $PSStyle.PSReadLine.Selection for selected elements (e.g., highlighted ListView items, RadioGroup options).
  • Error: Map to $PSStyle.Formatting.Error for error messages or states (e.g., invalid TextField input).
  • Warning (new): Map to $PSStyle.Formatting.Warning for warning messages.
  • Header (new): Map to $PSStyle.Formatting.TableHeader for table/list headers (e.g., TableView).

Implementation Notes:

  • Querying Colors: Develop a mechanism to query $PSStyle (e.g., via PowerShell script execution) for PowerShell terminals, or fall back to $TERM capabilities (16, 256, or 24-bit RGB) for non-PowerShell environments like Linux/macOS. This may require platform-specific logic.
  • ANSI Styles: Support PowerShell’s ANSI styles (Bold, Italic, Reverse, etc.) in Scheme to fully reflect user settings, building on truecolor support (Truecolors (direct RGB colors) support #48).
  • Accessibility: Enforce contrast (e.g., WCAG 2.1’s 4.5:1 ratio) to ensure readability, with fallbacks for low-contrast user settings.
  • Integration with ColorScheme Redesign: Align with the proposed ColorScheme to Scheme rename and ConfigurationManager.Themes migration discussed in Master Issue for Updating Color/Attribute System #457.

This approach focuses on output styling, deferring syntax highlighting (e.g., $PSStyle.PSReadLine tokens like Comment, Keyword) to separate efforts, such as enhancing the SyntaxHighlighting sample scenario.

Open Questions:

  • How can we best query $PSStyle or $TERM in a cross-platform way?
  • Should we prioritize certain $PSStyle.Formatting options (e.g., Error, Warning) over others?
  • How do we handle terminals with limited color support (e.g., 16 colors)?

Related: #48 (Truecolors support), #457 (ColorScheme redesign).

Community feedback on these mappings and querying approaches is welcome!

Original post:

Developers (like me) love tweaking their terminal colors/themes.

Terminal.Gui, today, overrides all this, defining it's own themes.

This means that when I run a TUI app, the effect is glaring and doesn't honor all the hard work I put into tweaking my terminal theme. E.g.:

JiQYZBw 1

In addition we always clear the Toplevel background vs, letting any bitmap the user has set show through.

For v2, I'd like to see Terminal.Gui pick up the colors theme of the Terminal and use it, by default.

Of course, this implies we nail #48 too.

I think this means a Tenet for v2:

  • Honor The Terminal Theme - To the extent possible, Terminal.Gui will use terminal color, keyboard, and other themes vs defining it's own.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📋 Approved - Need Owner

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions