@@ -60,6 +60,9 @@ public CellActivatedEventArgs (DataTable t, int col, int row)
60
60
private TableStyle style = new TableStyle ( ) ;
61
61
private Key cellActivationKey = Key . Enter ;
62
62
63
+ Point ? scrollLeftPoint ;
64
+ Point ? scrollRightPoint ;
65
+
63
66
/// <summary>
64
67
/// The default maximum cell width for <see cref="TableView.MaxCellWidth"/> and <see cref="ColumnStyle.MaxWidth"/>
65
68
/// </summary>
@@ -261,6 +264,9 @@ public override void Redraw (Rect bounds)
261
264
Move ( 0 , 0 ) ;
262
265
var frame = Frame ;
263
266
267
+ scrollRightPoint = null ;
268
+ scrollLeftPoint = null ;
269
+
264
270
// What columns to render at what X offset in viewport
265
271
var columnsToRender = CalculateViewport ( bounds ) . ToArray ( ) ;
266
272
@@ -420,19 +426,46 @@ private void RenderHeaderUnderline (int row, int availableWidth, ColumnToRender
420
426
421
427
for ( int c = 0 ; c < availableWidth ; c ++ ) {
422
428
429
+ // Start by assuming we just draw a straight line the
430
+ // whole way but update to instead draw a header indicator
431
+ // or scroll arrow etc
423
432
var rune = Driver . HLine ;
424
433
425
434
if ( Style . ShowVerticalHeaderLines ) {
426
435
if ( c == 0 ) {
436
+ // for first character render line
427
437
rune = Style . ShowVerticalCellLines ? Driver . LeftTee : Driver . LLCorner ;
438
+
439
+ // unless we have horizontally scrolled along
440
+ // in which case render an arrow, to indicate user
441
+ // can scroll left
442
+ if ( Style . ShowHorizontalScrollIndicators && ColumnOffset > 0 )
443
+ {
444
+ rune = Driver . LeftArrow ;
445
+ scrollLeftPoint = new Point ( c , row ) ;
446
+ }
447
+
428
448
}
429
449
// if the next column is the start of a header
430
450
else if ( columnsToRender . Any ( r => r . X == c + 1 ) ) {
431
451
432
452
/*TODO: is ┼ symbol in Driver?*/
433
453
rune = Style . ShowVerticalCellLines ? '┼' : Driver . BottomTee ;
434
454
} else if ( c == availableWidth - 1 ) {
455
+
456
+ // for the last character in the table
435
457
rune = Style . ShowVerticalCellLines ? Driver . RightTee : Driver . LRCorner ;
458
+
459
+ // unless there is more of the table we could horizontally
460
+ // scroll along to see. In which case render an arrow,
461
+ // to indicate user can scroll right
462
+ if ( Style . ShowHorizontalScrollIndicators &&
463
+ ColumnOffset + columnsToRender . Length < Table . Columns . Count )
464
+ {
465
+ rune = Driver . RightArrow ;
466
+ scrollRightPoint = new Point ( c , row ) ;
467
+ }
468
+
436
469
}
437
470
// if the next console column is the lastcolumns end
438
471
else if ( Style . ExpandLastColumn == false &&
@@ -898,6 +931,24 @@ public override bool MouseEvent (MouseEvent me)
898
931
899
932
if ( me . Flags . HasFlag ( MouseFlags . Button1Clicked ) ) {
900
933
934
+ if ( scrollLeftPoint != null
935
+ && scrollLeftPoint . Value . X == me . X
936
+ && scrollLeftPoint . Value . Y == me . Y )
937
+ {
938
+ ColumnOffset -- ;
939
+ EnsureValidScrollOffsets ( ) ;
940
+ SetNeedsDisplay ( ) ;
941
+ }
942
+
943
+ if ( scrollRightPoint != null
944
+ && scrollRightPoint . Value . X == me . X
945
+ && scrollRightPoint . Value . Y == me . Y )
946
+ {
947
+ ColumnOffset ++ ;
948
+ EnsureValidScrollOffsets ( ) ;
949
+ SetNeedsDisplay ( ) ;
950
+ }
951
+
901
952
var hit = ScreenToCell ( me . X , me . Y ) ;
902
953
if ( hit != null ) {
903
954
@@ -1369,6 +1420,14 @@ public class TableStyle {
1369
1420
/// </summary>
1370
1421
public bool ShowVerticalHeaderLines { get ; set ; } = true ;
1371
1422
1423
+ /// <summary>
1424
+ /// True to render a arrows on the right/left of the table when
1425
+ /// there are more column(s) that can be scrolled to. Requires
1426
+ /// <see cref="ShowHorizontalHeaderUnderline"/> to be true.
1427
+ /// Defaults to true
1428
+ /// </summary>
1429
+ public bool ShowHorizontalScrollIndicators { get ; set ; } = true ;
1430
+
1372
1431
/// <summary>
1373
1432
/// True to invert the colors of the first symbol of the selected cell in the <see cref="TableView"/>.
1374
1433
/// This gives the appearance of a cursor for when the <see cref="ConsoleDriver"/> doesn't otherwise show
0 commit comments