#nullable enable namespace Terminal.Gui.Drivers; /// /// Fake console output for testing that captures what would be written to the console. /// public class FakeConsoleOutput : OutputBase, IConsoleOutput { private readonly StringBuilder _output = new (); private int _cursorLeft; private int _cursorTop; private Size _consoleSize = new (80, 25); /// /// Gets the captured output as a string. /// public string Output => _output.ToString (); /// public void SetCursorPosition (int col, int row) { SetCursorPositionImpl (col, row); } /// public void SetSize (int width, int height) { _consoleSize = new (width, height); } /// protected override bool SetCursorPositionImpl (int col, int row) { _cursorLeft = col; _cursorTop = row; return true; } /// /// Sets the fake window size. /// public void SetConsoleSize (int width, int height) { _consoleSize = new (width, height); } /// /// Gets the current cursor position. /// public (int left, int top) GetCursorPosition () { return (_cursorLeft, _cursorTop); } /// public Size GetSize () { return _consoleSize; } /// public void Write (ReadOnlySpan text) { _output.Append (text); } /// public override void SetCursorVisibility (CursorVisibility visibility) { // Capture but don't act on it in fake output } /// public void Dispose () { // Nothing to dispose } /// protected override void AppendOrWriteAttribute (StringBuilder output, Attribute attr, TextStyle redrawTextStyle) { // For testing, we can skip the actual color/style output // or capture it if needed for verification } /// protected override void Write (StringBuilder output) { _output.Append (output); } }