Skip to content

Add theme/palette layer for syntax highlighting colors #99

@tig

Description

@tig

Problem

The xshd-based syntax highlighting engine (ported from AvaloniaEdit) hardcodes colors directly in each language definition file. For example, CSharp-Mode.xshd specifies:

<Color name="Comment" foreground="Green" />
<Color name="Keyword" foreground="Blue" />
<Color name="String" foreground="Blue" />

Users have no way to customize these colors at runtime. If someone wants comments to be dark green instead of green, they must edit the .xshd file.

The old TextMateSyntaxHighlighter supported theme switching (DarkPlus, LightPlus, Monokai, etc.) via a ThemeName dropdown. That capability was lost when we moved to the xshd engine.

Proposed Solution

Add a color palette / theme indirection layer between the xshd named colors and the rendered output:

  1. Define a IHighlightingTheme (or similar) interface that maps semantic color names (Comment, Keyword, String, etc.) to actual Attribute / foreground+background values.
  2. Ship a few built-in themes (e.g., Dark, Light) as simple name-to-color mappings.
  3. Have HighlightingColorizer resolve colors through the active theme instead of using the xshd values directly. Fall back to the xshd-specified color if the theme doesn't define an override.
  4. Expose an Editor.HighlightingTheme property (or similar) so users can switch themes at runtime.
  5. Restore the theme dropdown in ted's status bar.

Infrastructure Already in Place

The xshd engine already uses semantic named colors (NamedHighlightingColors, GetNamedColor()). The mapping surface exists — we just need the indirection layer.

Acceptance Criteria

  • Users can switch highlighting color themes at runtime
  • At least two built-in themes ship (dark + light)
  • Custom themes can be defined programmatically
  • ted demo has a theme selector in the status bar
  • Existing xshd color values serve as fallback defaults

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions