Browse Source

The wide runes fix must be done on the AddRune so the Contents are consistent.

BDisp 3 years ago
parent
commit
0a19fe5a58
1 changed files with 12 additions and 7 deletions
  1. 12 7
      Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs

+ 12 - 7
Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs

@@ -94,6 +94,7 @@ namespace Terminal.Gui {
 		public override void AddRune (Rune rune)
 		{
 			rune = MakePrintable (rune);
+			var runeWidth = Rune.ColumnWidth (rune);
 			var validClip = IsValidContent (ccol, crow, Clip);
 
 			if (validClip) {
@@ -102,6 +103,17 @@ namespace Terminal.Gui {
 					//MockConsole.CursorTop = crow;
 					needMove = false;
 				}
+				if (runeWidth < 2 && ccol > 0
+					&& Rune.ColumnWidth ((char)contents [crow, ccol - 1, 0]) > 1) {
+
+					contents [crow, ccol - 1, 0] = (int)(uint)' ';
+
+				} else if (runeWidth < 2 && ccol < Cols - 1
+					&& Rune.ColumnWidth ((char)contents [crow, ccol, 0]) > 1) {
+
+					contents [crow, ccol + 1, 0] = (int)(uint)' ';
+				}
+
 				contents [crow, ccol, 0] = (int)(uint)rune;
 				contents [crow, ccol, 1] = currentAttribute;
 				contents [crow, ccol, 2] = 1;
@@ -110,7 +122,6 @@ namespace Terminal.Gui {
 				needMove = true;
 
 			ccol++;
-			var runeWidth = Rune.ColumnWidth (rune);
 			if (runeWidth > 1) {
 				for (int i = 1; i < runeWidth; i++) {
 					if (validClip) {
@@ -251,12 +262,6 @@ namespace Terminal.Gui {
 							continue;
 						}
 
-						if (col < cols - 1 && Rune.ColumnWidth ((char)contents [row, col, 0]) > 1
-							&& (contents [row, col + 1, 2] == 1 || col == cols - 1)) {
-
-							contents [row, col, 0] = ' ';
-						}
-
 						var color = contents [row, col, 1];
 						if (color != redrawColor)
 							SetColor (color);