mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
For some reason, we went real hard on an architecture where the settings object contained the key bindings handler for the terminal. To make this work, we had to wind it through tons of layers: `TermControl`, `ControlInteractivity`, `ControlCore` (which saved it on `ControlSettings`), `ControlSettings`. Of course, because we have no clear delineation of concerns at the App layer this required us to put the bindings into the Settings Cache[^1]. Well, `TermControl` used `ControlCore` to get the Settings, to get the Bindings, to dispatch keys. Yes, `TermControl` stored `IKeyBindings` down three layers _only to fish it back out and use it itself._ There is one place in the application where `TermControl`s are hooked up to their owners. Instead of passing the key bindings dispatcher in through nine hundred layers, we can just set it once--definitively!-- there. [^1]: This was the last thing that made the settings cache page-specific...
166 lines
7.6 KiB
Plaintext
166 lines
7.6 KiB
Plaintext
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
import "IKeyBindings.idl";
|
|
import "IMouseWheelListener.idl";
|
|
import "IControlSettings.idl";
|
|
import "ControlInteractivity.idl";
|
|
import "EventArgs.idl";
|
|
import "ICoreState.idl";
|
|
import "ControlCore.idl";
|
|
|
|
namespace Microsoft.Terminal.Control
|
|
{
|
|
// This matches the definition in M.T.UI.
|
|
// Having it here prevents us from having to refer to M.T.UI in **all consuming projects**.
|
|
// WinRT is a trip.
|
|
[uuid("0ddf4edc-3fda-4dee-97ca-a417ee3dd510")]
|
|
interface IDirectKeyListener {
|
|
Boolean OnDirectKeyEvent(UInt32 vkey, UInt8 scanCode, Boolean down);
|
|
}
|
|
|
|
enum CursorDisplayState
|
|
{
|
|
Default,
|
|
Shown
|
|
};
|
|
|
|
[default_interface] runtimeclass TermControl : Windows.UI.Xaml.Controls.UserControl,
|
|
IDirectKeyListener,
|
|
IMouseWheelListener,
|
|
ICoreState,
|
|
Windows.UI.Xaml.Data.INotifyPropertyChanged
|
|
{
|
|
TermControl(ControlInteractivity content);
|
|
|
|
TermControl(IControlSettings settings,
|
|
IControlAppearance unfocusedAppearance,
|
|
Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);
|
|
|
|
static TermControl NewControlByAttachingContent(ControlInteractivity content);
|
|
|
|
static Windows.Foundation.Size GetProposedDimensions(IControlSettings settings,
|
|
UInt32 dpi,
|
|
Int32 commandlineCols,
|
|
Int32 commandlineRows);
|
|
|
|
void UpdateControlSettings(IControlSettings settings);
|
|
void UpdateControlSettings(IControlSettings settings, IControlAppearance unfocusedAppearance);
|
|
|
|
Microsoft.Terminal.TerminalConnection.ITerminalConnection Connection;
|
|
|
|
UInt64 ContentId{ get; };
|
|
|
|
Microsoft.Terminal.Control.IControlSettings Settings { get; };
|
|
|
|
// MIDL 3 does not support setter-only properties.
|
|
void KeyBindings(Microsoft.Terminal.Control.IKeyBindings KeyBindings);
|
|
|
|
event Windows.Foundation.TypedEventHandler<Object, TitleChangedEventArgs> TitleChanged;
|
|
event Windows.Foundation.TypedEventHandler<Object, WriteToClipboardEventArgs> WriteToClipboard;
|
|
event Windows.Foundation.TypedEventHandler<Object, PasteFromClipboardEventArgs> PasteFromClipboard;
|
|
event Windows.Foundation.TypedEventHandler<Object, OpenHyperlinkEventArgs> OpenHyperlink;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> SetTaskbarProgress;
|
|
event Windows.Foundation.TypedEventHandler<Object, NoticeEventArgs> RaiseNotice;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> WarningBell;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> HidePointerCursor;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> RestorePointerCursor;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> ReadOnlyChanged;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> FocusFollowMouseRequested;
|
|
event Windows.Foundation.TypedEventHandler<Object, WindowSizeChangedEventArgs> WindowSizeChanged;
|
|
|
|
event Windows.Foundation.TypedEventHandler<Object, CompletionsChangedEventArgs> CompletionsChanged;
|
|
|
|
event Windows.Foundation.TypedEventHandler<Object, KeySentEventArgs> KeySent;
|
|
event Windows.Foundation.TypedEventHandler<Object, CharSentEventArgs> CharSent;
|
|
event Windows.Foundation.TypedEventHandler<Object, StringSentEventArgs> StringSent;
|
|
event Windows.Foundation.TypedEventHandler<Object, SearchMissingCommandEventArgs> SearchMissingCommand;
|
|
|
|
|
|
Microsoft.UI.Xaml.Controls.CommandBarFlyout ContextMenu { get; };
|
|
Microsoft.UI.Xaml.Controls.CommandBarFlyout SelectionContextMenu { get; };
|
|
Windows.UI.Xaml.Controls.MenuFlyout QuickFixMenu { get; };
|
|
|
|
event Windows.Foundation.TypedEventHandler<TermControl, Windows.UI.Xaml.RoutedEventArgs> Initialized;
|
|
// This is an event handler forwarder for the underlying connection.
|
|
// We expose this and ConnectionState here so that it might eventually be data bound.
|
|
event Windows.Foundation.TypedEventHandler<Object, IInspectable> ConnectionStateChanged;
|
|
|
|
event Windows.Foundation.TypedEventHandler<Object, ShowWindowArgs> ShowWindowChanged;
|
|
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> CloseTerminalRequested;
|
|
event Windows.Foundation.TypedEventHandler<Object, Object> RestartTerminalRequested;
|
|
|
|
Boolean CopySelectionToClipboard(Boolean dismissSelection, Boolean singleLine, Boolean withControlSequences, CopyFormat formats);
|
|
void PasteTextFromClipboard();
|
|
void SelectAll();
|
|
Boolean ToggleBlockSelection();
|
|
void ToggleMarkMode();
|
|
Boolean SwitchSelectionEndpoint();
|
|
Boolean ExpandSelectionToWord();
|
|
void ClearBuffer(ClearBufferType clearType);
|
|
void RestoreFromPath(String path);
|
|
void PersistToPath(String path);
|
|
void OpenCWD();
|
|
void Close();
|
|
Windows.Foundation.Size CharacterDimensions { get; };
|
|
Windows.Foundation.Size MinimumSize { get; };
|
|
Single SnapDimensionToGrid(Boolean widthOrHeight, Single dimension);
|
|
|
|
void WindowVisibilityChanged(Boolean showOrHide);
|
|
|
|
void ScrollViewport(Int32 viewTop);
|
|
|
|
void CreateSearchBoxControl();
|
|
Boolean SearchBoxEditInFocus();
|
|
|
|
void SearchMatch(Boolean goForward);
|
|
|
|
void AdjustFontSize(Single fontSizeDelta);
|
|
void ResetFontSize();
|
|
|
|
void ToggleShaderEffects();
|
|
void SendInput(String input);
|
|
Boolean RawWriteKeyEvent(UInt16 vkey, UInt16 scanCode, Microsoft.Terminal.Core.ControlKeyStates modifiers, Boolean keyDown);
|
|
Boolean RawWriteChar(Char character, UInt16 scanCode, Microsoft.Terminal.Core.ControlKeyStates modifiers);
|
|
void RawWriteString(String text);
|
|
|
|
void BellLightOn();
|
|
|
|
Boolean ReadOnly { get; };
|
|
void ToggleReadOnly();
|
|
void SetReadOnly(Boolean readOnlyState);
|
|
|
|
String ReadEntireBuffer();
|
|
CommandHistoryContext CommandHistory();
|
|
void UpdateWinGetSuggestions(Windows.Foundation.Collections.IVector<String> suggestions);
|
|
|
|
void AdjustOpacity(Single Opacity, Boolean relative);
|
|
void PreviewInput(String text);
|
|
|
|
// You'd think this should just be "Opacity", but UIElement already
|
|
// defines an "Opacity", which we're actually not setting at all. We're
|
|
// not overriding or changing _that_ value. Callers that want the
|
|
// opacity set by the settings should call this instead.
|
|
Single BackgroundOpacity { get; };
|
|
|
|
CursorDisplayState CursorVisibility;
|
|
|
|
Windows.UI.Xaml.Media.Brush BackgroundBrush { get; };
|
|
|
|
void ColorSelection(SelectionColor fg, SelectionColor bg, Microsoft.Terminal.Core.MatchMode matchMode);
|
|
|
|
Windows.Foundation.Point CursorPositionInDips { get; };
|
|
Double QuickFixButtonWidth { get; };
|
|
Double QuickFixButtonCollapsedWidth { get; };
|
|
|
|
void ShowContextMenu();
|
|
Boolean OpenQuickFixMenu();
|
|
void RefreshQuickFixMenu();
|
|
void ClearQuickFix();
|
|
|
|
void Detach();
|
|
}
|
|
}
|