From e3323ec8c61343e50f14cac47dcdc0028db8ebf5 Mon Sep 17 00:00:00 2001 From: tznind Date: Sat, 14 Oct 2023 11:28:50 +0100 Subject: [PATCH] Remove use of HotFocus completely from TableView --- Terminal.Gui/Views/TableView/TableView.cs | 4 +-- UnitTests/Views/TableViewTests.cs | 30 +++++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Terminal.Gui/Views/TableView/TableView.cs b/Terminal.Gui/Views/TableView/TableView.cs index 073524627..a5c25f3d4 100644 --- a/Terminal.Gui/Views/TableView/TableView.cs +++ b/Terminal.Gui/Views/TableView/TableView.cs @@ -572,7 +572,7 @@ namespace Terminal.Gui { 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; } @@ -634,7 +634,7 @@ namespace Terminal.Gui { if (scheme != rowScheme) { if (isSelectedCell) { - color = focused ? rowScheme.HotFocus : rowScheme.HotNormal; + color = focused ? rowScheme.Focus : rowScheme.HotNormal; } else { color = Enabled ? rowScheme.Normal : rowScheme.Disabled; } diff --git a/UnitTests/Views/TableViewTests.cs b/UnitTests/Views/TableViewTests.cs index 12a086f8b..1ff9ea0c5 100644 --- a/UnitTests/Views/TableViewTests.cs +++ b/UnitTests/Views/TableViewTests.cs @@ -840,7 +840,7 @@ namespace Terminal.Gui.ViewsTests { // 0 tv.ColorScheme.Normal, // 1 - focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal}); + focused ? tv.ColorScheme.Focus : tv.ColorScheme.HotNormal}); Application.Shutdown (); } @@ -880,14 +880,14 @@ namespace Terminal.Gui.ViewsTests { 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 (); } @@ -906,11 +906,13 @@ namespace Terminal.Gui.ViewsTests { 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 @@ -940,7 +942,7 @@ namespace Terminal.Gui.ViewsTests { // 0 tv.ColorScheme.Normal, // 1 - focused ? rowHighlight.HotFocus : rowHighlight.HotNormal, + focused ? rowHighlight.Focus : rowHighlight.HotNormal, // 2 rowHighlight.Normal}); @@ -973,7 +975,7 @@ namespace Terminal.Gui.ViewsTests { // 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 (); @@ -993,12 +995,14 @@ namespace Terminal.Gui.ViewsTests { // 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; @@ -1030,7 +1034,7 @@ namespace Terminal.Gui.ViewsTests { // 0 tv.ColorScheme.Normal, // 1 - focused ? tv.ColorScheme.HotFocus : tv.ColorScheme.HotNormal, + focused ? tv.ColorScheme.Focus : tv.ColorScheme.HotNormal, // 2 cellHighlight.Normal}); @@ -1063,7 +1067,7 @@ namespace Terminal.Gui.ViewsTests { // 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 (); @@ -2771,7 +2775,7 @@ A B C tv.Draw (); // Focus color (1) should be used for rendering the selected line - // Note that because there are no vertical cell lines we use the hot focus + // Note that because there are no vertical cell lines we use the focus // color for the whole row expected = @"