SGR number for a named colour: base + n, or base + 60 + n bright.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | color | |||
| integer(kind=int32), | intent(in) | :: | base |
30 for foreground, 40 for background. |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int32), | private | :: | clamped |
pure function base_code(color, base) result(code) !! SGR number for a named colour: `base + n`, or `base + 60 + n` bright. integer(int32), intent(in) :: color integer(int32), intent(in) :: base !! 30 for foreground, 40 for background. integer(int32) :: code integer(int32) :: clamped clamped = max(0_int32, min(15_int32, color)) if (clamped < 8_int32) then code = base + clamped else code = base + 60_int32 + (clamped - 8_int32) end if end function base_code