[Qt-creator] Custom lines formatting in Compile Output
tobias.hunger at digia.com
Mon Dec 9 11:22:33 CET 2013
On 09.12.2013 10:13, Mateusz Loskot wrote:
> What I'm looking for is a way to customise formatting for the chain
> of calls that starts at emitted addOutput from here
> void AbstractProcessStep::stdOutput(const QString &line)
> if (m_outputParserChain)
> emit addOutput(line, BuildStep::NormalOutput, BuildStep::DontAppendNewline);
> and received in CompileOutputWindow::appendText
> which next calls OutputWindow::appendText.
Nobody tried to do that yet AFAIK, so I don't think there is much
infrastructure in place.
Check BuildManager::addToOutputWindow for the code.
It calls CompileOutputWindow::appendText which generates QTextCharFormat
from PE::BuildStep::OutputFormat and then calls appendText on its
m_outputWindow (which is a CompileOutputTextEdit, derived from
> Initially, I thought I can do
> that could be hooked by OutputWindow::appendMessage,
> Then, I could recognise some custom format markers for
> OutputFormat::NormlMessageFormat kind of lines.
> But, the appendMessage seems never called for outputting Build lines.
Nope, this ends up as a call to appendText.
> Long story short, I would like to add colorise some lines
> that my custom IOutputParser recognises.
Please don't. I have enough bug reports about the two colors we use
already:-) You would be surprised how many people ask to change one line
or another to be printed in red instead of black (or the other way
around)... or that complain that after changing the compiler the errors
are no longer printed in red as they used to or whatnot.
If you insist on doing you own custom highlighting: Please make your
lines stand out from the others in such a way that it is clear that no
compiler/buildsystem combo on earth would ever create them!
> If that is not possible, I will try to create tasks for those lines (events),
> that that is less convenient for my case as it seems that:
> 1) The task list in the Issues pane is not a 'grid' that could be
> sorted by type, file
I have bug reports for that for ages:-/
The problem here is that the parsers are just not up to the task of
recognizing which of all the output the compiler generates belong
together: "In file included from <blah>", etc. needs to stay with the
problem that refers to, otherwise the whole filtering makes little sense.
> 2) Or, there is no way, for tasks in "Compile" category, apply
> some finer filtering. The only available is on/off for warnings.
Also have bug reports for that... same problem as for the sorting.
> In my case, build output can contain
> - build errors
> - build warnings
> - compile-time testing status (fail/pass)
> - run-time testing status (fail/pass)
> and I'd like to visually distinguish output for the last two kinds,
> either in "Compile Output" view directly or in the "Issues" list.
I do not think compile output is the right place for this: Many users
seem to not display that at all and fully rely on the build issues.
https://codereview.qt-project.org/#change,72040 adds support for custom
icons to the tasks in the build issues. You could use those to make your
tests stand out a bit more in that list.
You could even move them into their own task category, so that you
toggle the tests in the build issues separately from the compile issues.
I would recommend doing that anyway: Tests are no compile problems after
all, so they deserve a separate category.
> If it makes sense, perhaps there is a way to achieve this.
> Best regards,
Tobias Hunger, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin. USt-IdNr: DE 286 306 868
Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Qt-creator