Skip to content

Commit

Permalink
Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tig committed Oct 17, 2023
2 parents f087247 + 2c80426 commit b0dc1e6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions Terminal.Gui/Views/FileDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public FileDialog (IFileSystem fileSystem)
};
this.tableView.AddKeyBinding (Key.Space, Command.ToggleChecked);
this.tableView.MouseClick += OnTableViewMouseClick;
tableView.Style.InvertSelectedCellFirstCharacter = true;
Style.TableStyle = tableView.Style;

var nameStyle = Style.TableStyle.GetOrCreateColumnStyle (0);
Expand Down
5 changes: 5 additions & 0 deletions Terminal.Gui/Views/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,11 @@ bool FindAndOpenChildrenMenuByHotkey (KeyEvent kb, MenuItem [] children)
var c = ((uint)kb.Key & (uint)Key.CharMask);
for (int i = 0; i < children.Length; i++) {
var mi = children [i];

if(mi == null) {
continue;
}

int p = mi.Title.IndexOf (MenuBar.HotKeySpecifier.ToString ());
if (p != -1 && p + 1 < mi.Title.GetRuneCount ()) {
if (Char.ToUpperInvariant ((char)mi.Title [p + 1]) == c) {
Expand Down
6 changes: 3 additions & 3 deletions Terminal.Gui/Views/TableView/TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ private void RenderRow (int row, int rowToRender, ColumnToRender [] columnsToRen
Attribute color;

if (FullRowSelect && IsSelected (0, rowToRender)) {
color = focused ? rowScheme.HotFocus : rowScheme.HotNormal;
color = focused ? rowScheme.Focus : rowScheme.HotNormal;
} else {
color = Enabled ? rowScheme.Normal : rowScheme.Disabled;
}
Expand Down Expand Up @@ -618,7 +618,7 @@ private void RenderRow (int row, int rowToRender, ColumnToRender [] columnsToRen

Attribute cellColor;
if (isSelectedCell) {
cellColor = focused ? scheme.HotFocus : scheme.HotNormal;
cellColor = focused ? scheme.Focus : scheme.HotNormal;
} else {
cellColor = Enabled ? scheme.Normal : scheme.Disabled;
}
Expand All @@ -634,7 +634,7 @@ private void RenderRow (int row, int rowToRender, ColumnToRender [] columnsToRen
if (scheme != rowScheme) {

if (isSelectedCell) {
color = focused ? rowScheme.HotFocus : rowScheme.HotNormal;
color = focused ? rowScheme.Focus : rowScheme.HotNormal;
} else {
color = Enabled ? rowScheme.Normal : rowScheme.Disabled;
}
Expand Down
42 changes: 23 additions & 19 deletions UnitTests/Views/TableViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ public void TableView_ColorTests_FocusedOrNot (bool focused)
// 0
tv.ColorScheme.Normal,
// 1
focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal});
focused ? tv.ColorScheme.Focus : tv.ColorScheme.HotNormal});

Application.Shutdown ();
}
Expand Down Expand Up @@ -880,14 +880,14 @@ public void TableView_ColorTests_InvertSelectedCellFirstCharacter (bool focused)
01000
";

var invertHotFocus = new Attribute (tv.ColorScheme.HotFocus.Background, tv.ColorScheme.HotFocus.Foreground);
var invertFocus = new Attribute (tv.ColorScheme.Focus.Background, tv.ColorScheme.Focus.Foreground);
var invertHotNormal = new Attribute (tv.ColorScheme.HotNormal.Background, tv.ColorScheme.HotNormal.Foreground);

TestHelpers.AssertDriverColorsAre (expectedColors, new Attribute [] {
// 0
tv.ColorScheme.Normal,
// 1
focused ? invertHotFocus : invertHotNormal});
focused ? invertFocus : invertHotNormal});

Application.Shutdown ();
}
Expand All @@ -906,11 +906,13 @@ public void TableView_ColorsTest_RowColorGetter (bool focused)
var rowHighlight = new ColorScheme () {
Normal = new Attribute (Color.BrightCyan, Color.DarkGray),
HotNormal = new Attribute (Color.Green, Color.Blue),
HotFocus = new Attribute (Color.BrightYellow, Color.White),
Focus = new Attribute (Color.Cyan, Color.Magenta),
Focus = new Attribute (Color.BrightYellow, Color.White),

// Not used by TableView
HotFocus = new Attribute (Color.Cyan, Color.Magenta),
};

