colorize_str Function

private pure function colorize_str(self, color_fg, color_bg, style) result(colorized)

Colorize and stylize strings, DEFAULT kind.

 type(string) :: astring
 astring = 'say all Hello WorLD!'
 print '(L1)', astring%colorize(color_fg='red')=='say all Hello WorLD!'

Type Bound

string

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The 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.

Return Value character(len=:), allocatable

Colorized string.


Calls

proc~~colorize_str~~CallsGraph proc~colorize_str stringifor_string_t::string%colorize_str colorize colorize proc~colorize_str->colorize proc~chars stringifor_string_t::string%chars proc~colorize_str->proc~chars

Contents

Source Code


Source Code

   pure function colorize_str(self, color_fg, color_bg, style) result(colorized)
   !< Colorize and stylize strings, DEFAULT kind.
   !<
   !<```fortran
   !< type(string) :: astring
   !< astring = 'say all Hello WorLD!'
   !< print '(L1)', astring%colorize(color_fg='red')=='say all Hello WorLD!'
   !<```
   !=> T <<<
   class(string),    intent(in)           :: self      !< The 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.

   colorized = colorize(string=self%chars(), color_fg=color_fg, color_bg=color_bg, style=style)
   endfunction colorize_str