ported to pty.js and term.js