[PR #6728] Refactor TerminalDispatch (graphics) to match AdaptDispatch #26774

Open
opened 2026-01-31 09:18:05 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/6728

State: closed
Merged: Yes


Summary of the Pull Request

This is essentially a rewrite of the TerminalDispatch::SetGraphicsRendition method, bringing it into closer alignment with the AdaptDispatch implementation, simplifying the ITerminalApi interface, and making the code easier to extend. It adds support for a number of attributes which weren't previously implemented.

References

  • This is a mirror of the AdaptDispatch refactoring in PR #5758.
  • The closer alignment with AdaptDispatch is a small step towards solving issue #3849.
  • The newly supported attributes should help a little with issues #5461 (italics) and #6205 (strike-through).

PR Checklist

  • Closes I dont see text after i type "--" (#6725)
  • CLA signed.
  • Tests added/passed
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan.

Detailed Description of the Pull Request / Additional comments

I've literally copied and pasted the SetGraphicsRendition implementation from AdaptDispatch into TerminalDispatch, with only few minor changes:

  • The SetTextAttribute and GetTextAttribute calls are slightly different in the TerminalDispatch version, since they don't return a pointless success value, and in the case of the getter, the TextAttribute is returned directly instead of by reference. Ultimately I'd like to move the AdaptDispatch code towards that way of doing things too, but I'd like to deal with that later as part of a wider refactoring of the ConGetSet interface.
  • The SetIndexedForeground256 and SetIndexedBackground256 calls required the color indices to be remapped in the AdaptDispatch implementation, because the conhost color table is in a different order to the XTerm standard. TerminalDispatch doesn't have that problem, so doesn't require the mapping.
  • The index color constants used in the 16-color SetIndexedForeground and SetIndexedBackground calls are also slightly different for the same reason.

Validation Steps Performed

I cherry-picked this code on top of the #6506 and #6698 PRs, since that's only way to really get the different color formats passed-through to the terminal. I then ran a bunch of manual tests with various color coverage scripts that I have, and confirmed that all the different color formats were being rendered as expected.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/6728 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This is essentially a rewrite of the `TerminalDispatch::SetGraphicsRendition` method, bringing it into closer alignment with the `AdaptDispatch` implementation, simplifying the `ITerminalApi` interface, and making the code easier to extend. It adds support for a number of attributes which weren't previously implemented. ## References * This is a mirror of the `AdaptDispatch` refactoring in PR #5758. * The closer alignment with `AdaptDispatch` is a small step towards solving issue #3849. * The newly supported attributes should help a little with issues #5461 (italics) and #6205 (strike-through). ## PR Checklist * [x] Closes #6725 * [x] CLA signed. * [ ] Tests added/passed * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. ## Detailed Description of the Pull Request / Additional comments I've literally copied and pasted the `SetGraphicsRendition` implementation from `AdaptDispatch` into `TerminalDispatch`, with only few minor changes: * The `SetTextAttribute` and `GetTextAttribute` calls are slightly different in the `TerminalDispatch` version, since they don't return a pointless `success` value, and in the case of the getter, the `TextAttribute` is returned directly instead of by reference. Ultimately I'd like to move the `AdaptDispatch` code towards that way of doing things too, but I'd like to deal with that later as part of a wider refactoring of the `ConGetSet` interface. * The `SetIndexedForeground256` and `SetIndexedBackground256` calls required the color indices to be remapped in the `AdaptDispatch` implementation, because the conhost color table is in a different order to the XTerm standard. `TerminalDispatch` doesn't have that problem, so doesn't require the mapping. * The index color constants used in the 16-color `SetIndexedForeground` and `SetIndexedBackground` calls are also slightly different for the same reason. ## Validation Steps Performed I cherry-picked this code on top of the #6506 and #6698 PRs, since that's only way to really get the different color formats passed-through to the terminal. I then ran a bunch of manual tests with various color coverage scripts that I have, and confirmed that all the different color formats were being rendered as expected.
claunia added the pull-request label 2026-01-31 09:18:05 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26774