forked from qt-creator/qt-creator
QtSupport: Use a fixed cursor in QtOutputFormatter
Change-Id: I5fb762cd767c31673f4dba6044db9f135e71102b Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
dc08efac6f
commit
93bb48893f
@@ -58,7 +58,7 @@ public:
|
|||||||
virtual ~OutputFormatter();
|
virtual ~OutputFormatter();
|
||||||
|
|
||||||
QPlainTextEdit *plainTextEdit() const;
|
QPlainTextEdit *plainTextEdit() const;
|
||||||
void setPlainTextEdit(QPlainTextEdit *plainText);
|
virtual void setPlainTextEdit(QPlainTextEdit *plainText);
|
||||||
|
|
||||||
QFont font() const;
|
QFont font() const;
|
||||||
void setFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
@@ -81,6 +81,7 @@ public:
|
|||||||
QPointer<Project> project;
|
QPointer<Project> project;
|
||||||
QString lastLine;
|
QString lastLine;
|
||||||
FileInProjectFinder projectFinder;
|
FileInProjectFinder projectFinder;
|
||||||
|
QTextCursor cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -172,14 +173,14 @@ void QtOutputFormatter::appendMessagePart(QTextCursor &cursor, const QString &tx
|
|||||||
|
|
||||||
void QtOutputFormatter::appendMessage(const QString &txt, const QTextCharFormat &format)
|
void QtOutputFormatter::appendMessage(const QString &txt, const QTextCharFormat &format)
|
||||||
{
|
{
|
||||||
QTextCursor cursor(plainTextEdit()->document());
|
if (!d->cursor.atEnd())
|
||||||
cursor.movePosition(QTextCursor::End);
|
d->cursor.movePosition(QTextCursor::End);
|
||||||
cursor.beginEditBlock();
|
d->cursor.beginEditBlock();
|
||||||
|
|
||||||
foreach (const FormattedText &output, parseAnsi(txt, format))
|
foreach (const FormattedText &output, parseAnsi(txt, format))
|
||||||
appendMessagePart(cursor, output.text, output.format);
|
appendMessagePart(d->cursor, output.text, output.format);
|
||||||
|
|
||||||
cursor.endEditBlock();
|
d->cursor.endEditBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtOutputFormatter::appendLine(QTextCursor &cursor, const LinkResult &lr,
|
void QtOutputFormatter::appendLine(QTextCursor &cursor, const LinkResult &lr,
|
||||||
@@ -263,6 +264,12 @@ void QtOutputFormatter::handleLink(const QString &href)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtOutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText)
|
||||||
|
{
|
||||||
|
OutputFormatter::setPlainTextEdit(plainText);
|
||||||
|
d->cursor = plainText ? plainText->textCursor() : QTextCursor();
|
||||||
|
}
|
||||||
|
|
||||||
void QtOutputFormatter::clearLastLine()
|
void QtOutputFormatter::clearLastLine()
|
||||||
{
|
{
|
||||||
OutputFormatter::clearLastLine();
|
OutputFormatter::clearLastLine();
|
||||||
|
@@ -63,6 +63,7 @@ public:
|
|||||||
void appendMessage(const QString &text, Utils::OutputFormat format);
|
void appendMessage(const QString &text, Utils::OutputFormat format);
|
||||||
void appendMessage(const QString &text, const QTextCharFormat &format);
|
void appendMessage(const QString &text, const QTextCharFormat &format);
|
||||||
void handleLink(const QString &href);
|
void handleLink(const QString &href);
|
||||||
|
void setPlainTextEdit(QPlainTextEdit *plainText);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void clearLastLine();
|
void clearLastLine();
|
||||||
|
Reference in New Issue
Block a user