Refactoring ANSI escape codes generation