Skip to content

Commit

Permalink
A few changes to startup details
Browse files Browse the repository at this point in the history
* Even when emitting smcup, emit an explicit screen clear, to handle
  smcup that fills the screen with old background color #1045
* Rather than emitting notcurses_mouse_disable(), emit the more
  powerful (proper superset) reset_term_attributes)
* Emit a diagnostic when we're not connected to a terminal
  • Loading branch information
dankamongmen committed Oct 9, 2020
1 parent 1b3f979 commit fd93646
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ typedef struct tinfo {
char* getm; // get mouse events
bool RGBflag; // ti-reported "RGB" flag for 24bpc truecolor
bool CCCflag; // ti-reported "CCC" flag for palette set capability
bool BCEflag; // ti-reported "BCE" flag for erases with background color
bool AMflag; // ti-reported "AM" flag for automatic movement to next line
char* smcup; // enter alternate mode
char* rmcup; // restore primary mode
Expand Down
7 changes: 6 additions & 1 deletion src/lib/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,6 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
}
ret->ttyfd = get_tty_fd(ret, ret->ttyfp);
is_linux_console(ret, !!(opts->flags & NCOPTION_NO_FONT_CHANGES));
notcurses_mouse_disable(ret);
if(ret->ttyfd >= 0){
if(tcgetattr(ret->ttyfd, &ret->tpreserved)){
fprintf(stderr, "Couldn't preserve terminal state for %d (%s)\n", ret->ttyfd, strerror(errno));
Expand Down Expand Up @@ -975,6 +974,7 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
}else{
dimy = 24; // fuck it, lol
dimx = 80;
fprintf(stderr, "Defaulting to %dx%d (output is not to a terminal)\n", dimy, dimx);
}
ret->suppress_banner = opts->flags & NCOPTION_SUPPRESS_BANNERS;
char* shortname_term = termname();
Expand All @@ -988,6 +988,7 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
if(interrogate_terminfo(&ret->tcache)){
goto err;
}
reset_term_attributes(ret);
if(ncinputlayer_init(&ret->input, stdin)){
goto err;
}
Expand Down Expand Up @@ -1029,6 +1030,10 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
free_plane(ret->top);
goto err;
}
// explicit clear even though smcup *might* clear
if(tty_emit("clear", ret->tcache.clearscr, ret->ttyfd)){
notcurses_refresh(ret, NULL, NULL);
}
}else if(!(opts->flags & NCOPTION_NO_ALTERNATE_SCREEN)){
// if they expected the alternate screen, but we didn't have one to
// offer, at least clear the screen. try using "clear"; if that doesn't
Expand Down

0 comments on commit fd93646

Please sign in to comment.