This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lonetwin
Recipients georg.brandl, lonetwin
Date 2014-01-23.14:43:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390488236.82.0.616068777711.issue20359@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2014-01-23 14:43:56lonetwinsetrecipients: + lonetwin, georg.brandl
2014-01-23 14:43:56lonetwinsetmessageid: <1390488236.82.0.616068777711.issue20359@psf.upfronthosting.co.za>
2014-01-23 14:43:56lonetwinlinkissue20359 messages
2014-01-23 14:43:55lonetwincreate