diff --git a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs index 9f2a45465..617c1be61 100644 --- a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs @@ -484,6 +484,9 @@ public abstract class ConsoleDriver /// Gets whether the supports TrueColor output. public virtual bool SupportsTrueColor => true; + // TODO: make not static TODO: gets set in mouse logic in net driver :/ + public static bool SupportsSixel { get; set; } + // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application. // BUGBUG: Application.Force16Colors should be bool? so if SupportsTrueColor and Application.Force16Colors == false, this doesn't override /// diff --git a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs index 1eb63e34a..d4b6fc47b 100644 --- a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs +++ b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs @@ -47,6 +47,10 @@ public static class EscSeqUtils /// public const string CSI = "\u001B["; + + public const string CSI_Device_Attributes_Request = CSI + "c"; + public const string CSI_Device_Attributes_Request_Terminator = "c"; + /// /// ESC [ ? 1047 h - Activate xterm alternative buffer (no backscroll) /// diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index 6d49d6279..d72017a47 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -632,6 +632,9 @@ internal class NetEvents : IDisposable break; } + break; + case EscSeqUtils.CSI_Device_Attributes_Request_Terminator: + ConsoleDriver.SupportsSixel = values.Any (v => v == "4"); break; default: EnqueueRequestResponseEvent (c1Control, code, values, terminating); @@ -1135,9 +1138,13 @@ internal class NetDriver : ConsoleDriver _mainLoopDriver = new NetMainLoop (this); _mainLoopDriver.ProcessInput = ProcessInput; + _mainLoopDriver._netEvents.EscSeqRequests.Add ("c"); + // Determine if sixel is supported + Console.Out.Write (EscSeqUtils.CSI_Device_Attributes_Request); + return new MainLoop (_mainLoopDriver); } - + private void ProcessInput (InputResult inputEvent) { switch (inputEvent.EventType) @@ -1338,6 +1345,7 @@ internal class NetDriver : ConsoleDriver } private CursorVisibility? _cachedCursorVisibility; + private static bool _supportsSixel; public override void UpdateCursor () { diff --git a/UICatalog/Scenarios/Images.cs b/UICatalog/Scenarios/Images.cs index cdab42e3c..0c79df0c4 100644 --- a/UICatalog/Scenarios/Images.cs +++ b/UICatalog/Scenarios/Images.cs @@ -53,6 +53,18 @@ public class Images : Scenario }; win.Add (cbSupportsTrueColor); + var cbSupportsSixel = new CheckBox + { + X = Pos.Right (lblDriverName) + 2, + Y = 1, + CheckedState = ConsoleDriver.SupportsSixel + ? CheckState.Checked : CheckState.UnChecked, + CanFocus = false, + Enabled = false, + Text = "Supports Sixel" + }; + win.Add (cbSupportsSixel); + var cbUseTrueColor = new CheckBox { X = Pos.Right (cbSupportsTrueColor) + 2, @@ -69,7 +81,7 @@ public class Images : Scenario var tv = new TabView { - Y = Pos.Bottom (lblDriverName), Width = Dim.Fill (), Height = Dim.Fill () + Y = Pos.Bottom (cbSupportsSixel), Width = Dim.Fill (), Height = Dim.Fill () }; tv.AddTab (tabBasic, true);