Browse Source

HexView improvements

Tig 9 months ago
parent
commit
f3bdfc3144
2 changed files with 14 additions and 6 deletions
  1. 1 1
      Terminal.Gui/Views/HexView.cs
  2. 13 5
      UnitTests/Views/HexViewTests.cs

+ 1 - 1
Terminal.Gui/Views/HexView.cs

@@ -689,7 +689,7 @@ public class HexView : View, IDesignable
         // Small buffers will just show the position, with the bsize field value (4 bytes)
         BytesPerLine = NUM_BYTES_PER_HEX_COLUMN;
 
-        if (Viewport.Width - GetLeftSideStartColumn () > 17)
+        if (Viewport.Width - GetLeftSideStartColumn () >= HEX_COLUMN_WIDTH)
         {
             BytesPerLine = NUM_BYTES_PER_HEX_COLUMN * ((Viewport.Width - GetLeftSideStartColumn ()) / 18);
         }

+ 13 - 5
UnitTests/Views/HexViewTests.cs

@@ -12,24 +12,32 @@ public class HexViewTests
     [InlineData (20, 4)]
     [InlineData (24, 4)]
     [InlineData (30, 4)]
-    [InlineData (50, 4)]
-    public void BytesPerLine_Calculates_Correctly (int width, int expectedBPL)
+    [InlineData (31, 4)]
+    [InlineData (32, 4)]
+    [InlineData (33, 4)]
+    [InlineData (34, 4)]
+    [InlineData (35, 4)]
+    [InlineData (36, 4)]
+    [InlineData (37, 4)]
+    [InlineData (50, 8)]
+    [InlineData (51, 8)]
+    public void BytesPerLine_Calculates_Correctly (int width, int expectedBpl)
     {
         var hv = new HexView (LoadStream (null, out long _)) { Width = width, Height = 10 };
         hv.LayoutSubviews ();
 
-        Assert.Equal (expectedBPL, hv.BytesPerLine);
+        Assert.Equal (expectedBpl, hv.BytesPerLine);
     }
 
     [Theory]
     [InlineData ("01234", 20, 4)]
     [InlineData ("012345", 20, 4)]
-    public void xuz (string str, int width, int expectedBPL)
+    public void xuz (string str, int width, int expectedBpl)
     {
         var hv = new HexView (LoadStream (str, out long _)) { Width = width, Height = 10 };
         hv.LayoutSubviews ();
 
-        Assert.Equal (expectedBPL, hv.BytesPerLine);
+        Assert.Equal (expectedBpl, hv.BytesPerLine);
     }