In the output window all the printf'd text appears in purple on a black background,, which are my usual default colours.
None of it is red or green.
The ansi colour escapes show up in purple too, introduced with a boxed hexadecimall character.
In case it is relevant, I use drracket in dark mode, and I have configured it to present parantheses in code in yellow -- so I can see these all-important charcters.
I use printf while debugging, and I'd like to use colour to emphasize milestones in printf trace output.
I've now checked that ansi-color works fine outside DrRacket when the standard output goes to an uxterm terminal. But not to DrRacket's output panel.
Dominik's pict hack looks useful, but not for my purpose. I'm looking for a way to write out printf-style debugging output in a visually distinctive manner, mixed in with all the other standard-output a program produces.
There has to be some mechanism for colour in DrRacket's outut panel, because DrRacket uses colour in its welcome and error messages.
The DrRacket interactions panel indeed does not appear to recognise the ANSI colour escape sequences. So I'll give up on that tack, unless that gets certified as a bug.
But DrRacket itself uses colour on the interactions panel -- so there has to be a mechanism for it.
In particular, error messages show up in red, my own printf output shows up in purple, and prompts by the REPL show up i white. (I'm still using dark mode, so white is a reasonable colour choice.)
So there is a way to affect colour in the interactions window, and it's probably not ANSI escape sequences.
I'm just trying to find out how to do it myself.
Unfortunately, it is not really a general facility that's available to the programs running in the IDE. If you print to stdout, it comes out in purple. If you print to stderr, it comes out in red. To get the blue, you need to print to a secret port that you don't have access to.
If you want colored output, I think the best approach is to use another library somehow; perhaps one that makes picts or one that opens a separate window for your fancier output. There's not really a middle ground currently.
Dr Racket just colors REPL output based purely on the port it's coming from. So you can choose between two colors that way, but it would be hacky. (There's also drracket:rep:current-value-port but I think you’ll find it’s difficult to use without causing weird DrRacket behavior.)
Oh, @mflatt suggested off-list that one could use string snips and styles. I'm not sure this is a good approach as there are limitations (like I'm not seeing how to get the right font) but here is some code that does a thing: