Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #28 from FireyFly/master
Add 256-colour support
  • Loading branch information
thp committed Mar 31, 2014
2 parents 9f25337 + 3b52af7 commit c8cabf9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
24 changes: 24 additions & 0 deletions terminal.cpp
Expand Up @@ -747,6 +747,19 @@ void Terminal::ansiSequence(const QString& seq)
break;
}
if(params.count() > 0) {
// xterm 256-colour support
if(params.count() > 1 && (params[0] == 38 || params[0] == 48)) {
if(params.count() > 2 && params[1] == 5 &&
params[2] >= 0 && params[2] <= 255) {
if(params[0] == 38)
iTermAttribs.currentFgColor = params[2];
else
iTermAttribs.currentBgColor = params[2];
}
// TODO: 2;r;g;b for 24-bit colour support (Konsole etc)
break;
}

if(params.contains(0)) {
iTermAttribs.currentFgColor = defaultFgColor;
iTermAttribs.currentBgColor = defaultBgColor;
Expand Down Expand Up @@ -774,6 +787,17 @@ void Terminal::ansiSequence(const QString& seq)
iTermAttribs.currentBgColor = p-40;
}
}

// high-intensity regular-weight extension (nonstandard)
foreach(int p, params) {
if(p >= 90 && p<= 97) {
iTermAttribs.currentFgColor = p-90+8;
}
if(p >= 100 && p<= 107) {
iTermAttribs.currentBgColor = p-100+8;
}
}

if(params.contains(39))
iTermAttribs.currentFgColor = defaultFgColor;
if(params.contains(49))
Expand Down
17 changes: 16 additions & 1 deletion textrender.cpp
Expand Up @@ -42,6 +42,7 @@ TextRender::TextRender(QQuickItem *parent) :
iColorTable.append(QColor(210, 0, 210));
iColorTable.append(QColor(0, 210, 210));
iColorTable.append(QColor(235, 235, 235));

//bright
iColorTable.append(QColor(127, 127, 127));
iColorTable.append(QColor(255, 0, 0));
Expand All @@ -52,7 +53,21 @@ TextRender::TextRender(QQuickItem *parent) :
iColorTable.append(QColor(0, 255, 255));
iColorTable.append(QColor(255, 255, 255));

if(iColorTable.size()!=16)
//colour cube
for (int r = 0x00; r < 0x100; r += 0x33)
for (int g = 0x00; g < 0x100; g += 0x33)
for (int b = 0x00; b < 0x100; b += 0x33)
iColorTable.append(QColor(r, g, b));

//greyscale ramp
int ramp[] = {
0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121,
133, 144, 155, 166, 177, 188, 199, 210, 221, 232, 243, 255
};
for (int i = 0; i < 24; i++)
iColorTable.append(QColor(ramp[i], ramp[i], ramp[i]));

if(iColorTable.size() != 256)
qFatal("invalid color table");

iShowBufferScrollIndicator = false;
Expand Down

0 comments on commit c8cabf9

Please sign in to comment.