Compute scroll position to ensure cursor is visible.
Current scroll position
Cursor position
Visible viewport height in lines
Adjusted scroll position
Compute scroll position to ensure cursor is visible.