obliterate any query spillage w00t #2019

pull/1978/head
nick black 3 years ago
parent d25496220e
commit c7738c7d25
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1144,6 +1144,14 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
&ret->stats)){
goto err;
}
ret->rstate.x = ret->rstate.y = -1;
if(opts->flags & NCOPTION_PRESERVE_CURSOR){
// the u7 led the queries so that we would get a cursor position
// unaffected by any query spill (unconsumed control sequences). move
// us back to that location, in case there was any such spillage.
if(goto_location(ret, ret->ttyfp, ret->rstate.logendy, ret->rstate.logendx)){
}
}
int dimy, dimx;
if(update_term_dimensions(ret->ttyfd, &dimy, &dimx, &ret->tcache,
ret->margin_b)){
@ -1174,7 +1182,6 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
free_plane(ret->stdplane);
goto err;
}
ret->rstate.x = ret->rstate.y = -1;
init_banner(ret);
if(ncflush(ret->ttyfp)){
free_plane(ret->stdplane);

@ -344,6 +344,10 @@ grow_esc_table(tinfo* ti, const char* tstr, escape_e esc,
// FIXME ought be using the u7 terminfo string here, if it exists. the great
// thing is, if we get a response to this, we know we can use it for u7!
// we send this first because terminals which don't consume the entire escape
// sequences following will bleed the excess into the terminal, and we want
// to blow any such output away (or at least return to the cell where such
// output started).
#define DSRCPR "\x1b[6n"
// check for Synchronized Update Mode support. the p is necessary, but at
@ -360,7 +364,6 @@ grow_esc_table(tinfo* ti, const char* tstr, escape_e esc,
#define GEOMPIXEL "\x1b[14t"
#define DIRECTIVES CSI_BGQ \
DSRCPR \
SUMQUERY \
"\x1b[?1;3;256S" /* try to set 256 cregs */ \
CREGSXTSM \
@ -377,9 +380,9 @@ static int
send_initial_queries(int fd, bool minimal){
const char *queries;
if(minimal){
queries = DIRECTIVES;
queries = DSRCPR DIRECTIVES;
}else{
queries = IDQUERIES DIRECTIVES;
queries = DSRCPR IDQUERIES DIRECTIVES;
}
if(blocking_write(fd, queries, strlen(queries))){
return -1;
@ -711,11 +714,6 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
}
}
if(fd >= 0){
bool minimal = (qterm != TERMINAL_UNKNOWN);
if(send_initial_queries(fd, minimal)){
fprintf(stderr, "Error issuing terminal queries on %d\n", fd);
return -1;
}
if(tcgetattr(fd, &ti->tpreserved)){
fprintf(stderr, "Couldn't preserve terminal state for %d (%s)\n", fd, strerror(errno));
return -1;
@ -725,6 +723,13 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
if(cbreak_mode(fd, &ti->tpreserved)){
return -1;
}
// if we already know our terminal (e.g. on the linux console), there's no
// need to send the identification queries. the controls are sufficient.
bool minimal = (qterm != TERMINAL_UNKNOWN);
if(send_initial_queries(fd, minimal)){
fprintf(stderr, "Error issuing terminal queries on %d\n", fd);
return -1;
}
}
ti->sprixel_scale_height = 1;
get_default_geometry(ti);
@ -841,7 +846,7 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
if(!cursor_y){
cursor_y = &foolcursor_y;
}
*cursor_x = *cursor_y = 0;
*cursor_x = *cursor_y = -1;
if(ncinputlayer_init(ti, stdin, &qterm, &appsync_advertised,
cursor_y, cursor_x, stats)){
goto err;
@ -854,11 +859,9 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
}
}
}
if(cursor_x && cursor_y){
if(*cursor_x >= 0 && *cursor_y >= 0){
if(add_u7_escape(ti, &tablelen, &tableused)){
goto err;
}
if(*cursor_x >= 0 && *cursor_y >= 0){
if(add_u7_escape(ti, &tablelen, &tableused)){
goto err;
}
}
if(appsync_advertised){

Loading…
Cancel
Save