Skip to content

Conversation

@tig
Copy link
Collaborator

@tig tig commented Dec 15, 2025

Fixes

Proposed Changes/Todos

  • Add property
  • Update usages
  • FIgure out how to enable parallel tests to override config without actually setting Glyphs.ReplacementChar, which is a static.

tig added 8 commits December 7, 2025 15:43
Introduced Glyphs.ReplacementChar to allow overriding the Unicode replacement character, defaulting to a space (' '). Updated both config.json and Glyphs.cs with this property, scoped to ThemeScope and documented as an override for Rune.ReplacementChar.
Replaced all uses of Rune.ReplacementChar.ToString() with Glyphs.ReplacementChar.ToString() in OutputBufferImpl and related tests. This ensures consistent use of the replacement character when invalidating or overwriting wide characters in the output buffer.
@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.46%. Comparing base (fb1a3e0) to head (31d4bef).
⚠️ Report is 1 commits behind head on v2_develop.

Additional details and impacted files
@@              Coverage Diff               @@
##           v2_develop    #4498      +/-   ##
==============================================
+ Coverage       77.45%   77.46%   +0.01%     
==============================================
  Files             386      386              
  Lines           44678    44676       -2     
  Branches         6283     6281       -2     
==============================================
+ Hits            34605    34610       +5     
+ Misses           8220     8214       -6     
+ Partials         1853     1852       -1     
Files with missing lines Coverage Δ
Terminal.Gui/Drawing/Glyphs.cs 100.00% <100.00%> (ø)
Terminal.Gui/Drivers/DriverImpl.cs 70.30% <100.00%> (+0.18%) ⬆️
Terminal.Gui/Drivers/OutputBufferImpl.cs 88.55% <100.00%> (+4.43%) ⬆️
Terminal.Gui/ViewBase/View.Mouse.cs 83.09% <ø> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb1a3e0...31d4bef. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

tig added 2 commits December 15, 2025 05:53
Allows setting custom replacement characters for wide glyphs that cannot fit in the available space via IOutputBuffer.SetReplacementChars. Updated IDriver to expose GetOutputBuffer. All code paths and tests now use the configurable characters, improving testability and flexibility. Tests now use '①' and '②' for clarity instead of the default replacement character.
@tig
Copy link
Collaborator Author

tig commented Dec 15, 2025

This change is it points out that no existing test covers this code in OutputBufferImpl:

image

@tig tig marked this pull request as ready for review December 15, 2025 12:56
@tig tig requested review from BDisp and Copilot December 15, 2025 12:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the replacement character configurable to address issue #4497 and enable parallel test isolation. Previously, the replacement character was hardcoded to Rune.ReplacementChar. Now it can be configured globally via Glyphs.ReplacementChar or per-buffer via SetReplacementChars().

Key changes:

  • Added Glyphs.ReplacementChar as a configurable static property with a default of space character
  • Added SetReplacementChars() method to IOutputBuffer for per-buffer replacement character configuration
  • Added GetOutputBuffer() method to IDriver interface to access the output buffer
  • Updated all tests to use custom replacement characters (①, ②) for parallel test isolation

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Terminal.Gui/Drawing/Glyphs.cs Adds configurable ReplacementChar property with default space character
Terminal.Gui/Drivers/IOutputBuffer.cs Adds SetReplacementChars() method to interface
Terminal.Gui/Drivers/OutputBufferImpl.cs Implements replacement character configuration with two separate chars for different scenarios
Terminal.Gui/Drivers/IDriver.cs Adds GetOutputBuffer() method with documentation
Terminal.Gui/Drivers/DriverImpl.cs Implements GetOutputBuffer() method
Terminal.Gui/ViewBase/View.Mouse.cs Updates documentation references from Command.Select to Command.Activate (unrelated fix)
Tests/UnitTestsParallelizable/ViewBase/Draw/ViewDrawingClippingTests.cs Updates tests to use custom replacement chars for parallel isolation
Tests/UnitTestsParallelizable/Drivers/OutputBufferWideCharTests.cs Updates tests to use Glyphs.ReplacementChar and removes unused constructor parameter
Tests/UnitTestsParallelizable/Drivers/OutputBaseTests.cs Updates tests to use custom replacement chars
Tests/UnitTestsParallelizable/Drivers/DriverTests.cs Updates tests to use custom replacement chars
Tests/UnitTestsParallelizable/Drivers/AddRuneTests.cs Updates tests to use custom replacement chars
Tests/UnitTests/View/Draw/ClipTests.cs Updates tests to use custom replacement chars
Examples/UICatalog/Scenarios/WideGlyphs.cs Adds null-forgiving operator and reformats code (unrelated cleanup)
Examples/UICatalog/Resources/config.json Adds Glyphs.ReplacementChar configuration entry

tig and others added 4 commits December 15, 2025 06:21
Added three unit tests to OutputBufferWideCharTests.cs to verify and document OutputBufferImpl's behavior when wide (double-width) characters are written at the edges of a clipping region. Tests cover cases where the first or second column of a wide character is outside the clip, as well as when both columns are inside. The tests assert correct use of replacement characters, dirty flags, and column advancement, and document that certain code paths are currently unreachable due to IsValidLocation checks.
Added comments to mark a rarely executed code path as dead code, noting it is apparently never called. Referenced the related test scenario AddStr_WideChar_FirstColumnOutsideClip_SecondColumnInside_CurrentBehavior for context. No functional changes were made.
Copy link
Collaborator

@BDisp BDisp left a comment

Choose a reason for hiding this comment

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

It's useful for testing purposes, but in a real terminal it would be counterproductive.

tig added 2 commits December 15, 2025 08:52
Removed unreachable code that handled the case where the first column of a wide character is outside the clipping region but the second column is inside. This logic was marked as dead code and never called. Now, only the cases where the second column is outside the clip or both columns are in bounds are handled. This simplifies the code and removes unnecessary checks.
…larify its use for clipped wide glyphs. Updates IOutputBuffer to use SetWideGlyphReplacement (single Rune) instead of SetReplacementChars (two Runes). Refactors OutputBufferImpl and all test code to use the new property and method. Removes second-column replacement logic, simplifying the API and improving consistency. Updates comments and test assertions to match the new naming and behavior.
@tig
Copy link
Collaborator Author

tig commented Dec 15, 2025

Based on that, I've done some renaming and simplification here.

Renamed "UI Catalog Theme" to "UI Catalog" and removed the
"Glyphs.ReplacementChar" property. Added several new properties
to the "UI Catalog" theme, including default shadow, highlight
states, button alignment, and separator line style. Also added
"Glyphs.WideGlyphReplacement" to the "Hot Dog Stand" theme.
@tig tig merged commit 4c772bd into gui-cs:v2_develop Dec 15, 2025
14 checks passed
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 Glyphs.ReplacementChar to enable config

2 participants