From f2953b5a00b403f0832427eb587048b08305d107 Mon Sep 17 00:00:00 2001 From: BDisp Date: Tue, 29 Sep 2020 14:54:58 +0100 Subject: [PATCH 01/12] Fixes #919 Initialized and CanFocus. --- Terminal.Gui/Core/View.cs | 21 +++++++++++++++++++-- UnitTests/ViewTests.cs | 36 ++++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 16f447e09..852dd121d 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -283,12 +283,15 @@ namespace Terminal.Gui { public override bool CanFocus { get => base.CanFocus; set { + if (!addingView && IsInitialized && SuperView?.CanFocus == false && value) { + throw new InvalidOperationException ("Cannot set CanFocus to true if the SuperView CanFocus is false!"); + } if (base.CanFocus != value) { base.CanFocus = value; if (!value && tabIndex > -1) { TabIndex = -1; } - if (value && SuperView != null && !SuperView.CanFocus) { + if (value && SuperView?.CanFocus == false && addingView) { SuperView.CanFocus = value; } if (value && tabIndex == -1) { @@ -305,8 +308,12 @@ namespace Terminal.Gui { view.CanFocus = value; view.tabIndex = -1; } else { + if (addingView) { + view.addingView = true; + } view.CanFocus = view.oldCanFocus; view.tabIndex = view.oldTabIndex; + view.addingView = false; } } } @@ -693,6 +700,8 @@ namespace Terminal.Gui { container.ChildNeedsDisplay (); } + internal bool addingView = false; + /// /// Adds a subview (child) to this view. /// @@ -713,14 +722,22 @@ namespace Terminal.Gui { tabIndexes.Add (view); view.container = this; if (view.CanFocus) { + addingView = true; + if (SuperView?.CanFocus == false) { + SuperView.addingView = true; + SuperView.CanFocus = true; + SuperView.addingView = false; + } CanFocus = true; view.tabIndex = tabIndexes.IndexOf (view); + addingView = false; } SetNeedsLayout (); SetNeedsDisplay (); OnAdded (view); if (IsInitialized) { view.BeginInit (); + view.EndInit (); } } @@ -1985,7 +2002,6 @@ namespace Terminal.Gui { if (!IsInitialized) { oldCanFocus = CanFocus; oldTabIndex = tabIndex; - Initialized?.Invoke (this, EventArgs.Empty); } if (subviews?.Count > 0) { foreach (var view in subviews) { @@ -2009,6 +2025,7 @@ namespace Terminal.Gui { } } } + Initialized?.Invoke (this, EventArgs.Empty); } /// diff --git a/UnitTests/ViewTests.cs b/UnitTests/ViewTests.cs index 581cdc267..4f20e5505 100644 --- a/UnitTests/ViewTests.cs +++ b/UnitTests/ViewTests.cs @@ -578,10 +578,10 @@ namespace Terminal.Gui { t.Initialized += (s, e) => { tc++; Assert.Equal (1, tc); - Assert.Equal (0, wc); - Assert.Equal (0, v1c); - Assert.Equal (0, v2c); - Assert.Equal (0, sv1c); + Assert.Equal (1, wc); + Assert.Equal (1, v1c); + Assert.Equal (1, v2c); + Assert.Equal (1, sv1c); Assert.True (t.CanFocus); Assert.True (w.CanFocus); @@ -611,8 +611,8 @@ namespace Terminal.Gui { Assert.Equal (t.Frame.Width, sv1.Frame.Width); Assert.Equal (t.Frame.Height, sv1.Frame.Height); Assert.False (sv1.CanFocus); - sv1.CanFocus = true; - Assert.True (sv1.CanFocus); + Assert.Throws (() => sv1.CanFocus = true); + Assert.False (sv1.CanFocus); }; v1.Add (sv1); @@ -637,7 +637,10 @@ namespace Terminal.Gui { Assert.True (w.CanFocus); Assert.False (v1.CanFocus); Assert.False (v2.CanFocus); - Assert.True (sv1.CanFocus); + Assert.False (sv1.CanFocus); + + v1.CanFocus = true; + Assert.False (sv1.CanFocus); // False because sv1 was disposed and it isn't a subview of v1. } [Fact] @@ -656,10 +659,10 @@ namespace Terminal.Gui { t.Initialized += (s, e) => { tc++; Assert.Equal (1, tc); - Assert.Equal (0, wc); - Assert.Equal (0, v1c); - Assert.Equal (0, v2c); - Assert.Equal (0, sv1c); + Assert.Equal (1, wc); + Assert.Equal (1, v1c); + Assert.Equal (1, v2c); + Assert.Equal (0, sv1c); // Added after t in the Application.Iteration. Assert.True (t.CanFocus); Assert.True (w.CanFocus); @@ -694,8 +697,8 @@ namespace Terminal.Gui { Assert.NotEqual (t.Frame.Width, sv1.Frame.Width); Assert.NotEqual (t.Frame.Height, sv1.Frame.Height); Assert.False (sv1.CanFocus); - sv1.CanFocus = true; - Assert.True (sv1.CanFocus); + Assert.Throws (() => sv1.CanFocus = true); + Assert.False (sv1.CanFocus); }; v1.Add (sv1); @@ -813,7 +816,11 @@ namespace Terminal.Gui { Assert.False (f.CanFocus); Assert.False (v.CanFocus); - v.CanFocus = true; + Assert.Throws (() => v.CanFocus = true); + Assert.False (f.CanFocus); + Assert.False (v.CanFocus); + + f.CanFocus = true; Assert.True (f.CanFocus); Assert.True (v.CanFocus); }; @@ -1015,5 +1022,6 @@ namespace Terminal.Gui { Application.Run (); Application.Shutdown (); } + } } From 5ce12d05139c1982287c48b87f4837de0a2b3a61 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Mon, 28 Sep 2020 17:15:33 -0700 Subject: [PATCH 02/12] Use glyphs for checkmarks & selection --- .../CursesDriver/CursesDriver.cs | 10 -- .../ConsoleDrivers/FakeDriver/FakeDriver.cs | 27 --- Terminal.Gui/ConsoleDrivers/NetDriver.cs | 27 --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 27 --- Terminal.Gui/Views/Checkbox.cs | 9 +- Terminal.Gui/Views/ListView.cs | 24 ++- Terminal.Gui/Views/Menu.cs | 5 +- UICatalog/Scenarios/ListViewWithSelection.cs | 155 ++++++++++++++++++ 8 files changed, 181 insertions(+), 103 deletions(-) create mode 100644 UICatalog/Scenarios/ListViewWithSelection.cs diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs index 4ba273444..828dca838 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs @@ -531,20 +531,10 @@ namespace Terminal.Gui { RightTee = Curses.ACS_RTEE; TopTee = Curses.ACS_TTEE; BottomTee = Curses.ACS_BTEE; - Checked = '\u221a'; - UnChecked = ' '; - Selected = '\u25cf'; - UnSelected = '\u25cc'; RightArrow = Curses.ACS_RARROW; LeftArrow = Curses.ACS_LARROW; UpArrow = Curses.ACS_UARROW; DownArrow = Curses.ACS_DARROW; - LeftDefaultIndicator = '\u25e6'; - RightDefaultIndicator = '\u25e6'; - LeftBracket = '['; - RightBracket = ']'; - OnMeterSegment = '\u258c'; - OffMeterSegement = ' '; Colors.TopLevel = new ColorScheme (); Colors.Base = new ColorScheme (); diff --git a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs index 11cd1c912..13e670c4f 100644 --- a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs @@ -182,33 +182,6 @@ namespace Terminal.Gui { Colors.Error.HotNormal = MakeColor (ConsoleColor.Yellow, ConsoleColor.Red); Colors.Error.HotFocus = Colors.Error.HotNormal; - HLine = '\u2500'; - VLine = '\u2502'; - Stipple = '\u2592'; - Diamond = '\u25c6'; - ULCorner = '\u250C'; - LLCorner = '\u2514'; - URCorner = '\u2510'; - LRCorner = '\u2518'; - LeftTee = '\u251c'; - RightTee = '\u2524'; - TopTee = '\u22a4'; - BottomTee = '\u22a5'; - Checked = '\u221a'; - UnChecked = ' '; - Selected = '\u25cf'; - UnSelected = '\u25cc'; - RightArrow = '\u25ba'; - LeftArrow = '\u25c4'; - UpArrow = '\u25b2'; - DownArrow = '\u25bc'; - LeftDefaultIndicator = '\u25e6'; - RightDefaultIndicator = '\u25e6'; - LeftBracket = '['; - RightBracket = ']'; - OnMeterSegment = '\u258c'; - OffMeterSegement = ' '; - //MockConsole.Clear (); } diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index 1fe8f01c7..cf2f9e31d 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -152,33 +152,6 @@ namespace Terminal.Gui { Colors.Error.HotNormal = MakeColor (ConsoleColor.Yellow, ConsoleColor.Red); Colors.Error.HotFocus = Colors.Error.HotNormal; Console.Clear (); - - HLine = '\u2500'; - VLine = '\u2502'; - Stipple = '\u2592'; - Diamond = '\u25c6'; - ULCorner = '\u250C'; - LLCorner = '\u2514'; - URCorner = '\u2510'; - LRCorner = '\u2518'; - LeftTee = '\u251c'; - RightTee = '\u2524'; - TopTee = '\u22a4'; - BottomTee = '\u22a5'; - Checked = '\u221a'; - UnChecked = ' '; - Selected = '\u25cf'; - UnSelected = '\u25cc'; - RightArrow = '\u25ba'; - LeftArrow = '\u25c4'; - UpArrow = '\u25b2'; - DownArrow = '\u25bc'; - LeftDefaultIndicator = '\u25e6'; - RightDefaultIndicator = '\u25e6'; - LeftBracket = '['; - RightBracket = ']'; - OnMeterSegment = '\u258c'; - OffMeterSegement = ' '; } public override Attribute MakeAttribute (Color fore, Color back) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index aaf324449..ab2e083b9 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -563,33 +563,6 @@ namespace Terminal.Gui { Colors.Error.Focus = MakeColor (ConsoleColor.White, ConsoleColor.DarkRed); Colors.Error.HotNormal = MakeColor (ConsoleColor.Black, ConsoleColor.White); Colors.Error.HotFocus = MakeColor (ConsoleColor.Black, ConsoleColor.DarkRed); - - HLine = '\u2500'; - VLine = '\u2502'; - Stipple = '\u2591'; - Diamond = '\u25ca'; - ULCorner = '\u250C'; - LLCorner = '\u2514'; - URCorner = '\u2510'; - LRCorner = '\u2518'; - LeftTee = '\u251c'; - RightTee = '\u2524'; - TopTee = '\u252c'; - BottomTee = '\u2534'; - Checked = '\u221a'; - UnChecked = ' '; - Selected = '\u25cf'; - UnSelected = '\u25cc'; - RightArrow = '\u25ba'; - LeftArrow = '\u25c4'; - UpArrow = '\u25b2'; - DownArrow = '\u25bc'; - LeftDefaultIndicator = '\u25e6'; - RightDefaultIndicator = '\u25e6'; - LeftBracket = '['; - RightBracket = ']'; - OnMeterSegment = '\u258c'; - OffMeterSegement = ' '; } [StructLayout (LayoutKind.Sequential)] diff --git a/Terminal.Gui/Views/Checkbox.cs b/Terminal.Gui/Views/Checkbox.cs index 898c4658f..8d6b8a9a0 100644 --- a/Terminal.Gui/Views/Checkbox.cs +++ b/Terminal.Gui/Views/Checkbox.cs @@ -115,11 +115,12 @@ namespace Terminal.Gui { { Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal); Move (0, 0); - Driver.AddStr (Checked ? "[x] " : "[ ] "); - Move (4, 0); + Driver.AddRune (Checked ? Driver.Checked : Driver.UnChecked); + Driver.AddRune (' '); + Move (2, 0); Driver.AddStr (Text); if (hot_pos != -1) { - Move (4 + hot_pos, 0); + Move (2 + hot_pos, 0); Driver.SetAttribute (HasFocus ? ColorScheme.HotFocus : ColorScheme.HotNormal); Driver.AddRune (hot_key); } @@ -128,7 +129,7 @@ namespace Terminal.Gui { /// public override void PositionCursor () { - Move (1, 0); + Move (0, 0); } /// diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index b4bfe8ba7..c956717a3 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -180,7 +180,19 @@ namespace Terminal.Gui { /// /// If set to true allows more than one item to be selected. If false only allow one item selected. /// - public bool AllowsMultipleSelection { get; set; } = true; + public bool AllowsMultipleSelection { get => allowsMultipleSelection; + set { + allowsMultipleSelection = value; + if (Source != null && !allowsMultipleSelection) { + // Clear all selections except selected + for (int i = 0; i < Source.Count; i++) { + if (Source.IsMarked (i) && i != selected) { + Source.SetMark (i, false); + } + } + } + } + } /// /// Gets or sets the item that is displayed at the top of the . @@ -291,7 +303,7 @@ namespace Terminal.Gui { } var item = top; bool focused = HasFocus; - int col = allowsMarking ? 4 : 0; + int col = allowsMarking ? 2 : 0; for (int row = 0; row < f.Height; row++, item++) { bool isSelected = item == selected; @@ -308,7 +320,8 @@ namespace Terminal.Gui { Driver.AddRune (' '); } else { if (allowsMarking) { - Driver.AddStr (source.IsMarked (item) ? (AllowsMultipleSelection ? "[x] " : "(o)") : (AllowsMultipleSelection ? "[ ] " : "( )")); + Driver.AddRune (source.IsMarked (item) ? (AllowsMultipleSelection ? Driver.Selected : Driver.Checked) : (AllowsMultipleSelection ? Driver.UnSelected : Driver.UnChecked)); + Driver.AddRune (' '); } Source.Render (this, Driver, isSelected, item, col, row, f.Width - col); } @@ -537,6 +550,7 @@ namespace Terminal.Gui { } int lastSelectedItem = -1; + private bool allowsMultipleSelection = true; /// /// Invokes the SelectedChanged event if it is defined. @@ -593,9 +607,9 @@ namespace Terminal.Gui { public override void PositionCursor () { if (allowsMarking) - Move (1, selected - top); - else Move (0, selected - top); + else + Move (Bounds.Width - 1, selected - top); } /// diff --git a/Terminal.Gui/Views/Menu.cs b/Terminal.Gui/Views/Menu.cs index fb6c31ab9..67d27a85f 100644 --- a/Terminal.Gui/Views/Menu.cs +++ b/Terminal.Gui/Views/Menu.cs @@ -398,11 +398,10 @@ namespace Terminal.Gui { uncheckedChar = Driver.UnChecked; } - // Support Checked even though CHeckType wasn't set + // Support Checked even though CheckType wasn't set if (item.Checked) { textToDraw = ustring.Make (new Rune [] { checkChar, ' ' }) + item.Title; - } else if (item.CheckType.HasFlag (MenuItemCheckStyle.Checked) || - item.CheckType.HasFlag (MenuItemCheckStyle.Radio)) { + } else if (item.CheckType.HasFlag (MenuItemCheckStyle.Checked) || item.CheckType.HasFlag (MenuItemCheckStyle.Radio)) { textToDraw = ustring.Make (new Rune [] { uncheckedChar, ' ' }) + item.Title; } else { textToDraw = item.Title; diff --git a/UICatalog/Scenarios/ListViewWithSelection.cs b/UICatalog/Scenarios/ListViewWithSelection.cs new file mode 100644 index 000000000..5a0e03daa --- /dev/null +++ b/UICatalog/Scenarios/ListViewWithSelection.cs @@ -0,0 +1,155 @@ +using NStack; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Terminal.Gui; + +namespace UICatalog { + [ScenarioMetadata (Name: "List View With Selection", Description: "ListView with colunns and selection")] + [ScenarioCategory ("Controls")] + class ListViewWithSelection : Scenario { + + public CheckBox _customRenderCB; + public CheckBox _allowMarkingCB; + public CheckBox _allowMultipleCB; + public ListView _listView; + + public List _scenarios = Scenario.GetDerivedClasses().OrderBy (t => Scenario.ScenarioMetadata.GetName (t)).ToList (); + + public override void Setup () + { + _customRenderCB = new CheckBox ("Render with columns") { + X = 0, + Y = 0, + Height = 1, + }; + Win.Add (_customRenderCB); + _customRenderCB.Toggled += _customRenderCB_Toggled; ; + + _allowMarkingCB = new CheckBox ("Allow Marking") { + X = Pos.Right (_customRenderCB) + 1, + Y = 0, + Height = 1, + }; + Win.Add (_allowMarkingCB); + _allowMarkingCB.Toggled += AllowMarkingCB_Toggled; + + _allowMultipleCB = new CheckBox ("Allow Multi-Select") { + X = Pos.Right (_allowMarkingCB) + 1, + Y = 0, + Height = 1, + Visible = _allowMarkingCB.Checked + }; + Win.Add (_allowMultipleCB); + _allowMultipleCB.Toggled += AllowMultipleCB_Toggled; + + _listView = new ListView () { + X = 1, + Y = 2, + Height = Dim.Fill (), + Width = Dim.Fill (1), + //ColorScheme = Colors.TopLevel, + AllowsMarking = false, + AllowsMultipleSelection = false + }; + Win.Add (_listView); + + + _listView.SetSource (_scenarios); + + } + + private void _customRenderCB_Toggled (bool prev) + { + if (prev) { + _listView.SetSource (_scenarios); + } else { + _listView.Source = new ScenarioListDataSource (_scenarios); + } + + Win.SetNeedsDisplay (); + } + + private void AllowMarkingCB_Toggled (bool prev) + { + _listView.AllowsMarking = !prev; + _allowMultipleCB.Visible = _listView.AllowsMarking; + Win.SetNeedsDisplay (); + } + + private void AllowMultipleCB_Toggled (bool prev) + { + _listView.AllowsMultipleSelection = !prev; + Win.SetNeedsDisplay (); + } + + // This is basicaly the same implementation used by the UICatalog main window + internal class ScenarioListDataSource : IListDataSource { + int _nameColumnWidth = 30; + private List scenarios; + BitArray marks; + int count; + + public List Scenarios { + get => scenarios; + set { + if (value != null) { + count = value.Count; + marks = new BitArray (count); + scenarios = value; + } + } + } + public bool IsMarked (int item) + { + if (item >= 0 && item < count) + return marks [item]; + return false; + } + + public int Count => Scenarios != null ? Scenarios.Count : 0; + + public ScenarioListDataSource (List itemList) => Scenarios = itemList; + + public void Render (ListView container, ConsoleDriver driver, bool selected, int item, int col, int line, int width) + { + container.Move (col, line); + // Equivalent to an interpolated string like $"{Scenarios[item].Name, -widtestname}"; if such a thing were possible + var s = String.Format (String.Format ("{{0,{0}}}", -_nameColumnWidth), Scenario.ScenarioMetadata.GetName (Scenarios [item])); + RenderUstr (driver, $"{s} {Scenario.ScenarioMetadata.GetDescription (Scenarios [item])}", col, line, width); + } + + public void SetMark (int item, bool value) + { + if (item >= 0 && item < count) + marks [item] = value; + } + + // A slightly adapted method from: https://github.com/migueldeicaza/gui.cs/blob/fc1faba7452ccbdf49028ac49f0c9f0f42bbae91/Terminal.Gui/Views/ListView.cs#L433-L461 + private void RenderUstr (ConsoleDriver driver, ustring ustr, int col, int line, int width) + { + int used = 0; + int index = 0; + while (index < ustr.Length) { + (var rune, var size) = Utf8.DecodeRune (ustr, index, index - ustr.Length); + var count = Rune.ColumnWidth (rune); + if (used + count >= width) break; + driver.AddRune (rune); + used += count; + index += size; + } + + while (used < width) { + driver.AddRune (' '); + used++; + } + } + + public IList ToList () + { + return Scenarios; + } + } + } +} \ No newline at end of file From f5bf2d304ab979e57ed0e1d4038f71338b4f88b8 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Mon, 28 Sep 2020 17:29:36 -0700 Subject: [PATCH 03/12] fixed glyph that wasn't working with Cascadia --- Terminal.Gui/Core/ConsoleDriver.cs | 52 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Terminal.Gui/Core/ConsoleDriver.cs b/Terminal.Gui/Core/ConsoleDriver.cs index 612c22c60..2ad8e9954 100644 --- a/Terminal.Gui/Core/ConsoleDriver.cs +++ b/Terminal.Gui/Core/ConsoleDriver.cs @@ -913,132 +913,132 @@ namespace Terminal.Gui { /// /// Horizontal line character. /// - public Rune HLine; + public Rune HLine = '\u2500'; /// /// Vertical line character. /// - public Rune VLine; + public Rune VLine = '\u2502'; /// /// Stipple pattern /// - public Rune Stipple; + public Rune Stipple = '\u2591'; /// /// Diamond character /// - public Rune Diamond; + public Rune Diamond = '\u25ca'; /// /// Upper left corner /// - public Rune ULCorner; + public Rune ULCorner = '\u250C'; /// /// Lower left corner /// - public Rune LLCorner; + public Rune LLCorner = '\u2514'; /// /// Upper right corner /// - public Rune URCorner; + public Rune URCorner = '\u2510'; /// /// Lower right corner /// - public Rune LRCorner; + public Rune LRCorner = '\u2518'; /// /// Left tee /// - public Rune LeftTee; + public Rune LeftTee = '\u251c'; /// /// Right tee /// - public Rune RightTee; + public Rune RightTee = '\u2524'; /// /// Top tee /// - public Rune TopTee; + public Rune TopTee = '\u252c'; /// /// The bottom tee. /// - public Rune BottomTee; + public Rune BottomTee = '\u2534'; /// /// Checkmark. /// - public Rune Checked; + public Rune Checked = '\u221a'; /// /// Un-checked checkmark. /// - public Rune UnChecked; + public Rune UnChecked = '\u2574'; /// /// Selected mark. /// - public Rune Selected; + public Rune Selected = '\u25cf'; /// /// Un-selected selected mark. /// - public Rune UnSelected; + public Rune UnSelected = '\u25cc'; /// /// Right Arrow. /// - public Rune RightArrow; + public Rune RightArrow = '\u25ba'; /// /// Left Arrow. /// - public Rune LeftArrow; + public Rune LeftArrow = '\u25c4'; /// /// Down Arrow. /// - public Rune DownArrow; + public Rune DownArrow = '\u25bc'; /// /// Up Arrow. /// - public Rune UpArrow; + public Rune UpArrow = '\u25b2'; /// /// Left indicator for default action (e.g. for ). /// - public Rune LeftDefaultIndicator; + public Rune LeftDefaultIndicator = '\u25e6'; /// /// Right indicator for default action (e.g. for ). /// - public Rune RightDefaultIndicator; + public Rune RightDefaultIndicator = '\u25e6'; /// /// Left frame/bracket (e.g. '[' for ). /// - public Rune LeftBracket; + public Rune LeftBracket = '['; /// /// Right frame/bracket (e.g. ']' for ). /// - public Rune RightBracket; + public Rune RightBracket = ']'; /// /// On Segment indicator for meter views (e.g. . /// - public Rune OnMeterSegment; + public Rune OnMeterSegment = '\u258c'; /// /// Off Segment indicator for meter views (e.g. . /// - public Rune OffMeterSegement; + public Rune OffMeterSegement = ' '; /// /// Make the attribute for the foreground and background colors. From 24c4e53cff7a4198c399ba47fcfc071fd6758efd Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 07:26:48 -0700 Subject: [PATCH 04/12] bumped version to 1.00.00-pre as a test of nuget --- Terminal.Gui/Directory.Build.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Terminal.Gui/Directory.Build.props b/Terminal.Gui/Directory.Build.props index b5334f688..2db58eb0f 100644 --- a/Terminal.Gui/Directory.Build.props +++ b/Terminal.Gui/Directory.Build.props @@ -1,9 +1,9 @@ - 0.90.2 - 0.90.2 - 0.90.2 + 1.00.0-pre + 1.00.0-pre + 1.00.0-pre Miguel de Icaza, Charlie Kindel (@tig), @BDisp From 7e2690164bb69a67614e2616911efe1416534c85 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 08:25:15 -0700 Subject: [PATCH 05/12] trying new format --- Terminal.Gui/Directory.Build.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Terminal.Gui/Directory.Build.props b/Terminal.Gui/Directory.Build.props index 2db58eb0f..7cf3dcffb 100644 --- a/Terminal.Gui/Directory.Build.props +++ b/Terminal.Gui/Directory.Build.props @@ -1,9 +1,9 @@ - 1.00.0-pre - 1.00.0-pre - 1.00.0-pre + 1.00-pre.99.1 + 0.99.1 + 0.99.1 Miguel de Icaza, Charlie Kindel (@tig), @BDisp From e19332021a1b8c2c3cb7684654823602c4882b32 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 08:44:03 -0700 Subject: [PATCH 06/12] realized I had two directory.build.props --- .github/workflows/publish.yml | 2 +- Directory.Build.props | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 Directory.Build.props diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 54c2d6aab..3c3a7c3a1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,7 +27,7 @@ jobs: PACKAGE_NAME: Terminal.Gui # Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH - VERSION_FILE_PATH: Directory.Build.props + VERSION_FILE_PATH: Terminal.Gui/Directory.Build.props # Regex pattern to extract version info in a capturing group VERSION_REGEX: ^\s*(.*)<\/Version>\s*$ diff --git a/Directory.Build.props b/Directory.Build.props deleted file mode 100644 index 53f7dce48..000000000 --- a/Directory.Build.props +++ /dev/null @@ -1,10 +0,0 @@ - - - - 0.90.0 - 0.90.0 - 0.90.0 - Miguel de Icaza, Charlie Kindel (@tig), @BDisp - - - \ No newline at end of file From 85354d1d7fc67f66b79d5f42d746e08e3af41713 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 10:44:52 -0700 Subject: [PATCH 07/12] new version to update nuget --- Terminal.Gui/Directory.Build.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Terminal.Gui/Directory.Build.props b/Terminal.Gui/Directory.Build.props index b5334f688..657fe963a 100644 --- a/Terminal.Gui/Directory.Build.props +++ b/Terminal.Gui/Directory.Build.props @@ -1,9 +1,9 @@ - 0.90.2 - 0.90.2 - 0.90.2 + 0.90.3 + 0.90.3 + 0.90.3 Miguel de Icaza, Charlie Kindel (@tig), @BDisp From 5a95d0081b10be5d07f33075cb3ff1548c8dabc8 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 10:57:02 -0700 Subject: [PATCH 08/12] after reverting, bumping version and fixing Directory.build.props --- .github/workflows/publish.yml | 2 +- Directory.Build.props | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 Directory.Build.props diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 54c2d6aab..3c3a7c3a1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,7 +27,7 @@ jobs: PACKAGE_NAME: Terminal.Gui # Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH - VERSION_FILE_PATH: Directory.Build.props + VERSION_FILE_PATH: Terminal.Gui/Directory.Build.props # Regex pattern to extract version info in a capturing group VERSION_REGEX: ^\s*(.*)<\/Version>\s*$ diff --git a/Directory.Build.props b/Directory.Build.props deleted file mode 100644 index 53f7dce48..000000000 --- a/Directory.Build.props +++ /dev/null @@ -1,10 +0,0 @@ - - - - 0.90.0 - 0.90.0 - 0.90.0 - Miguel de Icaza, Charlie Kindel (@tig), @BDisp - - - \ No newline at end of file From db8f591b569a9b30748763f2a3cc5fe872e8dbd4 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 10:50:30 -0700 Subject: [PATCH 09/12] Revert "Use glyphs for checkmarks & selection" --- .../CursesDriver/CursesDriver.cs | 10 ++ .../ConsoleDrivers/FakeDriver/FakeDriver.cs | 27 +++ Terminal.Gui/ConsoleDrivers/NetDriver.cs | 27 +++ Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 27 +++ Terminal.Gui/Core/ConsoleDriver.cs | 52 +++--- Terminal.Gui/Views/Checkbox.cs | 9 +- Terminal.Gui/Views/ListView.cs | 24 +-- Terminal.Gui/Views/Menu.cs | 5 +- UICatalog/Scenarios/ListViewWithSelection.cs | 155 ------------------ 9 files changed, 129 insertions(+), 207 deletions(-) delete mode 100644 UICatalog/Scenarios/ListViewWithSelection.cs diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs index 828dca838..4ba273444 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs @@ -531,10 +531,20 @@ namespace Terminal.Gui { RightTee = Curses.ACS_RTEE; TopTee = Curses.ACS_TTEE; BottomTee = Curses.ACS_BTEE; + Checked = '\u221a'; + UnChecked = ' '; + Selected = '\u25cf'; + UnSelected = '\u25cc'; RightArrow = Curses.ACS_RARROW; LeftArrow = Curses.ACS_LARROW; UpArrow = Curses.ACS_UARROW; DownArrow = Curses.ACS_DARROW; + LeftDefaultIndicator = '\u25e6'; + RightDefaultIndicator = '\u25e6'; + LeftBracket = '['; + RightBracket = ']'; + OnMeterSegment = '\u258c'; + OffMeterSegement = ' '; Colors.TopLevel = new ColorScheme (); Colors.Base = new ColorScheme (); diff --git a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs index 13e670c4f..11cd1c912 100644 --- a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs @@ -182,6 +182,33 @@ namespace Terminal.Gui { Colors.Error.HotNormal = MakeColor (ConsoleColor.Yellow, ConsoleColor.Red); Colors.Error.HotFocus = Colors.Error.HotNormal; + HLine = '\u2500'; + VLine = '\u2502'; + Stipple = '\u2592'; + Diamond = '\u25c6'; + ULCorner = '\u250C'; + LLCorner = '\u2514'; + URCorner = '\u2510'; + LRCorner = '\u2518'; + LeftTee = '\u251c'; + RightTee = '\u2524'; + TopTee = '\u22a4'; + BottomTee = '\u22a5'; + Checked = '\u221a'; + UnChecked = ' '; + Selected = '\u25cf'; + UnSelected = '\u25cc'; + RightArrow = '\u25ba'; + LeftArrow = '\u25c4'; + UpArrow = '\u25b2'; + DownArrow = '\u25bc'; + LeftDefaultIndicator = '\u25e6'; + RightDefaultIndicator = '\u25e6'; + LeftBracket = '['; + RightBracket = ']'; + OnMeterSegment = '\u258c'; + OffMeterSegement = ' '; + //MockConsole.Clear (); } diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index cf2f9e31d..1fe8f01c7 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -152,6 +152,33 @@ namespace Terminal.Gui { Colors.Error.HotNormal = MakeColor (ConsoleColor.Yellow, ConsoleColor.Red); Colors.Error.HotFocus = Colors.Error.HotNormal; Console.Clear (); + + HLine = '\u2500'; + VLine = '\u2502'; + Stipple = '\u2592'; + Diamond = '\u25c6'; + ULCorner = '\u250C'; + LLCorner = '\u2514'; + URCorner = '\u2510'; + LRCorner = '\u2518'; + LeftTee = '\u251c'; + RightTee = '\u2524'; + TopTee = '\u22a4'; + BottomTee = '\u22a5'; + Checked = '\u221a'; + UnChecked = ' '; + Selected = '\u25cf'; + UnSelected = '\u25cc'; + RightArrow = '\u25ba'; + LeftArrow = '\u25c4'; + UpArrow = '\u25b2'; + DownArrow = '\u25bc'; + LeftDefaultIndicator = '\u25e6'; + RightDefaultIndicator = '\u25e6'; + LeftBracket = '['; + RightBracket = ']'; + OnMeterSegment = '\u258c'; + OffMeterSegement = ' '; } public override Attribute MakeAttribute (Color fore, Color back) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index ab2e083b9..aaf324449 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -563,6 +563,33 @@ namespace Terminal.Gui { Colors.Error.Focus = MakeColor (ConsoleColor.White, ConsoleColor.DarkRed); Colors.Error.HotNormal = MakeColor (ConsoleColor.Black, ConsoleColor.White); Colors.Error.HotFocus = MakeColor (ConsoleColor.Black, ConsoleColor.DarkRed); + + HLine = '\u2500'; + VLine = '\u2502'; + Stipple = '\u2591'; + Diamond = '\u25ca'; + ULCorner = '\u250C'; + LLCorner = '\u2514'; + URCorner = '\u2510'; + LRCorner = '\u2518'; + LeftTee = '\u251c'; + RightTee = '\u2524'; + TopTee = '\u252c'; + BottomTee = '\u2534'; + Checked = '\u221a'; + UnChecked = ' '; + Selected = '\u25cf'; + UnSelected = '\u25cc'; + RightArrow = '\u25ba'; + LeftArrow = '\u25c4'; + UpArrow = '\u25b2'; + DownArrow = '\u25bc'; + LeftDefaultIndicator = '\u25e6'; + RightDefaultIndicator = '\u25e6'; + LeftBracket = '['; + RightBracket = ']'; + OnMeterSegment = '\u258c'; + OffMeterSegement = ' '; } [StructLayout (LayoutKind.Sequential)] diff --git a/Terminal.Gui/Core/ConsoleDriver.cs b/Terminal.Gui/Core/ConsoleDriver.cs index 2ad8e9954..612c22c60 100644 --- a/Terminal.Gui/Core/ConsoleDriver.cs +++ b/Terminal.Gui/Core/ConsoleDriver.cs @@ -913,132 +913,132 @@ namespace Terminal.Gui { /// /// Horizontal line character. /// - public Rune HLine = '\u2500'; + public Rune HLine; /// /// Vertical line character. /// - public Rune VLine = '\u2502'; + public Rune VLine; /// /// Stipple pattern /// - public Rune Stipple = '\u2591'; + public Rune Stipple; /// /// Diamond character /// - public Rune Diamond = '\u25ca'; + public Rune Diamond; /// /// Upper left corner /// - public Rune ULCorner = '\u250C'; + public Rune ULCorner; /// /// Lower left corner /// - public Rune LLCorner = '\u2514'; + public Rune LLCorner; /// /// Upper right corner /// - public Rune URCorner = '\u2510'; + public Rune URCorner; /// /// Lower right corner /// - public Rune LRCorner = '\u2518'; + public Rune LRCorner; /// /// Left tee /// - public Rune LeftTee = '\u251c'; + public Rune LeftTee; /// /// Right tee /// - public Rune RightTee = '\u2524'; + public Rune RightTee; /// /// Top tee /// - public Rune TopTee = '\u252c'; + public Rune TopTee; /// /// The bottom tee. /// - public Rune BottomTee = '\u2534'; + public Rune BottomTee; /// /// Checkmark. /// - public Rune Checked = '\u221a'; + public Rune Checked; /// /// Un-checked checkmark. /// - public Rune UnChecked = '\u2574'; + public Rune UnChecked; /// /// Selected mark. /// - public Rune Selected = '\u25cf'; + public Rune Selected; /// /// Un-selected selected mark. /// - public Rune UnSelected = '\u25cc'; + public Rune UnSelected; /// /// Right Arrow. /// - public Rune RightArrow = '\u25ba'; + public Rune RightArrow; /// /// Left Arrow. /// - public Rune LeftArrow = '\u25c4'; + public Rune LeftArrow; /// /// Down Arrow. /// - public Rune DownArrow = '\u25bc'; + public Rune DownArrow; /// /// Up Arrow. /// - public Rune UpArrow = '\u25b2'; + public Rune UpArrow; /// /// Left indicator for default action (e.g. for ). /// - public Rune LeftDefaultIndicator = '\u25e6'; + public Rune LeftDefaultIndicator; /// /// Right indicator for default action (e.g. for ). /// - public Rune RightDefaultIndicator = '\u25e6'; + public Rune RightDefaultIndicator; /// /// Left frame/bracket (e.g. '[' for ). /// - public Rune LeftBracket = '['; + public Rune LeftBracket; /// /// Right frame/bracket (e.g. ']' for ). /// - public Rune RightBracket = ']'; + public Rune RightBracket; /// /// On Segment indicator for meter views (e.g. . /// - public Rune OnMeterSegment = '\u258c'; + public Rune OnMeterSegment; /// /// Off Segment indicator for meter views (e.g. . /// - public Rune OffMeterSegement = ' '; + public Rune OffMeterSegement; /// /// Make the attribute for the foreground and background colors. diff --git a/Terminal.Gui/Views/Checkbox.cs b/Terminal.Gui/Views/Checkbox.cs index 8d6b8a9a0..898c4658f 100644 --- a/Terminal.Gui/Views/Checkbox.cs +++ b/Terminal.Gui/Views/Checkbox.cs @@ -115,12 +115,11 @@ namespace Terminal.Gui { { Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal); Move (0, 0); - Driver.AddRune (Checked ? Driver.Checked : Driver.UnChecked); - Driver.AddRune (' '); - Move (2, 0); + Driver.AddStr (Checked ? "[x] " : "[ ] "); + Move (4, 0); Driver.AddStr (Text); if (hot_pos != -1) { - Move (2 + hot_pos, 0); + Move (4 + hot_pos, 0); Driver.SetAttribute (HasFocus ? ColorScheme.HotFocus : ColorScheme.HotNormal); Driver.AddRune (hot_key); } @@ -129,7 +128,7 @@ namespace Terminal.Gui { /// public override void PositionCursor () { - Move (0, 0); + Move (1, 0); } /// diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index c956717a3..b4bfe8ba7 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -180,19 +180,7 @@ namespace Terminal.Gui { /// /// If set to true allows more than one item to be selected. If false only allow one item selected. /// - public bool AllowsMultipleSelection { get => allowsMultipleSelection; - set { - allowsMultipleSelection = value; - if (Source != null && !allowsMultipleSelection) { - // Clear all selections except selected - for (int i = 0; i < Source.Count; i++) { - if (Source.IsMarked (i) && i != selected) { - Source.SetMark (i, false); - } - } - } - } - } + public bool AllowsMultipleSelection { get; set; } = true; /// /// Gets or sets the item that is displayed at the top of the . @@ -303,7 +291,7 @@ namespace Terminal.Gui { } var item = top; bool focused = HasFocus; - int col = allowsMarking ? 2 : 0; + int col = allowsMarking ? 4 : 0; for (int row = 0; row < f.Height; row++, item++) { bool isSelected = item == selected; @@ -320,8 +308,7 @@ namespace Terminal.Gui { Driver.AddRune (' '); } else { if (allowsMarking) { - Driver.AddRune (source.IsMarked (item) ? (AllowsMultipleSelection ? Driver.Selected : Driver.Checked) : (AllowsMultipleSelection ? Driver.UnSelected : Driver.UnChecked)); - Driver.AddRune (' '); + Driver.AddStr (source.IsMarked (item) ? (AllowsMultipleSelection ? "[x] " : "(o)") : (AllowsMultipleSelection ? "[ ] " : "( )")); } Source.Render (this, Driver, isSelected, item, col, row, f.Width - col); } @@ -550,7 +537,6 @@ namespace Terminal.Gui { } int lastSelectedItem = -1; - private bool allowsMultipleSelection = true; /// /// Invokes the SelectedChanged event if it is defined. @@ -607,9 +593,9 @@ namespace Terminal.Gui { public override void PositionCursor () { if (allowsMarking) - Move (0, selected - top); + Move (1, selected - top); else - Move (Bounds.Width - 1, selected - top); + Move (0, selected - top); } /// diff --git a/Terminal.Gui/Views/Menu.cs b/Terminal.Gui/Views/Menu.cs index 67d27a85f..fb6c31ab9 100644 --- a/Terminal.Gui/Views/Menu.cs +++ b/Terminal.Gui/Views/Menu.cs @@ -398,10 +398,11 @@ namespace Terminal.Gui { uncheckedChar = Driver.UnChecked; } - // Support Checked even though CheckType wasn't set + // Support Checked even though CHeckType wasn't set if (item.Checked) { textToDraw = ustring.Make (new Rune [] { checkChar, ' ' }) + item.Title; - } else if (item.CheckType.HasFlag (MenuItemCheckStyle.Checked) || item.CheckType.HasFlag (MenuItemCheckStyle.Radio)) { + } else if (item.CheckType.HasFlag (MenuItemCheckStyle.Checked) || + item.CheckType.HasFlag (MenuItemCheckStyle.Radio)) { textToDraw = ustring.Make (new Rune [] { uncheckedChar, ' ' }) + item.Title; } else { textToDraw = item.Title; diff --git a/UICatalog/Scenarios/ListViewWithSelection.cs b/UICatalog/Scenarios/ListViewWithSelection.cs deleted file mode 100644 index 5a0e03daa..000000000 --- a/UICatalog/Scenarios/ListViewWithSelection.cs +++ /dev/null @@ -1,155 +0,0 @@ -using NStack; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Terminal.Gui; - -namespace UICatalog { - [ScenarioMetadata (Name: "List View With Selection", Description: "ListView with colunns and selection")] - [ScenarioCategory ("Controls")] - class ListViewWithSelection : Scenario { - - public CheckBox _customRenderCB; - public CheckBox _allowMarkingCB; - public CheckBox _allowMultipleCB; - public ListView _listView; - - public List _scenarios = Scenario.GetDerivedClasses().OrderBy (t => Scenario.ScenarioMetadata.GetName (t)).ToList (); - - public override void Setup () - { - _customRenderCB = new CheckBox ("Render with columns") { - X = 0, - Y = 0, - Height = 1, - }; - Win.Add (_customRenderCB); - _customRenderCB.Toggled += _customRenderCB_Toggled; ; - - _allowMarkingCB = new CheckBox ("Allow Marking") { - X = Pos.Right (_customRenderCB) + 1, - Y = 0, - Height = 1, - }; - Win.Add (_allowMarkingCB); - _allowMarkingCB.Toggled += AllowMarkingCB_Toggled; - - _allowMultipleCB = new CheckBox ("Allow Multi-Select") { - X = Pos.Right (_allowMarkingCB) + 1, - Y = 0, - Height = 1, - Visible = _allowMarkingCB.Checked - }; - Win.Add (_allowMultipleCB); - _allowMultipleCB.Toggled += AllowMultipleCB_Toggled; - - _listView = new ListView () { - X = 1, - Y = 2, - Height = Dim.Fill (), - Width = Dim.Fill (1), - //ColorScheme = Colors.TopLevel, - AllowsMarking = false, - AllowsMultipleSelection = false - }; - Win.Add (_listView); - - - _listView.SetSource (_scenarios); - - } - - private void _customRenderCB_Toggled (bool prev) - { - if (prev) { - _listView.SetSource (_scenarios); - } else { - _listView.Source = new ScenarioListDataSource (_scenarios); - } - - Win.SetNeedsDisplay (); - } - - private void AllowMarkingCB_Toggled (bool prev) - { - _listView.AllowsMarking = !prev; - _allowMultipleCB.Visible = _listView.AllowsMarking; - Win.SetNeedsDisplay (); - } - - private void AllowMultipleCB_Toggled (bool prev) - { - _listView.AllowsMultipleSelection = !prev; - Win.SetNeedsDisplay (); - } - - // This is basicaly the same implementation used by the UICatalog main window - internal class ScenarioListDataSource : IListDataSource { - int _nameColumnWidth = 30; - private List scenarios; - BitArray marks; - int count; - - public List Scenarios { - get => scenarios; - set { - if (value != null) { - count = value.Count; - marks = new BitArray (count); - scenarios = value; - } - } - } - public bool IsMarked (int item) - { - if (item >= 0 && item < count) - return marks [item]; - return false; - } - - public int Count => Scenarios != null ? Scenarios.Count : 0; - - public ScenarioListDataSource (List itemList) => Scenarios = itemList; - - public void Render (ListView container, ConsoleDriver driver, bool selected, int item, int col, int line, int width) - { - container.Move (col, line); - // Equivalent to an interpolated string like $"{Scenarios[item].Name, -widtestname}"; if such a thing were possible - var s = String.Format (String.Format ("{{0,{0}}}", -_nameColumnWidth), Scenario.ScenarioMetadata.GetName (Scenarios [item])); - RenderUstr (driver, $"{s} {Scenario.ScenarioMetadata.GetDescription (Scenarios [item])}", col, line, width); - } - - public void SetMark (int item, bool value) - { - if (item >= 0 && item < count) - marks [item] = value; - } - - // A slightly adapted method from: https://github.com/migueldeicaza/gui.cs/blob/fc1faba7452ccbdf49028ac49f0c9f0f42bbae91/Terminal.Gui/Views/ListView.cs#L433-L461 - private void RenderUstr (ConsoleDriver driver, ustring ustr, int col, int line, int width) - { - int used = 0; - int index = 0; - while (index < ustr.Length) { - (var rune, var size) = Utf8.DecodeRune (ustr, index, index - ustr.Length); - var count = Rune.ColumnWidth (rune); - if (used + count >= width) break; - driver.AddRune (rune); - used += count; - index += size; - } - - while (used < width) { - driver.AddRune (' '); - used++; - } - } - - public IList ToList () - { - return Scenarios; - } - } - } -} \ No newline at end of file From 7e8340b10b01dddb873988c68de01e0efe9a081e Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 10:53:27 -0700 Subject: [PATCH 10/12] Revert "bumped version to 1.00-pre.99.1 as a test of nuget" --- .github/workflows/publish.yml | 2 +- Directory.Build.props | 10 ++++++++++ Terminal.Gui/Directory.Build.props | 6 +++--- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 Directory.Build.props diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3c3a7c3a1..54c2d6aab 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,7 +27,7 @@ jobs: PACKAGE_NAME: Terminal.Gui # Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH - VERSION_FILE_PATH: Terminal.Gui/Directory.Build.props + VERSION_FILE_PATH: Directory.Build.props # Regex pattern to extract version info in a capturing group VERSION_REGEX: ^\s*(.*)<\/Version>\s*$ diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 000000000..53f7dce48 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + + 0.90.0 + 0.90.0 + 0.90.0 + Miguel de Icaza, Charlie Kindel (@tig), @BDisp + + + \ No newline at end of file diff --git a/Terminal.Gui/Directory.Build.props b/Terminal.Gui/Directory.Build.props index 7cf3dcffb..b5334f688 100644 --- a/Terminal.Gui/Directory.Build.props +++ b/Terminal.Gui/Directory.Build.props @@ -1,9 +1,9 @@ - 1.00-pre.99.1 - 0.99.1 - 0.99.1 + 0.90.2 + 0.90.2 + 0.90.2 Miguel de Icaza, Charlie Kindel (@tig), @BDisp From f28c9150facaa3536b779c16d0293b43d94f6be5 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 13:11:34 -0700 Subject: [PATCH 11/12] new versioning --- Terminal.Gui/Directory.Build.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Terminal.Gui/Directory.Build.props b/Terminal.Gui/Directory.Build.props index b5334f688..41914b2d9 100644 --- a/Terminal.Gui/Directory.Build.props +++ b/Terminal.Gui/Directory.Build.props @@ -1,9 +1,9 @@ - 0.90.2 - 0.90.2 - 0.90.2 + 1.0.0-pre.1 + 1.0.1 + 1.0.1 Miguel de Icaza, Charlie Kindel (@tig), @BDisp From 6e1438e2bade81d0847d32cd34dcf00af9f604c7 Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Tue, 29 Sep 2020 13:21:41 -0700 Subject: [PATCH 12/12] documented & updated --- Terminal.Gui/Directory.Build.props | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Directory.Build.props b/Terminal.Gui/Directory.Build.props index 41914b2d9..0363e2dee 100644 --- a/Terminal.Gui/Directory.Build.props +++ b/Terminal.Gui/Directory.Build.props @@ -1,9 +1,17 @@ + 1.0.0-pre.1 - 1.0.1 - 1.0.1 + 1.0.0.1 + 1.0.0.1 Miguel de Icaza, Charlie Kindel (@tig), @BDisp