diff --git a/Terminal.Gui/Input/ShortcutHelper.cs b/Terminal.Gui/Input/ShortcutHelper.cs
index 5bd8ba05a..ea4aa2d8b 100644
--- a/Terminal.Gui/Input/ShortcutHelper.cs
+++ b/Terminal.Gui/Input/ShortcutHelper.cs
@@ -2,6 +2,7 @@
namespace Terminal.Gui;
+// TODO: Nuke when #2975 is completed
/// Represents a helper to manipulate shortcut keys used on views.
public class ShortcutHelper
{
@@ -115,8 +116,6 @@ public class ShortcutHelper
return true;
}
- Debug.WriteLine ($"WARNING: {Key.ToString (key)} is not a valid shortcut key.");
-
return false;
}
diff --git a/Terminal.Gui/Resources/config.json b/Terminal.Gui/Resources/config.json
index 8380a14f5..3af8aaa85 100644
--- a/Terminal.Gui/Resources/config.json
+++ b/Terminal.Gui/Resources/config.json
@@ -10,7 +10,8 @@
// note that not all values here will be recreated (e.g. the Light and Dark themes and any property initialized
// null).
//
- "$schema": "https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json",
+ // TODO: V2 - Reference via http
+ "$schema": "../../docfx/schemas/tui-config-schema.json",
// Set this to true in a .config file to be loaded to cause JSON parsing errors
// to throw exceptions.
@@ -18,8 +19,7 @@
"Application.AlternateBackwardKey": "Ctrl+PageUp",
"Application.AlternateForwardKey": "Ctrl+PageDown",
- "Application.QuitKey": "Ctrl+Q",
- "Application.IsMouseDisabled": false,
+ "Application.QuitKey": "Esc",
"Theme": "Default",
"Themes": [
{
diff --git a/Terminal.Gui/View/ViewKeyboard.cs b/Terminal.Gui/View/ViewKeyboard.cs
index d1f04c654..508bbd9da 100644
--- a/Terminal.Gui/View/ViewKeyboard.cs
+++ b/Terminal.Gui/View/ViewKeyboard.cs
@@ -633,6 +633,7 @@ public partial class View
/// See for an overview of Terminal.Gui keyboard APIs.
///
/// Contains the details about the key that produced the event.
+ /// The scope.
///
/// if the key press was not handled. if the keypress was handled
/// and no other view should see it.
@@ -744,7 +745,8 @@ public partial class View
///
/// Returns true if Key is bound in this view heirarchy. For debugging
///
- ///
+ /// The key to test.
+ /// Returns the view the key is bound to.
///
public bool IsHotKeyKeyBound (Key key, out View boundView)
{
@@ -779,6 +781,7 @@ public partial class View
/// See for an overview of Terminal.Gui keyboard APIs.
///
/// The key event passed.
+ /// The scope.
///
/// if no command was bound the . if
/// commands were invoked and at least one handled the command. if commands were invoked and at
diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs
index 2ab97a98e..b3e3730f9 100644
--- a/Terminal.Gui/Views/Dialog.cs
+++ b/Terminal.Gui/Views/Dialog.cs
@@ -10,8 +10,8 @@ namespace Terminal.Gui;
///
/// To run the modally, create the , and pass it to
/// . This will execute the dialog until
-/// it terminates via the
-/// [ESC] or [CTRL-Q] key, or when one of the views or buttons added to the dialog calls
+/// it terminates via the (`Esc` by default),
+/// or when one of the views or buttons added to the dialog calls
/// .
///
public class Dialog : Window
diff --git a/Terminal.Gui/Views/Line.cs b/Terminal.Gui/Views/Line.cs
index 95a8287c8..6a25fa55b 100644
--- a/Terminal.Gui/Views/Line.cs
+++ b/Terminal.Gui/Views/Line.cs
@@ -11,8 +11,6 @@ public class Line : View
SuperViewRendersLineCanvas = true;
}
- public Dim Length { get; set; } = Dim.Fill ();
-
private Orientation _orientation;
///
@@ -30,12 +28,9 @@ public class Line : View
{
case Orientation.Horizontal:
Height = 1;
- // Width = Length;
- //Border.Thickness = new Thickness (1, 0, 1, 0);
break;
case Orientation.Vertical:
- Height = Length;
Width = 1;
break;
diff --git a/Terminal.Gui/Views/Shortcut.cs b/Terminal.Gui/Views/Shortcut.cs
index 7290537a0..08c7e0a00 100644
--- a/Terminal.Gui/Views/Shortcut.cs
+++ b/Terminal.Gui/Views/Shortcut.cs
@@ -631,7 +631,7 @@ public class Shortcut : View
/// - if the user presses the HotKey specified by CommandView
/// - if HasFocus and the user presses Space or Enter (or any other key bound to Command.Accept).
///
- protected new bool? OnAccept (CommandContext ctx)
+ protected bool? OnAccept (CommandContext ctx)
{
var cancel = false;
diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs
index 6dca6f8c4..1b96bda0d 100644
--- a/Terminal.Gui/Views/Slider.cs
+++ b/Terminal.Gui/Views/Slider.cs
@@ -1743,7 +1743,7 @@ public class Slider : View
return true;
}
- internal bool Accept ()
+ internal new bool Accept ()
{
SetFocusedOption ();
diff --git a/UICatalog/Resources/config.json b/UICatalog/Resources/config.json
index 2accf1b4d..342146a2d 100644
--- a/UICatalog/Resources/config.json
+++ b/UICatalog/Resources/config.json
@@ -1,6 +1,5 @@
{
"$schema": "https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json",
- "Application.QuitKey": "Esc",
"FileDialog.MaxSearchResults": 10000,
"FileDialogStyle.DefaultUseColors": false,
"FileDialogStyle.DefaultUseUnicodeCharacters": false,
diff --git a/UICatalog/Scenario.cs b/UICatalog/Scenario.cs
index df8e510d9..c5a724ba7 100644
--- a/UICatalog/Scenario.cs
+++ b/UICatalog/Scenario.cs
@@ -271,7 +271,7 @@ public class Scenario : IDisposable
/// Defines the category names used to categorize a
[AttributeUsage (AttributeTargets.Class, AllowMultiple = true)]
- public class ScenarioCategory (string Name) : System.Attribute
+ public class ScenarioCategory (string name) : System.Attribute
{
/// Static helper function to get the Categories given a Type
///
@@ -291,15 +291,15 @@ public class Scenario : IDisposable
public static string GetName (Type t) { return ((ScenarioCategory)GetCustomAttributes (t) [0]).Name; }
/// Category Name
- public string Name { get; set; } = Name;
+ public string Name { get; set; } = name;
}
/// Defines the metadata (Name and Description) for a
[AttributeUsage (AttributeTargets.Class)]
- public class ScenarioMetadata (string Name, string Description) : System.Attribute
+ public class ScenarioMetadata (string name, string description) : System.Attribute
{
/// Description
- public string Description { get; set; } = Description;
+ public string Description { get; set; } = description;
/// Static helper function to get the Description given a Type
///
@@ -312,6 +312,6 @@ public class Scenario : IDisposable
public static string GetName (Type t) { return ((ScenarioMetadata)GetCustomAttributes (t) [0]).Name; }
/// Name
- public string Name { get; set; } = Name;
+ public string Name { get; set; } = name;
}
}
diff --git a/UICatalog/Scenarios/KeyBindings.cs b/UICatalog/Scenarios/KeyBindings.cs
index 3daa8c3c9..98350d564 100644
--- a/UICatalog/Scenarios/KeyBindings.cs
+++ b/UICatalog/Scenarios/KeyBindings.cs
@@ -54,11 +54,13 @@ public sealed class KeyBindings : Scenario
Height = Dim.Auto (DimAutoStyle.Text),
HotKeySpecifier = (Rune)'_',
Title = "_KeyBindingsDemo",
- Text = @"These keys will cause this view to show a message box:
-- Hotkey: k, K, Alt-K, Alt-Shift-K
-- Focused: F3
-- Application: F4
-Pressing Ctrl-Q will cause it to quit the app.",
+ Text = $"""
+ These keys will cause this view to show a message box:
+ - Hotkey: k, K, Alt-K, Alt-Shift-K
+ - Focused: F3
+ - Application: F4
+ Pressing Esc or {Application.QuitKey} will cause it to quit the app.
+ """,
BorderStyle = LineStyle.Dashed
};
appWindow.Add (keyBindingsDemo);
diff --git a/UICatalog/Scenarios/MenuBarScenario.cs b/UICatalog/Scenarios/MenuBarScenario.cs
index bef318f68..4dce938b4 100644
--- a/UICatalog/Scenarios/MenuBarScenario.cs
+++ b/UICatalog/Scenarios/MenuBarScenario.cs
@@ -57,16 +57,14 @@ public class MenuBarScenario : Scenario
),
null,
- // Don't use Ctrl-Q so we can disambiguate between quitting and closing the toplevel
+ // Don't use Application.Quit so we can disambiguate between quitting and closing the toplevel
new (
"_Quit",
"",
() => actionFn ("Quit"),
null,
null,
- KeyCode.AltMask
- | KeyCode.CtrlMask
- | KeyCode.Q
+ KeyCode.CtrlMask | KeyCode.Q
)
}
),
diff --git a/UICatalog/Scenarios/SingleBackgroundWorker.cs b/UICatalog/Scenarios/SingleBackgroundWorker.cs
index 896cac096..3e990779f 100644
--- a/UICatalog/Scenarios/SingleBackgroundWorker.cs
+++ b/UICatalog/Scenarios/SingleBackgroundWorker.cs
@@ -203,7 +203,7 @@ public class SingleBackgroundWorker : Scenario
_top.KeyDown += (s, e) =>
{
- // Prevents Ctrl+Q from closing this.
+ // Prevents App.QuitKey from closing this.
// Only Ctrl+C is allowed.
if (e == Application.QuitKey)
{
diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs
index 12ccb9a3b..fca7a0c3e 100644
--- a/UICatalog/UICatalog.cs
+++ b/UICatalog/UICatalog.cs
@@ -484,7 +484,7 @@ internal class UICatalogApp
{
((CheckBox)ShForce16Colors.CommandView).Checked =
Application.Force16Colors = (bool)!((CheckBox)ShForce16Colors.CommandView).Checked!;
- MiForce16Colors.Checked = Application.Force16Colors;
+ MiForce16Colors!.Checked = Application.Force16Colors;
Application.Refresh ();
};
diff --git a/UnitTests/Application/KeyboardTests.cs b/UnitTests/Application/KeyboardTests.cs
index 799163104..13f29a496 100644
--- a/UnitTests/Application/KeyboardTests.cs
+++ b/UnitTests/Application/KeyboardTests.cs
@@ -36,31 +36,32 @@ public class KeyboardTests
Application.Begin (top);
top.Running = true;
- Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
- Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
+ Key prevKey = Application.QuitKey;
+
+ Application.OnKeyDown (Application.QuitKey);
Assert.True (isQuiting);
isQuiting = false;
- Application.OnKeyDown (Key.Q.WithCtrl);
+ Application.OnKeyDown (Application.QuitKey);
Assert.True (isQuiting);
isQuiting = false;
Application.QuitKey = Key.C.WithCtrl;
- Application.Driver.SendKeys ('Q', ConsoleKey.Q, false, false, true);
+ Application.OnKeyDown (prevKey); // Should not quit
Assert.False (isQuiting);
- Application.OnKeyDown (Key.Q.WithCtrl);
+ Application.OnKeyDown (Key.Q.WithCtrl);// Should not quit
Assert.False (isQuiting);
Application.OnKeyDown (Application.QuitKey);
Assert.True (isQuiting);
// Reset the QuitKey to avoid throws errors on another tests
- Application.QuitKey = Key.Q.WithCtrl;
+ Application.QuitKey = prevKey;
top.Dispose ();
}
[Fact]
- public void QuitKey_Default_Is_CtrlQ ()
+ public void QuitKey_Default_Is_Esc ()
{
Application.ResetState (true);
// Before Init
@@ -68,7 +69,7 @@ public class KeyboardTests
Application.Init (new FakeDriver ());
// After Init
- Assert.Equal (Key.Q.WithCtrl, Application.QuitKey);
+ Assert.Equal (Key.Esc, Application.QuitKey);
Application.Shutdown();
}
@@ -397,6 +398,8 @@ public class KeyboardTests
// Setup some fake keypresses (This)
var input = "Tests";
+ Key originalQuitKey = Application.QuitKey;
+ Application.QuitKey = Key.Q.WithCtrl;
// Put a control-q in at the end
FakeConsole.MockKeyPresses.Push (new ConsoleKeyInfo ('Q', ConsoleKey.Q, false, false, true));
@@ -458,6 +461,7 @@ public class KeyboardTests
};
Application.Run (top);
+ Application.QuitKey = originalQuitKey;
// Input string should match output
Assert.Equal (input, output);
diff --git a/UnitTests/Configuration/ConfigurationMangerTests.cs b/UnitTests/Configuration/ConfigurationMangerTests.cs
index b1b7f2150..6ecfbada5 100644
--- a/UnitTests/Configuration/ConfigurationMangerTests.cs
+++ b/UnitTests/Configuration/ConfigurationMangerTests.cs
@@ -166,7 +166,7 @@ public class ConfigurationManagerTests
fired = true;
// assert
- Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
+ Assert.Equal (Key.Esc, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
Assert.Equal (
KeyCode.PageDown | KeyCode.CtrlMask,
@@ -250,7 +250,7 @@ public class ConfigurationManagerTests
// assert
Assert.NotEmpty (Themes);
Assert.Equal ("Default", Themes.Theme);
- Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
+ Assert.Equal (Key.Esc, Application.QuitKey);
Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey.KeyCode);
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey.KeyCode);
Assert.False (Application.IsMouseDisabled);
@@ -271,7 +271,7 @@ public class ConfigurationManagerTests
// assert
Assert.NotEmpty (Themes);
Assert.Equal ("Default", Themes.Theme);
- Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
+ Assert.Equal (KeyCode.Esc, Application.QuitKey.KeyCode);
Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey.KeyCode);
Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey.KeyCode);
Assert.False (Application.IsMouseDisabled);
@@ -436,9 +436,6 @@ public class ConfigurationManagerTests
public void TestConfigurationManagerInitDriver ()
{
Assert.Equal ("Default", Themes.Theme);
- Assert.True (Themes.ContainsKey ("Default"));
-
- Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
Assert.Equal (new Color (Color.White), Colors.ColorSchemes ["Base"].Normal.Foreground);
Assert.Equal (new Color (Color.Blue), Colors.ColorSchemes ["Base"].Normal.Background);
@@ -804,7 +801,7 @@ public class ConfigurationManagerTests
Settings.Update (json, "TestConfigurationManagerUpdateFromJson");
- Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
+ Assert.Equal (KeyCode.Esc, Application.QuitKey.KeyCode);
Assert.Equal (KeyCode.Z | KeyCode.AltMask, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
Assert.Equal ("Default", Themes.Theme);
diff --git a/UnitTests/Configuration/SettingsScopeTests.cs b/UnitTests/Configuration/SettingsScopeTests.cs
index 04ce56862..58ce88e50 100644
--- a/UnitTests/Configuration/SettingsScopeTests.cs
+++ b/UnitTests/Configuration/SettingsScopeTests.cs
@@ -9,7 +9,7 @@ public class SettingsScopeTests
public void Apply_ShouldApplyProperties ()
{
// arrange
- Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
+ Assert.Equal (Key.Esc, (Key)Settings ["Application.QuitKey"].PropertyValue);
Assert.Equal (
KeyCode.PageDown | KeyCode.CtrlMask,
diff --git a/UnitTests/UICatalog/ScenarioTests.cs b/UnitTests/UICatalog/ScenarioTests.cs
index af6560799..30b0d7cc8 100644
--- a/UnitTests/UICatalog/ScenarioTests.cs
+++ b/UnitTests/UICatalog/ScenarioTests.cs
@@ -7,8 +7,6 @@ namespace UICatalog.Tests;
public class ScenarioTests : TestsAllViews
{
- private readonly ITestOutputHelper _output;
-
public ScenarioTests (ITestOutputHelper output)
{
#if DEBUG_IDISPOSABLE
@@ -17,11 +15,7 @@ public class ScenarioTests : TestsAllViews
_output = output;
}
- public static IEnumerable