No Clock  1.0.2
Pretty Printing Colours

Use pretty colours. More...

Macros

#define PP_BLACK   "\x1B[30m"
 Use the system black colour. More...
 
#define PP_BLUE   "\x1B[34m"
 Use the system blue colour. More...
 
#define PP_BOLD   "\x1B[1m"
 Bold terminal text. More...
 
#define PP_CALL   PP_BOLD PP_IDENTIFIER
 Colour for function calls. More...
 
#define PP_CONSTANT   PP_GREEN
 Colour for constants. More...
 
#define PP_CYAN   "\x1B[36m"
 Use the system cyan colour. More...
 
#define PP_GRAY   PP_GREY
 Alias for PP_GREY. More...
 
#define PP_GREEN   "\x1B[32m"
 Use the system green colour. More...
 
#define PP_GREY   "\x1B[37m"
 Use the system grey colour. More...
 
#define PP_IDENTIFIER   PP_YELLOW
 Colour for identifiers. More...
 
#define PP_KEYWORD   PP_BOLD PP_BLUE
 Colour for normal keywords (for, if, etc.) More...
 
#define PP_KEYWORD_NOT_WANTED   PP_BOLD PP_RED
 Colour for the keywords this program aims to remove (clocked, advance) More...
 
#define PP_KEYWORD_SPECIAL   PP_BOLD PP_CYAN
 Colour for special keywords (finish, async) More...
 
#define PP_PURPLE   "\x1B[35m"
 Use the system purple colour. More...
 
#define PP_RED   "\x1B[31m"
 Use the system red colour. More...
 
#define PP_RESET   "\x1B[0m"
 Reset terminal text modifications. More...
 
#define PP_YELLOW   "\x1B[33m"
 Use the system yellow colour. More...
 

Functions

static void pretty_print_color_disable (void)
 Disable colours. More...
 
static void pretty_print_color_enable (void)
 Enable colours. More...
 
static bool pretty_print_color_get_state (void)
 Get the current colour state. More...
 
static void pretty_print_color_set_state (bool state)
 Set the colour state. More...
 
static bool pretty_print_color_state (void)
 Get the current colour state. More...
 
void pretty_print_colour_disable (void)
 Disable colours. More...
 
void pretty_print_colour_enable (void)
 Enable colours. More...
 
static bool pretty_print_colour_get_state (void)
 Get the current colour state. More...
 
void pretty_print_colour_set_state (bool state)
 Set the colour state. More...
 
bool pretty_print_colour_state (void)
 Get the current colour state. More...
 

Detailed Description

Use pretty colours.

Since
version 1.0.0

Pretty printing colour mode

The pretty printing colour mode can be inspected using the pretty_print_colour_state() function.

It can be enabled with pretty_print_colour_enable() and disabled with pretty_print_colour_disable().

Usage

Several colours or modificators are defined using macros. Since C automatically concatenates strings, one can simply put these macros besides C strings. When attempting to use these macros, the user should first check whether the pretty printing colour mode is enabled.

It is also strongly advised to always add PP_RESET at the end of the strings, in order to make sure that any following text will be normal, unless this is not the desired behaviour.

Available macros

Modifications

Modification Macro Text representation
Reset PP_RESET "\x1B[0m"
Bold PP_BOLD "\x1B[1m"

Colours

Modification Macro Text representation
Black PP_BLACK "\x1B[30m"
Red PP_RED "\x1B[31m"
Green PP_GREEN "\x1B[32m"
Yellow PP_YELLOW "\x1B[33m"
Blue PP_BLUE "\x1B[34m"
Purple PP_PURPLE "\x1B[35m"
Cyan PP_CYAN "\x1B[36m"
Grey PP_GREY "\x1B[37m"
Gray PP_GRAY "\x1B[37m"

Example

bool enabled = pretty_printing_colour_state ();
if (enabled)
printf (PP_BOLD PP_BLUE "Some text\n" PP_RESET);
else
printf ("Some text\n");

Macro Definition Documentation

#define PP_BLACK   "\x1B[30m"

#include <include/noclock/pretty_print.h>

Use the system black colour.

Since
version 1.0.0
#define PP_BLUE   "\x1B[34m"

#include <include/noclock/pretty_print.h>

Use the system blue colour.

Since
version 1.0.0
#define PP_BOLD   "\x1B[1m"

#include <include/noclock/pretty_print.h>

Bold terminal text.

Since
version 1.0.0
#define PP_CALL   PP_BOLD PP_IDENTIFIER

#include <include/noclock/pretty_print.h>

Colour for function calls.

Since
version 1.0.0
#define PP_CONSTANT   PP_GREEN

