terminal/src/cascadia/TerminalControl/XamlUiaTextRange.h
Mike Griese d749df70ed
Rename Microsoft.Terminal.TerminalControl to .Control; Split into dll & lib (#9472)
**BE NOT AFRAID**. I know that there's 107 files in this PR, but almost
all of it is just find/replacing `TerminalControl` with `Control`.

This is the start of the work to move TermControl into multiple pieces,
for #5000. The PR starts this work by:
* Splits `TerminalControl` into separate lib and dll projects. We'll
  want control tests in the future, and for that, we'll need a lib.
* Moves `ICoreSettings` back into the `Microsoft.Terminal.Core`
  namespace. We'll have other types in there soon too. 
  * I could not tell you why this works suddenly. New VS versions? New
    cppwinrt version? Maybe we're just better at dealing with mdmerge
    bugs these days.
* RENAMES  `Microsoft.Terminal.TerminalControl` to
  `Microsoft.Terminal.Control`. This touches pretty much every file in
  the sln. Sorry about that (not sorry). 

An upcoming PR will move much of the logic in TermControl into a new
`ControlCore` class that we'll add in `Microsoft.Terminal.Core`.
`ControlCore` will then be unittest-able in the
`UnitTests_TerminalCore`, which will help prevent regressions like #9455 

## Detailed Description of the Pull Request / Additional comments
You're really gonna want to clean the sln first, then merge this into
your branch, then rebuild. It's very likely that old winmds will get
left behind. If you see something like 

```
Error    MDM2007    Cannot create type
Microsoft.Terminal.TerminalControl.KeyModifiers in read-only metadata
file Microsoft.Terminal.TerminalControl.
```

then that's what happened to you.
2021-03-17 20:47:24 +00:00

76 lines
4 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- XamlUiaTextRange.h
Abstract:
- This module is a wrapper for the UiaTextRange
(a text range accessibility provider). It allows
for UiaTextRange to be used in Windows Terminal.
- Wraps the UIAutomationCore ITextRangeProvider
(https://docs.microsoft.com/en-us/windows/win32/api/uiautomationcore/nn-uiautomationcore-itextrangeprovider)
with a XAML ITextRangeProvider
(https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.automation.provider.itextrangeprovider)
Author(s):
- Carlos Zamora (CaZamor) 2019
--*/
#pragma once
#include "TermControlAutomationPeer.h"
#include <UIAutomationCore.h>
#include "../types/TermControlUiaTextRange.hpp"
namespace winrt::Microsoft::Terminal::Control::implementation
{
class XamlUiaTextRange :
public winrt::implements<XamlUiaTextRange, Windows::UI::Xaml::Automation::Provider::ITextRangeProvider>
{
public:
XamlUiaTextRange(::ITextRangeProvider* uiaProvider, Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple parentProvider) :
_parentProvider{ parentProvider }
{
_uiaProvider.attach(uiaProvider);
}
#pragma region ITextRangeProvider
Windows::UI::Xaml::Automation::Provider::ITextRangeProvider Clone() const;
bool Compare(Windows::UI::Xaml::Automation::Provider::ITextRangeProvider pRange) const;
int32_t CompareEndpoints(Windows::UI::Xaml::Automation::Text::TextPatternRangeEndpoint endpoint,
Windows::UI::Xaml::Automation::Provider::ITextRangeProvider pTargetRange,
Windows::UI::Xaml::Automation::Text::TextPatternRangeEndpoint targetEndpoint);
void ExpandToEnclosingUnit(Windows::UI::Xaml::Automation::Text::TextUnit unit) const;
Windows::UI::Xaml::Automation::Provider::ITextRangeProvider FindAttribute(int32_t textAttributeId,
winrt::Windows::Foundation::IInspectable val,
bool searchBackward);
Windows::UI::Xaml::Automation::Provider::ITextRangeProvider FindText(winrt::hstring text,
bool searchBackward,
bool ignoreCase);
winrt::Windows::Foundation::IInspectable GetAttributeValue(int32_t textAttributeId) const;
void GetBoundingRectangles(winrt::com_array<double>& returnValue) const;
Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple GetEnclosingElement();
winrt::hstring GetText(int32_t maxLength) const;
int32_t Move(Windows::UI::Xaml::Automation::Text::TextUnit unit,
int32_t count);
int32_t MoveEndpointByUnit(Windows::UI::Xaml::Automation::Text::TextPatternRangeEndpoint endpoint,
Windows::UI::Xaml::Automation::Text::TextUnit unit,
int32_t count) const;
void MoveEndpointByRange(Windows::UI::Xaml::Automation::Text::TextPatternRangeEndpoint endpoint,
Windows::UI::Xaml::Automation::Provider::ITextRangeProvider pTargetRange,
Windows::UI::Xaml::Automation::Text::TextPatternRangeEndpoint targetEndpoint) const;
void Select() const;
void AddToSelection() const;
void RemoveFromSelection() const;
void ScrollIntoView(bool alignToTop) const;
winrt::com_array<Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple> GetChildren() const;
#pragma endregion ITextRangeProvider
private:
wil::com_ptr<::ITextRangeProvider> _uiaProvider;
Windows::UI::Xaml::Automation::Provider::IRawElementProviderSimple _parentProvider;
};
}