Browse Source

Stop-gap for slow rendering with lots of writes

Bepis 6 years ago
parent
commit
843950d689
1 changed files with 19 additions and 0 deletions
  1. 19 0
      NTERA/Console/ConsoleRenderer.cs

+ 19 - 0
NTERA/Console/ConsoleRenderer.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Drawing;
 using System.Linq;
 using System.Windows.Forms;
+using NTERA.Console.RenderItem;
 
 namespace NTERA.Console
 {
@@ -28,6 +29,24 @@ namespace NTERA.Console
 
 		public void WriteItem(IRenderItem item)
 		{
+			var list = Items[Items.Count - 1];
+
+			var lastItem = list.LastOrDefault();
+
+			if (lastItem != null)
+			{
+				if (lastItem is TextRenderItem lastTextItem && item is TextRenderItem newTextItem)
+				{
+					if (lastTextItem.TextBrush.Color == newTextItem.TextBrush.Color)
+					{
+						lastTextItem.Text += newTextItem.Text;
+						
+						AddedItem?.Invoke(item);
+						return;
+					}
+				}
+			}
+
 			Items[Items.Count - 1].Add(item);
 
 			AddedItem?.Invoke(item);