mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
convert last two into esctable (initc/getm) #1525
This commit is contained in:
parent
59ddd3b0aa
commit
1b15de9532
@ -782,6 +782,7 @@ int term_fg_rgb8(const tinfo* ti, FILE* out, unsigned r, unsigned g, unsigned b)
|
||||
static inline int
|
||||
update_palette(notcurses* nc, FILE* out){
|
||||
if(nc->tcache.CCCflag){
|
||||
const char* initc = get_escape(&nc->tcache, ESCAPE_INITC);
|
||||
for(size_t damageidx = 0 ; damageidx < sizeof(nc->palette.chans) / sizeof(*nc->palette.chans) ; ++damageidx){
|
||||
unsigned r, g, b;
|
||||
if(nc->palette_damage[damageidx]){
|
||||
@ -791,7 +792,7 @@ update_palette(notcurses* nc, FILE* out){
|
||||
r = r * 1000 / 255;
|
||||
g = g * 1000 / 255;
|
||||
b = b * 1000 / 255;
|
||||
term_emit(tiparm(nc->tcache.initc, damageidx, r, g, b), out, false);
|
||||
term_emit(tiparm(initc, damageidx, r, g, b), out, false);
|
||||
nc->palette_damage[damageidx] = false;
|
||||
}
|
||||
}
|
||||
|
@ -188,22 +188,13 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
|
||||
// allow the "rgb" boolean terminfo capability, a COLORTERM environment
|
||||
// variable of either "truecolor" or "24bit", or unconditionally enable it
|
||||
// for several terminals known to always support 8bpc rgb setaf/setab.
|
||||
ti->RGBflag = query_rgb();
|
||||
int colors = tigetnum("colors");
|
||||
if(colors <= 0){
|
||||
ti->colors = 1;
|
||||
ti->CCCflag = false;
|
||||
ti->RGBflag = false;
|
||||
ti->initc = NULL;
|
||||
}else{
|
||||
ti->colors = colors;
|
||||
terminfostr(&ti->initc, "initc");
|
||||
if(ti->initc){
|
||||
ti->CCCflag = tigetflag("ccc") == 1;
|
||||
}else{
|
||||
ti->CCCflag = false;
|
||||
}
|
||||
}
|
||||
ti->RGBflag = query_rgb(); // independent of colors
|
||||
// verify that the terminal provides cursor addressing (absolute movement)
|
||||
const struct strtdesc {
|
||||
escape_e esc;
|
||||
@ -227,6 +218,8 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
|
||||
{ ESCAPE_CUF, "cuf", },
|
||||
{ ESCAPE_CUF1, "cuf1", },
|
||||
{ ESCAPE_CUB, "cub", },
|
||||
{ ESCAPE_INITC, "initc", },
|
||||
{ ESCAPE_GETM, "getm", },
|
||||
{ ESCAPE_SMKX, "smkx", },
|
||||
{ ESCAPE_RMKX, "rmkx", },
|
||||
{ ESCAPE_SMXX, "smxx", },
|
||||
@ -248,6 +241,14 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
|
||||
fprintf(stderr, "Required terminfo capability 'cup' not defined\n");
|
||||
goto err;
|
||||
}
|
||||
if(colors){
|
||||
const char* initc = get_escape(ti, ESCAPE_INITC);
|
||||
if(initc){
|
||||
ti->CCCflag = tigetflag("ccc") == 1;
|
||||
}
|
||||
}else{ // disable initc if there's no color support
|
||||
ti->escindices[ESCAPE_INITC] = 0;
|
||||
}
|
||||
// neither of these is supported on e.g. the "linux" virtual console.
|
||||
if(!noaltscreen){
|
||||
if(init_terminfo_esc(ti, "smcup", ESCAPE_SMCUP, &tablelen, &tableused) ||
|
||||
@ -314,7 +315,6 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
|
||||
ti->escindices[ESCAPE_SITM] = 0;
|
||||
ti->escindices[ESCAPE_RITM] = 0;
|
||||
}
|
||||
terminfostr(&ti->getm, "getm"); // get mouse events
|
||||
// if the keypad neen't be explicitly enabled, smkx is not present
|
||||
const char* smkx = get_escape(ti, ESCAPE_SMKX);
|
||||
if(smkx && fd >= 0){
|
||||
|
@ -54,6 +54,8 @@ typedef enum {
|
||||
ESCAPE_RC, // "rc" pop the cursor off the stack
|
||||
ESCAPE_CLEAR, // "clear" clear screen and home cursor
|
||||
ESCAPE_HOME, // "home" home cursor
|
||||
ESCAPE_INITC, // "initc" set up palette entry
|
||||
ESCAPE_GETM, // "getm" get mouse events
|
||||
ESCAPE_MAX
|
||||
} escape_e;
|
||||
|
||||
@ -66,8 +68,6 @@ typedef struct tinfo {
|
||||
uint16_t escindices[ESCAPE_MAX]; // table of 1-biased indices into esctable
|
||||
char* esctable; // packed table of escape sequences
|
||||
unsigned colors;// number of colors terminfo reported usable for this screen
|
||||
char* initc; // set a palette entry's RGB value
|
||||
char* getm; // get mouse events
|
||||
// we use the cell's size in pixels for pixel blitting. this information can
|
||||
// be acquired on all terminals with pixel support.
|
||||
int cellpixy; // cell pixel height, might be 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user