Extract the term size method used by SSH and pty into a function, and remove the need to change the video mode.