فهرست منبع

Do not output sixel if driver does not support it
Allow overriding driver sixel support in Images scenario

tznind 10 ماه پیش
والد
کامیت
23cd8889a5
3فایلهای تغییر یافته به همراه18 افزوده شده و 9 حذف شده
  1. 7 4
      Terminal.Gui/ConsoleDrivers/NetDriver.cs
  2. 6 3
      Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
  3. 5 2
      UICatalog/Scenarios/Images.cs

+ 7 - 4
Terminal.Gui/ConsoleDrivers/NetDriver.cs

@@ -1024,12 +1024,15 @@ internal class NetDriver : ConsoleDriver
                 Console.Write (output);
             }
 
-            foreach (var s in Application.Sixel)
+            if (ConsoleDriver.SupportsSixel)
             {
-                if (!string.IsNullOrWhiteSpace (s.SixelData))
+                foreach (var s in Application.Sixel)
                 {
-                    SetCursorPosition (s.ScreenPosition.X, s.ScreenPosition.Y);
-                    Console.Write (s.SixelData);
+                    if (!string.IsNullOrWhiteSpace (s.SixelData))
+                    {
+                        SetCursorPosition (s.ScreenPosition.X, s.ScreenPosition.Y);
+                        Console.Write (s.SixelData);
+                    }
                 }
             }
         }

+ 6 - 3
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -127,11 +127,14 @@ internal class WindowsConsole
 
             _lastWrite = s;
 
-            foreach (var sixel in Application.Sixel)
+            if (ConsoleDriver.SupportsSixel)
             {
-                SetCursorPosition (new Coord ((short)sixel.ScreenPosition.X, (short)sixel.ScreenPosition.Y));
-                WriteConsole (_screenBuffer, sixel.SixelData, (uint)sixel.SixelData.Length, out uint _, nint.Zero);
+                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);
 
+                }
             }
         }
 

+ 5 - 2
UICatalog/Scenarios/Images.cs

@@ -62,10 +62,13 @@ public class Images : Scenario
             Y = 1,
             CheckedState = ConsoleDriver.SupportsSixel
                 ? CheckState.Checked : CheckState.UnChecked,
-            CanFocus = false,
-            Enabled = false,
             Text = "Supports Sixel"
         };
+
+        cbSupportsSixel.CheckedStateChanging += (s, e) =>
+                                                {
+                                                    ConsoleDriver.SupportsSixel = e.NewValue == CheckState.Checked;
+                                                };
         _win.Add (cbSupportsSixel);
 
         var cbUseTrueColor = new CheckBox