| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i8), | intent(in), | optional | :: | style | ||
| integer(kind=i16), | intent(in), | optional | :: | fg_color | ||
| integer(kind=i16), | intent(in), | optional | :: | bg_color |
pure module function set_ansi_code(style, fg_color, bg_color) result(ansi_code) integer(i8), optional, intent(in) :: style integer(i16), optional, intent(in) :: fg_color, bg_color type(AnsiCode) :: ansi_code ansi_code%use_style = .false. ansi_code%use_fg = .false. ansi_code%use_bg = .false. if (present(style)) then ansi_code%use_style = style >= 0 .and. style < 10 if (ansi_code%use_style) ansi_code%style = style end if if (present(fg_color)) then ansi_code%use_fg = fg_color >= 0 .and. fg_color <= 255 if (ansi_code%use_fg) ansi_code%fg = fg_color end if if (present(bg_color)) then ansi_code%use_bg = bg_color >= 0 .and. bg_color <= 255 if (ansi_code%use_bg) ansi_code%bg = bg_color end if if (.not. (ansi_code%use_style .or. ansi_code%use_fg .or. ansi_code%use_bg)) then ansi_code = Ansi_Constants%STYLE_RESET end if end function set_ansi_code