Skip to content

Rename ColorScheme to Scheme and Migrate Colors to ConfigurationManager.Themes #4057

@tig

Description

@tig

As discussed in:

The names ColorScheme and Colors in Terminal.Gui are misleading because they imply color-only functionality, yet Attributes within ColorScheme will soon support non-color styles (e.g., Bold, Italic, per #4058). The static Colors dictionary (Terminal.Gui.Colors.ColorSchemes) causes thread-safety issues and lacks type safety, making it unsuitable for modern theme management. I propose:

  • Rename ColorScheme to Scheme to reflect its role in defining both color and non-color visual styles.

  • Remove Colors and migrate its functionality to ConfigurationManager.Themes, leveraging Terminal.Gui’s JSON-driven theme management system.

This issue focuses on these naming and structural changes, keeping #457 as the master issue for the broader ColorSchemes redesign, including per-view defaults and terminal settings (#2381). Backward compatibility for Colors is not required, simplifying the migration.

Current State

  • ColorScheme is a class defining Attributes (Normal, HotNormal, Focus, HotFocus, Disabled) used by views for styling.

  • Colors is a static dictionary with string keys (e.g., "Base", "Dialog", "Menu", "Error"), which is prone to threading issues and not configurable by users.

  • ConfigurationManager.Themes manages themes (e.g., “Light”, “Dark”) as a non-static dictionary of ColorScheme instances, loaded from JSON configs (e.g., .tui/config.json, embedded config.json). It supports user-defined themes, runtime overrides (e.g., ConfigurationManager.RuntimeConfig = """{ "Theme": "Light" }"""), and a robust API for theme management (e.g., adding, retrieving, applying themes).

  • Current ConfigurationManager.Themes JSON structure:

{
  "Dark": {
    "ColorSchemes": [
      {
        "TopLevel": {
          "Normal": {
            // Color and attribute definitions
          }
...

Proposed Changes

  • Rename ColorScheme to Scheme:

  • Remove Colors and Migrate to ConfigurationManager.Themes:

    • Eliminate the static Terminal.Gui.Colors class and its ColorSchemes dictionary.

    • Migrate default schemes (Base, Dialog, Menu, Error) to ConfigurationManager.Themes, storing them as Scheme instances in the embedded config.json or user .tui configs.

    • Update ThemeManager to store and manage Scheme instances, ensuring seamless integration with the existing theme management API.

    • Example updated JSON structure:

{
  "Dark": {
    "Schemes": [
      {
        "TopLevel": {
          "Normal": {
            // Color and attribute definitions
          }
...
  • Support Theme Inheritance:

  • Support Future Terminal Settings:

  • Documentation and Testing:

    • Update documentation, samples (e.g., UICatalog, Example.cs), and API docs to reflect Scheme and ConfigurationManager.Themes.

    • Fix unit tests to remove Colors dependencies and validate ThemeManager integration.

Benefits

Tasks

  • Refactor ColorScheme to Scheme across the codebase and JSON schema.

  • Remove Terminal.Gui.Colors and migrate its schemes to ConfigurationManager.Themes.

  • Update documentation, samples, and UICatalog to use Scheme and ConfigurationManager.Themes.

  • Fix unit tests to eliminate Colors dependencies and validate ThemeManager integration.

Related Issues

Open Questions

  • Are there edge cases in ThemeManager that need addressing for Scheme migration?

  • Should ConfigurationManager.Themes include additional validation for user-defined themes?

  • Should the JSON structure for Schemes be flattened or simplified (e.g., remove nested array)?

Community feedback on the rename, migration approach, and ThemeManager integration is welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    ✅ Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions