mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
[termdesc] don't duplicate query defs, saves ~10KB of object size
This commit is contained in:
parent
8431910937
commit
437f24c92c
@ -569,6 +569,8 @@ init_terminfo_esc(tinfo* ti, const char* name, escape_e idx,
|
|||||||
// enter the alternate screen (smcup). we could technically get this from
|
// enter the alternate screen (smcup). we could technically get this from
|
||||||
// terminfo, but everyone who supports it supports it the same way, and we
|
// terminfo, but everyone who supports it supports it the same way, and we
|
||||||
// need to send it before our other directives if we're going to use it.
|
// need to send it before our other directives if we're going to use it.
|
||||||
|
// we warn later in setup if what we get from terminfo doesn't match what
|
||||||
|
// we sent here.
|
||||||
#define SMCUP DECSET(SET_SMCUP)
|
#define SMCUP DECSET(SET_SMCUP)
|
||||||
#define RMCUP DECRST(SET_SMCUP)
|
#define RMCUP DECRST(SET_SMCUP)
|
||||||
|
|
||||||
@ -582,41 +584,38 @@ init_terminfo_esc(tinfo* ti, const char* name, escape_e idx,
|
|||||||
static int
|
static int
|
||||||
send_initial_queries(int fd, unsigned minimal, unsigned noaltscreen,
|
send_initial_queries(int fd, unsigned minimal, unsigned noaltscreen,
|
||||||
unsigned draininput){
|
unsigned draininput){
|
||||||
const char *queries;
|
size_t total = 0;
|
||||||
if(noaltscreen){
|
// everything sends DSRCPR, and everything sends DIRECTIVES afterwards.
|
||||||
if(minimal){
|
// we send KKBDENTER immediately before DIRECTIVES unless input is being
|
||||||
if(draininput){
|
// drained. we send IDQUERIES unless minimal is set. we send SMCUP (as
|
||||||
queries = DSRCPR DIRECTIVES;
|
// the first thing) unless noaltscreen is set.
|
||||||
}else{
|
if(!noaltscreen){
|
||||||
queries = DSRCPR KKBDENTER DIRECTIVES;
|
if(blocking_write(fd, SMCUP, strlen(SMCUP))){
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(draininput){
|
|
||||||
queries = DSRCPR IDQUERIES DIRECTIVES;
|
|
||||||
}else{
|
|
||||||
queries = DSRCPR KKBDENTER IDQUERIES DIRECTIVES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(minimal){
|
|
||||||
if(draininput){
|
|
||||||
queries = SMCUP DSRCPR DIRECTIVES;
|
|
||||||
}else{
|
|
||||||
queries = SMCUP DSRCPR KKBDENTER DIRECTIVES;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(draininput){
|
|
||||||
queries = SMCUP DSRCPR IDQUERIES DIRECTIVES;
|
|
||||||
}else{
|
|
||||||
queries = SMCUP DSRCPR KKBDENTER IDQUERIES DIRECTIVES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
size_t len = strlen(queries);
|
|
||||||
loginfo("sending %lluB", (unsigned long long)len);
|
|
||||||
if(blocking_write(fd, queries, len)){
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
total += strlen(SMCUP);
|
||||||
|
}
|
||||||
|
if(blocking_write(fd, DSRCPR, strlen(DSRCPR))){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
total += strlen(DSRCPR);
|
||||||
|
if(!draininput){
|
||||||
|
if(blocking_write(fd, KKBDENTER, strlen(KKBDENTER))){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
total += strlen(KKBDENTER);
|
||||||
|
}
|
||||||
|
if(!minimal){
|
||||||
|
if(blocking_write(fd, IDQUERIES, strlen(IDQUERIES))){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
total += strlen(IDQUERIES);
|
||||||
|
}
|
||||||
|
if(blocking_write(fd, DIRECTIVES, strlen(DIRECTIVES))){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
total += strlen(DIRECTIVES);
|
||||||
|
loginfo("sent %" PRIuPTR "B", total);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user