Add support for previously unhandled ANSI codes, improve approach on handling color state

Please apply pull request #31 first, this one depends on the former.
I am happy to answer any questions coming up during review. Best, Sebastian