Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding TextPattern providers to Text controls (port from 5.0) #3853

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ internal static partial class Richedit
[Flags]
public enum SCF : uint
{
SELECTION = 0x0001,
WORD = 0x0002,
DEFAULT = 0x0000,
ALL = 0x0004,
USEUIRULES = 0x0008,
ASSOCIATEFONT = 0x0010,
NOKBUPDATE = 0x0020,
ASSOCIATEFONT2 = 0x0040,
SMARTFONT = 0x0080,
DEFAULT = 0x0000,
SELECTION = 0x0001,
WORD = 0x0002,
ALL = 0x0004,
USEUIRULES = 0x0008,
ASSOCIATEFONT = 0x0010,
NOKBUPDATE = 0x0020,
ASSOCIATEFONT2 = 0x0040,
SMARTFONT = 0x0080,
CHARREPFROMLCID = 0x0100,
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Drawing;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class UiaCore
{
[ComImport]
[Guid("3589c92c-63f3-4367-99bb-ada653b77cf2")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITextProvider
{
ITextRangeProvider[]? GetSelection();

ITextRangeProvider[]? GetVisibleRanges();

ITextRangeProvider? RangeFromChild(IRawElementProviderSimple childElement);

ITextRangeProvider? RangeFromPoint(Point screenLocation);

ITextRangeProvider? DocumentRange { get; }

SupportedTextSelection SupportedTextSelection { get; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Drawing;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class UiaCore
{
[ComImport]
[Guid("0dc5e6ed-3e16-4bf1-8f9a-a979878bc195")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITextProvider2 : ITextProvider
{
new ITextRangeProvider[]? GetSelection();

new ITextRangeProvider[]? GetVisibleRanges();

new ITextRangeProvider? RangeFromChild(IRawElementProviderSimple childElement);

new ITextRangeProvider? RangeFromPoint(Point screenLocation);

new ITextRangeProvider? DocumentRange { get; }

new SupportedTextSelection SupportedTextSelection { get; }

ITextRangeProvider? RangeFromAnnotation(IRawElementProviderSimple annotation);

ITextRangeProvider? GetCaretRange(out BOOL isActive);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class UiaCore
{
[ComImport]
[Guid("5347ad7b-c355-46f8-aff5-909033582f63")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITextRangeProvider
{
ITextRangeProvider Clone();

BOOL Compare(ITextRangeProvider range);

int CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint);

void ExpandToEnclosingUnit(TextUnit unit);

ITextRangeProvider? FindAttribute(int attribute, object value, BOOL backward);

ITextRangeProvider? FindText(string text, BOOL backward, BOOL ignoreCase);

object? GetAttributeValue(int attribute);

double[] GetBoundingRectangles();

IRawElementProviderSimple GetEnclosingElement();

string GetText(int maxLength);

int Move(TextUnit unit, int count);

int MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count);

void MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint);

void Select();

void AddToSelection();

void RemoveFromSelection();

void ScrollIntoView(BOOL alignToTop);

IRawElementProviderSimple[] GetChildren();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

internal static partial class Interop
{
internal static partial class UiaCore
{
[Flags]
public enum SupportedTextSelection
{
None = 0,
Single = 1,
Multiple = 2
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

internal static partial class Interop
{
internal static partial class UiaCore
{
public enum TextAttributeIdentifier
{
AnimationStyleAttributeId = 40000,
BackgroundColorAttributeId = 40001,
BulletStyleAttributeId = 40002,
CapStyleAttributeId = 40003,
CultureAttributeId = 40004,
FontNameAttributeId = 40005,
FontSizeAttributeId = 40006,
FontWeightAttributeId = 40007,
ForegroundColorAttributeId = 40008,
HorizontalTextAlignmentAttributeId = 40009,
IndentationFirstLineAttributeId = 40010,
IndentationLeadingAttributeId = 40011,
IndentationTrailingAttributeId = 40012,
IsHiddenAttributeId = 40013,
IsItalicAttributeId = 40014,
IsReadOnlyAttributeId = 40015,
IsSubscriptAttributeId = 40016,
IsSuperscriptAttributeId = 40017,
MarginBottomAttributeId = 40018,
MarginLeadingAttributeId = 40019,
MarginTopAttributeId = 40020,
MarginTrailingAttributeId = 40021,
OutlineStylesAttributeId = 40022,
OverlineColorAttributeId = 40023,
OverlineStyleAttributeId = 40024,
StrikethroughColorAttributeId = 40025,
StrikethroughStyleAttributeId = 40026,
TabsAttributeId = 40027,
TextFlowDirectionsAttributeId = 40028,
UnderlineColorAttributeId = 40029,
UnderlineStyleAttributeId = 40030,
AnnotationTypesAttributeId = 40031,
AnnotationObjectsAttributeId = 40032,
StyleNameAttributeId = 40033,
StyleIdAttributeId = 40034,
LinkAttributeId = 40035,
IsActiveAttributeId = 40036,
SelectionActiveEndAttributeId = 40037,
CaretPositionAttributeId = 40038,
CaretBidiModeAttributeId = 40039,
LineSpacingAttributeId = 40040,
BeforeParagraphSpacingAttributeId = 40041,
AfterParagraphSpacingAttributeId = 40042
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class UiaCore
{
public enum TextPatternRangeEndpoint
{
Start = 0,
End = 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class UiaCore
{
public enum TextUnit
{
Character = 0,
Format = 1,
Word = 2,
Line = 3,
Paragraph = 4,
Page = 5,
Document = 6
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class UiaCore
{
private static object? s_notSupportedValue;

[DllImport(Libraries.UiaCore, ExactSpelling = true)]
private static extern int UiaGetReservedNotSupportedValue([MarshalAs(UnmanagedType.IUnknown)] out object notSupportedValue);

public static object UiaGetReservedNotSupportedValue()
{
if (s_notSupportedValue == null)
{
UiaGetReservedNotSupportedValue(out s_notSupportedValue);
}

return s_notSupportedValue;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

internal static partial class Interop
{
/// <summary>
/// Simple wrapper for an ATOM
/// </summary>
public struct Atom
{
// #define MAXINTATOM 0xC000
// #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i)))
// #define INVALID_ATOM ((ATOM)0)

// Strange uses for window class atoms
// https://blogs.msdn.microsoft.com/oldnewthing/20080501-00/?p=22503/

public ushort ATOM;

public Atom(ushort atom) => ATOM = atom;

public static Atom Null = new Atom(0);

public bool IsValid => ATOM != 0;

public static implicit operator uint(Atom atom) => atom.ATOM;
public static implicit operator Atom(IntPtr atom) => new Atom((ushort)atom);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ internal static partial class User32
[Flags]
public enum ES : uint
{
LEFT = 0x0000,
CENTER = 0x0001,
RIGHT = 0x0002,
MULTILINE = 0x0004,
UPPERCASE = 0x0008,
LOWERCASE = 0x0010,
PASSWORD = 0x0020,
LEFT = 0x0000,
CENTER = 0x0001,
RIGHT = 0x0002,
MULTILINE = 0x0004,
UPPERCASE = 0x0008,
LOWERCASE = 0x0010,
PASSWORD = 0x0020,
AUTOVSCROLL = 0x0040,
AUTOHSCROLL = 0x0080,
NOHIDESEL = 0x0100,
OEMCONVERT = 0x0400,
READONLY = 0x0800,
WANTRETURN = 0x1000,
NUMBER = 0x2000
NOHIDESEL = 0x0100,
OEMCONVERT = 0x0400,
READONLY = 0x0800,
WANTRETURN = 0x1000,
NUMBER = 0x2000
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

internal static partial class Interop
{
internal static partial class User32
{
public enum GCL : int
{
/// <summary>
/// (GCL_WNDPROC)
/// </summary>
WNDPROC = -24,

/// <summary>
/// (GCW_ATOM)
/// </summary>
ATOM = -32,
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Drawing;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL GetCaretPos(out Point pt);
}
}
Loading