How do you get the position of the cursor or of a line within the window?
I want to know where the cursor is relative to the window, or where a certain line is relative to the window. For example, say the cursor is on line 7 of the buffer. If line 7 is at the top of the window, I want 1. If line 7 is a little ways down in the window, I want 20. If my window height is 100 and line 7 is at the very bottom, then I want 100.
Is there a way to obtain this information?
I have looked at nvim_win_get_cursor, getcurpos, win_screenpos, getwininfo, getpos and others, but these deal with either the position of the cursor in the buffer, or the position of the window in the layout, neither of which are what I want.
I would recommend to use screenpos()
or:
For the line information you can also do: