Quote:
The reason that makes it break is that all the characters i use to make the ANSI codes work are being treated as just normal characters when i use the string .length property.
That's because, in the terms of a string, they ARE normal characters.
The control sequences only become meaningful when the console rendering engine sees the ESC character and start interpreting the characters after it. The only way you're going to get an accurate character count for the rest of your string is to write your own interpreter to identify the control sequences and remove them from the string. The problem you have is there are a LOT of control commands and not all control sequences are the same number of characters. They vary in length by the command character and length of parameters for that command.
Once you scan the string for all the control sequences and remove them, then you can get the length of the remaining string.