Fix cursor positioning bug.
Redo insert line to handle scrolling regions.