Author Topic: determine the vertical scroll position  (Read 2374 times)

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
determine the vertical scroll position
« on: January 01, 2018, 09:04:34 AM »
I've written my own vertical scrollbar showing local bookmarks and modified lines (when possible).  I use the p_line property to determine the current line - the line the cursor is on.  If it's fairly trivial to do, I would like a means of determining the current vertical scroll position i.e. the number of the line that is currently showing at the top of the screen.  If the edit window is scrolled e.g. with the mouse, the current cursor line (p_line) may not actually be visible on the screen.  Only if it's easy.


jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: determine the vertical scroll position
« Reply #1 on: January 07, 2018, 01:52:46 AM »
The top_of_window() function puts the cursor on the top line, then you can use p_line, no?
Oh, and internally it uses p_cursor_y - so you can calculate it then without moving the cursor.

The tricky bit is likely to be wrapped lines ... lines that are really long get split (without adding a newline) by Slick on load.
(See Tools > Options > File Options > Load "Wrap Line Length" )

My findLongest() function deals with this pretty well using p_RLine. p_RLine has the same value on each segment of a split line, while p_line does not.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: determine the vertical scroll position
« Reply #2 on: January 07, 2018, 01:54:08 AM »
Oh, never mind, I see now what you are asking is different --- like when you scroll with the mouse wheel and the cursor isn't on screen anymore.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: determine the vertical scroll position
« Reply #3 on: January 07, 2018, 03:28:36 AM »
Yep, it's just scrolling with the mouse that's a problem.  I personally don't care about it but if I get round to posting it, other people might.