Last week I was complaining how complicated terminal emulation is, but it turns out the situation is much worse than I thought.
Here is the state diagram required to parse VT escape sequences robustly.
Something needs to be done. We need a new text-mode interface network protocol that is much, much simpler. Emulating VT100s in 2005 is nuts.