Commit 93bb4889 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

QtSupport: Use a fixed cursor in QtOutputFormatter



Change-Id: I5fb762cd767c31673f4dba6044db9f135e71102b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent dc08efac
......@@ -58,7 +58,7 @@ public:
virtual ~OutputFormatter();
QPlainTextEdit *plainTextEdit() const;
void setPlainTextEdit(QPlainTextEdit *plainText);
virtual void setPlainTextEdit(QPlainTextEdit *plainText);
QFont font() const;
void setFont(const QFont &font);
......
......@@ -81,6 +81,7 @@ public:
QPointer<Project> project;
QString lastLine;
FileInProjectFinder projectFinder;
QTextCursor cursor;
};
} // namespace Internal
......@@ -172,14 +173,14 @@ void QtOutputFormatter::appendMessagePart(QTextCursor &cursor, const QString &tx
void QtOutputFormatter::appendMessage(const QString &txt, const QTextCharFormat &format)
{
QTextCursor cursor(plainTextEdit()->document());
cursor.movePosition(QTextCursor::End);
cursor.beginEditBlock();
if (!d->cursor.atEnd())
d->cursor.movePosition(QTextCursor::End);
d->cursor.beginEditBlock();
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,
......@@ -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()
{
OutputFormatter::clearLastLine();
......
......@@ -63,6 +63,7 @@ public:
void appendMessage(const QString &text, Utils::OutputFormat format);
void appendMessage(const QString &text, const QTextCharFormat &format);
void handleLink(const QString &href);
void setPlainTextEdit(QPlainTextEdit *plainText);
protected:
void clearLastLine();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment