Skip to content

Commit

Permalink
Tidying up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp committed Oct 31, 2023
1 parent 2289293 commit 919df85
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ public bool WriteToConsole (Size size, ExtendedRuneInfo [,] charInfoBuffer, Coor
var attr = ci.Attribute;

if (prev == null) {
SetAttribute (force16Colors, ci, attr);
SetAttribute (ci, attr);
} else if (attr != prev) {
if (_stringBuilder.Length > 0) {
ProcessWriteToConsole ();
}
SetAttribute (force16Colors, ci, attr);
ProcessWriteToConsole ();
SetAttribute (ci, attr);
}

_stringBuilder.Append (ci.Rune);
Expand All @@ -133,7 +131,7 @@ public bool WriteToConsole (Size size, ExtendedRuneInfo [,] charInfoBuffer, Coor

return result;

void SetAttribute (bool force16Colors, ExtendedRuneInfo ci, Attribute attr)
void SetAttribute (ExtendedRuneInfo ci, Attribute attr)
{
prev = attr;
SetTextAttribute (((int)ci.Attribute.Foreground.ColorName) |
Expand All @@ -151,6 +149,10 @@ void ProcessSurrogatePair (Rune nextRune, int col)

void ProcessWriteToConsole ()
{
if (_stringBuilder.Length == 0) {
return;
}

s = _stringBuilder.ToString ();
result = WriteConsole (_screenBuffer, s, (uint)(s.Length), out uint _, null);
GetScreenBufferInfo (ref csbi);
Expand Down

0 comments on commit 919df85

Please sign in to comment.