forked from qt-creator/qt-creator
VCS: Remove removeColorCodes
status output can be uncolorized using the git config value color.status=false (works for short status since git 1.7.0) Change-Id: I0887ab9a02f4c98fe54a94a53ffcd4f91fef8699 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
54b7146986
commit
8aa1c9bc37
@@ -284,9 +284,6 @@ void Command::run()
|
||||
}
|
||||
}
|
||||
|
||||
if (ok && d->m_jobs.front().arguments.at(0) == QLatin1String("status"))
|
||||
removeColorCodes(&stdOut);
|
||||
|
||||
d->m_lastExecSuccess = ok;
|
||||
d->m_lastExecExitCode = exitCode;
|
||||
|
||||
@@ -307,29 +304,6 @@ void Command::run()
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
// Clean output from carriage return and ANSI color codes.
|
||||
// @TODO: Remove once all relevant commands support "--no-color",
|
||||
//("status" is missing it as of git 1.6.2)
|
||||
|
||||
void Command::removeColorCodes(QByteArray *data)
|
||||
{
|
||||
// Remove ansi color codes that look like "ESC[<stuff>m"
|
||||
const QByteArray ansiColorEscape("\033[");
|
||||
int escapePos = 0;
|
||||
while (true) {
|
||||
const int nextEscapePos = data->indexOf(ansiColorEscape, escapePos);
|
||||
if (nextEscapePos == -1)
|
||||
break;
|
||||
const int endEscapePos = data->indexOf('m', nextEscapePos + ansiColorEscape.size());
|
||||
if (endEscapePos != -1) {
|
||||
data->remove(nextEscapePos, endEscapePos - nextEscapePos + 1);
|
||||
escapePos = nextEscapePos;
|
||||
} else {
|
||||
escapePos = nextEscapePos + ansiColorEscape.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QVariant &Command::cookie() const
|
||||
{
|
||||
return d->m_cookie;
|
||||
|
||||
Reference in New Issue
Block a user