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
api/window: simplify window_set_height/width