While you are free to provide any command-line option to enable the
styling of the output, it is good if different GNU programs use the same
command-line options for this purpose. These options are described in
the sections The --color
option and The --style
option. To
achieve this, use the following API (declared in <textstyle.h>
):
bool
color_test_mode ¶True if a --color
option with value test
has been seen.
enum color_option
color_mode ¶Stores the value of the --color
option.
const char *
style_file_name ¶Stores the value of the --style
option.
Note: These variables, like any variables exported from shared libraries, can only be used in executable code. You cannot portably use their address in initializers of global or static variables. This is a restriction that is imposed by the Windows, Cygwin, and Android platforms.
bool
handle_color_option (const char *option)
¶You invoke this function when, during argument parsing, you have
encountered a --color
or --color=...
option. The return
value is an error indicator: true
means an invalid option.
void
handle_style_option (const char *option)
¶You invoke this function when, during argument parsing, you have
encountered a --style
or --style=...
option.
void
print_color_test (void)
¶Prints a color test page. You invoke this function after argument
parsing, when the color_test_mode
variable is true.
void
style_file_prepare (const char *style_file_envvar, const char *stylesdir_envvar, const char *stylesdir_after_install, const char *default_style_file)
¶Assigns a default value to style_file_name
if necessary. You
invoke this function after argument parsing, when color_test_mode
is false.
style_file_envvar
is an environment variable that, when set
to a non-empty value, specifies the style file to use. This environment
variable is meant to be set by the user.
stylesdir_envvar
is an environment variable that, when set
to a non-empty value, specifies the directory with the style files, or
NULL
. This is necessary for running the testsuite before
‘make install’.
stylesdir_after_install
is the directory with the style
files after ‘make install’.
default_style_file
is the file name of the default style
file, relative to stylesdir.