Commit 61eb2308 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

ANSI: Simplify escape sequence

Change-Id: I0088a922af7723aabb6751ac80af39467d4cfb0b
Reviewed-by: default avatarAndré Hartmann <aha_1980@gmx.de>
Reviewed-by: default avatarPetar Perisin <petar.perisin@gmail.com>
parent f1f1f65f
......@@ -77,7 +77,7 @@ QList<StringFormatPair> AnsiEscapeCodeHandler::parseText(const QString &text,
QTextCharFormat charFormat = m_previousFormatClosed ? defaultFormat : m_previousFormat;
const QString escape = QChar::fromLatin1(27) + QLatin1Char('[');
const QString escape = QLatin1String("\x1b[");
if (!text.contains(escape)) {
outputData << StringFormatPair(text, charFormat);
return outputData;
......
......@@ -40,6 +40,11 @@ Q_DECLARE_METATYPE(QTextCharFormat);
Q_DECLARE_METATYPE(StringFormatPair);
Q_DECLARE_METATYPE(ResultList);
static QString ansiEscape(const QByteArray &sequence)
{
return QString::fromLatin1("\x1b[" + sequence);
}
class tst_AnsiEscapeCodeHandler : public QObject
{
Q_OBJECT
......@@ -52,18 +57,17 @@ private Q_SLOTS:
void testCase1_data();
private:
static const QString red;
static const QString bold;
static const QString normal;
static const QString normal1;
const QString red;
const QString bold;
const QString normal;
const QString normal1;
};
const QString tst_AnsiEscapeCodeHandler::red = QChar::fromLatin1(27) + "[31m";
const QString tst_AnsiEscapeCodeHandler::bold = QChar::fromLatin1(27) + "[1m";
const QString tst_AnsiEscapeCodeHandler::normal = QChar::fromLatin1(27) + "[0m";
const QString tst_AnsiEscapeCodeHandler::normal1 = QChar::fromLatin1(27) + "[m";
tst_AnsiEscapeCodeHandler::tst_AnsiEscapeCodeHandler()
tst_AnsiEscapeCodeHandler::tst_AnsiEscapeCodeHandler() :
red(ansiEscape("31m")),
bold(ansiEscape("1m")),
normal(ansiEscape("0m")),
normal1(ansiEscape("m"))
{
}
......
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