Fixes issues where cursor goes off the right side of the screen and both the cursor and line highlight going off the bottom of the screen.