(via Qt Creator, ncurses and Linux | Robotics, Teaching & Learning)
In bash:
sudo apt-get install libncurses5-dev
In the .pro
file, add the line:
LIBS += -lncurses
Now in the main.cpp
file, try this:
#include <ncurses.h>
int main()
{
// Initialize ncurses (read terminal configuration)
initscr();
// Initiliaze color mode and create a color pair
start_color();
init_pair(1, COLOR_WHITE, COLOR_BLUE);
// Display colorized pair
attron(COLOR_PAIR(1));
printw("This should be printed in white with a blue background!\n");
// Display uncolorized text
attroff(COLOR_PAIR(1));
printw ("Press a key to exit\n");
// Update screen
refresh();
// Wait for a key before exiting
getch();
// Restore initial terminal configuration
endwin();
}
0 comments:
Post a Comment