Sample Header Ad - 728x90

NCURSES SW runs in lxterminal, but doesn't run in a native Linux terminal

1 vote
1 answer
633 views
I wrote a "complex" C program using the ncurses library. It "correctly" runs in a lxterminal or gnome-terminal session; but doesn't run in a "native Linux terminal" session without X started *(obtained both restarting the PC without X or using Ctrl-Alt-F3 terminal).* The problem is that in the "native Linux session" the program doesn't display any windows, it displays only one of the text printed in the third generated window. * I saw that in gnome-terminal the TERM environment variable is set as xterm-256color. In contrast, the native Linux terminal has TERM set as linux. * Then I set TERM in the native Linux terminal using:
export TERM=xterm-256color
When I set TERM as xterm-256color the program runs better and displays an usable interface, but all the chars to construct boxes are substituted by other chars, the vertical line char is substituted by the xchar. * But I thought xterm is for X terminal section then I tried ansi:
export TERM=ansi
With this last setting, the program displays almost nothing as in the case of the native setting. * Using vt100:
export TERM=vt100
The programs runs better, but is displayed in B/W. The same behaviour happens also with the examples released with the ncurses library. Have you some explanation? How do I set the terminal capability in a way I may correctly start my ncurses program? It's possible that I've not set something relevant to terminal (or relevan to ncurses) in the code? **Example** #include static void initGeneralScreen(void); int main() { WINDOW * deskW, * msgW, * otherW; initGeneralScreen(); deskW = newwin(21,80,0,0); wbkgd(deskW, COLOR_PAIR(3)); box(deskW, 0, 0 ); // sets default borders for the window wrefresh( deskW ); // update the terminal screen msgW = newwin(3, 80, 21, 0); wbkgd(msgW, COLOR_PAIR(1)); box(msgW, 0, 0 ); // sets default borders for the window wrefresh(msgW ); // update the terminal screen otherW = newwin(1,78,0,1); wbkgd(otherW, COLOR_PAIR(1)); wrefresh(otherW ); // update the terminal screen mvwprintw(msgW,1,1,"Test ... "); wrefresh(msgW ); // update the terminal screen mvwprintw(otherW,0,0,"Test1"); wrefresh(otherW ); // update the terminal screen wgetch(deskW); delwin( otherW ); delwin( msgW ); delwin( deskW ); endwin(); return 0; } void initGeneralScreen(void) { initscr(); // initialize Ncurses noecho(); // disable echoing of characters on the screen raw(); // keypad(stdscr,TRUE); start_color(); init_pair(1,COLOR_YELLOW | 8, COLOR_BLUE); init_pair(2,COLOR_YELLOW, COLOR_BLUE); init_pair(3,COLOR_WHITE | 8, COLOR_BLACK | 8); } **Notes:** * Kernel
Linux 4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
* libncurses.so.5.9
Asked by Sir Jo Black (250 rep)
May 20, 2020, 07:16 AM
Last activity: May 20, 2020, 07:25 PM