using Microsoft.Extensions.Logging; namespace Terminal.Gui.Drivers; internal class FakeWindowSizeMonitor (IConsoleOutput consoleOut, IOutputBuffer outputBuffer) : IWindowSizeMonitor { private Size _lastSize = new (0, 0); /// Invoked when the terminal's size changed. The new size of the terminal is provided. public event EventHandler SizeChanging; /// Raises the event with the specified size. Used for testing. /// The new size to report. public void RaiseSizeChanging (Size newSize) { SizeChanging?.Invoke (this, new (newSize)); } /// public bool Poll () { if (ConsoleDriver.RunningUnitTests) { return false; } Size size = consoleOut.GetWindowSize (); if (size != _lastSize) { Logging.Logger.LogInformation ($"Console size changes from '{_lastSize}' to {size}"); outputBuffer.SetWindowSize (size.Width, size.Height); _lastSize = size; SizeChanging?.Invoke (this, new (size)); return true; } return false; } }