Whoa, has it been this long already? Anyway...
Assume you have an ncurses program that is used remotely (either via telnet or ssh) and it resides in a chroot. The program (of course) needs terminfo files inside the chroot.
Usually, ncurses mode is started with:
But what happens when user uses some strange terminal (for which you have no terminfo file for) to connect? The program will show a black screen or quit, because initscr fails.
Use newterm instead:
Just #define DEFAULT_TERM "xterm" or whatever you want to use and have terminfo file for. The setenv is optional, but good if you plan on exec'ing other programs.
Assume you have an ncurses program that is used remotely (either via telnet or ssh) and it resides in a chroot. The program (of course) needs terminfo files inside the chroot.
Usually, ncurses mode is started with:
initscr();
But what happens when user uses some strange terminal (for which you have no terminfo file for) to connect? The program will show a black screen or quit, because initscr fails.
Use newterm instead:
if (newterm(NULL, stdout, stdin) == NULL) {
if (newterm(DEFAULT_TERM, stdout, stdin) == NULL) {
/* Die! */
}
setenv("TERM", DEFAULT_TERM, 1);
}
Just #define DEFAULT_TERM "xterm" or whatever you want to use and have terminfo file for. The setenv is optional, but good if you plan on exec'ing other programs.
Tags: