Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 2e335fe7 authored by deuce's avatar deuce

Support palette reset (default palette only).

ESC ] 104 ESC \ will reset all palette entries.
ESC ] 104;X;Y... ESC \ will reset specified palette entries only.

ie: perl -e 'print "\e]104;1;2\e\\"'
Will reset palette entries 1 and 2.
parent d402e155
......@@ -49,6 +49,7 @@
#include "ciolib.h"
#include "cterm.h"
#include "vidmodes.h"
#define BUFSIZE 2048
......@@ -1958,15 +1959,15 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
case CTERM_STRING_OSC:
/* Is this an xterm Change Color(s)? */
if (cterm->strbuf[0] == '4' && cterm->strbuf[1] == ';') {
uint32_t index = UINT32_MAX;
unsigned long index = ULONG_MAX;
char *seqlast;
p2 = &cterm->strbuf[2];
while ((p = strtok_r(p2, ";", &seqlast)) != NULL) {
p2=NULL;
if (index == UINT32_MAX) {
if (index == ULONG_MAX) {
index = strtoull(p, NULL, 10);
if (index == UINT32_MAX || index > 13200)
if (index == ULONG_MAX || index > 13200)
break;
}
else {
......@@ -2004,11 +2005,28 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
}
if (ccount == 3)
setpalette(index, rgb[0], rgb[1], rgb[2]);
index = ULONG_MAX;
}
}
}
else if (strncmp("104", cterm->strbuf, 3)==0) {
// TODO reset color(s)
if (strlen(cterm->strbuf) == 3) {
// Reset all colours
for (i=0; i < sizeof(dac_default)/sizeof(struct dac_colors); i++)
setpalette(i, dac_default[i].red << 8 | dac_default[i].red, dac_default[i].green << 8 | dac_default[i].green, dac_default[i].blue << 8 | dac_default[i].blue);
}
else if(cterm->strbuf[3] == ';') {
char *seqlast;
unsigned long pi;
p2 = &cterm->strbuf[4];
while ((p = strtok_r(p2, ";", &seqlast)) != NULL) {
p2=NULL;
pi = strtoull(p, NULL, 10);
if (pi < sizeof(dac_default)/sizeof(struct dac_colors))
setpalette(pi, dac_default[pi].red << 8 | dac_default[pi].red, dac_default[pi].green << 8 | dac_default[pi].green, dac_default[pi].blue << 8 | dac_default[pi].blue);
}
}
}
}
// TODO: Handle the string...
......
......@@ -84,6 +84,13 @@ ESC ] Operating System Command
SOURCE: xterm
104 [ ; Ps ... ]
Resets palette entry to default. If the entire string
is "104", resets all colours. Otherwise, only each index
separated by a semicolon is reset.
SOURCE: xterm
ESC X Start Of String
As the above strings, but may contain any characters except
a Start Of String sequence or a String Terminator sequence.
......
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