#nullable enable
using System.Diagnostics.CodeAnalysis;
namespace Terminal.Gui.App;
public static partial class Application // Driver abstractions
{
///
public static IDriver? Driver
{
get => ApplicationImpl.Instance.Driver;
internal set => ApplicationImpl.Instance.Driver = value;
}
///
[ConfigurationProperty (Scope = typeof (SettingsScope))]
public static bool Force16Colors
{
get => ApplicationImpl.Instance.Force16Colors;
set => ApplicationImpl.Instance.Force16Colors = value;
}
///
[ConfigurationProperty (Scope = typeof (SettingsScope))]
public static string ForceDriver
{
get => ApplicationImpl.Instance.ForceDriver;
set => ApplicationImpl.Instance.ForceDriver = value;
}
///
public static List Sixel => ApplicationImpl.Instance.Sixel;
/// Gets a list of types and type names that are available.
///
[RequiresUnreferencedCode ("AOT")]
public static (List, List) GetDriverTypes ()
{
// use reflection to get the list of drivers
List 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 driverTypeNames = driverTypes
.Where (d => !typeof (IDriver).IsAssignableFrom (d))
.Select (d => d!.Name)
.Union (["dotnet", "windows", "unix", "fake"])
.ToList ()!;
return (driverTypes, driverTypeNames);
}
}