api/window_set_cursor: make sure cursor line is visible.

Previously, the cursor could be left outside the visible range if window
is not the current window
test/api: add test for set_cursor always updating the screen
Merge pull request #951 from bfredl/curfix

api: window_set_cursor doesn't always update position.