// when B is 2 use the custom highlight colour for the row
// when B is 2 use the custom highlight color for the row
tv.Style.RowColorGetter += (e) => Convert.ToInt32 (e.Table [e.RowIndex, 1]) == 2 ? rowHighlight : null;

// private method for forcing the view to be focused/not focused
Expand Down Expand Up @@ -940,7 +942,7 @@ public void TableView_ColorsTest_RowColorGetter (bool focused)
// 0
tv.ColorScheme.Normal,
// 1
focused ? rowHighlight.HotFocus : rowHighlight.HotNormal,
focused ? rowHighlight.Focus : rowHighlight.HotNormal,
// 2
rowHighlight.Normal});

Expand Down Expand Up @@ -973,7 +975,7 @@ public void TableView_ColorsTest_RowColorGetter (bool focused)
// 0
tv.ColorScheme.Normal,
// 1
focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal });
focused ? tv.ColorScheme.Focus : tv.ColorScheme.HotNormal });

// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
Expand All @@ -993,12 +995,14 @@ public void TableView_ColorsTest_ColorGetter (bool focused)
// Create a style for column B
var bStyle = tv.Style.GetOrCreateColumnStyle (1);

// when B is 2 use the custom highlight colour
// when B is 2 use the custom highlight color
var cellHighlight = new ColorScheme () {
Normal = new Attribute (Color.BrightCyan, Color.DarkGray),
HotNormal = new Attribute (Color.Green, Color.Blue),
HotFocus = new Attribute (Color.BrightYellow, Color.White),
Focus = new Attribute (Color.Cyan, Color.Magenta),

// Not used by TableView
HotFocus = new Attribute (Color.BrightYellow, Color.White),
};

bStyle.ColorGetter = (a) => Convert.ToInt32 (a.CellValue) == 2 ? cellHighlight : null;
Expand Down Expand Up @@ -1030,7 +1034,7 @@ public void TableView_ColorsTest_ColorGetter (bool focused)
// 0
tv.ColorScheme.Normal,
// 1
focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal,
focused ? tv.ColorScheme.Focus : tv.ColorScheme.HotNormal,
// 2
cellHighlight.Normal});

Expand Down Expand Up @@ -1063,7 +1067,7 @@ public void TableView_ColorsTest_ColorGetter (bool focused)
// 0
tv.ColorScheme.Normal,
// 1
focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal });
focused ? tv.ColorScheme.Focus : tv.ColorScheme.HotNormal });

// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
Expand Down Expand Up @@ -2213,11 +2217,11 @@ public void TestFullRowSelect_SelectionColorStopsAtTableEdge_WithCellLines ()
TestHelpers.AssertDriverContentsAre (expected, output);

var normal = tv.ColorScheme.Normal;
var focus = tv.ColorScheme.HotFocus = new Attribute (Color.Magenta, Color.White);
var focus = tv.ColorScheme.Focus = new Attribute (Color.Magenta, Color.White);

tv.Draw ();

// HotFocus color (1) should be used for rendering the selected line
// Focus color (1) should be used for rendering the selected line
// But should not spill into the borders. Normal color (0) should be
// used for the rest.
expected =
Expand Down Expand Up @@ -2271,11 +2275,11 @@ public void TestFullRowSelect_AlwaysUseNormalColorForVerticalCellLines ()
TestHelpers.AssertDriverContentsAre (expected, output);

var normal = tv.ColorScheme.Normal;
var focus = tv.ColorScheme.HotFocus = new Attribute (Color.Magenta, Color.White);
var focus = tv.ColorScheme.Focus = new Attribute (Color.Magenta, Color.White);

tv.Draw ();

// HotFocus color (1) should be used for cells only because
// Focus color (1) should be used for cells only because
// AlwaysUseNormalColorForVerticalCellLines is true
expected =
@"
Expand Down Expand Up @@ -2766,12 +2770,12 @@ 1 2 3
TestHelpers.AssertDriverContentsAre (expected, output);

var normal = tv.ColorScheme.Normal;
var focus = tv.ColorScheme.HotFocus = new Attribute (Color.Magenta, Color.White);
var focus = tv.ColorScheme.Focus = new Attribute (Color.Magenta, Color.White);

tv.Draw ();

// HotFocus color (1) should be used for rendering the selected line
// Note that because there are no vertical cell lines we use the hot focus
// Focus color (1) should be used for rendering the selected line
// Note that because there are no vertical cell lines we use the focus
// color for the whole row
expected =
@"
Expand Down

0 comments on commit b0dc1e6

Please sign in to comment.