diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-03-18 12:56:35 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-03-19 09:31:02 +0000 |
commit | ef6af1b7df7374eab6bb85a2fa80dd3a5e12e2a2 (patch) | |
tree | 4c35e12818c55e44d5af23e3a99107bdc2156f68 /src/libs/utils/outputformatter.h | |
parent | c8a2ea54333b4d0582afb62b4120558f8c6945e7 (diff) |
OutputFormatter: Do the newline handling centrally
All output formatters are line-based, and they all did their own line
splitting and, if they didn't entirely ignore it, handling of partial
lines.
Instead, we now do all the book-keeping in the base class, and the
subclasses always work with complete lines.
Change-Id: I0b0df7951d0e4f6601f4d912230071784c87b3d3
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/libs/utils/outputformatter.h')
-rw-r--r-- | src/libs/utils/outputformatter.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libs/utils/outputformatter.h b/src/libs/utils/outputformatter.h index 626e073e50..a5d9c4b331 100644 --- a/src/libs/utils/outputformatter.h +++ b/src/libs/utils/outputformatter.h @@ -61,16 +61,24 @@ public: static QTextCharFormat linkFormat(const QTextCharFormat &inputFormat, const QString &href); protected: + // text contains at most one line feed character, and if it does occur, it's the last character. + // Either way, the input is to be considered "complete" for formatting purposes. + virtual void doAppendMessage(const QString &text, OutputFormat format); + virtual void clearLastLine(); + QTextCharFormat charFormat(OutputFormat format) const; QList<FormattedText> parseAnsi(const QString &text, const QTextCharFormat &format); - virtual void doAppendMessage(const QString &text, OutputFormat format); QTextCursor &cursor() const; private: - virtual void doAppendMessage(const QString &text, const QTextCharFormat &format); + void doAppendMessage(const QString &text, const QTextCharFormat &format); + virtual void reset() {} + void append(const QString &text, const QTextCharFormat &format); void initFormats(); + void flushIncompleteLine(); + void dumpIncompleteLine(const QString &line, OutputFormat format); Internal::OutputFormatterPrivate *d; }; |