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~~CallsGraph proc~colorize_default colorize_default proc~color_index color_index proc~colorize_default->proc~color_index proc~upper upper proc~colorize_default->proc~upper proc~style_index style_index proc~colorize_default->proc~style_index

Called by

proc~~colorize_default~~CalledByGraph proc~colorize_default colorize_default interface~colorize colorize interface~colorize->proc~colorize_default proc~colorize_str colorize_str proc~colorize_str->interface~colorize proc~styles_samples styles_samples proc~styles_samples->interface~colorize proc~colorize_str~2 colorize_str proc~colorize_str~2->interface~colorize program~face_test_colors face_test_colors program~face_test_colors->interface~colorize program~face_test_styles~2 face_test_styles program~face_test_styles~2->interface~colorize program~face_test_styles~3 face_test_styles program~face_test_styles~3->interface~colorize program~face_test_colors~4 face_test_colors program~face_test_colors~4->interface~colorize proc~colors_samples colors_samples proc~colors_samples->interface~colorize program~face_test_styles face_test_styles program~face_test_styles->interface~colorize program~face_test_colors~2 face_test_colors program~face_test_colors~2->interface~colorize program~face_test_colors~3 face_test_colors program~face_test_colors~3->interface~colorize program~face_test_styles~4 face_test_styles program~face_test_styles~4->interface~colorize program~face_test_basic face_test_basic program~face_test_basic->proc~styles_samples program~face_test_basic->proc~colors_samples program~face_test_basic~2 face_test_basic program~face_test_basic~2->proc~styles_samples program~face_test_basic~2->proc~colors_samples program~face_test_basic~3 face_test_basic program~face_test_basic~3->proc~styles_samples program~face_test_basic~3->proc~colors_samples program~face_test_basic~4 face_test_basic program~face_test_basic~4->proc~styles_samples program~face_test_basic~4->proc~colors_samples

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