mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Fixes #4391. Weird situation where ForceDriver with args doesn't persists on open scenario
* Prevents change ForceDriver if app it's already initialized and allowing also initialize with driver instead of only by driver name.
* Add dispose into FakeDriverBase and reset ForceDriver
* Moving test to Application folder
* Fix unit test
* Remove unnecessary GlobalTestSetup
* Add GC.SuppressFinalize
* Revert "Add GC.SuppressFinalize"
This reverts commit 2bd7cd7791.
* Reset MouseGrabView
* Avoid CI warnings
* Add GlobalTestSetup in all test that use Application
* Trying to fix unit test
* Reverting scope changes
* Remove UICatalog testing Run
* Force re-run CI test
* Fix merge errors
* Fix ansi for the red background color code
* Fix more ANSI color code unit tests
---------
Co-authored-by: Tig <tig@users.noreply.github.com>
81 lines
2.9 KiB
C#
81 lines
2.9 KiB
C#
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Terminal.Gui.App;
|
|
|
|
public static partial class Application // Driver abstractions
|
|
{
|
|
/// <inheritdoc cref="IApplication.Driver"/>
|
|
[Obsolete ("The legacy static Application object is going away.")]
|
|
public static IDriver? Driver
|
|
{
|
|
get => ApplicationImpl.Instance.Driver;
|
|
internal set => ApplicationImpl.Instance.Driver = value;
|
|
}
|
|
|
|
/// <inheritdoc cref="IApplication.Force16Colors"/>
|
|
[ConfigurationProperty (Scope = typeof (SettingsScope))]
|
|
[Obsolete ("The legacy static Application object is going away.")]
|
|
public static bool Force16Colors
|
|
{
|
|
get => ApplicationImpl.Instance.Force16Colors;
|
|
set => ApplicationImpl.Instance.Force16Colors = value;
|
|
}
|
|
|
|
/// <inheritdoc cref="IApplication.ForceDriver"/>
|
|
[ConfigurationProperty (Scope = typeof (SettingsScope))]
|
|
[Obsolete ("The legacy static Application object is going away.")]
|
|
public static string ForceDriver
|
|
{
|
|
get => ApplicationImpl.Instance.ForceDriver;
|
|
set
|
|
{
|
|
if (!string.IsNullOrEmpty (ApplicationImpl.Instance.ForceDriver) && value != Driver?.GetName ())
|
|
{
|
|
// ForceDriver cannot be changed if it has a valid value
|
|
return;
|
|
}
|
|
|
|
if (ApplicationImpl.Instance.Initialized && value != Driver?.GetName ())
|
|
{
|
|
throw new InvalidOperationException ($"The {nameof (ForceDriver)} can only be set before initialized.");
|
|
}
|
|
|
|
ApplicationImpl.Instance.ForceDriver = value;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc cref="IApplication.Sixel"/>
|
|
[Obsolete ("The legacy static Application object is going away.")]
|
|
public static List<SixelToRender> Sixel => ApplicationImpl.Instance.Sixel;
|
|
|
|
/// <summary>Gets a list of <see cref="IDriver"/> types and type names that are available.</summary>
|
|
/// <returns></returns>
|
|
[RequiresUnreferencedCode ("AOT")]
|
|
[Obsolete ("The legacy static Application object is going away.")]
|
|
public static (List<Type?>, List<string?>) GetDriverTypes ()
|
|
{
|
|
// use reflection to get the list of drivers
|
|
List<Type?> driverTypes = new ();
|
|
|
|
// Only inspect the IDriver assembly
|
|
var asm = typeof (IDriver).Assembly;
|
|
|
|
foreach (Type? type in asm.GetTypes ())
|
|
{
|
|
if (typeof (IDriver).IsAssignableFrom (type) && type is { IsAbstract: false, IsClass: true })
|
|
{
|
|
driverTypes.Add (type);
|
|
}
|
|
}
|
|
|
|
List<string?> driverTypeNames = driverTypes
|
|
.Where (d => !typeof (IDriver).IsAssignableFrom (d))
|
|
.Select (d => d!.Name)
|
|
.Union (["dotnet", "windows", "unix", "fake"])
|
|
.ToList ()!;
|
|
|
|
return (driverTypes, driverTypeNames);
|
|
}
|
|
}
|