move terminfo cap parser and output to Write