move winch check to top of loop

should change nothing, allows us to use loop condition
better name for !stop: attached
detach on EOF from attached client

Now "echo command | dtattach bash-sock" will return a successful exit
status.
return 3 from dtattach on master termination

Normal exit for dtattach is assumed to be detaching.  If it closes
because the master terminated, return a code that indicates that.
Current return values from dtattach are:

0 - detached
1 - error
2 - connection refused on socket
3 - master terminated
move normal output from dtattach into dtach script

[detached] now displays appropriately, and using dtattach directly will
not display it (a la scripting)
remove unneeded `tput cnorm' lines
Add minimal parser to track pty state

Parser will catch and track state-changing strings such as smkx and
rmkx, as well as intercept answerbacks like ^E or ^[[c.