| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System.Diagnostics.CodeAnalysis;
- namespace Terminal.Gui.App;
- public static partial class Application // Run (Begin -> Run -> Layout/Draw -> End -> Stop)
- {
- private static Key _quitKey = Key.Esc; // Resources/config.json overrides
- /// <summary>Gets or sets the key to quit the application.</summary>
- [ConfigurationProperty (Scope = typeof (SettingsScope))]
- public static Key QuitKey
- {
- get => _quitKey;
- set
- {
- Key oldValue = _quitKey;
- _quitKey = value;
- QuitKeyChanged?.Invoke (null, new ValueChangedEventArgs<Key> (oldValue, _quitKey));
- }
- }
- /// <summary>Raised when <see cref="QuitKey"/> changes.</summary>
- public static event EventHandler<ValueChangedEventArgs<Key>>? QuitKeyChanged;
- private static Key _arrangeKey = Key.F5.WithCtrl; // Resources/config.json overrides
- /// <summary>Gets or sets the key to activate arranging views using the keyboard.</summary>
- [ConfigurationProperty (Scope = typeof (SettingsScope))]
- public static Key ArrangeKey
- {
- get => _arrangeKey;
- set
- {
- Key oldValue = _arrangeKey;
- _arrangeKey = value;
- ArrangeKeyChanged?.Invoke (null, new ValueChangedEventArgs<Key> (oldValue, _arrangeKey));
- }
- }
- /// <summary>Raised when <see cref="ArrangeKey"/> changes.</summary>
- public static event EventHandler<ValueChangedEventArgs<Key>>? ArrangeKeyChanged;
- /// <inheritdoc cref="IApplication.Begin(IRunnable)"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static SessionToken Begin (IRunnable runnable) => ApplicationImpl.Instance.Begin (runnable)!;
- /// <inheritdoc cref="IApplication.PositionCursor"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static bool PositionCursor () => ApplicationImpl.Instance.PositionCursor ();
- /// <inheritdoc cref="IApplication.Run{TRunnable}(Func{Exception, bool}, string)"/>
- [RequiresUnreferencedCode ("AOT")]
- [RequiresDynamicCode ("AOT")]
- [Obsolete ("The legacy static Application object is going away.")]
- public static IApplication Run<TRunnable> (Func<Exception, bool>? errorHandler = null, string? driverName = null)
- where TRunnable : IRunnable, new() => ApplicationImpl.Instance.Run<TRunnable> (errorHandler, driverName);
- /// <inheritdoc cref="IApplication.Run(IRunnable, Func{Exception, bool})"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static void Run (IRunnable runnable, Func<Exception, bool>? errorHandler = null) => ApplicationImpl.Instance.Run (runnable, errorHandler);
- /// <inheritdoc cref="IApplication.AddTimeout"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static object? AddTimeout (TimeSpan time, Func<bool> callback) => ApplicationImpl.Instance.AddTimeout (time, callback);
- /// <inheritdoc cref="IApplication.RemoveTimeout"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static bool RemoveTimeout (object token) => ApplicationImpl.Instance.RemoveTimeout (token);
- /// <inheritdoc cref="IApplication.TimedEvents"/>
- ///
- [Obsolete ("The legacy static Application object is going away.")]
- public static ITimedEvents? TimedEvents => ApplicationImpl.Instance.TimedEvents;
- /// <inheritdoc cref="IApplication.Invoke(Action{IApplication})"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static void Invoke (Action<IApplication> action) => ApplicationImpl.Instance.Invoke (action);
- /// <inheritdoc cref="IApplication.Invoke(Action)"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static void Invoke (Action action) => ApplicationImpl.Instance.Invoke (action);
- /// <inheritdoc cref="IApplication.LayoutAndDraw"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static void LayoutAndDraw (bool forceRedraw = false) => ApplicationImpl.Instance.LayoutAndDraw (forceRedraw);
- /// <inheritdoc cref="IApplication.StopAfterFirstIteration"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static bool StopAfterFirstIteration
- {
- get => ApplicationImpl.Instance.StopAfterFirstIteration;
- set => ApplicationImpl.Instance.StopAfterFirstIteration = value;
- }
- /// <inheritdoc cref="IApplication.RequestStop(IRunnable)"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static void RequestStop (IRunnable? runnable = null) => ApplicationImpl.Instance.RequestStop (runnable);
- /// <inheritdoc cref="IApplication.End(SessionToken)"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static void End (SessionToken sessionToken) => ApplicationImpl.Instance.End (sessionToken);
- /// <inheritdoc cref="IApplication.Iteration"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static event EventHandler<EventArgs<IApplication?>>? Iteration
- {
- add => ApplicationImpl.Instance.Iteration += value;
- remove => ApplicationImpl.Instance.Iteration -= value;
- }
- /// <inheritdoc cref="IApplication.SessionBegun"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static event EventHandler<SessionTokenEventArgs>? SessionBegun
- {
- add => ApplicationImpl.Instance.SessionBegun += value;
- remove => ApplicationImpl.Instance.SessionBegun -= value;
- }
- /// <inheritdoc cref="IApplication.SessionEnded"/>
- [Obsolete ("The legacy static Application object is going away.")]
- public static event EventHandler<SessionTokenEventArgs>? SessionEnded
- {
- add => ApplicationImpl.Instance.SessionEnded += value;
- remove => ApplicationImpl.Instance.SessionEnded -= value;
- }
- }
|