AvalonEdit - visible text

I am trying to get the visible text of an avalonedit control, but it VisualLines[]only handles wordwrap with TextLines[], and I don't know how to check if the TextLine is in the visible area or not.

The problem will also be solved if I can get the start and end point (or length) of the visible text in text form, but I did not find such a function or member ...

Can anyone help me? thank

+3
source share
1 answer

You can use TextView.GetPositionto get the document position for corners of the text view:

TextViewPosition? start = textView.GetPosition(new Point(0, 0) + textView.ScrollOffset);
TextViewPosition? end = textView.GetPosition(new Point(textView.ActualWidth, textView.ActualHeight) + textView.ScrollOffset);

TextDocument.GetOffset TextViewPosition . , null, - , , , :

int startOffset = start != null ? document.GetOffset(start.Value.Location) : document.TextLength;
int endOffset = end != null ? document.GetOffset(end.Value.Location) : document.TextLength;

, , VisualLine/TextLines: VisualLine.VisualTop , ( Y), TextLine VisualLine Height. , , , GetCharacterHitFromDistance VisualLine.GetRelativeOffset . ( , TextView.GetPosition)

+4

Source: https://habr.com/ru/post/1770807/


All Articles