Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created August 23, 2020 10:49
Show Gist options
  • Save CodeDrome/300b50fa958bcccf036bdf526416b932 to your computer and use it in GitHub Desktop.
Save CodeDrome/300b50fa958bcccf036bdf526416b932 to your computer and use it in GitHub Desktop.
ncursesdemo.c part 4
//--------------------------------------------------------
// FUNCTION colouring
//--------------------------------------------------------
void colouring()
{
if(has_colors())
{
if(start_color() == OK)
{
init_pair(1, COLOR_YELLOW, COLOR_RED);
init_pair(2, COLOR_GREEN, COLOR_GREEN);
init_pair(3, COLOR_MAGENTA, COLOR_CYAN);
attrset(COLOR_PAIR(1));
addstr("Yellow and red\n\n");
refresh();
attroff(COLOR_PAIR(1));
attrset(COLOR_PAIR(2) | A_BOLD);
addstr("Green and green A_BOLD\n\n");
refresh();
attroff(COLOR_PAIR(2));
attroff(A_BOLD);
attrset(COLOR_PAIR(3));
addstr("Magenta and cyan\n");
refresh();
attroff(COLOR_PAIR(3));
}
else
{
addstr("Cannot start colours\n");
refresh();
}
}
else
{
addstr("Not colour capable\n");
refresh();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment