GoToLine as FirstVisibleLine

SyntaxEditor for Windows Forms Forum

Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
When I invoke the 'GoToLine' method, there doesn't appear to be any consistency in how the editor positions this line in the visible area of the current view. I would like the 'GoToLine' method to make the indicated line the first visible line in that view.

Based on a previous post, I can't use 'FirstVisibleLine' since it doesn't count lines that are not currently displayed (i.e. collapsed nodes). Is there any way to do this in the current release?

Thanks in advance!

Comments (13)

Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
GoToLine is intended for the document line. So if you have the line number margin displayed, it matches up with those.

We will be doing a lot of work with allowing you to manipulate display lines in an upcoming version. I don't think you can do what you want with this version however.


Actipro Software Support

Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
I understand that 'GoToLine' matches with the document line. The problem is that, after invoking this method, the line I goto might be the first visible line, last visible line (or even partially visible at that), or somewhere in between.

The behavior I'm looking for is to have the line I goto be at the top of the display area (i.e. the first visible line). Is there any way to accomplish this now? I had this working using the 'FirstVisibleLine' property until I implemented collapsable nodes. I'm looking for a workaround until you release an update that handles this better. Any ideas?
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Unfortunately I can't think of a workaround at the moment.


Actipro Software Support

Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
This is resulting in a major implementation problem for me. Is there any chance of getting a quick fix in a maintenance release to address this since your next major release probably won't be out anytime soon?

All I'd be looking for is a simple overloaded method for 'GoToLine' that accepts a boolean value indicating if the line you jump to should be the first visible line in the editor. <IMG SRC="frown.gif" border="0">
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok let me see what I can do.


Actipro Software Support

Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Any assistance is GREATLY appreciated... thank you!
Posted 20 years ago by Eric J. Smith
Avatar
Boyd,

What I do is after I call the GoToLine method to move the selection to the desired line, then I call this code to center that line in the view.

int targetFirstLine = editor.Document.CurrentView.Selection.EndPosition.Line - (editor.Document.CurrentView.VisibleLines / 2);
if (targetFirstLine &gt;= 0)
{
editor.Document.CurrentView.FirstVisibleLine = targetFirstLine;
}
else
{
editor.Document.CurrentView.FirstVisibleLine = 0;
}

This should work since GoToLine will ensure that the target line is visible.

Hope this helps,
Eric J. Smith

[ 08-12-2004: Message edited by: Eric J. Smith ]
Posted 20 years ago by Eric J. Smith
Avatar
OK, nevermind my last post. <IMG SRC="smile.gif" border="0"> I just realized what you are talking about with the collapsed lines and realized that my implementation no longer works in all situations with outlining. So count me in as needing this feature ASAP as well <IMG SRC="smile.gif" border="0">

Eric J. Smith
Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Eric,

I appreciate the help anyway, and I'm glad to hear I'm not the only one. <IMG SRC="wink.gif" border="0">
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The next maintenance release will include an overload of GoToLine that lets you indicate the number of display lines from the top that you'd like the specified line to appear. This allows you to place the specified line at the very top of the view or even a couple display lines from the top.


Actipro Software Support

Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
That'll be perfect! ... thank you!!
Posted 20 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Thanks for the overloaded method to 'GoToLine'. This certainly helps! Due to the confusion caused by the 'GoToLine' method and 'FirstVisibleLine' property, it might be beneficial to note in the documentation whether the 'line' refers to the actual document line number (as in 'GoToLine') or the visible line number after nodes are collapsed (as in 'FirstVisibleLine'). Even better, having all references to 'line' mean the same thing (preferrable document line number) would be even better.

While implementing this, I noticed some strange functionality. If the cursor is already on the line you specify in the 'GoToLine' method, the method has no affect.

Open the Sample application. The default document will load and the cursor will be on line 1. Now scroll all the way to the bottom of the document. If you now try to "Go To" line 1, nothing will happen. I would expect the editor to ensure that the line specified in the 'GoToLine' method will not only be the active line but will be visible as well.

It appears the workaround is to move the selected line to another line prior to calling the 'GoToLine' method, but it would be nice if this was fixed for a future release.

Thanks again!
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The problem with it not scrolling to the line if it's already on it is now fixed for the next release.


Actipro Software Support

The latest build of this product (v24.1.1) was released 24 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.