learn XTPOPCOLORS/XTPUSHCOLORS for xterm+kitty #1296

pull/1935/head
nick black 3 years ago
parent 2c838e3aa7
commit 95cdfd7524
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -900,6 +900,8 @@ rasterize_scrolls(ncpile* p, FILE* out){
// 1) if we're a different pile, issue the kitty universal clear
// 2) first, hide all sprixels in the HIDE state
// 3) then, make allo LOADED sprixels visible
//
// don't account for sprixelemissions here, as they were already counted.
static int64_t
rasterize_sprixels(notcurses* nc, ncpile* p, FILE* out){
int64_t bytesemitted = 0;
@ -917,7 +919,6 @@ rasterize_sprixels(notcurses* nc, ncpile* p, FILE* out){
}
bytesemitted += r;
nc->rstate.hardcursorpos = true;
++nc->stats.sprixelemissions;
}else if(s->invalidated == SPRIXEL_LOADED){
if(nc->tcache.pixel_commit){
int y,x;

@ -407,6 +407,18 @@ add_appsync_escapes_dcs(tinfo* ti, size_t* tablelen, size_t* tableused){
return 0;
}
static int
add_pushcolors_escapes(tinfo* ti, size_t* tablelen, size_t* tableused){
if(get_escape(ti, ESCAPE_SAVECOLORS)){
return 0;
}
if(grow_esc_table(ti, "\x1b[#P", ESCAPE_SAVECOLORS, tablelen, tableused) ||
grow_esc_table(ti, "\x1b[#Q", ESCAPE_RESTORECOLORS, tablelen, tableused)){
return -1;
}
return 0;
}
// Qui si convien lasciare ogne sospetto; ogne viltà convien che qui sia morta.
static int
apply_term_heuristics(tinfo* ti, const char* termname, int fd,
@ -443,6 +455,9 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd,
}else{
setup_kitty_bitmaps(ti, fd, 0);
}
if(add_pushcolors_escapes(ti, tablelen, tableused)){
return -1;
}
}else if(qterm == TERMINAL_ALACRITTY){
termname = "Alacritty";
ti->caps.quadrants = true;
@ -485,6 +500,12 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd,
}
}else if(qterm == TERMINAL_XTERM){
termname = "XTerm";
// xterm 357 added color palette escapes XT{PUSH,POP,REPORT}COLORS
if(compare_versions(ti->termversion, "357") >= 0){
if(add_pushcolors_escapes(ti, tablelen, tableused)){
return -1;
}
}
}else if(qterm == TERMINAL_CONTOUR){
termname = "Contour";
ti->caps.quadrants = true;

@ -66,6 +66,8 @@ typedef enum {
// (https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec)
ESCAPE_BSUM, // Begin Synchronized Update Mode
ESCAPE_ESUM, // End Synchronized Update Mode
ESCAPE_SAVECOLORS, // XTPUSHCOLORS (push palette/fg/bg)
ESCAPE_RESTORECOLORS, // XTPOPCOLORS (pop palette/fg/bg)
ESCAPE_MAX
} escape_e;

Loading…
Cancel
Save