mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
TableView - adds last column dividing line (#1289)
* Adds a final vertical column line at the end of the last header in TableView * Added clear line as first step in RenderRow * Added TableStyle.EnforceMaxWidthOnLastColumn * Added Scenario toggle setting and tests * Fixed EnforceMaxWidthOnLastColumn when Bounds match exactly the last column width * Fixed whitespace and comment on ColumntoRender.Width * Renamed EnforceMaxWidthOnLastColumn to ExpandLastColumn
This commit is contained in:
@@ -418,7 +418,92 @@ namespace Terminal.Gui.Views {
|
||||
Assert.Equal(new Point(8,3),selected[5]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
[Fact]
|
||||
public void TableView_ExpandLastColumn_True()
|
||||
{
|
||||
var tv = SetUpMiniTable();
|
||||
|
||||
// the thing we are testing
|
||||
tv.Style.ExpandLastColumn = true;
|
||||
|
||||
tv.Redraw(tv.Bounds);
|
||||
|
||||
string expected = @"
|
||||
┌─┬──────┐
|
||||
│A│B │
|
||||
├─┼──────┤
|
||||
│1│2 │
|
||||
";
|
||||
GraphViewTests.AssertDriverContentsAre(expected);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TableView_ExpandLastColumn_False()
|
||||
{
|
||||
var tv = SetUpMiniTable();
|
||||
|
||||
// the thing we are testing
|
||||
tv.Style.ExpandLastColumn = false;
|
||||
|
||||
tv.Redraw(tv.Bounds);
|
||||
|
||||
string expected = @"
|
||||
┌─┬─┬────┐
|
||||
│A│B│ │
|
||||
├─┼─┼────┤
|
||||
│1│2│ │
|
||||
";
|
||||
GraphViewTests.AssertDriverContentsAre(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TableView_ExpandLastColumn_False_ExactBounds()
|
||||
{
|
||||
var tv = SetUpMiniTable();
|
||||
|
||||
// the thing we are testing
|
||||
tv.Style.ExpandLastColumn = false;
|
||||
// width exactly matches the max col widths
|
||||
tv.Bounds = new Rect(0,0,5,4);
|
||||
|
||||
tv.Redraw(tv.Bounds);
|
||||
|
||||
string expected = @"
|
||||
┌─┬─┐
|
||||
│A│B│
|
||||
├─┼─┤
|
||||
│1│2│
|
||||
";
|
||||
GraphViewTests.AssertDriverContentsAre(expected);
|
||||
}
|
||||
|
||||
private TableView SetUpMiniTable ()
|
||||
{
|
||||
|
||||
var tv = new TableView();
|
||||
tv.Bounds = new Rect(0,0,10,4);
|
||||
|
||||
var dt = new DataTable();
|
||||
var colA = dt.Columns.Add("A");
|
||||
var colB = dt.Columns.Add("B");
|
||||
dt.Rows.Add(1,2);
|
||||
|
||||
tv.Table = dt;
|
||||
tv.Style.GetOrCreateColumnStyle(colA).MinWidth=1;
|
||||
tv.Style.GetOrCreateColumnStyle(colA).MinWidth=1;
|
||||
tv.Style.GetOrCreateColumnStyle(colB).MaxWidth=1;
|
||||
tv.Style.GetOrCreateColumnStyle(colB).MaxWidth=1;
|
||||
|
||||
GraphViewTests.InitFakeDriver();
|
||||
tv.ColorScheme = new ColorScheme(){
|
||||
Normal = Application.Driver.MakeAttribute(Color.White,Color.Black),
|
||||
HotFocus = Application.Driver.MakeAttribute(Color.White,Color.Black)
|
||||
};
|
||||
return tv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a simple table of string columns with the requested number of columns and rows
|
||||
/// </summary>
|
||||
/// <param name="cols"></param>
|
||||
|
||||
Reference in New Issue
Block a user