colorize_default Function

private pure function colorize_default(string, color_fg, color_bg, style) result(colorized)

Arguments

TypeIntentOptionalAttributesName
character(len=*), intent(in) :: string
character(len=*), intent(in), optional :: color_fg
character(len=*), intent(in), optional :: color_bg
character(len=*), intent(in), optional :: style

Return Value character(len=:),allocatable


Calls

proc~~colorize_default~3~~CallsGraph proc~colorize_default~3 colorize_default proc~color_index~3 color_index proc~colorize_default~3->proc~color_index~3 proc~upper~4 upper proc~colorize_default~3->proc~upper~4 proc~style_index~3 style_index proc~colorize_default~3->proc~style_index~3

Called by

proc~~colorize_default~3~~CalledByGraph proc~colorize_default~3 colorize_default interface~colorize~3 colorize interface~colorize~3->proc~colorize_default~3 proc~colors_samples~3 colors_samples proc~colors_samples~3->interface~colorize~3 proc~styles_samples~3 styles_samples proc~styles_samples~3->interface~colorize~3

Contents

Source Code


Source Code

   pure function colorize_default(string, color_fg, color_bg, style) result(colorized)
   !< Colorize and stylize strings, DEFAULT kind.
   character(len=*), intent(in)           :: string    !< Input string.
   character(len=*), intent(in), optional :: color_fg  !< Foreground color definition.
   character(len=*), intent(in), optional :: color_bg  !< Background color definition.
   character(len=*), intent(in), optional :: style     !< Style definition.
   character(len=:), allocatable          :: colorized !< Colorized string.
   integer(int32)                         :: i         !< Counter.

   colorized = string
   if (present(color_fg)) then
      i = color_index(upper(color_fg))
      if (i>0) colorized = CODE_START//trim(COLORS_FG(2, i))//CODE_END//colorized//CODE_CLEAR
   endif
   if (present(color_bg)) then
      i = color_index(upper(color_bg))
      if (i>0) colorized = CODE_START//trim(COLORS_BG(2, i))//CODE_END//colorized//CODE_CLEAR
   endif
   if (present(style)) then
      i = style_index(upper(style))
      if (i>0) colorized = CODE_START//trim(STYLES(2, i))//CODE_END//colorized//CODE_CLEAR
   endif
   endfunction colorize_default