Added a 'fail' command to the demo

It signals an error.
This is mostly for development purposes.
Reworked tty handling

Introduced a with-tty macro and refactored some other related bits.
Command condition handling

Also adjusts frontend code to new tty API.
Return status handling for immediate command mode
Missing newline
Support for some more key escape sequences

By now this could use some refactoring for compactness.