Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LineCanvas to draw TableView borders #2574

Draft
wants to merge 32 commits into
base: v2_develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1d78048
Use LineCanvas to draw TableView borders
Nutzzz Apr 24, 2023
3aa57ec
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz May 3, 2023
cab5ca9
Fix merge
Nutzzz May 3, 2023
385f668
Fix column names
Nutzzz May 3, 2023
95a13cf
Fix most of the failing table unit tests
Nutzzz May 3, 2023
a1bbc6f
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz May 4, 2023
4f5bab7
Fix merge
Nutzzz May 4, 2023
62ed8a7
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz May 6, 2023
f036091
Fix missing separator after null cell entries where NullSymbol is nul…
Nutzzz May 6, 2023
8313dc0
Fix SeparatorSymbol (when cell lines are disabled)
Nutzzz May 6, 2023
f11a5d1
Change default for AlwaysUseNormalColorForVerticalCellLines back to f…
Nutzzz May 6, 2023
915dc36
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz May 10, 2023
9f23974
Fix merge
Nutzzz May 10, 2023
3a1d3ee
Add table LineStyles to TableEditor scenario
Nutzzz May 10, 2023
1898677
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz May 10, 2023
b64ea4f
Fix ExpandLastColumn=false and make HeaderThroughline respect LineStyle
Nutzzz May 10, 2023
29ce0e1
Merge branch 'tableview_linecanvasborders' of https://github.com/Nutz…
Nutzzz May 10, 2023
979c74d
Fix merge
Nutzzz May 10, 2023
846aab9
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz May 13, 2023
e701805
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz May 22, 2023
aeecd22
Merge branch 'v2_develop' into tableview_linecanvasborders
tig May 22, 2023
2baf075
Merge remote-tracking branch 'upstream/v2_develop' into tableview_lin…
Nutzzz May 25, 2023
ebf1c03
Update TableStyle.cs
Nutzzz May 25, 2023
503bc98
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz Oct 11, 2023
bbc4419
Merge branch 'v2_develop' into tableview_linecanvasborders
tig Jan 17, 2024
e8f8235
Merge branch 'v2_develop' into tableview_linecanvasborders
tig Jan 20, 2024
0c0d854
Fixes after upstream changes
Nutzzz Jan 21, 2024
3d37ad2
Merge branch 'v2_develop' into tableview_linecanvasborders
Nutzzz Jan 25, 2024
5a055f0
New features, including return of empty column behavior
Nutzzz Jan 29, 2024
a1c9808
Use Runes for SeparatorSymbols and BackgroundSymbol
Nutzzz Jan 29, 2024
b28d72e
Add glyph suggestion for SeparatorSymbols
Nutzzz Jan 29, 2024
d3c9a26
Allow user to use HeaderThroughline with HeaderOverline and HeaderUnd…
Nutzzz Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 95 additions & 5 deletions Terminal.Gui/Views/TableView/TableStyle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace Terminal.Gui;

