Commit 67099363 authored by Matan Ziv-Av's avatar Matan Ziv-Av
Browse files

Add support for `OSC 4` and `OSC 104`

For managing the text color table.
The color table may be modified, but currently konsole still uses the unmodified table for display.
parent 3a6a62ed
......@@ -78,6 +78,10 @@ Vt102Emulation::Vt102Emulation()
tokenData = QByteArray();
_graphicsImages = std::map<int, QImage *>();
for (int i = 0; i < 256; i++) {
colorTable[i] = QColor();
}
}
Vt102Emulation::~Vt102Emulation()
......@@ -753,6 +757,35 @@ void Vt102Emulation::processSessionAttributeRequest(int tokenSize)
_currentScreen->setLineProperty(LINE_PROMPT_START, true);
}
}
if (attribute == 4) {
// RGB colors
QStringList params = value.split(QLatin1Char(';'));
for (int i = 0; i < params.length(); i += 2) {
if (params.length() == i + 1) {
return;
}
int c = params[i].toInt();
if (params[i + 1] == QLatin1String("?")) {
QColor color = colorTable[c];
if (!color.isValid()) {
color = CharacterColor(COLOR_SPACE_256, c).color(ColorScheme::defaultTable);
}
reportColor(c, color);
return;
}
QColor col(params[1]);
colorTable[c] = col;
}
return;
}
if (attribute == 104) {
// RGB colors
QStringList params = value.split(QLatin1Char(';'));
for (int i = 0; i < params.length(); i++) {
int c = params[i].toInt();
colorTable[c] = QColor();
}
}
if (value == QLatin1String("?")) {
// pass terminator type indication here, because OSC response terminator
......@@ -1574,6 +1607,22 @@ void Vt102Emulation::reportCellSize()
sendString(tmp);
}
void Vt102Emulation::reportColor(int c, QColor color)
{
char tmp[60];
snprintf(tmp,
sizeof(tmp),
"\033]4;%i;rgb:%02x%02x/%02x%02x/%02x%02x\007",
c,
color.red(),
color.red(),
color.green(),
color.green(),
color.blue(),
color.blue());
sendString(tmp);
}
void Vt102Emulation::reportSize()
{
char tmp[30];
......
......@@ -163,6 +163,7 @@ private:
void reportPixelSize();
void reportCellSize();
void reportSize();
void reportColor(int c, QColor color);
void reportTerminalParms(int p);
// clears the screen and resizes it to the specified
......@@ -195,6 +196,8 @@ private:
bool _reportFocusEvents;
QColor colorTable[256];
// Sixel:
#define MAX_SIXEL_COLORS 256
#define MAX_IMAGE_DIM 16384
......
Supports Markdown
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