Refactor TTY input handling
This patch is a cleanup of the TTY input logic, which simplifies a lot of the code, fixes a few TTY-related output issues and makes it behave more like a typical UNIX application. This is what has been changed:
- Line clearing is now done with carriage returns instead of backspaces, which fixes a lot of issues when printing lines while the prompt is non-empty.
- Console output handling is greatly simplified, and now handles partial lines properly.
- EOF (Ctrl+D) from console is now respected and will shut down the game once received (most UNIX applications have this behavior).