Skip to content

feat: Syntax colorizer — xshd-based highlighting engine#94

Merged
tig merged 8 commits into
developfrom
syntax-colorizer
May 13, 2026
Merged

feat: Syntax colorizer — xshd-based highlighting engine#94
tig merged 8 commits into
developfrom
syntax-colorizer

Conversation

@tig

@tig tig commented May 13, 2026

Copy link
Copy Markdown
Member

Summary

End-to-end syntax highlighting via AvaloniaEdit's xshd engine, replacing the [Obsolete]\ \SyntaxHighlighter/\SyntaxLanguage\ stopgap.

Model layer (\Terminal.Gui.Editor)

  • Highlighting/ — lifted ~49 files from AvaloniaEdit: core types (\IHighlightingDefinition, \HighlightingColor, \HighlightingEngine, \HighlightingManager, \DocumentHighlighter), xshd loader pipeline (V1 + V2), and 14 .xshd\ language definitions (C#, Java, JS, XML, HTML, CSS, Python, SQL, PowerShell, VB, etc.)
  • Adaptations: \IBrush\ → \Color?, dropped \FontFamily/\FontSize, \FontWeight/\FontStyle\ → \�ool? Bold/\�ool? Italic\

View layer (\Terminal.Gui.Editor)

  • *\HighlightingColorizer : IVisualLineTransformer* — maps \DocumentHighlighter\ sections onto \CellVisualLineElement.Attribute\
  • *\Editor.HighlightingDefinition* property replaces the removed obsolete API
  • Selection ordering fix: \VisualLineBuilder\ now applies selection AFTER transformers, preventing the colorizer from overwriting selection attributes

ted demo

  • Auto-detects language by file extension via \HighlightingManager\
  • \LanguageShortcut\ status bar label replaces the TextMate theme dropdown

Tests

  • 33 new highlighting tests + updated existing tests
  • 353 unit + 108 integration tests, all green

Closes #28, closes #32.

Per \specs/syntax-colorizer/spec.md\ and constitution R9 (end-to-end features).

tig and others added 4 commits May 12, 2026 07:39
Adapt ~30 source files and 16 resource files from AvaloniaEdit commit d7a6b63
for the syntax highlighting subsystem.

Key adaptations:
- HighlightingBrush: replaced IBrush hierarchy with Terminal.Gui.Drawing.Color?
- HighlightingColor: FontWeight/FontStyle -> bool? Bold/Italic; dropped FontFamily/FontSize
- V2Loader: ParseFontWeight/ParseFontStyle return bool?; ParseColor uses TG Color
- XshdColor/XmlHighlightingDefinition/SaveXshdVisitor: Bold/Italic fields
- HighlightedLine: stripped WriteTo/ToHtml/ToRichTextModel (depend on Avalonia types)
- DocumentHighlighter: stripped Dispatcher.UIThread.VerifyAccess()
- Resources.cs: prefix changed to Terminal.Gui.Editor.Highlighting.Resources
- All files: #nullable disable (upstream predates NRT)
- AddRange on IList<T> replaced with foreach loops
- Added XmlReaderExtensions.GetBoolAttribute (from Utils/ExtensionMethods.cs)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gColorizer

Lift AvaloniaEdit's Highlighting/ engine (~49 files) and create a
HighlightingColorizer : IVisualLineTransformer that maps highlighted
sections onto CellVisualLineElement attributes.

Model layer (Terminal.Gui.Editor):
- Highlighting/ — core types: IHighlightingDefinition, HighlightingColor,
  HighlightingEngine, HighlightingManager, DocumentHighlighter,
  HighlightingRule/RuleSet/Span, HighlightedLine/Section
- Highlighting/Xshd/ — xshd loader pipeline (V1 + V2)
- Highlighting/Resources/ — 14 .xshd definitions (C#, Java, JS, XML,
  HTML, CSS, Python, SQL, PowerShell, VB, etc.)
- HighlightingBrush: IBrush → Color?; HighlightingColor: dropped
  FontFamily/FontSize, FontWeight → bool? Bold, FontStyle → bool? Italic

View layer (Terminal.Gui.Editor):
- Rendering/HighlightingColorizer.cs — IVisualLineTransformer that
  resolves DocumentHighlighter sections to terminal Attributes
- Editor.HighlightingDefinition property replaces [Obsolete]
  SyntaxHighlighter/SyntaxLanguage
- VisualLineBuilder: selection now applied AFTER transformers to prevent
  colorizer from overwriting selection attributes

ted demo:
- Auto-detects language by file extension via HighlightingManager
- LanguageShortcut in status bar replaces TextMate theme dropdown
- Removed TextMateSharp.Grammars dependency

Tests: 33 new highlighting tests + updated existing tests (353 unit +
108 integration, all green).

Closes #28, closes #32.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 478a120f13

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Terminal.Gui.Editor/Rendering/HighlightingColorizer.cs
Comment thread src/Terminal.Gui.Editor/Highlighting/DocumentHighlighter.cs Outdated
@tig

tig commented May 13, 2026

Copy link
Copy Markdown
Member Author

@copilot See the CR commetns and address. CI/Cd is failing too.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

@copilot See the CR commetns and address. CI/Cd is failing too.

Addressed the review feedback and the Ubuntu CI failure in e14c37f. The fix avoids rebuilding the colorizer when nothing changed, exposes the definition’s named default highlighting color for theme background fill, and fixes the ted formatting issue that was breaking dotnet format. I also re-ran format, build, unit tests, integration tests, and validation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.jetbrains.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Editor.slnx --profile=TG.Editor Full Cleanup (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Editor.slnx --profile=TG.Editor Full Cleanup --no-build --exclude=third_party/**/* (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of tig May 13, 2026 05:57
@tig

tig commented May 13, 2026

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copilot AI and others added 2 commits May 13, 2026 06:11
Co-authored-by: tig <585482+tig@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts by merging the latest develop into this branch in da2ca99, then pushed a small follow-up cleanup in c506da1. The branch now contains develop as an ancestor and the merged tree was validated with format, build, and Ted-focused integration tests.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.jetbrains.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2026.1.1/tools/net8.0/any/cleanupcode.exe Terminal.Gui.Editor.slnx --profile=TG.Editor Full Cleanup --no-build --exclude=third_party/**/* (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of tig May 13, 2026 06:16
@tig tig merged commit 3a856ad into develop May 13, 2026
8 checks passed
@tig tig deleted the syntax-colorizer branch May 13, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants