How to get a line of the document?

SyntaxEditor for WPF Forum

Posted 6 years ago by matt2012
Version: 13.1.0582
Avatar

Hello,

how can I access the lines of the Document?

I don't find a property like "Lines" (Collection of lines)

I only find the property Text in Document.Text

Thank you!

Comments (5)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Matt,

Look at the document's CurrentSnapshot property.  That is a mutable view of the document's text and has properties like Text and Lines on it.


Actipro Software Support

Posted 6 years ago by matt2012
Avatar

Thank you!

Yes I can read a line with:

int lineToRead=10;

String lineContent= Document.CurrentSnapshot.Lines[lineToRead].Text;

 But how can I write a line? "Text" has no setter.

Can you help me with that?

Thanks.

[Modified 6 years ago]

Posted 6 years ago by matt2012
Avatar

Hello,

I also need the information which lines of the document are visible on the screen:

First line that is visible.

Last line that is visible.

Thank you.

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Matt,

Take a look at the "SyntaxEditor / Text/Parsing Framework / Core Text Features / Text Changes and Operations" topic in the documentation that comes with SyntaxEditor.  It describes the ways to create text changes (via document).  You'd need to pass in the TextRange of the snapshot line to replace.

The editor view (editor.ActiveView.VisibleViewLines) gives you the list of IEditorViewLine objects that are currently visible.  Note that view lines can contain partial snapshot lines (when word wrap is on) or more than one snapshot line (when there are collapsed outlining nodes).


Actipro Software Support

Posted 6 years ago by matt2012
Avatar

Thank you.

The latest build of this product (v2019.1 build 0683) was released 17 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.