[Qt-creator] About ANSI color support for Qt-creator output panel

Xiaofeng Wu djangowu at gmail.com
Sun Dec 28 16:35:14 CET 2014


Can I make a slight modification to the code to fixed the problem?

Thanks
Xiaofeng

On Sun, Dec 28, 2014 at 2:45 AM, Orgad Shaneh <orgads at gmail.com> wrote:

> On Sun, Dec 28, 2014 at 4:13 AM, Xiaofeng Wu <djangowu at gmail.com> wrote:
>
>> It works for compile output, but when I use std::cout to print out the
>> message, the output is not colored.
>>
>> Xiaofeng
>>
>> On Sat, Dec 27, 2014 at 8:56 PM, Henry Skoglund <fromqt at tungware.se>
>> wrote:
>>
>>> Hi, it works fine when output from the compiler, for example if you have
>>> a Visual Studio-flavored Qt Creator you can stuff #pragma message lines in
>>> your code, like this:
>>> #pragma message("\x1b[38;5;82mHello")
>>> #pragma message("\x1b[38;5;198mWorld")
>>>
>>> Rgrds Henry
>>>
>>>
>>> On 2014-12-27 16:13, Xiaofeng Wu wrote:
>>>
>>>> Now the output is
>>>> " [32mHello  [34mWorld [m"
>>>> with code,
>>>> std::cout << "\x1b[32mHello \x1b[34mWorld\x1b[m" << std::endl;
>>>>
>>>> Best,
>>>> Xiaofeng
>>>>
>>>> On Sat, Dec 27, 2014 at 9:56 AM, Petar Perisin <petar.perisin at gmail.com
>>>> <mailto:petar.perisin at gmail.com>> wrote:
>>>>
>>>>     It seems like ansiescapecodehandler.cpp defines escape as
>>>>
>>>>     \x1b[
>>>>
>>>>     so try that instead of '\e['
>>>>
>>>>     try simple colors for start, like
>>>>
>>>>     \x1b[32mHello \x1b[34mWorld\x1b[m
>>>>
>>>>     or something similar.
>>>>
>>>>
>>>>     Regards,
>>>>     Petar
>>>>
>>>>
>>>>
>>>>     On Sat, Dec 27, 2014 at 3:43 PM, Xiaofeng Wu <djangowu at gmail.com
>>>>     <mailto:djangowu at gmail.com>> wrote:
>>>>
>>>>         Hi,
>>>>
>>>>         I tried double the backslash with code
>>>>         std::cout << "\\e[38;5;82mHello \\e[38;5;198mWorld" <<
>>>> std::endl;,
>>>>           the output is like
>>>>         "\e[38;5;82mHello \e[38;5;198mWorld"
>>>>         Any other suggestion for making it work correctly?
>>>>
>>>>         Thanks,
>>>>         Xiaofeng
>>>>
>>>>         On Sat, Dec 27, 2014 at 9:14 AM, Petar Perisin
>>>>         <petar.perisin at gmail.com <mailto:petar.perisin at gmail.com>>
>>>> wrote:
>>>>
>>>>             Hi,
>>>>
>>>>             I haven't tried, but try to double the backslash:
>>>>
>>>>             std::cout << “\\e[38;5;82mHello \\e[38;5;198mWorld” <<
>>>>             std::endl;
>>>>
>>>>             also, you might need to end colors somewhere.
>>>>
>>>>             Regards,
>>>>             Petar
>>>>
>>>>             On Sat, Dec 27, 2014 at 3:34 AM, Xiaofeng Wu
>>>>             <djangowu at gmail.com <mailto:djangowu at gmail.com>> wrote:
>>>>
>>>>                 In the change log of Qt Creator 3.3.0, it says the
>>>>                 application output panel support ansi color.
>>>>                 But when I try to print colored texts like
>>>>
>>>>                 std::cout << “\e[38;5;82mHello \e[38;5;198mWorld” <<
>>>>                 std::endl;
>>>>
>>>>                 What I can see from the application output panel is the
>>>>                 verbatim output of the string, instead of colored text
>>>>                 of “Hello Wolrd”
>>>>
>>>>                 Am I using it in the wrong way?
>>>>
>>>>
>>>>                 _______________________________________________
>>>>                 Qt-creator mailing list
>>>>                 Qt-creator at qt-project.org <mailto:
>>>> Qt-creator at qt-project.org>
>>>>                 http://lists.qt-project.org/mailman/listinfo/qt-creator
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Qt-creator mailing list
>>>> Qt-creator at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/qt-creator
>>>>
>>>>
>>>
>>>
>>
>> _______________________________________________
>> Qt-creator mailing list
>> Qt-creator at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/qt-creator
>>
>>
> The application output pane uses QtOutputFormatter, which doesn't support
> ANSI escape code handling (as opposed to OutputFormatter which does).
>
> Please file a bugreport <https://bugreports.qt-project.org/>.
>
> Thanks,
> - Orgad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20141228/09920f4b/attachment.html>


More information about the Qt-creator mailing list