// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import "IMouseWheelListener.idl";

namespace Microsoft.Terminal.TerminalControl
{
    delegate void TitleChangedEventArgs(String newTitle);
    delegate void FontSizeChangedEventArgs(Int32 width, Int32 height, Boolean isInitialChange);
    delegate void ScrollPositionChangedEventArgs(Int32 viewTop, Int32 viewHeight, Int32 bufferLength);

    // C++/winrt makes it difficult to share this idl between two projects,
    // Instead, we just pin the uuid and include it in both TermControl and App
    // If you update this one, please update TerminalApp\IDirectKeyListener.idl.
    // If you change this interface, please update the guid.
    // If you press F7 or Alt and get a runtime error, go make sure both copies are the same.
    [uuid("0ddf4edc-3fda-4dee-97ca-a417ee3dd510")] interface IDirectKeyListener {
        Boolean OnDirectKeyEvent(UInt32 vkey, UInt8 scanCode, Boolean down);
    }

    runtimeclass CopyToClipboardEventArgs
    {
        String Text { get; };
        String Html { get; };
        String Rtf { get; };
    }

    runtimeclass PasteFromClipboardEventArgs
    {
        void HandleClipboardData(String data);
    }

    [default_interface] runtimeclass TermControl : Windows.UI.Xaml.Controls.UserControl, IDirectKeyListener, IMouseWheelListener
    {
        TermControl();
        TermControl(Microsoft.Terminal.Settings.IControlSettings settings, Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);

        static Windows.Foundation.Point GetProposedDimensions(Microsoft.Terminal.Settings.IControlSettings settings, UInt32 dpi);

        void UpdateSettings(Microsoft.Terminal.Settings.IControlSettings newSettings);

        event TitleChangedEventArgs TitleChanged;
        event FontSizeChangedEventArgs FontSizeChanged;
        event Windows.Foundation.TypedEventHandler<TermControl, CopyToClipboardEventArgs> CopyToClipboard;
        event Windows.Foundation.TypedEventHandler<TermControl, PasteFromClipboardEventArgs> PasteFromClipboard;

        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<TermControl, IInspectable> ConnectionStateChanged;
        Microsoft.Terminal.TerminalConnection.ConnectionState ConnectionState { get; };

        String Title { get; };

        Boolean CopySelectionToClipboard(Boolean collapseText);
        void PasteTextFromClipboard();
        void Close();
        Windows.Foundation.Size CharacterDimensions { get; };
        Windows.Foundation.Size MinimumSize { get; };
        Single SnapDimensionToGrid(Boolean widthOrHeight, Single dimension);

        void ScrollViewport(Int32 viewTop);
        Int32 GetScrollOffset();
        Int32 GetViewHeight();
        event ScrollPositionChangedEventArgs ScrollPositionChanged;

        void CreateSearchBoxControl();

        void AdjustFontSize(Int32 fontSizeDelta);
        void ResetFontSize();

        void ToggleRetroEffect();
    }
}
