has_colors Subroutine

Purpose

Determines whether a terminal supports color.

Library

Curses Library (libcurses.a)

Syntax

#include <curses.h>
has_colors() 

Description

The has_colors subroutine determines whether a terminal supports color. If the terminal supports color, the has_colors subroutine returns TRUE. Otherwise, it returns FALSE. Because this subroutine tests for color, you can call it before the start_color subroutine.

The has_colors routine makes writing terminal-independent programs easier because you can use the subroutine to determine whether to use color or another video attribute.

Use the can_change_colors subroutine to determine whether a terminal that supports colors also supports changing its color definitions.

Examples

To determine whether or not a terminal supports color, use:

has_colors();