document some more of the terminal handling code