Roll my own line wrapping for termcap mode.

This is unfortunate, but it seems that there is no way to manage long
command lines directly in termcap - I have to actually calculate the number
of lines needed and manage the text myself. Ugh.

Also fixes a bug in last_command, since current_history might not be set.