[Konsole-devel] [Bug 107487] Please add the xterm-256 colour support.
Witold Filipczyk
witekfl at poczta.onet.pl
Sat Jun 17 14:07:13 UTC 2006
Here is the patch. Memory usage is threefolded.
fg_rgb and bg_rgb is used only in 256/true colour mode. Mode is indicated by
fg == 128 or bg == 128 respectively. I didn't init colors_256
programmatically, because I didn't know where to do it.
rgbused is used in many places, because of usage of color_table there.
Please, don't ask me to rewrite it again.
Witek
-------------- next part --------------
--- konsole/TEmuVt102.cpp.old 2006-06-04 15:49:07.000000000 +0200
+++ konsole/TEmuVt102.cpp 2006-06-17 12:34:53.654162168 +0200
@@ -344,6 +344,28 @@
for (i=0;i<=argc;i++)
if ( epp( )) { tau( TY_CSI_PR(cc,argv[i]), 0, 0); }
else if(egt( )) { tau( TY_CSI_PG(cc ), 0, 0); } // spec. case for ESC]>0c or ESC]>c
+ else if (cc == 'm' && argc - i >= 4 && argv[i] == 38 && argv[i+1] == 2) // ESC]38;2;<red>;<green>;<blue>
+ {
+ i += 2;
+ tau( TY_CSI_PS(cc, 38), 2, (argv[i] << 16) | (argv[i+1] << 8) | argv[i+2]);
+ i += 2;
+ }
+ else if (cc == 'm' && argc - i >= 4 && argv[i] == 48 && argv[i+1] == 2) // ESC48;2;<red>;<green>;<blue>
+ {
+ i += 2;
+ tau( TY_CSI_PS(cc, 48), 2, (argv[i] << 16) | (argv[i+1] << 8) | argv[i+2]);
+ i += 2;
+ }
+ else if (cc == 'm' && argc - i >= 2 && argv[i] == 38 && argv[i+1] == 5) // ESC]38;5;<index>
+ {
+ i += 2;
+ tau( TY_CSI_PS(cc, 38), 5, argv[i]);
+ }
+ else if (cc == 'm' && argc - i >= 2 && argv[i] == 48 && argv[i+1] == 5) // ESC]48;5;<index>
+ {
+ i += 2;
+ tau( TY_CSI_PS(cc, 48), 5, argv[i]);
+ }
else { tau( TY_CSI_PS(cc,argv[i]), 0, 0); }
resetToken();
}
@@ -551,6 +573,16 @@
case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break;
case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break;
case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break;
+
+ case TY_CSI_PS('m', 38) :
+ if (p == 2) scr->setForeColorRGB(q);
+ else if (p == 5)
+ {
+ if (q >= 0 && q < 16) scr->setForeColor(q);
+ else if (q >= 16 && q <= 255) scr->setForeColor256(q);
+ }
+ break;
+
case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break;
case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break;
@@ -561,6 +593,16 @@
case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break;
case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break;
case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break;
+
+ case TY_CSI_PS('m', 48) :
+ if (p == 2) scr->setBackColorRGB(q);
+ else if (p == 5)
+ {
+ if (q >= 0 && q < 16) scr->setBackColor(q);
+ else if (q >= 16 && q <= 255) scr->setBackColor256(q);
+ }
+ break;
+
case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break;
case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break;
--- konsole/TECommon.h.old 2006-06-04 16:19:34.000000000 +0200
+++ konsole/TECommon.h 2006-06-17 15:15:30.486141024 +0200
@@ -46,10 +46,38 @@
#define RE_INTENSIVE (1 << 3) // Widget only
#define RE_CURSOR (1 << 4)
+#define RGB_USED 128
+#define rgbused(a) ((a) & RGB_USED)
/*! \class ca
* \brief a character with rendition attributes.
*/
+class rgbcolor
+{
+public:
+ inline rgbcolor(UINT8 _r = 0,
+ UINT8 _g = 0,
+ UINT8 _b = 0)
+ : r(_r), g(_g), b(_b) {}
+public:
+ UINT8 r;
+ UINT8 g;
+ UINT8 b;
+public:
+ friend bool operator == (rgbcolor a, rgbcolor b);
+ friend bool operator != (rgbcolor a, rgbcolor b);
+};
+
+inline bool operator == (rgbcolor a, rgbcolor b)
+{
+ return a.r == b.r && a.g == b.g && a.b == b.b;
+}
+
+inline bool operator != (rgbcolor a, rgbcolor b)
+{
+ return a.r != b.r || a.g != b.g || a.b != b.b;
+}
+
class ca
{
public:
@@ -62,6 +90,8 @@
UINT16 c; // character
UINT8 f; // foreground color
UINT8 b; // background color
+ rgbcolor fg_rgb; // used when rgbused(f) is true
+ rgbcolor bg_rgb; // used when rgbused(b) is true
UINT8 r; // rendition
public:
friend bool operator == (ca a, ca b);
@@ -69,13 +99,17 @@
};
inline bool operator == (ca a, ca b)
-{
- return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r;
+{
+ return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r &&
+ (!rgbused(a.f) || (a.fg_rgb == b.fg_rgb)) && (!rgbused(a.b) ||
+ (a.bg_rgb == b.bg_rgb));
}
inline bool operator != (ca a, ca b)
{
- return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r;
+ return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r ||
+ (rgbused(a.f) && (a.fg_rgb != b.fg_rgb)) || (rgbused(a.b) &&
+ (a.bg_rgb != b.bg_rgb));
}
/*!
--- konsole/TEWidget.cpp.old 2006-06-04 16:21:34.000000000 +0200
+++ konsole/TEWidget.cpp 2006-06-17 15:35:36.937732504 +0200
@@ -586,7 +586,11 @@
QString& str, const ca *attr, bool pm, bool clear)
{
int a = font_a + m_lineSpacing / 2;
- QColor fColor = printerFriendly ? Qt::black : color_table[attr->f].color;
+ QColor fRGBColor = QColor(attr->fg_rgb.r, attr->fg_rgb.g, attr->fg_rgb.b);
+ QColor bRGBColor = QColor(attr->bg_rgb.r, attr->bg_rgb.g, attr->bg_rgb.b);
+ QColor fColor2 = rgbused(attr->f) ? fRGBColor : color_table[attr->f].color;
+ QColor fColor = printerFriendly ? Qt::black : fColor2;
+ QColor bColor = rgbused(attr->b) ? bRGBColor : color_table[attr->b].color;
QString drawstr;
if ((attr->r & RE_CURSOR) && !isPrinting)
@@ -595,7 +599,7 @@
// Paint background
if (!printerFriendly)
{
- if (color_table[attr->b].transparent)
+ if (!rgbused(attr->b) && color_table[attr->b].transparent)
{
if (pm)
paint.setBackgroundMode( TransparentMode );
@@ -604,12 +608,12 @@
}
else
{
- if (pm || color_table[attr->b].color != color_table[ colorsSwapped ? DEFAULT_FORE_COLOR : DEFAULT_BACK_COLOR ].color
+ if (pm || bColor != color_table[ colorsSwapped ? DEFAULT_FORE_COLOR : DEFAULT_BACK_COLOR ].color
|| clear || (blinking && (attr->r & RE_BLINK)))
// draw background colors with 75% opacity
if ( argb_visual && qAlpha(blend_color) < 0xff ) {
- QRgb col = color_table[attr->b].color.rgb();
+ QRgb col = bColor.rgb();
Q_UINT8 salpha = 192;
Q_UINT8 dalpha = 255 - salpha;
@@ -625,7 +629,7 @@
paint.fillRect(rect, QColor(col, pixel));
} else
- paint.fillRect(rect, color_table[attr->b].color);
+ paint.fillRect(rect, bColor);
}
QString tmpStr = str.simplifyWhiteSpace();
@@ -664,8 +668,8 @@
{
if (!cursorBlinking)
{
- paint.fillRect(r, color_table[attr->f].color);
- fColor = color_table[attr->b].color;
+ paint.fillRect(r, fColor2);
+ fColor = bColor;
}
}
else
@@ -685,7 +689,7 @@
bool shadow = false;
paint.setPen(fColor);
int x = rect.x();
- if (color_table[attr->f].bold && printerBold)
+ if (!rgbused(attr->f) && color_table[attr->f].bold && printerBold)
{
// When printing we use a bold font for bold
paint.save();
@@ -721,13 +725,13 @@
paint.drawText(x,y, str, -1, bidiEnabled ? QPainter::Auto : QPainter::LTR );
}
- if (color_table[attr->f].bold && isPrinting)
+ if (!rgbused(attr->f) && color_table[attr->f].bold && isPrinting)
{
// When printing we use a bold font for bold
paint.restore();
}
- if (color_table[attr->f].bold && !printerBold)
+ if (!rgbused(attr->f) && color_table[attr->f].bold && !printerBold)
{
paint.setClipRect(rect);
// On screen we use overstrike for bold
@@ -799,6 +803,8 @@
int cf = -1; // undefined
int cb = -1; // undefined
int cr = -1; // undefined
+ rgbcolor cf_rgb;
+ rgbcolor cb_rgb;
int lins = QMIN(this->lines, QMAX(0,lines ));
int cols = QMIN(this->columns,QMAX(0,columns));
@@ -847,6 +853,8 @@
cr = ext[x].r;
cb = ext[x].b;
if (ext[x].f != cf) cf = ext[x].f;
+ cf_rgb = ext[x].fg_rgb;
+ cb_rgb = ext[x].bg_rgb;
int lln = cols - x;
for (len = 1; len < lln; len++)
{
@@ -854,7 +862,7 @@
if (!c)
continue; // Skip trailing part of multi-col chars.
- if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
+ if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len].fg_rgb != cf_rgb || ext[x+len].bg_rgb != cb_rgb ||
!dirtyMask[x+len] || isLineChar(c) != lineDraw || (ext[x+len+1].c == 0) != doubleWidth)
break;
--- konsole/TEScreen.h.old 2006-06-17 12:36:25.394215560 +0200
+++ konsole/TEScreen.h 2006-06-17 15:10:44.121675040 +0200
@@ -113,6 +113,11 @@
void setForeColor (int fgcolor);
void setBackColor (int bgcolor);
//
+ void setForeColorRGB(int rgb);
+ void setBackColorRGB(int rgb);
+ void setForeColor256(int index);
+ void setBackColor256(int index);
+ //
void setDefaultRendition();
void setForeColorToDefault();
void setBackColorToDefault();
@@ -220,6 +225,8 @@
UINT8 cu_fg; // foreground
UINT8 cu_bg; // background
+ rgbcolor cu_fg_rgb; // red, green, blue used in 256/true color mode
+ rgbcolor cu_bg_rgb;
UINT8 cu_re; // rendition
// margins ----------------
@@ -247,6 +254,8 @@
UINT8 ef_fg; // These are derived from
UINT8 ef_bg; // the cu_* variables above
+ rgbcolor ef_fg_rgb;
+ rgbcolor ef_bg_rgb;
UINT8 ef_re; // to speed up operation
//
--- konsole/TEScreen.cpp.old 2006-06-04 16:15:39.000000000 +0200
+++ konsole/TEScreen.cpp 2006-06-17 15:12:27.419971312 +0200
@@ -60,6 +60,255 @@
/*! creates a `TEScreen' of `lines' lines and `columns' columns.
*/
+static rgbcolor colors_256[240] = {
+ rgbcolor(0x00, 0x00, 0x00), /* 16 */
+ rgbcolor(0x00, 0x00, 0x5f), /* 17 */
+ rgbcolor(0x00, 0x00, 0x87), /* 18 */
+ rgbcolor(0x00, 0x00, 0xaf), /* 19 */
+ rgbcolor(0x00, 0x00, 0xd7), /* 20 */
+ rgbcolor(0x00, 0x00, 0xff), /* 21 */
+ rgbcolor(0x00, 0x5f, 0x00), /* 22 */
+ rgbcolor(0x00, 0x5f, 0x5f), /* 23 */
+ rgbcolor(0x00, 0x5f, 0x87), /* 24 */
+ rgbcolor(0x00, 0x5f, 0xaf), /* 25 */
+ rgbcolor(0x00, 0x5f, 0xd7), /* 26 */
+ rgbcolor(0x00, 0x5f, 0xff), /* 27 */
+ rgbcolor(0x00, 0x87, 0x00), /* 28 */
+ rgbcolor(0x00, 0x87, 0x5f), /* 29 */
+ rgbcolor(0x00, 0x87, 0x87), /* 30 */
+ rgbcolor(0x00, 0x87, 0xaf), /* 31 */
+ rgbcolor(0x00, 0x87, 0xd7), /* 32 */
+ rgbcolor(0x00, 0x87, 0xff), /* 33 */
+ rgbcolor(0x00, 0xaf, 0x00), /* 34 */
+ rgbcolor(0x00, 0xaf, 0x5f), /* 35 */
+ rgbcolor(0x00, 0xaf, 0x87), /* 36 */
+ rgbcolor(0x00, 0xaf, 0xaf), /* 37 */
+ rgbcolor(0x00, 0xaf, 0xd7), /* 38 */
+ rgbcolor(0x00, 0xaf, 0xff), /* 39 */
+ rgbcolor(0x00, 0xd7, 0x00), /* 40 */
+ rgbcolor(0x00, 0xd7, 0x5f), /* 41 */
+ rgbcolor(0x00, 0xd7, 0x87), /* 42 */
+ rgbcolor(0x00, 0xd7, 0xaf), /* 43 */
+ rgbcolor(0x00, 0xd7, 0xd7), /* 44 */
+ rgbcolor(0x00, 0xd7, 0xff), /* 45 */
+ rgbcolor(0x00, 0xff, 0x00), /* 46 */
+ rgbcolor(0x00, 0xff, 0x5f), /* 47 */
+ rgbcolor(0x00, 0xff, 0x87), /* 48 */
+ rgbcolor(0x00, 0xff, 0xaf), /* 49 */
+ rgbcolor(0x00, 0xff, 0xd7), /* 50 */
+ rgbcolor(0x00, 0xff, 0xff), /* 51 */
+
+ rgbcolor(0x5f, 0x00, 0x00), /* 52 */
+ rgbcolor(0x5f, 0x00, 0x5f), /* 53 */
+ rgbcolor(0x5f, 0x00, 0x87), /* 54 */
+ rgbcolor(0x5f, 0x00, 0xaf), /* 55 */
+ rgbcolor(0x5f, 0x00, 0xd7), /* 56 */
+ rgbcolor(0x5f, 0x00, 0xff), /* 57 */
+ rgbcolor(0x5f, 0x5f, 0x00), /* 58 */
+ rgbcolor(0x5f, 0x5f, 0x5f), /* 59 */
+ rgbcolor(0x5f, 0x5f, 0x87), /* 60 */
+ rgbcolor(0x5f, 0x5f, 0xaf), /* 61 */
+ rgbcolor(0x5f, 0x5f, 0xd7), /* 62 */
+ rgbcolor(0x5f, 0x5f, 0xff), /* 63 */
+ rgbcolor(0x5f, 0x87, 0x00), /* 64 */
+ rgbcolor(0x5f, 0x87, 0x5f), /* 65 */
+ rgbcolor(0x5f, 0x87, 0x87), /* 66 */
+ rgbcolor(0x5f, 0x87, 0xaf), /* 67 */
+ rgbcolor(0x5f, 0x87, 0xd7), /* 68 */
+ rgbcolor(0x5f, 0x87, 0xff), /* 69 */
+ rgbcolor(0x5f, 0xaf, 0x00), /* 70 */
+ rgbcolor(0x5f, 0xaf, 0x5f), /* 71 */
+ rgbcolor(0x5f, 0xaf, 0x87), /* 72 */
+ rgbcolor(0x5f, 0xaf, 0xaf), /* 73 */
+ rgbcolor(0x5f, 0xaf, 0xd7), /* 74 */
+ rgbcolor(0x5f, 0xaf, 0xff), /* 75 */
+ rgbcolor(0x5f, 0xd7, 0x00), /* 76 */
+ rgbcolor(0x5f, 0xd7, 0x5f), /* 77 */
+ rgbcolor(0x5f, 0xd7, 0x87), /* 78 */
+ rgbcolor(0x5f, 0xd7, 0xaf), /* 79 */
+ rgbcolor(0x5f, 0xd7, 0xd7), /* 80 */
+ rgbcolor(0x5f, 0xd7, 0xff), /* 81 */
+ rgbcolor(0x5f, 0xff, 0x00), /* 82 */
+ rgbcolor(0x5f, 0xff, 0x5f), /* 83 */
+ rgbcolor(0x5f, 0xff, 0x87), /* 84 */
+ rgbcolor(0x5f, 0xff, 0xaf), /* 85 */
+ rgbcolor(0x5f, 0xff, 0xd7), /* 86 */
+ rgbcolor(0x5f, 0xff, 0xff), /* 87 */
+
+ rgbcolor(0x87, 0x00, 0x00), /* 88 */
+ rgbcolor(0x87, 0x00, 0x5f), /* 89 */
+ rgbcolor(0x87, 0x00, 0x87), /* 90 */
+ rgbcolor(0x87, 0x00, 0xaf), /* 91 */
+ rgbcolor(0x87, 0x00, 0xd7), /* 92 */
+ rgbcolor(0x87, 0x00, 0xff), /* 93 */
+ rgbcolor(0x87, 0x5f, 0x00), /* 94 */
+ rgbcolor(0x87, 0x5f, 0x5f), /* 95 */
+ rgbcolor(0x87, 0x5f, 0x87), /* 96 */
+ rgbcolor(0x87, 0x5f, 0xaf), /* 97 */
+ rgbcolor(0x87, 0x5f, 0xd7), /* 98 */
+ rgbcolor(0x87, 0x5f, 0xff), /* 99 */
+ rgbcolor(0x87, 0x87, 0x00), /* 100 */
+ rgbcolor(0x87, 0x87, 0x5f), /* 101 */
+ rgbcolor(0x87, 0x87, 0x87), /* 102 */
+ rgbcolor(0x87, 0x87, 0xaf), /* 103 */
+ rgbcolor(0x87, 0x87, 0xd7), /* 104 */
+ rgbcolor(0x87, 0x87, 0xff), /* 105 */
+ rgbcolor(0x87, 0xaf, 0x00), /* 106 */
+ rgbcolor(0x87, 0xaf, 0x5f), /* 107 */
+ rgbcolor(0x87, 0xaf, 0x87), /* 108 */
+ rgbcolor(0x87, 0xaf, 0xaf), /* 109 */
+ rgbcolor(0x87, 0xaf, 0xd7), /* 110 */
+ rgbcolor(0x87, 0xaf, 0xff), /* 111 */
+ rgbcolor(0x87, 0xd7, 0x00), /* 112 */
+ rgbcolor(0x87, 0xd7, 0x5f), /* 113 */
+ rgbcolor(0x87, 0xd7, 0x87), /* 114 */
+ rgbcolor(0x87, 0xd7, 0xaf), /* 115 */
+ rgbcolor(0x87, 0xd7, 0xd7), /* 116 */
+ rgbcolor(0x87, 0xd7, 0xff), /* 117 */
+ rgbcolor(0x87, 0xff, 0x00), /* 118 */
+ rgbcolor(0x87, 0xff, 0x5f), /* 119 */
+ rgbcolor(0x87, 0xff, 0x87), /* 120 */
+ rgbcolor(0x87, 0xff, 0xaf), /* 121 */
+ rgbcolor(0x87, 0xff, 0xd7), /* 122 */
+ rgbcolor(0x87, 0xff, 0xff), /* 123 */
+
+ rgbcolor(0xaf, 0x00, 0x00), /* 124 */
+ rgbcolor(0xaf, 0x00, 0x5f), /* 125 */
+ rgbcolor(0xaf, 0x00, 0x87), /* 126 */
+ rgbcolor(0xaf, 0x00, 0xaf), /* 127 */
+ rgbcolor(0xaf, 0x00, 0xd7), /* 128 */
+ rgbcolor(0xaf, 0x00, 0xff), /* 129 */
+ rgbcolor(0xaf, 0x5f, 0x00), /* 130 */
+ rgbcolor(0xaf, 0x5f, 0x5f), /* 131 */
+ rgbcolor(0xaf, 0x5f, 0x87), /* 132 */
+ rgbcolor(0xaf, 0x5f, 0xaf), /* 133 */
+ rgbcolor(0xaf, 0x5f, 0xd7), /* 134 */
+ rgbcolor(0xaf, 0x5f, 0xff), /* 135 */
+ rgbcolor(0xaf, 0x87, 0x00), /* 136 */
+ rgbcolor(0xaf, 0x87, 0x5f), /* 137 */
+ rgbcolor(0xaf, 0x87, 0x87), /* 138 */
+ rgbcolor(0xaf, 0x87, 0xaf), /* 139 */
+ rgbcolor(0xaf, 0x87, 0xd7), /* 140 */
+ rgbcolor(0xaf, 0x87, 0xff), /* 141 */
+ rgbcolor(0xaf, 0xaf, 0x00), /* 142 */
+ rgbcolor(0xaf, 0xaf, 0x5f), /* 143 */
+ rgbcolor(0xaf, 0xaf, 0x87), /* 144 */
+ rgbcolor(0xaf, 0xaf, 0xaf), /* 145 */
+ rgbcolor(0xaf, 0xaf, 0xd7), /* 146 */
+ rgbcolor(0xaf, 0xaf, 0xff), /* 147 */
+ rgbcolor(0xaf, 0xd7, 0x00), /* 148 */
+ rgbcolor(0xaf, 0xd7, 0x5f), /* 149 */
+ rgbcolor(0xaf, 0xd7, 0x87), /* 150 */
+ rgbcolor(0xaf, 0xd7, 0xaf), /* 151 */
+ rgbcolor(0xaf, 0xd7, 0xd7), /* 152 */
+ rgbcolor(0xaf, 0xd7, 0xff), /* 153 */
+ rgbcolor(0xaf, 0xff, 0x00), /* 154 */
+ rgbcolor(0xaf, 0xff, 0x5f), /* 155 */
+ rgbcolor(0xaf, 0xff, 0x87), /* 156 */
+ rgbcolor(0xaf, 0xff, 0xaf), /* 157 */
+ rgbcolor(0xaf, 0xff, 0xd7), /* 158 */
+ rgbcolor(0xaf, 0xff, 0xff), /* 159 */
+
+ rgbcolor(0xd7, 0x00, 0x00), /* 160 */
+ rgbcolor(0xd7, 0x00, 0x5f), /* 161 */
+ rgbcolor(0xd7, 0x00, 0x87), /* 162 */
+ rgbcolor(0xd7, 0x00, 0xaf), /* 163 */
+ rgbcolor(0xd7, 0x00, 0xd7), /* 164 */
+ rgbcolor(0xd7, 0x00, 0xff), /* 165 */
+ rgbcolor(0xd7, 0x5f, 0x00), /* 166 */
+ rgbcolor(0xd7, 0x5f, 0x5f), /* 167 */
+ rgbcolor(0xd7, 0x5f, 0x87), /* 168 */
+ rgbcolor(0xd7, 0x5f, 0xaf), /* 169 */
+ rgbcolor(0xd7, 0x5f, 0xd7), /* 170 */
+ rgbcolor(0xd7, 0x5f, 0xff), /* 171 */
+ rgbcolor(0xd7, 0x87, 0x00), /* 172 */
+ rgbcolor(0xd7, 0x87, 0x5f), /* 173 */
+ rgbcolor(0xd7, 0x87, 0x87), /* 174 */
+ rgbcolor(0xd7, 0x87, 0xaf), /* 175 */
+ rgbcolor(0xd7, 0x87, 0xd7), /* 176 */
+ rgbcolor(0xd7, 0x87, 0xff), /* 177 */
+ rgbcolor(0xd7, 0xaf, 0x00), /* 178 */
+ rgbcolor(0xd7, 0xaf, 0x5f), /* 179 */
+ rgbcolor(0xd7, 0xaf, 0x87), /* 180 */
+ rgbcolor(0xd7, 0xaf, 0xaf), /* 181 */
+ rgbcolor(0xd7, 0xaf, 0xd7), /* 182 */
+ rgbcolor(0xd7, 0xaf, 0xff), /* 183 */
+ rgbcolor(0xd7, 0xd7, 0x00), /* 184 */
+ rgbcolor(0xd7, 0xd7, 0x5f), /* 185 */
+ rgbcolor(0xd7, 0xd7, 0x87), /* 186 */
+ rgbcolor(0xd7, 0xd7, 0xaf), /* 187 */
+ rgbcolor(0xd7, 0xd7, 0xd7), /* 188 */
+ rgbcolor(0xd7, 0xd7, 0xff), /* 189 */
+ rgbcolor(0xd7, 0xff, 0x00), /* 190 */
+ rgbcolor(0xd7, 0xff, 0x5f), /* 191 */
+ rgbcolor(0xd7, 0xff, 0x87), /* 192 */
+ rgbcolor(0xd7, 0xff, 0xaf), /* 193 */
+ rgbcolor(0xd7, 0xff, 0xd7), /* 194 */
+ rgbcolor(0xd7, 0xff, 0xff), /* 195 */
+
+ rgbcolor(0xff, 0x00, 0x00), /* 196 */
+ rgbcolor(0xff, 0x00, 0x5f), /* 197 */
+ rgbcolor(0xff, 0x00, 0x87), /* 198 */
+ rgbcolor(0xff, 0x00, 0xaf), /* 199 */
+ rgbcolor(0xff, 0x00, 0xd7), /* 200 */
+ rgbcolor(0xff, 0x00, 0xff), /* 201 */
+ rgbcolor(0xff, 0x5f, 0x00), /* 202 */
+ rgbcolor(0xff, 0x5f, 0x5f), /* 203 */
+ rgbcolor(0xff, 0x5f, 0x87), /* 204 */
+ rgbcolor(0xff, 0x5f, 0xaf), /* 205 */
+ rgbcolor(0xff, 0x5f, 0xd7), /* 206 */
+ rgbcolor(0xff, 0x5f, 0xff), /* 207 */
+ rgbcolor(0xff, 0x87, 0x00), /* 208 */
+ rgbcolor(0xff, 0x87, 0x5f), /* 209 */
+ rgbcolor(0xff, 0x87, 0x87), /* 210 */
+ rgbcolor(0xff, 0x87, 0xaf), /* 211 */
+ rgbcolor(0xff, 0x87, 0xd7), /* 212 */
+ rgbcolor(0xff, 0x87, 0xff), /* 213 */
+ rgbcolor(0xff, 0xaf, 0x00), /* 214 */
+ rgbcolor(0xff, 0xaf, 0x5f), /* 215 */
+ rgbcolor(0xff, 0xaf, 0x87), /* 216 */
+ rgbcolor(0xff, 0xaf, 0xaf), /* 217 */
+ rgbcolor(0xff, 0xaf, 0xd7), /* 218 */
+ rgbcolor(0xff, 0xaf, 0xff), /* 219 */
+ rgbcolor(0xff, 0xd7, 0x00), /* 220 */
+ rgbcolor(0xff, 0xd7, 0x5f), /* 221 */
+ rgbcolor(0xff, 0xd7, 0x87), /* 222 */
+ rgbcolor(0xff, 0xd7, 0xaf), /* 223 */
+ rgbcolor(0xff, 0xd7, 0xd7), /* 224 */
+ rgbcolor(0xff, 0xd7, 0xff), /* 225 */
+ rgbcolor(0xff, 0xff, 0x00), /* 226 */
+ rgbcolor(0xff, 0xff, 0x5f), /* 227 */
+ rgbcolor(0xff, 0xff, 0x87), /* 228 */
+ rgbcolor(0xff, 0xff, 0xaf), /* 229 */
+ rgbcolor(0xff, 0xff, 0xd7), /* 230 */
+ rgbcolor(0xff, 0xff, 0xff), /* 231 */
+
+ rgbcolor(0x08, 0x08, 0x08), /* 232 */
+ rgbcolor(0x12, 0x12, 0x12), /* 233 */
+ rgbcolor(0x1c, 0x1c, 0x1c), /* 234 */
+ rgbcolor(0x26, 0x26, 0x26), /* 235 */
+ rgbcolor(0x30, 0x30, 0x30), /* 236 */
+ rgbcolor(0x3a, 0x3a, 0x3a), /* 237 */
+ rgbcolor(0x44, 0x44, 0x44), /* 238 */
+ rgbcolor(0x4e, 0x4e, 0x4e), /* 239 */
+ rgbcolor(0x58, 0x58, 0x58), /* 240 */
+ rgbcolor(0x62, 0x62, 0x62), /* 241 */
+ rgbcolor(0x6c, 0x6c, 0x6c), /* 242 */
+ rgbcolor(0x76, 0x76, 0x76), /* 243 */
+ rgbcolor(0x80, 0x80, 0x80), /* 244 */
+ rgbcolor(0x8a, 0x8a, 0x8a), /* 245 */
+ rgbcolor(0x94, 0x94, 0x94), /* 246 */
+ rgbcolor(0x9e, 0x9e, 0x9e), /* 247 */
+ rgbcolor(0xa8, 0xa8, 0xa8), /* 248 */
+ rgbcolor(0xb2, 0xb2, 0xb2), /* 249 */
+ rgbcolor(0xbc, 0xbc, 0xbc), /* 250 */
+ rgbcolor(0xc6, 0xc6, 0xc6), /* 251 */
+ rgbcolor(0xd0, 0xd0, 0xd0), /* 252 */
+ rgbcolor(0xda, 0xda, 0xda), /* 253 */
+ rgbcolor(0xe4, 0xe4, 0xe4), /* 254 */
+ rgbcolor(0xee, 0xee, 0xee) /* 255 */
+};
+
TEScreen::TEScreen(int l, int c)
: lines(l),
columns(c),
@@ -67,13 +316,19 @@
histCursor(0),
hist(new HistoryScrollNone()),
cuX(0), cuY(0),
- cu_fg(0), cu_bg(0), cu_re(0),
+ cu_fg(0), cu_bg(0),
+ cu_fg_rgb(),
+ cu_bg_rgb(),
+ cu_re(0),
tmargin(0), bmargin(0),
tabstops(0),
sel_begin(0), sel_TL(0), sel_BR(0),
sel_busy(false),
columnmode(false),
- ef_fg(0), ef_bg(0), ef_re(0),
+ ef_fg(0), ef_bg(0),
+ ef_fg_rgb(),
+ ef_bg_rgb(),
+ ef_re(0),
sa_cuX(0), sa_cuY(0),
sa_cu_re(0), sa_cu_fg(0), sa_cu_bg(0),
lastPos(-1)
@@ -506,13 +761,17 @@
{
ef_fg = cu_bg;
ef_bg = cu_fg;
+ ef_fg_rgb = cu_bg_rgb;
+ ef_bg_rgb = cu_fg_rgb;
}
else
{
ef_fg = cu_fg;
ef_bg = cu_bg;
+ ef_fg_rgb = cu_fg_rgb;
+ ef_bg_rgb = cu_bg_rgb;
}
- if (cu_re & RE_BOLD)
+ if ((cu_re & RE_BOLD) && !rgbused(ef_fg))
{
if (ef_fg < BASE_COLORS)
ef_fg += BASE_COLORS;
@@ -758,6 +1017,8 @@
image[i].c = c;
image[i].f = ef_fg;
image[i].b = ef_bg;
+ image[i].fg_rgb = ef_fg_rgb;
+ image[i].bg_rgb = ef_bg_rgb;
image[i].r = ef_re;
lastPos = i;
@@ -770,6 +1031,8 @@
image[i].c = 0;
image[i].f = ef_fg;
image[i].b = ef_bg;
+ image[i].fg_rgb = ef_fg_rgb;
+ image[i].bg_rgb = ef_bg_rgb;
image[i].r = ef_re;
w--;
}
@@ -922,6 +1185,8 @@
image[i].c = c;
image[i].f = cu_fg;
image[i].b = cu_bg;
+ image[i].fg_rgb = cu_fg_rgb;
+ image[i].bg_rgb = cu_bg_rgb;
image[i].r = DEFAULT_RENDITION;
}
@@ -1108,7 +1373,48 @@
/*!
*/
+void TEScreen::setForeColorRGB(int rgb)
+{
+ cu_fg = RGB_USED;
+ cu_fg_rgb.r = (rgb >> 16) & 255;
+ cu_fg_rgb.g = (rgb >> 8) & 255;
+ cu_fg_rgb.b = rgb & 255;
+ effectiveRendition();
+}
+
+/*!
+*/
+void TEScreen::setBackColorRGB(int rgb)
+{
+ cu_bg = RGB_USED;
+ cu_bg_rgb.r = (rgb >> 16) & 255;
+ cu_bg_rgb.g = (rgb >> 8) & 255;
+ cu_bg_rgb.b = rgb & 255;
+ effectiveRendition();
+}
+
+/*!
+*/
+void TEScreen::setForeColor256(int index)
+{
+ index -= 16;
+ cu_fg = RGB_USED;
+ cu_fg_rgb = colors_256[index];
+ effectiveRendition();
+}
+
+/*!
+*/
+void TEScreen::setBackColor256(int index)
+{
+ index -= 16;
+ cu_bg = RGB_USED;
+ cu_bg_rgb = colors_256[index];
+ effectiveRendition();
+}
+/*!
+*/
void TEScreen::setBackColorToDefault()
{
cu_bg = DEFAULT_BACK_COLOR;
More information about the konsole-devel
mailing list