Ensure TextRange is Visible

SyntaxEditor for WPF Forum

Posted 15 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
I originally wrote this as a reply to the selection behavior around Find/Next functionality, but then realized it was a little off-topic as well. Didn't want the concept to be lost under the wrong thread.

I think keeping selection behavior consistent with VS is ideal for find/replace. As part of this effort, you'll obviously have to implement some methods for ensuring a particular text range is visible. Not sure what is already in SE for this, but here are my thoughts...

I see three basic scenarios for how a particular text range needs to be visible and vertical scrolling is required... you enter want the range to be visible at the top, middle, or bottom of the visible area.

Middle is pretty obvious and good for operations like Find/Next. Top/Bottom would be important based on the context of what you are trying to show.

For instance, if I'm jumping to the closing "}" of a class declaration, I would prefer that item to be at the bottom of the screen where more of the corresponding class is visible. If I was wanting to show the opening "{" of a class declaration, I would prefer the range to be at the top for the same reason.

Top/Bottom preferences should also allow for a certain amount of padding. So I could indicate that x number of lines should be padded above any top-based view and below any bottom-based view.

I think these same concepts also apply to horizontal scrolling behavior. Sometimes you want left, middle, or right.

I also think that SE4 allows you to specify an offset to be visible instead of a range. Any time I had a range of text to be visible, I would always have to first attempt to make the end offset visible and then make the start offset visible. If I didn't do this, it would be common for SE4 to scroll horizontally until the first offset of my range was visible, but the end offset was still out-of-view. Having SE handle text ranges instead of offsets would be ideal.
The latest build of this product (v24.1.1) was released 1 month ago, which was after this thread was created.

Add Comment

Please log in to a validated account to post comments.