FirstVisibleDisplayLineIndex is wrong if outlining collapsed

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Chris Morris
Version: 4.0.0275
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Avatar
The method FirstVisibleDisplayLineIndex in EditorView class does not take in to account collapsed outlining sections.

If an outlining section is collapsed previous to the first current displayed line then the FirstVisibleDisplayLineIndex returns the (first current line number - number of lines collapsed) and not the first current line number.

Is there a work around?Please?

Steps to reproduce in c# "SDI Editor Application" example:
1. Add the following code line to the c# mainform.cs so that it will can be called:
int firstVisibleLine = this.editor.SelectedView.FirstVisibleDisplayLineIndex + 1
2. Run "SDI Editor Application" launch the SDI Edior Application
3. Default program ActiproSoftware.SyntaxEditor.TestClass is displayed in editor.
4. Collapse the using System; outlining on line 2 - hides 2 lines.
5. Scroll down so that line 21 is first visible line: public int Double(int x) {
6. Call the line of code added in step 1.
7. Result instead of firstVisibleLine being 21 the value is 19.

Note. Works okay if all outlining before first visible line are expanded.

Comments (3)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Chris,

That is by design, in SyntaxEditor 4.0 there are offsets, document positions, and edit positions. Offsets are 0 through the length of the document. Document positions are line/character positions within the document (which seems like what you want). Edit positions are line/character positions within the view, meaning when there are collapsed regions or word wrapped lines, they will not sync up with document positions.

FirstVisibleDisplayLineIndex ties to the Line of an EditPosition.

The "Getting Started" topic in the documentation reviews the differences between these pretty well and how to convert between them.


Actipro Software Support

Posted 16 years ago by Chris Morris
Avatar
Thanks for the prompt reply. My mistake in trying to set the FirstVisibleDisplayLineIndex witha document line number.

I understand that the document uses DocumentPosition and the view uses EditPosition and there are various convertions between offset and line position.

In my example I will convert the document line number to offset (Document.PositionToOffset), then use this offset to set the visible line number(SelectedView.OffsetToPosition) so that I can set the FirstVisibleDisplayLineIndex.

Example to set line 21 as first visible line:
int offset = this.editor.Document.PositionToOffset(new DocumentPosition(21, 0));
EditPosition editPosition = this.editor.SelectedView.OffsetToPosition(offset);
this.editor.SelectedView.FirstVisibleDisplayLineIndex = editPosition.Line;
[Modified at 09/08/2008 03:06 AM]

[Modified at 09/08/2008 03:08 AM]
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That looks perfect.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.