Skip to content

Add code-token VisualRoles, Code view, theme palettes, and Markdown highlighting fixes#5313

Merged
tig merged 16 commits into
developfrom
copilot/add-code-token-visualrole-vocabulary
May 17, 2026
Merged

Add code-token VisualRoles, Code view, theme palettes, and Markdown highlighting fixes#5313
tig merged 16 commits into
developfrom
copilot/add-code-token-visualrole-vocabulary

Conversation

Copilot AI commented May 15, 2026

Copy link
Copy Markdown
Contributor

Fixes

Adds shared, theme-driven code-token visual roles for syntax-highlighted content across Markdown, the new Code view, UICatalog samples, and downstream editor scenarios. Fixes code-block highlighting for MarkdownTester by preserving explicitly configured Base code-token roles in derived Accent schemes.

Proposed Changes/Todos

  • Added VisualRole.CodeComment through VisualRole.CodeAttribute with Scheme storage, JSON round-trip support, and fallback behavior.
  • Added Default/Base and bundled theme Code/Code* palettes, preserving 8-Bit monochrome behavior.
  • Updated Markdown and MarkdownCodeBlock rendering to resolve TextMate-highlighted tokens through VisualRole.Code*.
  • Added the public Code view for syntax-highlighted code display.
  • Added UICatalog demos and design-time samples that exercise every code visual role.
  • Shared the code-role legend highlighter between Code.EnableForDesign and CodeViewDemo to avoid duplicated marker logic.
  • Fixed MarkdownTester code-block highlighting when using the derived Accent scheme.
  • Updated DeriveAccent so only explicitly set Base code-token roles are copied into Accent schemes.
  • Added/updated tests for scheme derivation, JSON conversion, TextMate scope mapping, Markdown rendering, code-token background inheritance, Code rendering, and design-time role coverage.

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/87c31cb1-c209-40bb-a480-6f3fbe9e8d55

Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot AI changed the title [WIP] Add code-token VisualRole vocabulary and unify markdown highlighter Add code-token VisualRoles and Code view May 15, 2026
Copilot finished work on behalf of tig May 15, 2026 18:54
Copilot AI requested a review from tig May 15, 2026 18:54
@tig tig marked this pull request as ready for review May 16, 2026 22:31

@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: fb8c1f7be6

ℹ️ 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 Terminal.Gui/Drawing/Markdown/MarkdownAttributeHelper.cs Outdated
@tig

This comment was marked as outdated.

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot see CR feedback. Plus, as this shows, syntax coloring is not working at least with the Default theme:

<img width="352" height="250" alt="image" src="https://github.com/user-attachments/ass...

Fixed in 45ac4fc. Default now gets an explicit Code* palette, and Code View Demo now lays the code panel below the full theme selector so all themes are visible. I captured an updated UI screenshot during validation at /tmp/tg-ui-review/code-demo.png.

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:

  • accounts.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=4978 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.Ej6kUJ --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,2725822441057920996,1310311505937363881,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,1145042349965070522,16301931831828469840,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui-review/code-demo.png --window-size=1000,560 file:///tmp/tg-ui-review/code-demo.html (dns block)
  • clients2.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=4978 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.Ej6kUJ --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,2725822441057920996,1310311505937363881,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,1145042349965070522,16301931831828469840,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui-review/code-demo.png --window-size=1000,560 file:///tmp/tg-ui-review/code-demo.html (dns block)
  • redirector.gvt1.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=4978 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.Ej6kUJ --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,2725822441057920996,1310311505937363881,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,1145042349965070522,16301931831828469840,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui-review/code-demo.png --window-size=1000,560 file:///tmp/tg-ui-review/code-demo.html (dns block)
  • www.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=4978 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.Ej6kUJ --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,2725822441057920996,1310311505937363881,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,1145042349965070522,16301931831828469840,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui-review/code-demo.png --window-size=1000,560 file:///tmp/tg-ui-review/code-demo.html (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 16, 2026 22:45
@tig

