diff --git a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs index 2065ced28..6330c3370 100644 --- a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs +++ b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs @@ -1356,6 +1356,8 @@ public static class EscSeqUtils /// public const string CSI_ReportDeviceAttributes_Terminator = "c"; + /* + TODO: depends on https://github.com/gui-cs/Terminal.Gui/pull/3768 /// /// CSI 16 t - Request sixel resolution (width and height in pixels) /// @@ -1365,6 +1367,7 @@ public static class EscSeqUtils /// CSI 14 t - Request window size in pixels (width x height) /// public static readonly AnsiEscapeSequenceRequest CSI_RequestWindowSizeInPixels = new () { Request = CSI + "14t", Terminator = "t" }; + */ /// /// CSI 1 8 t | yes | yes | yes | report window size in chars diff --git a/Terminal.Gui/Drawing/AssumeSupportDetector.cs b/Terminal.Gui/Drawing/AssumeSupportDetector.cs new file mode 100644 index 000000000..c01b03f1c --- /dev/null +++ b/Terminal.Gui/Drawing/AssumeSupportDetector.cs @@ -0,0 +1,20 @@ +namespace Terminal.Gui; + +/// +/// Implementation of that assumes best +/// case scenario (full support including transparency with 10x20 resolution). +/// +public class AssumeSupportDetector : ISixelSupportDetector +{ + /// + public SixelSupportResult Detect () + { + return new SixelSupportResult + { + IsSupported = true, + MaxPaletteColors = 256, + Resolution = new Size (10, 20), + SupportsTransparency = true + }; + } +} diff --git a/Terminal.Gui/Drawing/ISixelSupportDetector.cs b/Terminal.Gui/Drawing/ISixelSupportDetector.cs new file mode 100644 index 000000000..07ca43508 --- /dev/null +++ b/Terminal.Gui/Drawing/ISixelSupportDetector.cs @@ -0,0 +1,15 @@ +namespace Terminal.Gui; + +/// +/// Interface for detecting sixel support. Either through +/// ansi requests to terminal or config file etc. +/// +public interface ISixelSupportDetector +{ + /// + /// Gets the supported sixel state e.g. by sending Ansi escape sequences + /// or from a config file etc. + /// + /// Description of sixel support. + public SixelSupportResult Detect (); +} diff --git a/Terminal.Gui/Drawing/SixelSupportDetector.cs b/Terminal.Gui/Drawing/SixelSupportDetector.cs index 4713d5e25..d6044ff48 100644 --- a/Terminal.Gui/Drawing/SixelSupportDetector.cs +++ b/Terminal.Gui/Drawing/SixelSupportDetector.cs @@ -1,12 +1,12 @@ using System.Text.RegularExpressions; namespace Terminal.Gui; - +/* TODO : Depends on https://github.com/gui-cs/Terminal.Gui/pull/3768 /// /// Uses Ansi escape sequences to detect whether sixel is supported /// by the terminal. /// -public class SixelSupportDetector +public class SixelSupportDetector : ISixelSupportDetector { /// /// Sends Ansi escape sequences to the console to determine whether @@ -130,4 +130,4 @@ public class SixelSupportDetector return false; } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/UICatalog/Scenarios/Images.cs b/UICatalog/Scenarios/Images.cs index 9fb4666da..727be180d 100644 --- a/UICatalog/Scenarios/Images.cs +++ b/UICatalog/Scenarios/Images.cs @@ -65,7 +65,8 @@ public class Images : Scenario public override void Main () { - var sixelSupportDetector = new SixelSupportDetector (); + // TODO: Change to the one that uses Ansi Requests later + var sixelSupportDetector = new AssumeSupportDetector (); _sixelSupportResult = sixelSupportDetector.Detect (); ConsoleDriver.SupportsSixel = _sixelSupportResult.IsSupported; @@ -143,7 +144,7 @@ public class Images : Scenario SetupSixelSupported (cbSupportsSixel.CheckedState == CheckState.Checked); - btnOpenImage.Accept += OpenImage; + btnOpenImage.Accepting += OpenImage; _win.Add (_tabView); Application.Run (_win); @@ -157,7 +158,7 @@ public class Images : Scenario _tabView.SetNeedsDisplay (); } - private void BtnStartFireOnAccept (object sender, HandledEventArgs e) + private void BtnStartFireOnAccept (object sender, CommandEventArgs e) { if (_fire != null) { @@ -233,7 +234,7 @@ public class Images : Scenario Application.Sixel.Clear (); } - private void OpenImage (object sender, HandledEventArgs e) + private void OpenImage (object sender, CommandEventArgs e) { var ofd = new OpenDialog { Title = "Open Image", AllowsMultipleSelection = false }; Application.Run (ofd); @@ -334,7 +335,7 @@ public class Images : Scenario Y = 0, Text = "Output Sixel", Width = Dim.Auto () }; - btnSixel.Accept += OutputSixelButtonClick; + btnSixel.Accepting += OutputSixelButtonClick; _sixelSupported.Add (btnSixel); var btnStartFire = new Button @@ -343,7 +344,7 @@ public class Images : Scenario Y = Pos.Bottom (btnSixel), Text = "Start Fire" }; - btnStartFire.Accept += BtnStartFireOnAccept; + btnStartFire.Accepting += BtnStartFireOnAccept; _sixelSupported.Add (btnStartFire); @@ -462,7 +463,7 @@ public class Images : Scenario } } - private void OutputSixelButtonClick (object sender, HandledEventArgs e) + private void OutputSixelButtonClick (object sender, CommandEventArgs e) { if (_imageView.FullResImage == null) { @@ -555,7 +556,7 @@ public class Images : Scenario Text = "Ok" }; - btn.Accept += (s, e) => Application.RequestStop (); + btn.Accepting += (s, e) => Application.RequestStop (); dlg.Add (pv); dlg.AddButton (btn); Application.Run (dlg);