mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Improve wide character handling in output buffer Enhances rendering and state management for wide (double-width) characters. Marks both cells as clean after rendering wide graphemes, ensures replacement cells are marked dirty when partially clipped, and uses Move/AddStr for proper wide character handling and invalidation. * Fix FillRect to handle wide Unicode chars correctly Refactored OutputBufferImpl.FillRect to properly handle wide (double-width) Unicode characters, fixing visual corruption when overwriting CJK text (e.g., with MessageBox borders). Removed the char-based FillRect overload in favor of Rune-based handling. Added helper methods for attribute/dirty management and wide glyph invalidation. Updated OutputBase.Write to always mark adjacent cells dirty for wide chars. Updated tests and added OutputBufferWideCharTests to verify correct behavior in all scenarios. This resolves issue #4466 and ensures robust rendering for wide Unicode text. * Handle wide grapheme clusters in OutputBase rendering Added logic to mark both cells of wide grapheme clusters as clean after rendering, preventing unnecessary redraws. Also included a commented-out preprocessor directive and using statement for potential future use. * Clarify comment for IsDirty logic on wide graphemes Updated the comment explaining why the next cell is marked clean (IsDirty = false) after handling wide graphemes, and added a reference to GitHub issue #4466 for context. * Update test for dirty flag after wide glyph write Adjusted OutputBaseTests to expect column 1's dirty flag to be cleared after writing a wide glyph to column 0, matching current OutputBase.Write behavior. Added clarifying comment and GitHub issue reference. * Update Tests/UnitTestsParallelizable/Drivers/OutputBufferWideCharTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/Drivers/OutputBufferImpl.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/Drivers/OutputBase.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -23,12 +23,12 @@ public class ClipRegionTests (ITestOutputHelper output) : FakeDriverBase
|
||||
Assert.Equal ("x", driver.Contents [5, 5].Grapheme);
|
||||
|
||||
// Clear the contents
|
||||
driver.FillRect (new Rectangle (0, 0, driver.Rows, driver.Cols), ' ');
|
||||
driver.FillRect (new (0, 0, driver.Rows, driver.Cols), new Rune(' '));
|
||||
Assert.Equal (" ", driver.Contents [0, 0].Grapheme);
|
||||
|
||||
// Setup the region with a single rectangle, fill screen with 'x'
|
||||
driver.Clip = new (new Rectangle (5, 5, 5, 5));
|
||||
driver.FillRect (new Rectangle (0, 0, driver.Rows, driver.Cols), 'x');
|
||||
driver.Clip = new (new (5, 5, 5, 5));
|
||||
driver.FillRect (new (0, 0, driver.Rows, driver.Cols), new Rune ('x'));
|
||||
Assert.Equal (" ", driver.Contents [0, 0].Grapheme);
|
||||
Assert.Equal (" ", driver.Contents [4, 9].Grapheme);
|
||||
Assert.Equal ("x", driver.Contents [5, 5].Grapheme);
|
||||
|
||||
Reference in New Issue
Block a user