Skip to content

Commit

Permalink
Remove ConsoleDriver.SupportsSixel
Browse files Browse the repository at this point in the history
  • Loading branch information
tznind committed Oct 10, 2024
1 parent 9990a55 commit 64d286c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
3 changes: 0 additions & 3 deletions Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,6 @@ public virtual void Move (int col, int row)
/// <summary>Gets whether the <see cref="ConsoleDriver"/> supports TrueColor output.</summary>
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
/// <summary>
Expand Down
17 changes: 4 additions & 13 deletions Terminal.Gui/ConsoleDrivers/NetDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,6 @@ private void HandleRequestResponseEvent (string c1Control, string code, string [
break;
}

break;
case EscSeqUtils.CSI_ReportDeviceAttributes_Terminator:
ConsoleDriver.SupportsSixel = values.Any (v => v == "4");
break;
default:
EnqueueRequestResponseEvent (c1Control, code, values, terminating);
Expand Down Expand Up @@ -1024,15 +1021,12 @@ public override void UpdateScreen ()
Console.Write (output);
}

if (ConsoleDriver.SupportsSixel)
foreach (var s in Application.Sixel)
{
foreach (var s in Application.Sixel)
if (!string.IsNullOrWhiteSpace (s.SixelData))
{
if (!string.IsNullOrWhiteSpace (s.SixelData))
{
SetCursorPosition (s.ScreenPosition.X, s.ScreenPosition.Y);
Console.Write (s.SixelData);
}
SetCursorPosition (s.ScreenPosition.X, s.ScreenPosition.Y);
Console.Write (s.SixelData);
}
}
}
Expand Down Expand Up @@ -1141,9 +1135,6 @@ internal override MainLoop Init ()
_mainLoopDriver = new NetMainLoop (this);
_mainLoopDriver.ProcessInput = ProcessInput;

_mainLoopDriver._netEvents.EscSeqRequests.Add ("c");
// Determine if sixel is supported
Console.Out.Write (EscSeqUtils.CSI_SendDeviceAttributes);

return new MainLoop (_mainLoopDriver);
}
Expand Down
10 changes: 3 additions & 7 deletions Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,10 @@ public bool WriteToConsole (Size size, ExtendedCharInfo [] charInfoBuffer, Coord

_lastWrite = s;

if (ConsoleDriver.SupportsSixel)
foreach (var sixel in Application.Sixel)
{
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);

}
SetCursorPosition (new Coord ((short)sixel.ScreenPosition.X, (short)sixel.ScreenPosition.Y));
WriteConsole (_screenBuffer, sixel.SixelData, (uint)sixel.SixelData.Length, out uint _, nint.Zero);
}
}

Expand Down
6 changes: 2 additions & 4 deletions UICatalog/Scenarios/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public override void Main ()
var sixelSupportDetector = new AssumeSupportDetector ();
_sixelSupportResult = sixelSupportDetector.Detect ();

ConsoleDriver.SupportsSixel = _sixelSupportResult.IsSupported;

Application.Init ();
_win = new() { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" };

Expand Down Expand Up @@ -103,15 +101,15 @@ public override void Main ()
{
X = Pos.Right (lblDriverName) + 2,
Y = 1,
CheckedState = ConsoleDriver.SupportsSixel
CheckedState = _sixelSupportResult.IsSupported
? CheckState.Checked
: CheckState.UnChecked,
Text = "Supports Sixel"
};

cbSupportsSixel.CheckedStateChanging += (s, e) =>
{
ConsoleDriver.SupportsSixel = e.NewValue == CheckState.Checked;
_sixelSupportResult.IsSupported = e.NewValue == CheckState.Checked;
SetupSixelSupported (e.NewValue == CheckState.Checked);
};

Expand Down

0 comments on commit 64d286c

Please sign in to comment.