using System.Diagnostics.CodeAnalysis; namespace Terminal.Gui.App; public static partial class Application // Driver abstractions { /// [Obsolete ("The legacy static Application object is going away.")] public static IDriver? Driver { get => ApplicationImpl.Instance.Driver; internal set => ApplicationImpl.Instance.Driver = value; } private static bool _force16Colors = false; // Resources/config.json overrides /// [ConfigurationProperty (Scope = typeof (SettingsScope))] [Obsolete ("The legacy static Application object is going away.")] public static bool Force16Colors { get => _force16Colors; set { bool oldValue = _force16Colors; _force16Colors = value; Force16ColorsChanged?.Invoke (null, new ValueChangedEventArgs (oldValue, _force16Colors)); } } /// Raised when changes. public static event EventHandler>? Force16ColorsChanged; private static string _forceDriver = string.Empty; // Resources/config.json overrides /// [ConfigurationProperty (Scope = typeof (SettingsScope))] [Obsolete ("The legacy static Application object is going away.")] public static string ForceDriver { get => _forceDriver; set { string oldValue = _forceDriver; _forceDriver = value; ForceDriverChanged?.Invoke (null, new ValueChangedEventArgs (oldValue, _forceDriver)); } } /// Raised when changes. public static event EventHandler>? ForceDriverChanged; /// [Obsolete ("The legacy static Application object is going away.")] public static List Sixel => ApplicationImpl.Instance.Sixel; /// Gets a list of types and type names that are available. /// [RequiresUnreferencedCode ("AOT")] [Obsolete ("The legacy static Application object is going away.")] 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); } }