From fea1d4f5c0646dabc32cb6eabde319a26423efd2 Mon Sep 17 00:00:00 2001 From: BDisp Date: Mon, 21 Jul 2025 23:38:25 +0100 Subject: [PATCH] Replace ExtendedCharInfo.Char with char array --- Terminal.Gui/Drivers/ConsoleDriver.cs | 4 ++-- Terminal.Gui/Drivers/V2/OutputBuffer.cs | 2 +- Terminal.Gui/Drivers/V2/WindowsOutput.cs | 14 +++++++------- .../Drivers/WindowsDriver/WindowsConsole.cs | 6 +++--- .../Drivers/WindowsDriver/WindowsDriver.cs | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Terminal.Gui/Drivers/ConsoleDriver.cs b/Terminal.Gui/Drivers/ConsoleDriver.cs index cf85db80c..5d2252337 100644 --- a/Terminal.Gui/Drivers/ConsoleDriver.cs +++ b/Terminal.Gui/Drivers/ConsoleDriver.cs @@ -269,7 +269,7 @@ public abstract class ConsoleDriver : IConsoleDriver if (Contents [Row, Col - 1].Rune.GetColumns () > 1) { // Invalidate cell to left - Contents [Row, Col - 1].Rune = Rune.ReplacementChar; + Contents [Row, Col - 1].Rune = (Rune)'\0'; Contents [Row, Col - 1].IsDirty = true; } } @@ -308,7 +308,7 @@ public abstract class ConsoleDriver : IConsoleDriver { // Invalidate cell to right so that it doesn't get drawn // TODO: Figure out if it is better to show a replacement character or ' ' - Contents [Row, Col + 1].Rune = Rune.ReplacementChar; + Contents [Row, Col + 1].Rune = (Rune)'\0'; Contents [Row, Col + 1].IsDirty = true; } } diff --git a/Terminal.Gui/Drivers/V2/OutputBuffer.cs b/Terminal.Gui/Drivers/V2/OutputBuffer.cs index fa44d5630..51382262c 100644 --- a/Terminal.Gui/Drivers/V2/OutputBuffer.cs +++ b/Terminal.Gui/Drivers/V2/OutputBuffer.cs @@ -256,7 +256,7 @@ public class OutputBuffer : IOutputBuffer { // Invalidate cell to right so that it doesn't get drawn // TODO: Figure out if it is better to show a replacement character or ' ' - Contents [Row, Col + 1].Rune = Rune.ReplacementChar; + Contents [Row, Col + 1].Rune = (Rune)'\0'; Contents [Row, Col + 1].IsDirty = true; } } diff --git a/Terminal.Gui/Drivers/V2/WindowsOutput.cs b/Terminal.Gui/Drivers/V2/WindowsOutput.cs index fb8e26815..8a155cd19 100644 --- a/Terminal.Gui/Drivers/V2/WindowsOutput.cs +++ b/Terminal.Gui/Drivers/V2/WindowsOutput.cs @@ -139,7 +139,7 @@ internal partial class WindowsOutput : IConsoleOutput if (buffer.Contents [row, col].IsDirty == false) { outputBuffer [position].Empty = true; - outputBuffer [position].Char = (char)Rune.ReplacementChar.Value; + outputBuffer [position].Char = [(char)buffer.Contents [row, col].Rune.Value]; continue; } @@ -148,12 +148,12 @@ internal partial class WindowsOutput : IConsoleOutput if (buffer.Contents [row, col].Rune.IsBmp) { - outputBuffer [position].Char = (char)buffer.Contents [row, col].Rune.Value; + outputBuffer [position].Char = [(char)buffer.Contents [row, col].Rune.Value]; } else { - //outputBuffer [position].Empty = true; - outputBuffer [position].Char = (char)Rune.ReplacementChar.Value; + outputBuffer [position].Char = [(char)buffer.Contents [row, col].Rune.ToString () [0], + (char)buffer.Contents [row, col].Rune.ToString () [1]]; if (buffer.Contents [row, col].Rune.GetColumns () > 1 && col + 1 < buffer.Cols) { @@ -161,7 +161,7 @@ internal partial class WindowsOutput : IConsoleOutput col++; position = row * buffer.Cols + col; outputBuffer [position].Empty = false; - outputBuffer [position].Char = ' '; + outputBuffer [position].Char = ['\0']; } } } @@ -216,7 +216,7 @@ internal partial class WindowsOutput : IConsoleOutput { ci [i++] = new () { - Char = new () { UnicodeChar = info.Char }, + Char = new () { UnicodeChar = info.Char [0] }, Attributes = (ushort)((int)info.Attribute.Foreground.GetClosestNamedColor16 () | ((int)info.Attribute.Background.GetClosestNamedColor16 () << 4)) }; @@ -246,7 +246,7 @@ internal partial class WindowsOutput : IConsoleOutput _redrawTextStyle = attr.Style; } - if (info.Char != '\x1b') + if (info.Char [0] != '\x1b') { if (!info.Empty) { diff --git a/Terminal.Gui/Drivers/WindowsDriver/WindowsConsole.cs b/Terminal.Gui/Drivers/WindowsDriver/WindowsConsole.cs index 6153df249..130058889 100644 --- a/Terminal.Gui/Drivers/WindowsDriver/WindowsConsole.cs +++ b/Terminal.Gui/Drivers/WindowsDriver/WindowsConsole.cs @@ -198,7 +198,7 @@ internal partial class WindowsConsole _redrawTextStyle = attr.Style; } - if (info.Char != '\x1b') + if (info.Char [0] != '\x1b') { if (!info.Empty) { @@ -791,11 +791,11 @@ internal partial class WindowsConsole public struct ExtendedCharInfo { - public char Char { get; set; } + public char [] Char { get; set; } public Attribute Attribute { get; set; } public bool Empty { get; set; } // TODO: Temp hack until virtual terminal sequences - public ExtendedCharInfo (char character, Attribute attribute) + public ExtendedCharInfo (char [] character, Attribute attribute) { Char = character; Attribute = attribute; diff --git a/Terminal.Gui/Drivers/WindowsDriver/WindowsDriver.cs b/Terminal.Gui/Drivers/WindowsDriver/WindowsDriver.cs index 59941924f..0f7e5616d 100644 --- a/Terminal.Gui/Drivers/WindowsDriver/WindowsDriver.cs +++ b/Terminal.Gui/Drivers/WindowsDriver/WindowsDriver.cs @@ -337,7 +337,7 @@ internal class WindowsDriver : ConsoleDriver if (Contents [row, col].IsDirty == false) { _outputBuffer [position].Empty = true; - _outputBuffer [position].Char = (char)Rune.ReplacementChar.Value; + _outputBuffer [position].Char = [(char)Contents [row, col].Rune.Value]; continue; } @@ -346,12 +346,12 @@ internal class WindowsDriver : ConsoleDriver if (Contents [row, col].Rune.IsBmp) { - _outputBuffer [position].Char = (char)Contents [row, col].Rune.Value; + _outputBuffer [position].Char = [(char)Contents [row, col].Rune.Value]; } else { - //_outputBuffer [position].Empty = true; - _outputBuffer [position].Char = (char)Rune.ReplacementChar.Value; + _outputBuffer [position].Char = [(char)Contents [row, col].Rune.ToString () [0], + (char)Contents [row, col].Rune.ToString () [1]]; if (Contents [row, col].Rune.GetColumns () > 1 && col + 1 < Cols) { @@ -359,7 +359,7 @@ internal class WindowsDriver : ConsoleDriver col++; position = row * Cols + col; _outputBuffer [position].Empty = false; - _outputBuffer [position].Char = ' '; + _outputBuffer [position].Char = ['\0']; } } }