fixed WindowsDriver to work in linux unit tests

This commit is contained in:
Tigger Kindel
2023-08-11 13:32:42 -06:00
committed by Tig
parent 411ce95e59
commit 06f7a9898e
4 changed files with 21 additions and 13 deletions

View File

@@ -369,6 +369,7 @@ public abstract class ConsoleDriver {
get => _force16Colors || !SupportsTrueColor;
set {
_force16Colors = (value || !SupportsTrueColor);
Refresh ();
}
}

View File

@@ -247,8 +247,10 @@ internal class CursesDriver : ConsoleDriver {
}
}
Curses.move (Row, Col);
_window.wrefresh ();
if (_window != null) {
Curses.move (Row, Col);
_window.wrefresh ();
}
}
public Curses.Window _window;

View File

@@ -671,6 +671,9 @@ internal class NetDriver : ConsoleDriver {
public override void UpdateScreen ()
{
if (NetWinConsole == null) {
return;
}
if (_winSizeChanging || Console.WindowHeight < 1 || Contents.Length != Rows * Cols || Rows != Console.WindowHeight) {
return;
}
@@ -862,6 +865,9 @@ internal class NetDriver : ConsoleDriver {
public override bool SetCursorVisibility (CursorVisibility visibility)
{
_cachedCursorVisibility = visibility;
if (NetWinConsole == null) {
return visibility == CursorVisibility.Default;
}
var isVisible = Console.CursorVisible = visibility == CursorVisibility.Default;
//Console.Out.Write (isVisible ? EscSeqUtils.CSI_ShowCursor : EscSeqUtils.CSI_HideCursor);
return isVisible;
@@ -885,8 +891,10 @@ internal class NetDriver : ConsoleDriver {
void SetWindowPosition (int col, int row)
{
Top = Console.WindowTop;
Left = Console.WindowLeft;
if (NetWinConsole != null) {
Top = Console.WindowTop;
Left = Console.WindowLeft;
}
}
private bool EnsureBufferSize ()

View File

@@ -92,21 +92,18 @@ namespace Terminal.Gui.DriverTests {
}
[Theory]
[InlineData (typeof (FakeDriver), true)]
[InlineData (typeof (NetDriver), false)]
[InlineData (typeof (CursesDriver), true)]
[InlineData (typeof (WindowsDriver), false)]
public void Force16Colors_Sets (Type driverType, bool expectedSetting)
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
[InlineData (typeof (CursesDriver))]
[InlineData (typeof (WindowsDriver))]
public void Force16Colors_Sets (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
driver.Init (() => { });
Assert.Equal (expectedSetting, driver.Force16Colors);
driver.Force16Colors = true;
Assert.True (driver.Force16Colors);
driver.End ();
// Shutdown must be called to safely clean up Application if Init has been called