Do not output sixel if driver does not support it

Allow overriding driver sixel support in Images scenario
This commit is contained in:
tznind
2024-10-03 19:47:01 +01:00
parent d60b1fa347
commit 23cd8889a5
3 changed files with 18 additions and 9 deletions

View File

@@ -1024,12 +1024,15 @@ internal class NetDriver : ConsoleDriver
Console.Write (output);
}
foreach (var s in Application.Sixel)
if (ConsoleDriver.SupportsSixel)
{
if (!string.IsNullOrWhiteSpace (s.SixelData))
foreach (var s in Application.Sixel)
{
SetCursorPosition (s.ScreenPosition.X, s.ScreenPosition.Y);
Console.Write (s.SixelData);
if (!string.IsNullOrWhiteSpace (s.SixelData))
{
SetCursorPosition (s.ScreenPosition.X, s.ScreenPosition.Y);
Console.Write (s.SixelData);
}
}
}
}

View File

@@ -127,11 +127,14 @@ internal class WindowsConsole
_lastWrite = s;
foreach (var sixel in Application.Sixel)
if (ConsoleDriver.SupportsSixel)
{
SetCursorPosition (new Coord ((short)sixel.ScreenPosition.X, (short)sixel.ScreenPosition.Y));
WriteConsole (_screenBuffer, sixel.SixelData, (uint)sixel.SixelData.Length, out uint _, nint.Zero);
foreach (var sixel in Application.Sixel)
{
SetCursorPosition (new Coord ((short)sixel.ScreenPosition.X, (short)sixel.ScreenPosition.Y));
WriteConsole (_screenBuffer, sixel.SixelData, (uint)sixel.SixelData.Length, out uint _, nint.Zero);
}
}
}

View File

@@ -62,10 +62,13 @@ public class Images : Scenario
Y = 1,
CheckedState = ConsoleDriver.SupportsSixel
? CheckState.Checked : CheckState.UnChecked,
CanFocus = false,
Enabled = false,
Text = "Supports Sixel"
};
cbSupportsSixel.CheckedStateChanging += (s, e) =>
{
ConsoleDriver.SupportsSixel = e.NewValue == CheckState.Checked;
};
_win.Add (cbSupportsSixel);
var cbUseTrueColor = new CheckBox