forked from qt-creator/qt-creator
merge addToOutputWindow and addToOutputWindowInline
This commit is contained in:
@@ -442,15 +442,13 @@ void DebuggerRunControl::start()
|
||||
|
||||
d->m_engine->startDebugger(this);
|
||||
|
||||
if (d->m_running) {
|
||||
emit addToOutputWindowInline(this, tr("Debugging starts"), false);
|
||||
emit addToOutputWindowInline(this, "\n", false);
|
||||
}
|
||||
if (d->m_running)
|
||||
emit addToOutputWindow(this, tr("Debugging starts"), false, false);
|
||||
}
|
||||
|
||||
void DebuggerRunControl::startFailed()
|
||||
{
|
||||
emit addToOutputWindowInline(this, tr("Debugging has failed"), false);
|
||||
emit addToOutputWindow(this, tr("Debugging has failed"), false, false);
|
||||
d->m_running = false;
|
||||
emit finished();
|
||||
d->m_engine->handleStartFailed();
|
||||
@@ -458,7 +456,7 @@ void DebuggerRunControl::startFailed()
|
||||
|
||||
void DebuggerRunControl::handleFinished()
|
||||
{
|
||||
emit addToOutputWindowInline(this, tr("Debugging has finished"), false);
|
||||
emit addToOutputWindow(this, tr("Debugging has finished"), false, false);
|
||||
if (d->m_engine)
|
||||
d->m_engine->handleFinished();
|
||||
debuggerCore()->runControlFinished(d->m_engine);
|
||||
@@ -468,10 +466,10 @@ void DebuggerRunControl::showMessage(const QString &msg, int channel)
|
||||
{
|
||||
switch (channel) {
|
||||
case AppOutput:
|
||||
emit addToOutputWindowInline(this, msg, false);
|
||||
emit addToOutputWindow(this, msg, false, true);
|
||||
break;
|
||||
case AppError:
|
||||
emit addToOutputWindowInline(this, msg, true);
|
||||
emit addToOutputWindow(this, msg, true, true);
|
||||
break;
|
||||
case AppStuff:
|
||||
emit appendMessage(this, msg, true);
|
||||
|
||||
@@ -132,7 +132,7 @@ void LocalApplicationRunControl::slotAppendMessage(const QString &err,
|
||||
void LocalApplicationRunControl::slotAddToOutputWindow(const QString &line,
|
||||
bool isError)
|
||||
{
|
||||
emit addToOutputWindowInline(this, line, isError);
|
||||
emit addToOutputWindow(this, line, isError, true);
|
||||
}
|
||||
|
||||
void LocalApplicationRunControl::processExited(int exitCode)
|
||||
|
||||
@@ -74,7 +74,7 @@ void OutputFormatter::appendMessage(const QString &text, OutputFormat format)
|
||||
cursor.insertText(text, m_formats[format]);
|
||||
}
|
||||
|
||||
QTextCharFormat OutputFormatter::format(OutputFormat format) const
|
||||
QTextCharFormat OutputFormatter::charFormat(OutputFormat format) const
|
||||
{
|
||||
return m_formats[format];
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
protected:
|
||||
void initFormats();
|
||||
void clearLastLine();
|
||||
QTextCharFormat format(OutputFormat format) const;
|
||||
QTextCharFormat charFormat(OutputFormat format) const;
|
||||
|
||||
static QColor mixColors(const QColor &a, const QColor &b);
|
||||
|
||||
|
||||
@@ -278,20 +278,11 @@ void OutputPane::createNewOutputWindow(RunControl *rc)
|
||||
}
|
||||
|
||||
void OutputPane::appendApplicationOutput(RunControl *rc, const QString &out,
|
||||
bool onStdErr)
|
||||
bool onStdErr, bool sameLine)
|
||||
{
|
||||
const int index = indexOf(rc);
|
||||
if (index != -1)
|
||||
m_runControlTabs.at(index).window->appendApplicationOutput(out, onStdErr);
|
||||
}
|
||||
|
||||
void OutputPane::appendApplicationOutputInline(RunControl *rc,
|
||||
const QString &out,
|
||||
bool onStdErr)
|
||||
{
|
||||
const int index = indexOf(rc);
|
||||
if (index != -1)
|
||||
m_runControlTabs.at(index).window->appendApplicationOutputInline(out, onStdErr);
|
||||
m_runControlTabs.at(index).window->appendApplicationOutput(out, onStdErr, sameLine);
|
||||
}
|
||||
|
||||
void OutputPane::appendMessage(RunControl *rc, const QString &out, bool isError)
|
||||
@@ -625,46 +616,39 @@ QString OutputWindow::doNewlineEnfocement(const QString &out)
|
||||
return s;
|
||||
}
|
||||
|
||||
void OutputWindow::appendApplicationOutput(const QString &output, bool onStdErr)
|
||||
void OutputWindow::appendApplicationOutput(const QString &output, bool onStdErr, bool sameLine)
|
||||
{
|
||||
QString out = output;
|
||||
out.remove(QLatin1Char('\r'));
|
||||
setMaximumBlockCount(MaxBlockCount);
|
||||
const bool atBottom = isScrollbarAtBottom();
|
||||
m_formatter->appendMessage(doNewlineEnfocement(out), onStdErr ? StdErrFormat : StdOutFormat);
|
||||
if (atBottom)
|
||||
scrollToBottom();
|
||||
enableUndoRedo();
|
||||
}
|
||||
|
||||
void OutputWindow::appendApplicationOutputInline(const QString &output, bool onStdErr)
|
||||
{
|
||||
QString out = output;
|
||||
out.remove(QLatin1Char('\r'));
|
||||
m_scrollToBottom = true;
|
||||
setMaximumBlockCount(MaxBlockCount);
|
||||
if (sameLine) {
|
||||
m_scrollToBottom = true;
|
||||
|
||||
int newline = -1;
|
||||
bool enforceNewline = m_enforceNewline;
|
||||
m_enforceNewline = false;
|
||||
const bool atBottom = isScrollbarAtBottom();
|
||||
int newline = -1;
|
||||
bool enforceNewline = m_enforceNewline;
|
||||
m_enforceNewline = false;
|
||||
|
||||
if (!enforceNewline) {
|
||||
newline = out.indexOf(QLatin1Char('\n'));
|
||||
moveCursor(QTextCursor::End);
|
||||
if (newline != -1)
|
||||
m_formatter->appendMessage(out.left(newline), onStdErr ? StdErrFormat : StdOutFormat); // doesn't enforce new paragraph like appendPlainText
|
||||
}
|
||||
|
||||
QString s = out.mid(newline+1);
|
||||
if (s.isEmpty()) {
|
||||
m_enforceNewline = true;
|
||||
} else {
|
||||
if (s.endsWith(QLatin1Char('\n'))) {
|
||||
m_enforceNewline = true;
|
||||
s.chop(1);
|
||||
if (!enforceNewline) {
|
||||
newline = out.indexOf(QLatin1Char('\n'));
|
||||
moveCursor(QTextCursor::End);
|
||||
if (newline != -1)
|
||||
m_formatter->appendMessage(out.left(newline), onStdErr ? StdErrFormat : StdOutFormat); // doesn't enforce new paragraph like appendPlainText
|
||||
}
|
||||
m_formatter->appendMessage(QLatin1Char('\n') + s, onStdErr ? StdErrFormat : StdOutFormat);
|
||||
|
||||
QString s = out.mid(newline+1);
|
||||
if (s.isEmpty()) {
|
||||
m_enforceNewline = true;
|
||||
} else {
|
||||
if (s.endsWith(QLatin1Char('\n'))) {
|
||||
m_enforceNewline = true;
|
||||
s.chop(1);
|
||||
}
|
||||
m_formatter->appendMessage(QLatin1Char('\n') + s, onStdErr ? StdErrFormat : StdOutFormat);
|
||||
}
|
||||
} else {
|
||||
m_formatter->appendMessage(doNewlineEnfocement(out), onStdErr ? StdErrFormat : StdOutFormat);
|
||||
}
|
||||
|
||||
if (atBottom)
|
||||
|
||||
@@ -97,14 +97,12 @@ signals:
|
||||
void allRunControlsFinished();
|
||||
|
||||
public slots:
|
||||
// ApplicationOutputspecifics
|
||||
// ApplicationOutput specifics
|
||||
void createNewOutputWindow(RunControl *rc);
|
||||
void projectRemoved();
|
||||
|
||||
void appendApplicationOutput(ProjectExplorer::RunControl *rc, const QString &out,
|
||||
bool onStdErr);
|
||||
void appendApplicationOutputInline(ProjectExplorer::RunControl *rc, const QString &out,
|
||||
bool onStdErr);
|
||||
bool onStdErr, bool sameLine);
|
||||
void appendMessage(ProjectExplorer::RunControl *rc, const QString &out, bool isError);
|
||||
|
||||
private slots:
|
||||
@@ -157,8 +155,7 @@ public:
|
||||
OutputFormatter* formatter() const;
|
||||
void setFormatter(OutputFormatter *formatter);
|
||||
|
||||
void appendApplicationOutput(const QString &out, bool onStdErr);
|
||||
void appendApplicationOutputInline(const QString &out, bool onStdErr);
|
||||
void appendApplicationOutput(const QString &out, bool onStdErr, bool sameLine);
|
||||
void appendMessage(const QString &out, bool isError);
|
||||
/// appends a \p text using \p format without using formater
|
||||
void appendText(const QString &text, const QTextCharFormat &format, int maxLineCount);
|
||||
|
||||
@@ -1387,10 +1387,8 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QStrin
|
||||
d->m_outputPane->popup(false);
|
||||
d->m_outputPane->showTabFor(runControl);
|
||||
|
||||
connect(runControl, SIGNAL(addToOutputWindow(ProjectExplorer::RunControl*,QString,bool)),
|
||||
d->m_outputPane, SLOT(appendApplicationOutput(ProjectExplorer::RunControl*,QString, bool)));
|
||||
connect(runControl, SIGNAL(addToOutputWindowInline(ProjectExplorer::RunControl*,QString,bool)),
|
||||
d->m_outputPane, SLOT(appendApplicationOutputInline(ProjectExplorer::RunControl*,QString,bool)));
|
||||
connect(runControl, SIGNAL(addToOutputWindow(ProjectExplorer::RunControl*,QString,bool,bool)),
|
||||
d->m_outputPane, SLOT(appendApplicationOutput(ProjectExplorer::RunControl*,QString, bool,bool)));
|
||||
connect(runControl, SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,bool)),
|
||||
d->m_outputPane, SLOT(appendMessage(ProjectExplorer::RunControl*,QString,bool)));
|
||||
|
||||
|
||||
@@ -147,8 +147,8 @@ const char * const G_SESSION_FILES = "Session.Group.Files";
|
||||
const char * const G_SESSION_OTHER = "Session.Group.Other";
|
||||
const char * const G_SESSION_CONFIG = "Session.Group.Config";
|
||||
|
||||
const char * const G_PROJECT_FIRST = "Project.Group.Open";
|
||||
const char * const G_PROJECT_FILES = "Project.Group.Files";
|
||||
const char * const G_PROJECT_FIRST = "Project.Group.Open";
|
||||
const char * const G_PROJECT_BUILD = "Project.Group.Build";
|
||||
const char * const G_PROJECT_OTHER = "Project.Group.Other";
|
||||
const char * const G_PROJECT_RUN = "Project.Group.Run";
|
||||
|
||||
@@ -201,8 +201,7 @@ public:
|
||||
QString runMode() const;
|
||||
|
||||
signals:
|
||||
void addToOutputWindow(ProjectExplorer::RunControl *, const QString &line, bool onStdErr);
|
||||
void addToOutputWindowInline(ProjectExplorer::RunControl *, const QString &line, bool onStdErr);
|
||||
void addToOutputWindow(ProjectExplorer::RunControl *, const QString &line, bool onStdErr, bool sameLine);
|
||||
void appendMessage(ProjectExplorer::RunControl *, const QString &error, bool isError);
|
||||
void started();
|
||||
void finished();
|
||||
|
||||
@@ -126,7 +126,7 @@ void QmlRunControl::slotError(const QString &err, bool isError)
|
||||
|
||||
void QmlRunControl::slotAddToOutputWindow(const QString &line, bool onStdErr)
|
||||
{
|
||||
emit addToOutputWindowInline(this, line, onStdErr);
|
||||
emit addToOutputWindow(this, line, onStdErr, true);
|
||||
}
|
||||
|
||||
void QmlRunControl::processExited(int exitCode)
|
||||
|
||||
@@ -119,12 +119,12 @@ void MaemoRunControl::handleRemoteProcessFinished(qint64 exitCode)
|
||||
|
||||
void MaemoRunControl::handleRemoteOutput(const QByteArray &output)
|
||||
{
|
||||
emit addToOutputWindowInline(this, QString::fromUtf8(output), false);
|
||||
emit addToOutputWindow(this, QString::fromUtf8(output), false, true);
|
||||
}
|
||||
|
||||
void MaemoRunControl::handleRemoteErrorOutput(const QByteArray &output)
|
||||
{
|
||||
emit addToOutputWindowInline(this, QString::fromUtf8(output), true);
|
||||
emit addToOutputWindow(this, QString::fromUtf8(output), true, true);
|
||||
}
|
||||
|
||||
void MaemoRunControl::handleProgressReport(const QString &progressString)
|
||||
@@ -134,7 +134,7 @@ void MaemoRunControl::handleProgressReport(const QString &progressString)
|
||||
|
||||
void MaemoRunControl::handleMountDebugOutput(const QString &output)
|
||||
{
|
||||
emit addToOutputWindowInline(this, output, true);
|
||||
emit addToOutputWindow(this, output, true, true);
|
||||
}
|
||||
|
||||
bool MaemoRunControl::isRunning() const
|
||||
|
||||
@@ -649,9 +649,9 @@ void S60DeviceRunControl::reportDeployFinished()
|
||||
}
|
||||
}
|
||||
|
||||
void S60DeviceRunControl::processStopped(uint pc, uint pid, uint tid, const QString& reason)
|
||||
void S60DeviceRunControl::processStopped(uint pc, uint pid, uint tid, const QString &reason)
|
||||
{
|
||||
emit addToOutputWindow(this, trk::Launcher::msgStopped(pid, tid, pc, reason), false);
|
||||
emit addToOutputWindow(this, trk::Launcher::msgStopped(pid, tid, pc, reason), false, false);
|
||||
m_launcher->terminate();
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ void S60DeviceRunControl::printApplicationOutput(const QString &output)
|
||||
|
||||
void S60DeviceRunControl::printApplicationOutput(const QString &output, bool onStdErr)
|
||||
{
|
||||
emit addToOutputWindowInline(this, output, onStdErr);
|
||||
emit addToOutputWindow(this, output, onStdErr, true);
|
||||
}
|
||||
|
||||
void S60DeviceRunControl::deviceRemoved(const SymbianUtils::SymbianDevice &d)
|
||||
|
||||
@@ -374,7 +374,7 @@ void S60EmulatorRunControl::slotAddToOutputWindow(const QString &line, bool onSt
|
||||
static int prefixLength = prefix.length();
|
||||
int index = line.indexOf(prefix);
|
||||
if (index != -1) {
|
||||
emit addToOutputWindowInline(this, line.mid(index + prefixLength + 1), onStdErr);
|
||||
emit addToOutputWindow(this, line.mid(index + prefixLength + 1), onStdErr, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ LinkResult QtOutputFormatter::matchLine(const QString &line) const
|
||||
return lr;
|
||||
}
|
||||
|
||||
void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdErr)
|
||||
void QtOutputFormatter::appendMessage(const QString &txt, OutputFormat format)
|
||||
{
|
||||
QTextCursor cursor(plainTextEdit()->document());
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
@@ -108,10 +108,10 @@ void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdEr
|
||||
LinkResult lr = matchLine(line);
|
||||
if (!lr.href.isEmpty()) {
|
||||
// Found something && line continuation
|
||||
cursor.insertText(deferedText, format(onStdErr ? StdErrFormat : StdOutFormat));
|
||||
cursor.insertText(deferedText, charFormat(format));
|
||||
deferedText.clear();
|
||||
clearLastLine();
|
||||
appendLine(cursor, lr, line, onStdErr);
|
||||
appendLine(cursor, lr, line, format);
|
||||
} else {
|
||||
// Found nothing, just emit the new part
|
||||
deferedText += newPart;
|
||||
@@ -122,9 +122,9 @@ void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdEr
|
||||
const QString line = txt.mid(start, pos - start + 1);
|
||||
LinkResult lr = matchLine(line);
|
||||
if (!lr.href.isEmpty()) {
|
||||
cursor.insertText(deferedText, format(onStdErr ? StdErrFormat : StdOutFormat));
|
||||
cursor.insertText(deferedText, charFormat(format));
|
||||
deferedText.clear();
|
||||
appendLine(cursor, lr, line, onStdErr);
|
||||
appendLine(cursor, lr, line, format);
|
||||
} else {
|
||||
deferedText += line;
|
||||
}
|
||||
@@ -142,10 +142,10 @@ void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdEr
|
||||
LinkResult lr = matchLine(m_lastLine);
|
||||
if (!lr.href.isEmpty()) {
|
||||
// Found something && line continuation
|
||||
cursor.insertText(deferedText, format(onStdErr ? StdErrFormat : StdOutFormat));
|
||||
cursor.insertText(deferedText, charFormat(format));
|
||||
deferedText.clear();
|
||||
clearLastLine();
|
||||
appendLine(cursor, lr, m_lastLine, onStdErr);
|
||||
appendLine(cursor, lr, m_lastLine, format);
|
||||
} else {
|
||||
// Found nothing, just emit the new part
|
||||
deferedText += newPart;
|
||||
@@ -154,22 +154,23 @@ void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdEr
|
||||
m_lastLine = txt.mid(start);
|
||||
LinkResult lr = matchLine(m_lastLine);
|
||||
if (!lr.href.isEmpty()) {
|
||||
cursor.insertText(deferedText, format(onStdErr ? StdErrFormat : StdOutFormat));
|
||||
cursor.insertText(deferedText, charFormat(format));
|
||||
deferedText.clear();
|
||||
appendLine(cursor, lr, m_lastLine, onStdErr);
|
||||
appendLine(cursor, lr, m_lastLine, format);
|
||||
} else {
|
||||
deferedText += m_lastLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.insertText(deferedText, format(onStdErr ? StdErrFormat : StdOutFormat));
|
||||
cursor.insertText(deferedText, charFormat(format));
|
||||
// deferedText.clear();
|
||||
cursor.endEditBlock();
|
||||
}
|
||||
|
||||
void QtOutputFormatter::appendLine(QTextCursor &cursor, LinkResult lr, const QString &line, bool onStdErr)
|
||||
void QtOutputFormatter::appendLine(QTextCursor &cursor, LinkResult lr,
|
||||
const QString &line, ProjectExplorer::OutputFormat format)
|
||||
{
|
||||
const QTextCharFormat normalFormat = format(onStdErr ? StdErrFormat : StdOutFormat);
|
||||
const QTextCharFormat normalFormat = charFormat(format);
|
||||
cursor.insertText(line.left(lr.start), normalFormat);
|
||||
|
||||
QTextCharFormat linkFormat = normalFormat;
|
||||
@@ -179,7 +180,6 @@ void QtOutputFormatter::appendLine(QTextCursor &cursor, LinkResult lr, const QSt
|
||||
linkFormat.setAnchor(true);
|
||||
linkFormat.setAnchorHref(lr.href);
|
||||
cursor.insertText(line.mid(lr.start, lr.end - lr.start), linkFormat);
|
||||
|
||||
cursor.insertText(line.mid(lr.end), normalFormat);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,7 @@ namespace ProjectExplorer {
|
||||
class Project;
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
namespace Qt4ProjectManager
|
||||
{
|
||||
namespace Qt4ProjectManager {
|
||||
|
||||
struct LinkResult
|
||||
{
|
||||
@@ -58,18 +57,20 @@ struct LinkResult
|
||||
QString href;
|
||||
};
|
||||
|
||||
class QT4PROJECTMANAGER_EXPORT QtOutputFormatter: public ProjectExplorer::OutputFormatter
|
||||
class QT4PROJECTMANAGER_EXPORT QtOutputFormatter
|
||||
: public ProjectExplorer::OutputFormatter
|
||||
{
|
||||
public:
|
||||
QtOutputFormatter(ProjectExplorer::Project *project);
|
||||
|
||||
virtual void appendApplicationOutput(const QString &text, bool onStdErr);
|
||||
|
||||
virtual void appendMessage(const QString &text,
|
||||
ProjectExplorer::OutputFormat format);
|
||||
virtual void handleLink(const QString &href);
|
||||
|
||||
private:
|
||||
LinkResult matchLine(const QString &line) const;
|
||||
void appendLine(QTextCursor & cursor, LinkResult lr, const QString &line, bool onStdError);
|
||||
void appendLine(QTextCursor & cursor, LinkResult lr,
|
||||
const QString &line, ProjectExplorer::OutputFormat);
|
||||
|
||||
QRegExp m_qmlError;
|
||||
QRegExp m_qtError;
|
||||
|
||||
Reference in New Issue
Block a user