public void WriteLine(string format, params object[] args)
 {
     var text = string.Format(format, args);
     if (_echo) Console.WriteLine(text);
     string overflow = "";
     overflow = _lines[Cursor.Y].WriteFormatted(_color, _background, Cursor.X, text);
     Cursor = new XY(0, Cursor.Y < _height ? Cursor.Y + 1 : _height);
     if (overflow != null) WriteLine(overflow);
 }
 public MockConsole(int width, int height, ConsoleColor color, ConsoleColor background, bool echo = false)
 {
     _width = width;
     _height = height;
     _echo = echo;
     _color = color;
     _background = background;
     Cursor = new XY(0, 0);
     _lastLineWrittenTo = 0;
     _lines = new Dictionary<int, Line>();
     for (int i = 0; i < height; i++) _lines.Add(i, new Line(width,' ', color, background));
 }
 public void Write(string text)
 {
     if (_echo) Console.Write(text);
     var overflow = "";
     while (overflow != null)
     {
         overflow = _lines[Cursor.Y].WriteFormatted(_color,_background, Cursor.X, text);
         var xinc = overflow == null ? 0 : overflow.Length;
         if (overflow == null)
         {
             Cursor = Cursor.IncX(text.Length);
         }
         else
         {
             Cursor = new XY(0, Cursor.Y + 1);
             Write(overflow);
         }
     }
 }
 public void PrintAt(int x, int y, string text)
 {
     Cursor = new XY(x, y);
     Write(text);
 }
 public void PrintAt(int x, int y, string format, params object[] args)
 {
     Cursor = new XY(x, y);
     Write(format, args);
 }