diff options
author | Christian Kandeler <[email protected]> | 2020-04-16 13:53:05 +0200 |
---|---|---|
committer | Christian Kandeler <[email protected]> | 2020-04-23 08:47:08 +0000 |
commit | 1c6e4fbd3211bc180b0de95d232226825bcb124d (patch) | |
tree | c9adce875a62a7fa980eb8a99231034585ae8fbf /src/libs/utils/ansiescapecodehandler.cpp | |
parent | b7851eeb55fd284bd647b7042e7f94a1ea1d3490 (diff) |
Merge output formatters and output parsers
Now only one piece of code needs to be written to both linkify output in
an output pane and create tasks for it in the issues pane.
The calling sites are also simplified. For instance, until now, build
steps had to feed their output parsers manually and then push the
created tasks up the signal stack in parallel with the actual output,
which the build manager relied upon for cross-linking the output pane
content. Afterwards, the output would get forwarded to the formatter
(and parsed for ANSI escape codes a second time). In contrast, a build
step now just forwards the process output, and task parsing as well as
output formatting is done centrally further up the stack.
Concrete user-visible improvements so far:
- File paths in compiler/linker messages are clickable links now.
- QtTest applications now create clickable links also when run
as part of a build step, not just in the app output pane.
Task-number: QTCREATORBUG-22665
Change-Id: Ic9fb95b2d97f2520ab3ec653315e9219466ec08d
Reviewed-by: Christian Kandeler <[email protected]>
Reviewed-by: hjk <[email protected]>
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/libs/utils/ansiescapecodehandler.cpp')
-rw-r--r-- | src/libs/utils/ansiescapecodehandler.cpp | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/libs/utils/ansiescapecodehandler.cpp b/src/libs/utils/ansiescapecodehandler.cpp index 24f66af0d76..510eb03f73a 100644 --- a/src/libs/utils/ansiescapecodehandler.cpp +++ b/src/libs/utils/ansiescapecodehandler.cpp @@ -93,6 +93,24 @@ QList<FormattedText> AnsiEscapeCodeHandler::parseText(const FormattedText &input while (!strippedText.isEmpty()) { QTC_ASSERT(m_pendingText.isEmpty(), break); + if (m_waitingForTerminator) { + // We ignore all escape codes taking string arguments. + QString terminator = "\x1b\\"; + int terminatorPos = strippedText.indexOf(terminator); + if (terminatorPos == -1 && !m_alternateTerminator.isEmpty()) { + terminator = m_alternateTerminator; + terminatorPos = strippedText.indexOf(terminator); + } + if (terminatorPos == -1) { + m_pendingText = strippedText; + break; + } + m_waitingForTerminator = false; + m_alternateTerminator.clear(); + strippedText.remove(0, terminatorPos + terminator.length()); + if (strippedText.isEmpty()) + break; + } const int escapePos = strippedText.indexOf(escape.at(0)); if (escapePos < 0) { outputData << FormattedText(strippedText, charFormat); @@ -111,11 +129,28 @@ QList<FormattedText> AnsiEscapeCodeHandler::parseText(const FormattedText &input break; } if (!strippedText.startsWith(escape)) { - // not a control sequence - m_pendingText.clear(); - outputData << FormattedText(strippedText.left(1), charFormat); - strippedText.remove(0, 1); - continue; + switch (strippedText.at(1).toLatin1()) { + case '\\': // Unexpected terminator sequence. + QTC_CHECK(false); + Q_FALLTHROUGH(); + case 'N': case 'O': // Ignore unsupported single-character sequences. + strippedText.remove(0, 2); + break; + case ']': + m_alternateTerminator = QChar(7); + Q_FALLTHROUGH(); + case 'P': case 'X': case '^': case '_': + strippedText.remove(0, 2); + m_waitingForTerminator = true; + break; + default: + // not a control sequence + m_pendingText.clear(); + outputData << FormattedText(strippedText.left(1), charFormat); + strippedText.remove(0, 1); + continue; + } + break; } m_pendingText += strippedText.midRef(0, escape.length()); strippedText.remove(0, escape.length()); |