#include <include/noclock/pretty_print.h>

Colour for constants.

Since
version 1.0.0
#define PP_CYAN   "\x1B[36m"

#include <include/noclock/pretty_print.h>

Use the system cyan colour.

Since
version 1.0.0
#define PP_GRAY   PP_GREY

#include <include/noclock/pretty_print.h>

Alias for PP_GREY.

Since
version 1.0.0
#define PP_GREEN   "\x1B[32m"

#include <include/noclock/pretty_print.h>

Use the system green colour.

Since
version 1.0.0
#define PP_GREY   "\x1B[37m"

#include <include/noclock/pretty_print.h>

Use the system grey colour.

Since
version 1.0.0
#define PP_IDENTIFIER   PP_YELLOW

#include <include/noclock/pretty_print.h>

Colour for identifiers.

Since
version 1.0.0
#define PP_KEYWORD   PP_BOLD PP_BLUE

#include <include/noclock/pretty_print.h>

Colour for normal keywords (for, if, etc.)

Since
version 1.0.0
#define PP_KEYWORD_NOT_WANTED   PP_BOLD PP_RED

#include <include/noclock/pretty_print.h>

Colour for the keywords this program aims to remove (clocked, advance)

Since
version 1.0.0
#define PP_KEYWORD_SPECIAL   PP_BOLD PP_CYAN

#include <include/noclock/pretty_print.h>

Colour for special keywords (finish, async)

Since
version 1.0.0
#define PP_PURPLE   "\x1B[35m"

#include <include/noclock/pretty_print.h>

Use the system purple colour.

Since
version 1.0.0
#define PP_RED   "\x1B[31m"

#include <include/noclock/pretty_print.h>

Use the system red colour.

Since
version 1.0.0
#define PP_RESET   "\x1B[0m"

#include <include/noclock/pretty_print.h>

Reset terminal text modifications.

Since
version 1.0.0
#define PP_YELLOW   "\x1B[33m"

#include <include/noclock/pretty_print.h>

Use the system yellow colour.

Since
version 1.0.0

Function Documentation

static void pretty_print_color_disable ( void  )
inlinestatic

#include <include/noclock/pretty_print.h>

Disable colours.

Since
version 1.0.0
Note
This is equivalent to:
See also
pretty_print_colour_disable()
static void pretty_print_color_enable ( void  )
inlinestatic

#include <include/noclock/pretty_print.h>

Enable colours.

Deprecated:
Please use pretty_print_colour_enable().
Since
version 1.0.0
Note
This is equivalent to:
See also
pretty_print_colour_enable()
static bool pretty_print_color_get_state ( void  )
inlinestatic

#include <include/noclock/pretty_print.h>

Get the current colour state.

Deprecated:
Please use pretty_print_colour_state().
Since
version 1.0.0
Return values
trueif colours are enabled.
falseotherwise.
Note
This is equivalent to:
See also
pretty_print_colour_state()
static void pretty_print_color_set_state ( bool  state)
inlinestatic

#include <include/noclock/pretty_print.h>

Set the colour state.

Deprecated:
Please use pretty_print_colour_set_state().
Since
version 1.0.0
Parameters
stateThe desired colour state.
Note
This is equivalent to:
See also
pretty_print_colour_set_state()
static bool pretty_print_color_state ( void  )
inlinestatic

#include <include/noclock/pretty_print.h>

Get the current colour state.

Deprecated:
Please use pretty_print_colour_state().
Since
version 1.0.0
Return values
trueif colours are enabled.
falseotherwise.
Note
This is equivalent to:
See also
pretty_print_colour_state()
void pretty_print_colour_disable ( void  )

#include <include/noclock/pretty_print.h>

Disable colours.

Since
version 1.0.0
Note
This is equivalent to:
void pretty_print_colour_enable ( void  )

#include <include/noclock/pretty_print.h>

Enable colours.

Since
version 1.0.0
Note
This is equivalent to:
static bool pretty_print_colour_get_state ( void  )
inlinestatic

#include <include/noclock/pretty_print.h>

Get the current colour state.

Deprecated:
Please use pretty_print_colour_state().
Since
version 1.0.0
Return values
trueif colours are enabled.
falseotherwise.
Note
This is equivalent to:
See also
pretty_print_colour_state()
void pretty_print_colour_set_state ( bool  state)

#include <include/noclock/pretty_print.h>

Set the colour state.

Since
version 1.0.0
Parameters
stateThe desired colour state.
bool pretty_print_colour_state ( void  )

#include <include/noclock/pretty_print.h>

Get the current colour state.

Since
version 1.0.0
Return values
trueif colours are enabled.
falseotherwise.