Skip to content

Commit f3bdfc3

Browse files
committed
HexView improvements
1 parent 573d6ee commit f3bdfc3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Terminal.Gui/Views/HexView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ private void HexView_LayoutComplete (object? sender, LayoutEventArgs e)
689689
// Small buffers will just show the position, with the bsize field value (4 bytes)
690690
BytesPerLine = NUM_BYTES_PER_HEX_COLUMN;
691691

692-
if (Viewport.Width - GetLeftSideStartColumn () > 17)
692+
if (Viewport.Width - GetLeftSideStartColumn () >= HEX_COLUMN_WIDTH)
693693
{
694694
BytesPerLine = NUM_BYTES_PER_HEX_COLUMN * ((Viewport.Width - GetLeftSideStartColumn ()) / 18);
695695
}

UnitTests/Views/HexViewTests.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,32 @@ public class HexViewTests
1212
[InlineData (20, 4)]
1313
[InlineData (24, 4)]
1414
[InlineData (30, 4)]
15-
[InlineData (50, 4)]
16-
public void BytesPerLine_Calculates_Correctly (int width, int expectedBPL)
15+
[InlineData (31, 4)]
16+
[InlineData (32, 4)]
17+
[InlineData (33, 4)]
18+
[InlineData (34, 4)]
19+
[InlineData (35, 4)]
20+
[InlineData (36, 4)]
21+
[InlineData (37, 4)]
22+
[InlineData (50, 8)]
23+
[InlineData (51, 8)]
24+
public void BytesPerLine_Calculates_Correctly (int width, int expectedBpl)
1725
{
1826
var hv = new HexView (LoadStream (null, out long _)) { Width = width, Height = 10 };
1927
hv.LayoutSubviews ();
2028

21-
Assert.Equal (expectedBPL, hv.BytesPerLine);
29+
Assert.Equal (expectedBpl, hv.BytesPerLine);
2230
}
2331

2432
[Theory]
2533
[InlineData ("01234", 20, 4)]
2634
[InlineData ("012345", 20, 4)]
27-
public void xuz (string str, int width, int expectedBPL)
35+
public void xuz (string str, int width, int expectedBpl)
2836
{
2937
var hv = new HexView (LoadStream (str, out long _)) { Width = width, Height = 10 };
3038
hv.LayoutSubviews ();
3139

32-
Assert.Equal (expectedBPL, hv.BytesPerLine);
40+
Assert.Equal (expectedBpl, hv.BytesPerLine);
3341
}
3442

3543

0 commit comments

Comments
 (0)