Skip to content

Commit

Permalink
Merge branch 'v2_develop' into sixel-encoder-tinkering
Browse files Browse the repository at this point in the history
  • Loading branch information
tznind authored Sep 26, 2024
2 parents 6149c5f + 10bdd4b commit 050db7a
Show file tree
Hide file tree
Showing 198 changed files with 8,096 additions and 8,002 deletions.
2 changes: 1 addition & 1 deletion NativeAot/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"NativeAot": {
"commandName": "Project"
},
"WSL : UICatalog": {
"WSL : NativeAot": {
"commandName": "Executable",
"executablePath": "wsl",
"commandLineArgs": "dotnet NativeAot.dll",
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

* The current, stable, release of Terminal.Gui v1 is [![Version](https://img.shields.io/nuget/v/Terminal.Gui.svg)](https://www.nuget.org/packages/Terminal.Gui).
* The current `prealpha` release of Terminal.Gui v2 can be found on [Nuget](https://www.nuget.org/packages/Terminal.Gui).
* Developers starting new TUI projects are encouraged to target `v2`. The API is signifcantly changed, and significantly improved. There will be breaking changes in the API before Beta, but the core API is stable.
* Developers starting new TUI projects are encouraged to target `v2`. The API is significantly changed, and significantly improved. There will be breaking changes in the API before Beta, but the core API is stable.
* `v1` is in maintenance mode and we will only accept PRs for issues impacting existing functionality.

**Terminal.Gui**: A toolkit for building rich console apps for .NET, .NET Core, and Mono that works on Windows, the Mac, and Linux/Unix.
Expand All @@ -35,9 +35,9 @@ dotnet run
* [API Documentation](https://gui-cs.github.io/Terminal.GuiV2Docs/api/Terminal.Gui.html)
* [Documentation Home](https://gui-cs.github.io/Terminal.GuiV2Docs)

The above documentation matches the most recent Nuget release from the `v2_develop` branch. Get the [v1 documentation here](This is the v2 API documentation. For v1 go here: https://gui-cs.github.io/Terminal.Gui/api/Terminal.Gui.html)
The above documentation matches the most recent Nuget release from the `v2_develop` branch. Get the [v1 documentation here](https://gui-cs.github.io/Terminal.Gui/api/Terminal.Gui.html).

See the [`Terminal.Gui/` README](https://github.com/gui-cs/Terminal.Gui/tree/master/Terminal.Gui) for an overview of how the library is structured.
See the [`Terminal.Gui/`README](https://github.com/gui-cs/Terminal.Gui/tree/master/Terminal.Gui) for an overview of how the library is structured.

## Showcase & Examples

Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Application/Application.Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static partial class Application // Driver abstractions

/// <summary>
/// Gets or sets whether <see cref="Application.Driver"/> will be forced to output only the 16 colors defined in
/// <see cref="ColorName"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
/// <see cref="ColorName16"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
/// as long as the selected <see cref="ConsoleDriver"/> supports TrueColor.
/// </summary>
[SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
Expand Down
12 changes: 9 additions & 3 deletions Terminal.Gui/Application/Application.Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal static void InternalInit (
if (!calledViaRunT)
{
// Reset all class variables (Application is a singleton).
ResetState ();
ResetState (ignoreDisposed: true);
}

Navigation = new ();
Expand Down Expand Up @@ -198,10 +198,16 @@ internal static void InternalInit (
public static void Shutdown ()
{
// TODO: Throw an exception if Init hasn't been called.

bool wasInitialized = IsInitialized;
ResetState ();
PrintJsonErrors ();
bool init = IsInitialized;
InitializedChanged?.Invoke (null, new (in init));

if (wasInitialized)
{
bool init = IsInitialized;
InitializedChanged?.Invoke (null, new (in init));
}
}

/// <summary>
Expand Down
113 changes: 59 additions & 54 deletions Terminal.Gui/Application/Application.Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ public static partial class Application // Keyboard handling
{
private static Key _nextTabGroupKey = Key.F6; // Resources/config.json overrrides
private static Key _nextTabKey = Key.Tab; // Resources/config.json overrrides

private static Key _prevTabGroupKey = Key.F6.WithShift; // Resources/config.json overrrides

private static Key _prevTabKey = Key.Tab.WithShift; // Resources/config.json overrrides

private static Key _quitKey = Key.Esc; // Resources/config.json overrrides
private static Key _arrangeKey = Key.F5.WithCtrl; // Resources/config.json overrrides

static Application () { AddApplicationKeyBindings (); }

Check warning on line 13 in Terminal.Gui/Application/Application.Keyboard.cs

View workflow job for this annotation

GitHub Actions / build_release

Non-nullable field 'Sixel' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 13 in Terminal.Gui/Application/Application.Keyboard.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

Non-nullable field 'Sixel' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 13 in Terminal.Gui/Application/Application.Keyboard.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (macos-latest)

Non-nullable field 'Sixel' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Expand Down Expand Up @@ -97,7 +95,7 @@ public static bool OnKeyDown (Key keyEvent)
return true;
}

if (Current is null)
if (Top is null)
{
foreach (Toplevel topLevel in TopLevels.ToList ())
{
Expand All @@ -114,7 +112,7 @@ public static bool OnKeyDown (Key keyEvent)
}
else
{
if (Current.NewKeyDownEvent (keyEvent))
if (Top.NewKeyDownEvent (keyEvent))
{
return true;
}
Expand Down Expand Up @@ -155,7 +153,7 @@ public static bool OnKeyDown (Key keyEvent)
}

/// <summary>
/// INTENRAL method to invoke one of the commands in <see cref="CommandImplementations"/>
/// INTENRAL method to invoke one of the commands in <see cref="CommandImplementations"/>
/// </summary>
/// <param name="command"></param>
/// <param name="keyEvent"></param>
Expand All @@ -174,6 +172,7 @@ public static bool OnKeyDown (Key keyEvent)
if (CommandImplementations.TryGetValue (command, out Func<CommandContext, bool?>? implementation))
{
var context = new CommandContext (command, keyEvent, appBinding); // Create the context here

return implementation (context);
}

Expand Down Expand Up @@ -262,24 +261,31 @@ public static Key QuitKey
}
}

/// <summary>Gets or sets the key to activate arranging views using the keyboard.</summary>
[SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
public static Key ArrangeKey
{
get => _arrangeKey;
set
{
if (_arrangeKey != value)
{
ReplaceKey (_arrangeKey, value);
_arrangeKey = value;
}
}
}

internal static void AddApplicationKeyBindings ()
{
CommandImplementations = new ();

// Things this view knows how to do
AddCommand (
Command.QuitToplevel, // TODO: IRunnable: Rename to Command.Quit to make more generic.
Command.Quit,
static () =>
{
if (ApplicationOverlapped.OverlappedTop is { })
{
RequestStop (Current!);
}
else
{
RequestStop ();
}
RequestStop ();
return true;
}
);
Expand All @@ -295,54 +301,50 @@ internal static void AddApplicationKeyBindings ()
);

AddCommand (
Command.NextView,
Command.NextTabStop,
static () => Navigation?.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop));

AddCommand (
Command.PreviousView,
Command.PreviousTabStop,
static () => Navigation?.AdvanceFocus (NavigationDirection.Backward, TabBehavior.TabStop));

AddCommand (
Command.NextViewOrTop,
static () =>
{
// TODO: This OverlapppedTop tomfoolery goes away in addressing #2491
if (ApplicationOverlapped.OverlappedTop is { })
{
ApplicationOverlapped.OverlappedMoveNext ();
return true;
}
Command.NextTabGroup,
static () => Navigation?.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabGroup));

return Navigation?.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabGroup);
}
);
AddCommand (
Command.PreviousTabGroup,
static () => Navigation?.AdvanceFocus (NavigationDirection.Backward, TabBehavior.TabGroup));

AddCommand (
Command.PreviousViewOrTop,
Command.Refresh,
static () =>
{
// TODO: This OverlapppedTop tomfoolery goes away in addressing #2491
if (ApplicationOverlapped.OverlappedTop is { })
{
ApplicationOverlapped.OverlappedMovePrevious ();
return true;
}
Refresh ();
return Navigation?.AdvanceFocus (NavigationDirection.Backward, TabBehavior.TabGroup);
return true;
}
);

AddCommand (
Command.Refresh,
Command.Edit,
static () =>
{
Refresh ();
View? viewToArrange = Navigation?.GetFocused ();
return true;
}
);
// Go up the superview hierarchy and find the first that is not ViewArrangement.Fixed
while (viewToArrange is { SuperView: { }, Arrangement: ViewArrangement.Fixed })
{
viewToArrange = viewToArrange.SuperView;
}
if (viewToArrange is { })
{
return viewToArrange.Border?.EnterArrangeMode (ViewArrangement.Fixed);
}
return false;
});

KeyBindings.Clear ();

Expand All @@ -352,18 +354,21 @@ internal static void AddApplicationKeyBindings ()
NextTabGroupKey = Key.F6;
PrevTabGroupKey = Key.F6.WithShift;
QuitKey = Key.Esc;
ArrangeKey = Key.F5.WithCtrl;

KeyBindings.Add (QuitKey, KeyBindingScope.Application, Command.Quit);

KeyBindings.Add (QuitKey, KeyBindingScope.Application, Command.QuitToplevel);
KeyBindings.Add (Key.CursorRight, KeyBindingScope.Application, Command.NextTabStop);
KeyBindings.Add (Key.CursorDown, KeyBindingScope.Application, Command.NextTabStop);
KeyBindings.Add (Key.CursorLeft, KeyBindingScope.Application, Command.PreviousTabStop);
KeyBindings.Add (Key.CursorUp, KeyBindingScope.Application, Command.PreviousTabStop);
KeyBindings.Add (NextTabKey, KeyBindingScope.Application, Command.NextTabStop);
KeyBindings.Add (PrevTabKey, KeyBindingScope.Application, Command.PreviousTabStop);

KeyBindings.Add (Key.CursorRight, KeyBindingScope.Application, Command.NextView);
KeyBindings.Add (Key.CursorDown, KeyBindingScope.Application, Command.NextView);
KeyBindings.Add (Key.CursorLeft, KeyBindingScope.Application, Command.PreviousView);
KeyBindings.Add (Key.CursorUp, KeyBindingScope.Application, Command.PreviousView);
KeyBindings.Add (NextTabKey, KeyBindingScope.Application, Command.NextView);
KeyBindings.Add (PrevTabKey, KeyBindingScope.Application, Command.PreviousView);
KeyBindings.Add (NextTabGroupKey, KeyBindingScope.Application, Command.NextTabGroup);
KeyBindings.Add (PrevTabGroupKey, KeyBindingScope.Application, Command.PreviousTabGroup);

KeyBindings.Add (NextTabGroupKey, KeyBindingScope.Application, Command.NextViewOrTop);
KeyBindings.Add (PrevTabGroupKey, KeyBindingScope.Application, Command.PreviousViewOrTop);
KeyBindings.Add (ArrangeKey, KeyBindingScope.Application, Command.Edit);

// TODO: Refresh Key should be configurable
KeyBindings.Add (Key.F5, KeyBindingScope.Application, Command.Refresh);
Expand Down
Loading

0 comments on commit 050db7a

Please sign in to comment.