Skip to content

Commit

Permalink
uia: add support for scrolling the viewport (#4525)
Browse files Browse the repository at this point in the history
The UIA Provider now scrolls the viewport when necessary. This just fills in the missing virtual function in Terminal to have the same behavior as what it does in ConHost.

* [X] Closes #2361 
* [X] CLA signed.

`ChangeViewport` is now a virtual function at the `ScreenInfoUiaProvider` layer to have access to the TermControl.

In ConHost, we pass this call up to the WindowUiaProvider layer. In Terminal, we don't need to do that because the concept of updating the viewport is handled at the TermControl layer. So we just call that function and _voila_!
  • Loading branch information
carlos-zamora authored Feb 11, 2020
1 parent 3b58e04 commit be614c2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/cascadia/TerminalControl/TermControlUiaProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ const winrt::Windows::UI::Xaml::Thickness TermControlUiaProvider::GetPadding() c
return _termControl->GetPadding();
}

void TermControlUiaProvider::ChangeViewport(const SMALL_RECT NewWindow)
{
_termControl->ScrollViewport(NewWindow.Top);
}

HRESULT TermControlUiaProvider::GetSelectionRanges(_In_ IRawElementProviderSimple* pProvider, const std::wstring_view wordDelimiters, _Out_ std::deque<ComPtr<UiaTextRangeBase>>& result)
{
try
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/TermControlUiaProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace Microsoft::Terminal

const COORD GetFontSize() const;
const winrt::Windows::UI::Xaml::Thickness GetPadding() const;
void ChangeViewport(const SMALL_RECT NewWindow) override;

protected:
HRESULT GetSelectionRanges(_In_ IRawElementProviderSimple* pProvider, const std::wstring_view wordDelimiters, _Out_ std::deque<WRL::ComPtr<Microsoft::Console::Types::UiaTextRangeBase>>& selectionRanges) override;
Expand Down
5 changes: 3 additions & 2 deletions src/cascadia/TerminalControl/UiaTextRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ IFACEMETHODIMP UiaTextRange::Clone(_Outptr_result_maybenull_ ITextRangeProvider*
return S_OK;
}

void UiaTextRange::_ChangeViewport(const SMALL_RECT /*NewWindow*/)
void UiaTextRange::_ChangeViewport(const SMALL_RECT NewWindow)
{
// TODO GitHub #2361: Update viewport when calling UiaTextRangeBase::ScrollIntoView()
auto provider = static_cast<TermControlUiaProvider*>(_pProvider);
provider->ChangeViewport(NewWindow);
}

// Method Description:
Expand Down
2 changes: 1 addition & 1 deletion src/interactivity/win32/screenInfoUiaProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Microsoft::Console::Interactivity::Win32
IFACEMETHODIMP get_FragmentRoot(_COM_Outptr_result_maybenull_ IRawElementProviderFragmentRoot** ppProvider) override;

HWND GetWindowHandle() const;
void ChangeViewport(const SMALL_RECT NewWindow);
void ChangeViewport(const SMALL_RECT NewWindow) override;

protected:
HRESULT GetSelectionRanges(_In_ IRawElementProviderSimple* pProvider, const std::wstring_view wordDelimiters, _Out_ std::deque<WRL::ComPtr<Microsoft::Console::Types::UiaTextRangeBase>>& selectionRanges) override;
Expand Down
1 change: 1 addition & 0 deletions src/types/ScreenInfoUiaProviderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace Microsoft::Console::Types
~ScreenInfoUiaProviderBase() = default;

[[nodiscard]] HRESULT Signal(_In_ EVENTID id);
virtual void ChangeViewport(const SMALL_RECT NewWindow) = 0;

// IRawElementProviderSimple methods
IFACEMETHODIMP get_ProviderOptions(_Out_ ProviderOptions* pOptions) noexcept override;
Expand Down

0 comments on commit be614c2

Please sign in to comment.