Skip to content

Add TextColor property to set base text color at runtime#31

Open
andrewtheart wants to merge 1 commit into
FrozenAssassine:masterfrom
andrewtheart:feat/textcolor-property
Open

Add TextColor property to set base text color at runtime#31
andrewtheart wants to merge 1 commit into
FrozenAssassine:masterfrom
andrewtheart:feat/textcolor-property

Conversation

@andrewtheart

Copy link
Copy Markdown

What

Adds a public TextColor property to set the editor's base body-text color at runtime, without replacing the whole Design object.

textBox.TextColor = Colors.Gainsboro;

Why

Today the only way to change the text color is to build and assign a whole new TextControlBoxDesign. All the internal plumbing for a granular setter already exists:

  • TextControlBoxDesign.TextColor (model field) ✔
  • DesignHelper.TextColorBrush + CreateColorResources() (already builds the brush from _Design.TextColor) ✔
  • TextRenderer already draws body text with designHelper.TextColorBrush

The only thing missing was a public property to change it and invalidate. This mirrors the existing granular properties (ShowLineNumbers, ShowLineHighlighter, etc.).

Change

  • CoreTextControlBox: new TextColor property — updates _Design.TextColor, forces ColorResourcesCreated = false (so the brush is rebuilt), flags NeedsUpdateTextLayout, and redraws. No-ops when the value is unchanged.
  • TextControlBox (public wrapper): forwards TextColor to the core control, with an XML doc note that syntax-highlighting token colors still take precedence when enabled.

Testing

  • Builds clean (TextControlBox.csproj, Release/x64).
  • Setting TextColor recolors the body text immediately; with syntax highlighting on, non-token text uses the new color while token colors are unaffected.

Extracted from downstream use of TextControlBox as a vendored editor and contributed back.

The internal plumbing (TextControlBoxDesign.TextColor, DesignHelper.TextColorBrush/CreateColorResources, and TextRenderer drawing body text with TextColorBrush) already existed; the only way to change it was to replace the whole Design object. Expose a granular public TextColor property on CoreTextControlBox and the public TextControlBox wrapper that updates the design color, rebuilds the brush and redraws, mirroring the other granular properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant