ANSI: Add 256-color escape sequences support

Task-number: QTCREATORBUG-12623
Change-Id: If2f3168a77b366aae570b48f5070e85087fe76a6
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Steve Mokris
2014-07-04 15:40:16 -04:00
parent ca59e8b53a
commit e5ae8f0062
2 changed files with 46 additions and 4 deletions

View File

@@ -59,6 +59,7 @@ private Q_SLOTS:
private:
const QString red;
const QString mustard;
const QString bold;
const QString normal;
const QString normal1;
@@ -66,6 +67,7 @@ private:
tst_AnsiEscapeCodeHandler::tst_AnsiEscapeCodeHandler() :
red(ansiEscape("31m")),
mustard(ansiEscape("38;5;220m")),
bold(ansiEscape("1m")),
normal(ansiEscape("0m")),
normal1(ansiEscape("m"))
@@ -110,6 +112,18 @@ void tst_AnsiEscapeCodeHandler::testSimpleFormat_data()
<< FormattedText("red", redFormat)
<< FormattedText(" text", defaultFormat));
// Test 256-color text-color change
{
QTextCharFormat mustardFormat;
mustardFormat.setForeground(QColor(255, 204, 0));
const QString text = "This is " + mustard + "mustard" + normal + " text";
QTest::newRow("Text-color change (ANSI 256 color)") << text << QTextCharFormat()
<< (FormattedTextList()
<< FormattedText("This is ", defaultFormat)
<< FormattedText("mustard", mustardFormat)
<< FormattedText(" text", defaultFormat));
}
// Test text format change to bold
QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);