mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
Clear screen if we want smcup but it's not available #817
This commit is contained in:
parent
0bd73e2f1f
commit
6d2ba86acc
@ -322,8 +322,6 @@ int main(void){
|
|||||||
if(!nc.mouse_enable()){
|
if(!nc.mouse_enable()){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
// clear the screen in the absence of smcup mode
|
|
||||||
nc.refresh(nullptr, nullptr);
|
|
||||||
int ret = input_demo(&nc);
|
int ret = input_demo(&nc);
|
||||||
if(!nc.stop() || ret){
|
if(!nc.stop() || ret){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -922,9 +922,18 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
|
|||||||
init_banner(ret);
|
init_banner(ret);
|
||||||
// flush on the switch to alternate screen, lest initial output be swept away
|
// flush on the switch to alternate screen, lest initial output be swept away
|
||||||
if(ret->ttyfd >= 0){
|
if(ret->ttyfd >= 0){
|
||||||
if(ret->tcache.smcup && tty_emit("smcup", ret->tcache.smcup, ret->ttyfd)){
|
if(ret->tcache.smcup){
|
||||||
free_plane(ret->top);
|
if(tty_emit("smcup", ret->tcache.smcup, ret->ttyfd)){
|
||||||
goto err;
|
free_plane(ret->top);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 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
|
||||||
|
// fly, use notcurses_refresh() to force a clearing via iterated writes.
|
||||||
|
if(tty_emit("clear", ret->tcache.clearscr, ret->ttyfd)){
|
||||||
|
notcurses_refresh(ret, NULL, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -35,7 +35,6 @@ int main(void) {
|
|||||||
ncopts.flags = NCOPTION_INHIBIT_SETLOCALE;
|
ncopts.flags = NCOPTION_INHIBIT_SETLOCALE;
|
||||||
ncpp::NotCurses nc(ncopts);
|
ncpp::NotCurses nc(ncopts);
|
||||||
{
|
{
|
||||||
nc.refresh(nullptr, nullptr); // clear screen if smcup+background are unavailable
|
|
||||||
Tetris t{nc, gameover};
|
Tetris t{nc, gameover};
|
||||||
std::thread tid(&Tetris::Ticker, &t);
|
std::thread tid(&Tetris::Ticker, &t);
|
||||||
if(IOLoop(nc, t, gameover)){
|
if(IOLoop(nc, t, gameover)){
|
||||||
|
Loading…
Reference in New Issue
Block a user