[UP]


Manual Reference Pages  - color (3)

NAME

color(3f) - [M_escape] colorize text using a simple function-based approach (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Example
Author
License

SYNOPSIS

use M_escape, only : color, color_mode, &

    ! FOREGROUND COLORS
        & fg_red, fg_cyan, fg_magenta, fg_blue, &
        & fg_green, fg_yellow, fg_white, fg_ebony, &
        & fg_default, &
    ! BACKGROUND COLORS
        & bg_red, bg_cyan, bg_magenta, bg_blue, &
        & bg_green, bg_yellow, bg_white, bg_ebony, &
        & bg_default, &
     ! ATTRIBUTES
        & bold, italic, inverse, underline,  &
        & unbold, unitalic, uninverse, ununderline,  &
        & reset, &
     ! DISPLAY
        & clear

function color(string,fg,bg,style) result (out)

character(len=*),intent(in) :: string character(len=*),intent(in),optional :: fg character(len=*),intent(in),optional :: bg character(len=*),intent(in),optional :: style

DESCRIPTION

The color constant strings can be used directly but unconditionally in an output statement. To allow the attributes to be ignored they can be called with the color(3f) routine, which the color_mode(3f) procedure can be used to toggle on and off. Note that this routine does an implicit reset at the end of each use.

OPTIONS

string string to assign attributes to
fg foreground color constant
bg background color constant
style style keyword or concatenated style keywords

EXAMPLE

Sample program

   program demo_color
      use M_escape, only : color, color_mode, &
     ! FOREGROUND COLORS
        & fg_red, fg_cyan, fg_magenta, fg_blue, &
        & fg_green, fg_yellow, fg_white, fg_ebony, &
        & fg_default, &
     ! BACKGROUND COLORS
        & bg_red, bg_cyan, bg_magenta, bg_blue, &
        & bg_green, bg_yellow, bg_white, bg_ebony, &
        & bg_default, &
     ! ATTRIBUTES
        & bold, italic, inverse, underline,  &
        & unbold, unitalic, uninverse, ununderline,  &
        & reset, &
     ! DISPLAY
        & clear
      implicit none
        write(*,’(*(g0))’)fg_red,bg_green,bold,’ Hello! ’,reset

write(*,’(a)’)color(’ Hello! ’,& & fg=fg_white,bg=bg_red,style=italic//bold) call color_mode(.false.) write(*,’(a)’)color(’ Hello! ’,& & fg=fg_red,bg=bg_red,style=italic//bold) end program demo_color

AUTHOR

John S. Urban, 2020

LICENSE

Public Domain


color (3) March 11, 2021
Generated by manServer 1.08 from 03c27904-0cfd-4a4f-9649-8eb485e31d6f using man macros.