using Microsoft.Extensions.Logging;
namespace Terminal.Gui.Drivers;
///
internal class SizeMonitorImpl (IOutput consoleOut) : ISizeMonitor
{
private Size _lastSize = Size.Empty;
/// Invoked when the terminal's size changed. The new size of the terminal is provided.
public event EventHandler? SizeChanged;
///
public bool Poll ()
{
Size size = consoleOut.GetSize ();
if (size != _lastSize)
{
//Logging.Trace ($"Size changed from '{_lastSize}' to {size}");
_lastSize = size;
SizeChanged?.Invoke (this, new (size));
return true;
}
return false;
}
}