Skip to content

Add code-token VisualRoles and Code view#5313

Draft
Copilot wants to merge 2 commits into
developfrom
copilot/add-code-token-visualrole-vocabulary
Draft

Add code-token VisualRoles and Code view#5313
Copilot wants to merge 2 commits into
developfrom
copilot/add-code-token-visualrole-vocabulary

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Fixes

Adds theme-driven token roles for syntax-highlighted code so Markdown, the new Code view, and downstream editors can share the active Terminal.Gui theme palette.

Proposed Changes/Todos

  • Code token roles

    • Added VisualRole.CodeComment through CodeAttribute.
    • Added Scheme storage, JSON round-trip support, and fallback: Code* → Code → Editable → Normal.
  • Theme/config support

    • Added Dark/Light Base.Code* colors.
    • Updated config schema.
    • Added Examples/Themes/code-dark.config.json.
  • Rendering pipeline

    • TextMateSyntaxHighlighter now emits StyledSegment.Role.
    • Markdown code blocks resolve token attributes from VisualRole.Code*.
    • Added public Code view:
Code code = new ()
{
    Language = "cs",
    Text = "public string Name => \"Ada\";"
};
  • UICatalog

    • Expanded Themes scenario with Code role swatches and live Markdown code.
    • Added Code View Demo scenario.
  • Tests

    • Added/updated coverage for Scheme derivation, JSON conversion, TextMate scope mapping, Markdown pipeline, and Code rendering.
    • Perf benchmark comparison remains pending on baseline benchmark availability in this checkout.

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

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=7412 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.0Zz0qB --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,18362738395879841708,9124006556522462828,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,3170967420076418732,10802322850313536385,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui/code-demo.png --window-size=1000,500 file:///tmp/tg-ui/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=7412 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.0Zz0qB --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,18362738395879841708,9124006556522462828,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,3170967420076418732,10802322850313536385,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui/code-demo.png --window-size=1000,500 file:///tmp/tg-ui/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=7412 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.0Zz0qB --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,18362738395879841708,9124006556522462828,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,3170967420076418732,10802322850313536385,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui/code-demo.png --window-size=1000,500 file:///tmp/tg-ui/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=7412 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.0Zz0qB --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,18362738395879841708,9124006556522462828,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,3170967420076418732,10802322850313536385,4 --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: /usr/bin/chromium chromium --headless --no-sandbox --disable-gpu --screenshot=/tmp/tg-ui/code-demo.png --window-size=1000,500 file:///tmp/tg-ui/code-demo.html (dns block)

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

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
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

2 participants