Add terminal size handling in TerminalEmulator and Pty