Skip to content

Commit 8104ef3

Browse files
committed
Merge branch 'v2_develop' into v2_3847_tabview-focus-fix
2 parents aa2f3f8 + 68daff5 commit 8104ef3

33 files changed

+855
-526
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
fetch-depth: 0 # fetch-depth is needed for GitVersion
2020

2121
- name: Install GitVersion
22-
uses: gittools/actions/gitversion/setup@v2
22+
uses: gittools/actions/gitversion/setup@v3
2323
with:
2424
versionSpec: '5.x'
2525
includePrerelease: true
2626

2727
- name: Determine Version
28-
uses: gittools/actions/gitversion/execute@v2
28+
uses: gittools/actions/gitversion/execute@v3
2929
with:
3030
useConfigFile: true
3131
#additionalArguments: /b develop

Showcase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
- **[Muse](https://github.com/MaciekWin3/Muse)** - Muse is terminal music player built with Terminal.Gui and NAudio on .NET platform.
2828
![Muse](https://github.com/user-attachments/assets/94aeb559-a889-4b52-bb0d-453b3e19b290)
29-
z
29+
3030
- **[Whale](https://github.com/MaciekWin3/Whale)** - Lightweight terminal user interface application that helps software engineers manage Docker containers.
3131
![Whale](https://github.com/user-attachments/assets/7ef6e348-c36b-4aee-a63c-4e5c60c3aad2)
3232

Terminal.Gui/Application/Application.Driver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public static partial class Application // Driver abstractions
88
/// <summary>Gets the <see cref="ConsoleDriver"/> that has been selected. See also <see cref="ForceDriver"/>.</summary>
99
public static ConsoleDriver? Driver { get; internal set; }
1010

11+
// BUGBUG: Force16Colors should be nullable.
1112
/// <summary>
1213
/// Gets or sets whether <see cref="Application.Driver"/> will be forced to output only the 16 colors defined in
1314
/// <see cref="ColorName16"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
@@ -16,6 +17,7 @@ public static partial class Application // Driver abstractions
1617
[SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
1718
public static bool Force16Colors { get; set; }
1819

20+
// BUGBUG: ForceDriver should be nullable.
1921
/// <summary>
2022
/// Forces the use of the specified driver (one of "fake", "ansi", "curses", "net", or "windows"). If not
2123
/// specified, the driver is selected based on the platform.

Terminal.Gui/Application/Application.Keyboard.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public static bool RaiseKeyDownEvent (Key key)
4949
{
5050
if (binding.Value.BoundView is { })
5151
{
52+
if (!binding.Value.BoundView.Enabled)
53+
{
54+
return false;
55+
}
56+
5257
bool? handled = binding.Value.BoundView?.InvokeCommands (binding.Value.Commands, binding.Key, binding.Value);
5358

5459
if (handled != null && (bool)handled)

Terminal.Gui/Drawing/Glyphs.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
/// </remarks>
2121
public class GlyphDefinitions
2222
{
23+
// IMPORTANT: If you change these, make sure to update the ./Resources/config.json file as
24+
// IMPORTANT: it is the source of truth for the default glyphs at runtime.
25+
// IMPORTANT: Configuration Manager test SaveDefaults uses this class to generate the default config file
26+
// IMPORTANT: in ./UnitTests/bin/Debug/netX.0/config.json
27+
2328
/// <summary>File icon. Defaults to ☰ (Trigram For Heaven)</summary>
2429
public Rune File { get; set; } = (Rune)'☰';
2530

Terminal.Gui/Input/KeyBindings.cs

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#nullable enable
22

3+
using static System.Formats.Asn1.AsnWriter;
4+
35
namespace Terminal.Gui;
46

57
/// <summary>
@@ -17,7 +19,7 @@ public class KeyBindings
1719
public KeyBindings () { }
1820

1921
/// <summary>Initializes a new instance bound to <paramref name="boundView"/>.</summary>
20-
public KeyBindings (View boundView) { BoundView = boundView; }
22+
public KeyBindings (View? boundView) { BoundView = boundView; }
2123

2224
/// <summary>Adds a <see cref="KeyBinding"/> to the collection.</summary>
2325
/// <param name="key"></param>
@@ -27,7 +29,12 @@ public void Add (Key key, KeyBinding binding, View? boundViewForAppScope = null)
2729
{
2830
if (BoundView is { } && binding.Scope.FastHasFlags (KeyBindingScope.Application))
2931
{
30-
throw new ArgumentException ("Application scoped KeyBindings must be added via Application.KeyBindings.Add");
32+
throw new InvalidOperationException ("Application scoped KeyBindings must be added via Application.KeyBindings.Add");
33+
}
34+
35+
if (BoundView is { } && boundViewForAppScope is null)
36+
{
37+
boundViewForAppScope = BoundView;
3138
}
3239

3340
if (TryGet (key, out KeyBinding _))
@@ -78,6 +85,10 @@ public void Add (Key key, KeyBindingScope scope, View? boundViewForAppScope = nu
7885
{
7986
throw new ArgumentException ("Application scoped KeyBindings must be added via Application.KeyBindings.Add");
8087
}
88+
else
89+
{
90+
// boundViewForAppScope = BoundView;
91+
}
8192

8293
if (key is null || !key.IsValid)
8394
{
@@ -93,11 +104,9 @@ public void Add (Key key, KeyBindingScope scope, View? boundViewForAppScope = nu
93104
if (TryGet (key, out KeyBinding binding))
94105
{
95106
throw new InvalidOperationException (@$"A key binding for {key} exists ({binding}).");
96-
97-
//Bindings [key] = new (commands, scope, BoundView);
98107
}
99108

100-
Add (key, new KeyBinding (commands, scope, BoundView), boundViewForAppScope);
109+
Add (key, new KeyBinding (commands, scope, boundViewForAppScope), boundViewForAppScope);
101110
}
102111

103112
/// <summary>
@@ -120,9 +129,14 @@ public void Add (Key key, KeyBindingScope scope, View? boundViewForAppScope = nu
120129
/// </param>
121130
public void Add (Key key, KeyBindingScope scope, params Command [] commands)
122131
{
132+
if (BoundView is null && !scope.FastHasFlags (KeyBindingScope.Application))
133+
{
134+
throw new InvalidOperationException ("BoundView cannot be null.");
135+
}
136+
123137
if (BoundView is { } && scope.FastHasFlags (KeyBindingScope.Application))
124138
{
125-
throw new ArgumentException ("Application scoped KeyBindings must be added via Application.KeyBindings.Add");
139+
throw new InvalidOperationException ("Application scoped KeyBindings must be added via Application.KeyBindings.Add");
126140
}
127141

128142
if (key == Key.Empty || !key.IsValid)
@@ -140,7 +154,7 @@ public void Add (Key key, KeyBindingScope scope, params Command [] commands)
140154
throw new InvalidOperationException (@$"A key binding for {key} exists ({binding}).");
141155
}
142156

143-
Add (key, new KeyBinding (commands, scope, BoundView));
157+
Add (key, new KeyBinding (commands, scope, BoundView), BoundView);
144158
}
145159

146160
/// <summary>
@@ -219,14 +233,22 @@ public void Add (Key key, params Command [] commands)
219233
/// <summary>The collection of <see cref="KeyBinding"/> objects.</summary>
220234
public Dictionary<Key, KeyBinding> Bindings { get; } = new (new KeyEqualityComparer ());
221235

236+
/// <summary>
237+
/// Gets the keys that are bound.
238+
/// </summary>
239+
/// <returns></returns>
240+
public IEnumerable<Key> GetBoundKeys ()
241+
{
242+
return Bindings.Keys;
243+
}
244+
222245
/// <summary>
223246
/// The view that the <see cref="KeyBindings"/> are bound to.
224247
/// </summary>
225248
/// <remarks>
226-
/// If <see langword="null"/>, the <see cref="KeyBindings"/> are not bound to a <see cref="View"/>. This is used for
227-
/// Application.KeyBindings.
249+
/// If <see langword="null"/> the KeyBindings object is being used for Application.KeyBindings.
228250
/// </remarks>
229-
public View? BoundView { get; }
251+
internal View? BoundView { get; }
230252

231253
/// <summary>Removes all <see cref="KeyBinding"/> objects from the collection.</summary>
232254
public void Clear () { Bindings.Clear (); }
@@ -312,7 +334,7 @@ public IEnumerable<Key> GetKeysFromCommands (params Command [] commands)
312334
/// <param name="boundViewForAppScope">Optional View for <see cref="KeyBindingScope.Application"/> bindings.</param>
313335
public void Remove (Key key, View? boundViewForAppScope = null)
314336
{
315-
if (!TryGet (key, out KeyBinding binding))
337+
if (!TryGet (key, out KeyBinding _))
316338
{
317339
return;
318340
}
@@ -371,6 +393,11 @@ public void ReplaceKey (Key oldKey, Key newKey)
371393
/// <returns><see langword="true"/> if the Key is bound; otherwise <see langword="false"/>.</returns>
372394
public bool TryGet (Key key, out KeyBinding binding)
373395
{
396+
//if (BoundView is null)
397+
//{
398+
// throw new InvalidOperationException ("KeyBindings must be bound to a View to use this method.");
399+
//}
400+
374401
binding = new (Array.Empty<Command> (), KeyBindingScope.Disabled, null);
375402

376403
if (key.IsValid)
@@ -394,6 +421,11 @@ public bool TryGet (Key key, KeyBindingScope scope, out KeyBinding binding)
394421
{
395422
if (!key.IsValid)
396423
{
424+
//if (BoundView is null)
425+
//{
426+
// throw new InvalidOperationException ("KeyBindings must be bound to a View to use this method.");
427+
//}
428+
397429
binding = new (Array.Empty<Command> (), KeyBindingScope.Disabled, null);
398430
return false;
399431
}

Terminal.Gui/Resources/config.json

Lines changed: 163 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,173 @@
1616
// to throw exceptions.
1717
"ConfigurationManager.ThrowOnJsonErrors": false,
1818

19-
"Application.NextTabKey": "Tab",
20-
"Application.PrevTabKey": "Shift+Tab",
19+
// --------------- Application Settings ---------------
20+
"Key.Separator": "+",
21+
22+
"Application.ArrangeKey": "Ctrl+F5",
23+
"Application.Force16Colors": false,
24+
//"Application.ForceDriver": "", // TODO: ForceDriver should be nullable
25+
"Application.IsMouseDisabled": false,
2126
"Application.NextTabGroupKey": "F6",
27+
"Application.NextTabKey": "Tab",
2228
"Application.PrevTabGroupKey": "Shift+F6",
29+
"Application.PrevTabKey": "Shift+Tab",
2330
"Application.QuitKey": "Esc",
24-
"Application.ArrangeKey": "Ctrl+F5",
25-
"Key.Separator": "+",
2631

32+
// --------------- Colors ---------------
33+
34+
35+
// --------------- View Specific Settings ---------------
36+
"ContextMenu.DefaultKey": "Shift+F10",
37+
"FileDialog.MaxSearchResults": 10000,
38+
"FileDialogStyle.DefaultUseColors": false,
39+
"FileDialogStyle.DefaultUseUnicodeCharacters": false,
40+
41+
// --------------- Glyphs ---------------
42+
"Glyphs": {
43+
"File": "",
44+
"Folder": "",
45+
"HorizontalEllipsis": "",
46+
"VerticalFourDots": "",
47+
"CheckStateChecked": "",
48+
"CheckStateUnChecked": "",
49+
"CheckStateNone": "",
50+
"Selected": "",
51+
"UnSelected": "",
52+
"RightArrow": "",
53+
"LeftArrow": "",
54+
"DownArrow": "",
55+
"UpArrow": "",
56+
"LeftDefaultIndicator": "",
57+
"RightDefaultIndicator": "",
58+
"LeftBracket": "",
59+
"RightBracket": "",
60+
"BlocksMeterSegment": "",
61+
"ContinuousMeterSegment": "",
62+
"Stipple": "",
63+
"Diamond": "",
64+
"Close": "",
65+
"Minimize": "",
66+
"Maximize": "",
67+
"Dot": "",
68+
"BlackCircle": "",
69+
"Expand": "+",
70+
"Collapse": "-",
71+
"IdenticalTo": "",
72+
"Move": "",
73+
"SizeHorizontal": "",
74+
"SizeVertical": "",
75+
"SizeTopLeft": "",
76+
"SizeTopRight": "",
77+
"SizeBottomRight": "",
78+
"SizeBottomLeft": "",
79+
"Apple": "\uD83C\uDF4E",
80+
"AppleBMP": "",
81+
"HLine": "",
82+
"VLine": "",
83+
"HLineDbl": "",
84+
"VLineDbl": "",
85+
"HLineHvDa2": "",
86+
"VLineHvDa3": "",
87+
"HLineHvDa3": "",
88+
"HLineHvDa4": "",
89+
"VLineHvDa2": "",
90+
"VLineHvDa4": "",
91+
"HLineDa2": "",
92+
"VLineDa3": "",
93+
"HLineDa3": "",
94+
"HLineDa4": "",
95+
"VLineDa2": "",
96+
"VLineDa4": "",
97+
"HLineHv": "",
98+
"VLineHv": "",
99+
"HalfLeftLine": "",
100+
"HalfTopLine": "",
101+
"HalfRightLine": "",
102+
"HalfBottomLine": "",
103+
"HalfLeftLineHv": "",
104+
"HalfTopLineHv": "",
105+
"HalfRightLineHv": "",
106+
"HalfBottomLineLt": "",
107+
"RightSideLineLtHv": "",
108+
"BottomSideLineLtHv": "",
109+
"LeftSideLineHvLt": "",
110+
"TopSideLineHvLt": "",
111+
"ULCorner": "",
112+
"ULCornerDbl": "",
113+
"ULCornerR": "",
114+
"ULCornerHv": "",
115+
"ULCornerHvLt": "",
116+
"ULCornerLtHv": "",
117+
"ULCornerDblSingle": "",
118+
"ULCornerSingleDbl": "",
119+
"LLCorner": "",
120+
"LLCornerHv": "",
121+
"LLCornerHvLt": "",
122+
"LLCornerLtHv": "",
123+
"LLCornerDbl": "",
124+
"LLCornerSingleDbl": "",
125+
"LLCornerDblSingle": "",
126+
"LLCornerR": "",
127+
"URCorner": "",
128+
"URCornerDbl": "",
129+
"URCornerR": "",
130+
"URCornerHv": "",
131+
"URCornerHvLt": "",
132+
"URCornerLtHv": "",
133+
"URCornerDblSingle": "",
134+
"URCornerSingleDbl": "",
135+
"LRCorner": "",
136+
"LRCornerDbl": "",
137+
"LRCornerR": "",
138+
"LRCornerHv": "",
139+
"LRCornerDblSingle": "",
140+
"LRCornerSingleDbl": "",
141+
"LRCornerLtHv": "",
142+
"LRCornerHvLt": "",
143+
"LeftTee": "",
144+
"LeftTeeDblH": "",
145+
"LeftTeeDblV": "",
146+
"LeftTeeDbl": "",
147+
"LeftTeeHvH": "",
148+
"LeftTeeHvV": "",
149+
"LeftTeeHvDblH": "",
150+
"RightTee": "",
151+
"RightTeeDblH": "",
152+
"RightTeeDblV": "",
153+
"RightTeeDbl": "",
154+
"RightTeeHvH": "",
155+
"RightTeeHvV": "",
156+
"RightTeeHvDblH": "",
157+
"TopTee": "",
158+
"TopTeeDblH": "",
159+
"TopTeeDblV": "",
160+
"TopTeeDbl": "",
161+
"TopTeeHvH": "",
162+
"TopTeeHvV": "",
163+
"TopTeeHvDblH": "",
164+
"BottomTee": "",
165+
"BottomTeeDblH": "",
166+
"BottomTeeDblV": "",
167+
"BottomTeeDbl": "",
168+
"BottomTeeHvH": "",
169+
"BottomTeeHvV": "",
170+
"BottomTeeHvDblH": "",
171+
"Cross": "",
172+
"CrossDblH": "",
173+
"CrossDblV": "",
174+
"CrossDbl": "",
175+
"CrossHvH": "",
176+
"CrossHvV": "",
177+
"CrossHv": "",
178+
"ShadowVerticalStart": "",
179+
"ShadowVertical": "",
180+
"ShadowHorizontalStart": "",
181+
"ShadowHorizontal": "",
182+
"ShadowHorizontalEnd": ""
183+
},
184+
185+
// --------------- Themes -----------------
27186
"Theme": "Default",
28187
"Themes": [
29188
{

Terminal.Gui/View/Layout/DimAuto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal override int Calculate (int location, int superviewContentSize, View us
3535
int screenX4 = dimension == Dimension.Width ? Application.Screen.Width * 4 : Application.Screen.Height * 4;
3636
int autoMax = MaximumContentDim?.GetAnchor (superviewContentSize) ?? screenX4;
3737

38-
Debug.Assert (autoMin <= autoMax, "MinimumContentDim must be less than or equal to MaximumContentDim.");
38+
Debug.WriteLineIf (autoMin > autoMax, "MinimumContentDim must be less than or equal to MaximumContentDim.");
3939

4040
if (Style.FastHasFlags (DimAutoStyle.Text))
4141
{

0 commit comments

Comments
 (0)