Why does initscr() after a delwin() return undef?

Viewed 397

Why does the delwin cause the second initscr to return nothing? I thought the endwin would reset to the state as it was before calling initscr.

use NCurses;

my $win = initscr();
addstr( 'AAA' );
nc_refresh();
sleep 2;
delwin( $win );
endwin();

...

my $new_win = initscr();
if ! $new_win.defined {
    endwin();
    dd $new_win;            # NCurses::WINDOW $new_win = NCurses::WINDOW
    die "win undefined";    # win undefined
}
addstr( 'BBB' );
nc_refresh();
sleep 2;
delwin( $new_win );
endwin;
1 Answers
Related