ANSI escape sequences for coloured terminal output.
Add ANSI parameters directly to print statements, for instance:
print '(2a)', ANSI_CLEAR_SCREEN, 'Hello, World!'
The foreground colour can be changed through routine
dm_ansi_color().
You may want to disable ANSI colour output depending on whether
environment variable NO_COLOR is set, for example:
logical :: no_color
no_color = dm_env_has('NO_COLOR')
call dm_ansi_color(COLOR_RED, no_color)
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=*), | public, | parameter | :: | ANSI_CLEAR_SCREEN | = | ASCII_ESC//'[2J' | |
| character(len=*), | public, | parameter | :: | ANSI_RESET_CURSOR | = | ASCII_ESC//'[0;0H' | |
| character(len=*), | public, | parameter | :: | ANSI_HIDE_CURSOR | = | ASCII_ESC//'[?25l' | |
| character(len=*), | public, | parameter | :: | ANSI_SHOW_CURSOR | = | ASCII_ESC//'[?25h' | |
| integer, | public, | parameter | :: | COLOR_BLACK | = | 0 | |
| integer, | public, | parameter | :: | COLOR_RED | = | 1 | |
| integer, | public, | parameter | :: | COLOR_GREEN | = | 2 | |
| integer, | public, | parameter | :: | COLOR_YELLOW | = | 3 | |
| integer, | public, | parameter | :: | COLOR_BLUE | = | 4 | |
| integer, | public, | parameter | :: | COLOR_MAGENTA | = | 5 | |
| integer, | public, | parameter | :: | COLOR_CYAN | = | 6 | |
| integer, | public, | parameter | :: | COLOR_WHITE | = | 7 | |
| integer, | public, | parameter | :: | COLOR_RESET | = | 9 |
Changes foreground to color. Writes to stdout if no unit is passed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | color |
Colour. |
||
| logical, | intent(in), | optional | :: | no_color |
No output if |
|
| integer, | intent(in), | optional | :: | unit |
File unit. |
Resets colours. Writes to stdout if unit is passed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in), | optional | :: | no_color |
No output if |
|
| integer, | intent(in), | optional | :: | unit |
File unit. |