Expand All @@ -9,6 +10,36 @@ namespace Terminal.Gui;
/// </summary>
public class TableStyle {

/// <summary>
/// Gets or sets the LineStyle for the borders surrounding header rows of a <see cref="TableView"/>.
/// Defaults to <see cref="LineStyle.Single"/>.
/// </summary>
public LineStyle OuterHeaderBorderStyle { get; set; } = LineStyle.Single;

/// <summary>
/// Gets or sets the LineStyle for the vertical lines separating header items in a <see cref="TableView"/>.
/// Defaults to <see cref="LineStyle.Single"/>.
/// </summary>
public LineStyle InnerHeaderBorderStyle { get; set; } = LineStyle.Single;

/// <summary>
/// Gets or sets the LineStyle for the borders surrounding the regular (non-header) portion of a <see cref="TableView"/>.
/// Defaults to <see cref="LineStyle.Single"/>.
/// </summary>
public LineStyle OuterBorderStyle { get; set; } = LineStyle.Single;

/// <summary>
/// Gets or sets the LineStyle for the lines separating regular (non-header) items in a <see cref="TableView"/>.
/// Defaults to <see cref="LineStyle.Single"/>.
/// </summary>
public LineStyle InnerBorderStyle { get; set; } = LineStyle.Single;

/// <summary>
/// Gets or sets the color Attribute of the inner and outer borders of a <see cref="TableView"/>.
/// Defaults to Attribute(-1, -1) which results in <see cref="Border.ColorScheme.Normal"/>.
/// </summary>
public Attribute BorderColor { get; set; } = new Attribute(-1, -1);

/// <summary>
/// Gets or sets a flag indicating whether to render headers of a <see cref="TableView"/>.
/// Defaults to <see langword="true"/>.
Expand All @@ -32,6 +63,11 @@ public class TableStyle {
/// </summary>
public bool ShowHorizontalHeaderUnderline { get; set; } = true;

/// <summary>
/// True to render a solid line through the headers (only when Overline and/or Underline are <see langword="false"/>)
/// </summary>
public bool ShowHorizontalHeaderThroughline { get; set; } = false;

/// <summary>
/// True to render a solid line vertical line between cells
/// </summary>
Expand All @@ -57,18 +93,62 @@ public class TableStyle {
/// </summary>
public bool ShowHorizontalBottomline { get; set; } = false;

/// <summary>
/// True to invert the colors of the entire selected cell in the <see cref="TableView"/>.
/// Helpful for when <see cref="TableView.FullRowSelect"/> is on, especially when the <see cref="ConsoleDriver"/> doesn't show
/// the cursor
/// </summary>
public bool InvertSelectedCell { get; set; } = false;

/// <summary>
/// True to invert the colors of the first symbol of the selected cell in the <see cref="TableView"/>.
/// This gives the appearance of a cursor for when the <see cref="ConsoleDriver"/> doesn't otherwise show
/// this
/// </summary>
public bool InvertSelectedCellFirstCharacter { get; set; } = false;

// NOTE: This is equivalent to True by default after change to LineCanvas borders and can't be turned off
// without disabling ShowVerticalCellLines, however SeparatorSymbol and HeaderSeparatorSymbol could be
// used to approximate the previous default behavior with FullRowSelect
// TODO: Explore ways of changing this without a workaround
/// <summary>
/// Gets or sets a flag indicating whether to force <see cref="ColorScheme.Normal"/> use when rendering
/// vertical cell lines (even when <see cref="TableView.FullRowSelect"/> is on).
/// </summary>
public bool AlwaysUseNormalColorForVerticalCellLines { get; set; } = false;
//public bool AlwaysUseNormalColorForVerticalCellLines { get; set; } = false;

/// <summary>
/// The symbol to add after each header value to visually seperate values (if not using vertical gridlines)
/// <remarks>CM.Glyphs.VLine can be used to emulate vertical grindlines that highlight with <see cref="TableView.FullRowSelect"/></remarks>
/// </summary>
public Rune HeaderSeparatorSymbol { get; set; } = (Rune)' ';

/// <summary>
/// The symbol to add after each cell value to visually seperate values (if not using vertical gridlines)
/// <remarks>CM.Glyphs.VLine can be used to emulate vertical grindlines that highlight with <see cref="TableView.FullRowSelect"/></remarks>
/// </summary>
public Rune SeparatorSymbol { get; set; } = (Rune)' ';

/// <summary>
/// The text representation that should be rendered for cells with the value <see cref="DBNull.Value"/>
/// </summary>
public string NullSymbol { get; set; } = "-";

/// <summary>
/// The symbol to pad around values (between separators) in the header line
/// </summary>
public char HeaderPaddingSymbol { get; set; } = ' ';

/// <summary>
/// The symbol to pad around values (between separators)
/// </summary>
public char CellPaddingSymbol { get; set; } = ' ';

/// <summary>
/// The symbol to pad outside table (if both <see cref="ExpandLastColumn"/> and <see cref="AddEmptyColumn"/>
/// are False)
/// </summary>
public Rune BackgroundSymbol { get; set; } = (Rune)' ';

/// <summary>
/// Collection of columns for which you want special rendering (e.g. custom column lengths, text alignment etc)
Expand All @@ -82,15 +162,25 @@ public class TableStyle {
public RowColorGetterDelegate RowColorGetter { get; set; }

/// <summary>
/// Determines rendering when the last column in the table is visible but it's
/// Determines rendering when the last column in the table is visible but its
/// content or <see cref="ColumnStyle.MaxWidth"/> is less than the remaining
/// space in the control. True (the default) will expand the column to fill
/// the remaining bounds of the control. False will draw a column ending line
/// and leave a blank column that cannot be selected in the remaining space.
/// the remaining bounds of the control. If false, <see cref="AddEmptyColumn"/>
/// determines the behavior of the remaining space.
/// </summary>
/// <value></value>
public bool ExpandLastColumn { get; set; } = true;

/// <summary>
/// Determines rendering when the last column in the table is visible but its
/// content or <see cref="ColumnStyle.MaxWidth"/> is less than the remaining
/// space in the control *and* <see cref="ExpandLastColumn"/> is False. True (the default)
/// will add a blank column that cannot be selected in the remaining space.
/// False will fill the remaining space with <see cref="BackgroundSymbol"/>.
/// </summary>
/// <value></value>
public bool AddEmptyColumn { get; set; } = true;

/// <summary>
/// <para>
/// Determines how <see cref="TableView.ColumnOffset"/> is updated when scrolling
Expand Down
Loading
Loading