It's simple to find the number of lines from the cursor to top of the screen, eg:
(- (line-number-at-pos (point)) (line-number-at-pos (window-start))))
However when the
hideshow library is used to hide certain text, this is no longer valid in that my cursor may have an on-screen offset of N lines from the top of the screen, which is a much larger number if the hidden text is not taken into account.
Is there a way to calculate the number of lines the cursor is from the top of the screen that takes hidden text into account?
n.b. This question initially referred to "narrowing", which is why so many of the comments are about that.