Steve added the comment: Hi Georg,
Thanks again for the responses and your help. After a bit of research, I discovered the /reasons/ behind needing the \001 and \002 escapes. Thought I'd log the links here for posterity sake: - To color something in on a color capable terminal console you just need to use the "\033[<color code>m" escape sequence. This would be sufficient[1] - However readline messes up the line width calculation because it measures the escape sequences as a characters too. To avoid this you have to wrap the escape sequences within \001 and \002.[2] - On some terminal applications (like the one I am using - terminator[3]), if you add the \001 and \002 escapes to color text which is *not* interpreted by readline, (for instance if you have a single function to color text and you want to use it to color both your sys.ps1 and output text), the \001 and \002 codes will get printed out using a representation (like a unicode 'box'[4]). So, one would have to workaround that in the text coloring function. [1] http://en.wikipedia.org/wiki/ANSI_escape_code#Colors [2] bugs.python.org/issue17337/ and http://stackoverflow.com/questions/9468435/look-how-to-fix-column-calculation-in-python-readline-if-use-color-prompt [3] http://gnometerminator.blogspot.sg/p/introduction.html [4] http://en.wikipedia.org/wiki/Control_character#Display ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20359> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com