mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-28 08:47:59 +01:00
Update sixel status class name and move to new file
This commit is contained in:
@@ -9,9 +9,9 @@ namespace Terminal.Gui;
|
||||
/// </summary>
|
||||
public class SixelSupportDetector
|
||||
{
|
||||
public SixelSupport Detect ()
|
||||
public SixelSupportResult Detect ()
|
||||
{
|
||||
var result = new SixelSupport ();
|
||||
var result = new SixelSupportResult ();
|
||||
|
||||
result.IsSupported =
|
||||
AnsiEscapeSequenceRequest.TryExecuteAnsiRequest (EscSeqUtils.CSI_SendDeviceAttributes, out AnsiEscapeSequenceResponse darResponse)
|
||||
@@ -77,25 +77,4 @@ public class SixelSupportDetector
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class SixelSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the current driver supports sixel graphic format.
|
||||
/// Defaults to false.
|
||||
/// </summary>
|
||||
public bool IsSupported { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of pixels of sixel that corresponds to each Col (<see cref="Size.Width"/>)
|
||||
/// and each Row (<see cref="Size.Height"/>. Defaults to 10x20.
|
||||
/// </summary>
|
||||
public Size Resolution { get; set; } = new (10, 20);
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of colors that can be included in a sixel image. Defaults
|
||||
/// to 256.
|
||||
/// </summary>
|
||||
public int MaxPaletteColors { get; set; } = 256;
|
||||
}
|
||||
}
|
||||
27
Terminal.Gui/Drawing/SixelSupportResult.cs
Normal file
27
Terminal.Gui/Drawing/SixelSupportResult.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace Terminal.Gui;
|
||||
|
||||
/// <summary>
|
||||
/// Describes the discovered state of sixel support and ancillary information
|
||||
/// e.g. <see cref="Resolution"/>. You can use <see cref="SixelSupportDetector"/>
|
||||
/// to discover this information.
|
||||
/// </summary>
|
||||
public class SixelSupportResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the current driver supports sixel graphic format.
|
||||
/// Defaults to false.
|
||||
/// </summary>
|
||||
public bool IsSupported { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of pixels of sixel that corresponds to each Col (<see cref="Size.Width"/>)
|
||||
/// and each Row (<see cref="Size.Height"/>. Defaults to 10x20.
|
||||
/// </summary>
|
||||
public Size Resolution { get; set; } = new (10, 20);
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of colors that can be included in a sixel image. Defaults
|
||||
/// to 256.
|
||||
/// </summary>
|
||||
public int MaxPaletteColors { get; set; } = 256;
|
||||
}
|
||||
@@ -61,14 +61,14 @@ public class Images : Scenario
|
||||
private RadioGroup _rgDistanceAlgorithm;
|
||||
private NumericUpDown _popularityThreshold;
|
||||
private SixelToRender _sixelImage;
|
||||
private SixelSupport _sixelSupport;
|
||||
private SixelSupportResult _sixelSupportResult;
|
||||
|
||||
public override void Main ()
|
||||
{
|
||||
var sixelSupportDetector = new SixelSupportDetector ();
|
||||
_sixelSupport = sixelSupportDetector.Detect ();
|
||||
_sixelSupportResult = sixelSupportDetector.Detect ();
|
||||
|
||||
ConsoleDriver.SupportsSixel = _sixelSupport.IsSupported;
|
||||
ConsoleDriver.SupportsSixel = _sixelSupportResult.IsSupported;
|
||||
|
||||
Application.Init ();
|
||||
_win = new() { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" };
|
||||
@@ -166,7 +166,7 @@ public class Images : Scenario
|
||||
|
||||
_fire = new DoomFire (_win.Frame.Width * _pxX.Value, _win.Frame.Height * _pxY.Value);
|
||||
_fireEncoder = new SixelEncoder ();
|
||||
_fireEncoder.Quantizer.MaxColors = Math.Min (_fireEncoder.Quantizer.MaxColors, _sixelSupport.MaxPaletteColors);
|
||||
_fireEncoder.Quantizer.MaxColors = Math.Min (_fireEncoder.Quantizer.MaxColors, _sixelSupportResult.MaxPaletteColors);
|
||||
_fireEncoder.Quantizer.PaletteBuildingAlgorithm = new ConstPalette (_fire.Palette);
|
||||
|
||||
_fireFrameCounter = 0;
|
||||
@@ -344,7 +344,7 @@ public class Images : Scenario
|
||||
{
|
||||
X = Pos.Right (lblPxX),
|
||||
Y = Pos.Bottom (btnStartFire) + 1,
|
||||
Value = _sixelSupport.Resolution.Width
|
||||
Value = _sixelSupportResult.Resolution.Width
|
||||
};
|
||||
|
||||
var lblPxY = new Label
|
||||
@@ -358,7 +358,7 @@ public class Images : Scenario
|
||||
{
|
||||
X = Pos.Right (lblPxY),
|
||||
Y = Pos.Bottom (_pxX),
|
||||
Value = _sixelSupport.Resolution.Height
|
||||
Value = _sixelSupportResult.Resolution.Height
|
||||
};
|
||||
|
||||
var l1 = new Label ()
|
||||
@@ -507,7 +507,7 @@ public class Images : Scenario
|
||||
)
|
||||
{
|
||||
var encoder = new SixelEncoder ();
|
||||
encoder.Quantizer.MaxColors = Math.Min (encoder.Quantizer.MaxColors, _sixelSupport.MaxPaletteColors);
|
||||
encoder.Quantizer.MaxColors = Math.Min (encoder.Quantizer.MaxColors, _sixelSupportResult.MaxPaletteColors);
|
||||
encoder.Quantizer.PaletteBuildingAlgorithm = GetPaletteBuilder ();
|
||||
encoder.Quantizer.DistanceAlgorithm = GetDistanceAlgorithm ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user