Colored text in the Compile Output panel on Windows? (works on Linux)
-
I am running a Windows batch file as a "Custom Process Step" after the regular build has finished. If there is an error, I would like to use my own highlighting (red on yellow, for example) so that it stands out in the flood of other text which is printed there.
On Linux Ubuntu, it is a similar thing, but running a
bashscript and using the standard ANSI escape sequences. This works very nicely. It is supposed to work on Windows according to this site. But my escape sequences are mangled by Creator.I tried using various methods of escaping:
'^[91;103m'does not work, neither does'^^[91;103m'(using delayed expansion), also not'\[91;103m', nor the literal'␛[91;103m'where I was able to copy and paste the ESC character from the web page linked in the above discussion thread.Is there any way of doing this on Windows 10 using CMD.EXE (not PowerShell)?
-
I've just tested that with Creator 17.0 and it works for me with the following example script (provided by https://ss64.com/nt/syntax-ansi.html)
Can you please re-check? I think specifying the correct <ESC> is the problem.
Regards
-
I've just tested that with Creator 17.0 and it works for me with the following example script (provided by https://ss64.com/nt/syntax-ansi.html)
Can you please re-check? I think specifying the correct <ESC> is the problem.
Regards
@aha_1980 Thanks for the link ... this works fine if I open the .BAT file from a command prompt.
But did yiou actually run this in Qt Creator as a "Custom Process Step"? I get red text on a white background instead of yellow background. I think that Qt Creator (on Windows, at least) is overriding this somehow.
-
@Robert-Hairgrove Yes I did and it works.
But if you get red text, that sounds as if the output is from
stderrand not fromstdout. Errors are always printed in red.Regards
-
@Robert-Hairgrove Yes I did and it works.
But if you get red text, that sounds as if the output is from
stderrand not fromstdout. Errors are always printed in red.Regards
@aha_1980 Instead of just trying the codes in my own batch file, I changed the name from
echoansi.txttoechoansi.BATand set that as the custom process step, and it worked fine. However, when I tried to use the same codes in my own batch file, I noticed that some combinations of colors just won't work -- others are fine, but not what I need.For example, the Qt Creator output doesn't seem to recognize the codes for yellow (or bright yellow) background, nor for white or yellow text on a dark background -- although these look fine in the
echoansi.BAToutput.I need to look at this some more. At least it is nice to know that the endeavour isn't totally hopeless! Thanks for your input, @aha_1980!