mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Fixes #4139. Application.Run<T> isn't initializing properly by setting the Application.ForceDriver property * Trying fix unit tests * Only to force again CI tests because I haven't errors locally * This should pass, unless RunningUnitTests is set to false somewhere * Fix Unix unit tests and failures via ReSharper * Changes suggested by @tig * Prevent empty string * Centralize all the entry logic in the InternalInit method * Change GetDriverTypes to return a tuple
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Terminal.Gui.Drivers;
|
|
|
|
internal class WindowSizeMonitor : IWindowSizeMonitor
|
|
{
|
|
private readonly IConsoleOutput _consoleOut;
|
|
private readonly IOutputBuffer _outputBuffer;
|
|
private Size _lastSize = new (0, 0);
|
|
|
|
/// <summary>Invoked when the terminal's size changed. The new size of the terminal is provided.</summary>
|
|
public event EventHandler<SizeChangedEventArgs> SizeChanging;
|
|
|
|
public WindowSizeMonitor (IConsoleOutput consoleOut, IOutputBuffer outputBuffer)
|
|
{
|
|
_consoleOut = consoleOut;
|
|
_outputBuffer = outputBuffer;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
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;
|
|
}
|
|
}
|