[terminfo] store initial palette in termdesc #2435

This commit is contained in:
nick black 2021-12-09 19:49:44 -05:00 committed by nick black
parent 35ff603c17
commit ed7213a8bf
4 changed files with 6 additions and 4 deletions

View File

@ -1279,14 +1279,13 @@ palette_cb(inputctx* ictx){
if(ictx->initdata){
unsigned idx = amata_next_numeric(&ictx->amata, "\x1b]4;", ';');
char* str = amata_next_string(&ictx->amata, "rgb:");
if(idx > NCPALETTESIZE){
if(idx > sizeof(ictx->initdata->palette.chans) / sizeof(*ictx->initdata->palette.chans)){
logerror("invalid index %u\n", idx);
}else if(str == NULL){
logerror("empty palette string\n");
}else{
uint32_t color;
if(get_default_color(str, &color) == 0){
loginfo("index %u 0x%06x\n", idx, color);
if(get_default_color(str, &ictx->initdata->palette.chans[idx]) == 0){
loginfo("index %u 0x%06x\n", idx, ictx->initdata->palette.chans[idx]);
}
free(str);
}

View File

@ -77,6 +77,7 @@ struct initial_responses {
int sixelx; // maximum sixel width
char* version; // version string, heap-allocated
unsigned kbdlevel; // enabled kitty keyboard functions
ncpalette palette; // palette entries
};
// Blocking call. Waits until the input thread has processed all responses to

View File

@ -1233,6 +1233,7 @@ int interrogate_terminfo(tinfo* ti, FILE* out, unsigned utf8,
ti->dimy = iresp->dimy;
ti->dimx = iresp->dimx;
}
memcpy(&ti->originalpalette, &iresp->palette, sizeof(ti->originalpalette));
if(iresp->rgb){
ti->caps.rgb = true;
}

View File

@ -184,6 +184,7 @@ typedef struct tinfo {
int default_rows; // LINES environment var / lines terminfo / 24
int default_cols; // COLUMNS environment var / cols terminfo / 80
ncpalette originalpalette; // palette as read from initial queries
pthread_t gpmthread; // thread handle for GPM watcher
int gpmfd; // connection to GPM daemon
char mouseproto; // DECSET level (100x, '0', '2', '3')