using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Terminal.Gui; /// /// Uses ANSII escape sequences to detect whether sixel is supported /// by the terminal. /// public class SixelSupportDetector { public SixelSupport Detect () { var darResponse = AnsiEscapeSequenceRequest.ExecuteAnsiRequest (EscSeqUtils.CSI_SendDeviceAttributes); var result = new SixelSupport (); result.IsSupported = darResponse.Response.Split (';').Contains ("4"); return result; } } public class SixelSupport { /// /// Whether the current driver supports sixel graphic format. /// Defaults to false. /// public bool IsSupported { get; set; } /// /// The number of pixels of sixel that corresponds to each Col () /// and each Row (. Defaults to 10x20. /// public Size Resolution { get; set; } = new Size (10, 20); /// /// The maximum number of colors that can be included in a sixel image. Defaults /// to 256. /// public int MaxPaletteColors { get; set; } = 256; }