This comment was marked as outdated.

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Only Default and 8-bit (because it's supposed to be b&w) Themes look correct.
...

Fixed in a5e4751. Added Code/Code* palettes for the non-Default built-in and UICatalog themes, kept 8-Bit monochrome, and made token backgrounds inherit the Code background so Dark/Light/etc. render consistently. Updated screenshot captured at /tmp/tg-ui-review/code-demo-themes.svg.

Copilot AI changed the title Add code-token VisualRoles and Code view Add code-token VisualRoles, Code view, and theme palettes May 16, 2026
Copilot finished work on behalf of tig May 16, 2026 23:13
@tig

tig commented May 16, 2026

Copy link
Copy Markdown
Member

@copilot make the Code.EnableForDesign include code that shows every code visualstyle. Same for all the examples in the CodeViewDemo scenario.

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot make the Code.EnableForDesign include code that shows every code visualstyle. Same for all the examples in the CodeViewDemo scenario.

Fixed in 07aeabe. Code.EnableForDesign and each Code View Demo sample now include a visible role legend that exercises every Code visual role. Updated screenshot captured at /tmp/tg-ui-review/code-demo-role-samples.svg.

tig and others added 3 commits May 16, 2026 16:49
DeriveAccent now copies every Code* attribute from baseScheme (resolved via GetAttributeForRole) into the accent scheme as explicitly set values. Because GetAttributeForRole walks the derivation chain, even unset code-token roles on the base scheme become explicit on the accent. This means: (a) accent schemes will report TryGetExplicitlySetAttributeForRole(VisualRole.CodeXxx) as true even though the original theme didn't set them, and (b) future changes to baseScheme's Code attribute will no longer propagate to the accent's code tokens because the accent now pins concrete copies. Consider only copying values that were explicitly set on the base scheme (using TryGetExplicitlySetAttributeForRole) so derivation continues to work.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot finished work on behalf of tig May 16, 2026 23:57
tig added a commit to tui-cs/Editor that referenced this pull request May 17, 2026
Phase 2 of specs/syntax-theme/spec.md. Routes the xshd highlighter through
Terminal.Gui's Scheme/VisualRole machinery so themes drive syntax colors and
the editor background follows the active scheme (fixes #128; restores #99's
theme story via ThemeManager).

- XshdRoleMap: xshd <Color name> -> VisualRole.Code* bridge table (spec 6.2)
- HighlightingColor.Role + xshd category= override (XshdColor/V2Loader/
  XmlHighlightingDefinition/SaveXshdVisitor); logged in UPSTREAM.md
- HighlightingColorizer.ToAttribute resolves: explicit scheme role ->
  xshd foreground over scheme bg -> default; ctor takes role-lookup funcs
- Removed Editor.UseThemeBackground end-to-end (theme decides bg now)
- Editor repaints on ThemeManager.ThemeChanged
- ted: status-bar Theme shortcut cycles ThemeManager.Theme
- Tests: scheme-role / xshd-fallback / XshdRoleMap coverage / category
  override (unit) + scheme-swap render smoke (integration). 439 + 174 green.

Blocked on tui-cs/Terminal.Gui#5313 (code-token VisualRoles) reaching a
published develop pre-release. <TerminalGuiVersion> must be bumped to that
build before CI can go green; verified locally against a #5313 pack via
-p:TerminalGuiVersion.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tig tig merged commit cec8623 into develop May 17, 2026
13 checks passed
@tig tig deleted the copilot/add-code-token-visualrole-vocabulary branch May 17, 2026 04:43
tig added a commit to tui-cs/Editor that referenced this pull request May 17, 2026
tui-cs/Terminal.Gui#5313 (code-token VisualRoles) is published on the
develop NuGet feed as 2.1.1-develop.95 (later .125-.163 are bad/unlisted).
Bumped <TerminalGuiVersion> off the placeholder and removed the TODO.

Verified against the real published package: build 0 warnings/0 errors,
Tests 439/439, IntegrationTests 190/190, dotnet format clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Add code-token VisualRole vocabulary (CodeComment/CodeKeyword/etc.); add Code view; unify markdown highlighter

5 participants