StringStyle

struct StringStyle

Available string styles.

This styles can be used in string iterpolation:

print("Result is \(result.exitCode, styled: .fgRed, .italic)")

or can be used with any instances of StringProtocol:

print("Init...".styled(.bgMagenta, .bold, .fgRed))

Note

Uses SGR parameters from ANSI escape codes
  • Bold or increased intensity style.

    Declaration

    Swift

    public static var bold: CLI.StringStyle
  • Faint or decreased intensity style.

    Declaration

    Swift

    public static var faint: CLI.StringStyle
  • Italic text style.

    Declaration

    Swift

    public static var italic: CLI.StringStyle
  • Underline text decoration.

    Declaration

    Swift

    public static var underline: CLI.StringStyle
  • Style for swap foreground and background colors.

    Declaration

    Swift

    public static var inverse: CLI.StringStyle
  • Strikethrough text decoration.

    Declaration

    Swift

    public static var strikethrough: CLI.StringStyle
  • Black foreground color.

    Declaration

    Swift

    public static var fgBlack: CLI.StringStyle
  • Red foreground color.

    Declaration

    Swift

    public static var fgRed: CLI.StringStyle
  • Green foreground color.

    Declaration

    Swift

    public static var fgGreen: CLI.StringStyle
  • Yellow foreground color.

    Declaration

    Swift

    public static var fgYellow: CLI.StringStyle
  • Blue foreground color.

    Declaration

    Swift

    public static var fgBlue: CLI.StringStyle
  • Magenta foreground color.

    Declaration

    Swift

    public static var fgMagenta: CLI.StringStyle
  • Cyan foreground color.

    Declaration

    Swift

    public static var fgCyan: CLI.StringStyle
  • White foreground color.

    Declaration

    Swift

    public static var fgWhite: CLI.StringStyle
  • Black background color.

    Declaration

    Swift

    public static var bgBlack: CLI.StringStyle
  • Red background color.

    Declaration

    Swift

    public static var bgRed: CLI.StringStyle
  • Green background color.

    Declaration

    Swift

    public static var bgGreen: CLI.StringStyle
  • Yellow background color.

    Declaration

    Swift

    public static var bgYellow: CLI.StringStyle
  • Blue background color.

    Declaration

    Swift

    public static var bgBlue: CLI.StringStyle
  • Magenta background color.

    Declaration

    Swift

    public static var bgMagenta: CLI.StringStyle
  • Cyan background color.

    Declaration

    Swift

    public static var bgCyan: CLI.StringStyle
  • White background color.

    Declaration

    Swift

    public static var bgWhite: CLI.StringStyle
  • Creates a bright version of text color.

    Precondition

    style must be one of foreground or background colors.

    Declaration

    Swift

    public static func bright(_ style: StringStyle) -> StringStyle

    Parameters

    style

    One of text color styles.

  • Creates a foreground text 8-bit color style with specific color code.

    Precondition

    colorCode must be one ininterval 0..<265

    Declaration

    Swift

    public static func fg(_ colorCode: Int) -> StringStyle

    Parameters

    colorCode

    The specific color code in interval 0..<256

  • Creates a foreground text true color style with define color code for each color component (red, green and blue).

    Precondition

    red, green and blue must be one ininterval 0..<265

    Declaration

    Swift

    public static func fg(r red: Int, g green: Int, b blue: Int) -> StringStyle

    Parameters

    red

    The color code for red component (in interval 0..<256).

    green

    The color code for green component (in interval 0..<256).

    blue

    The color code for blue component (in interval 0..<256).

  • Creates a bacground text 8-bit color style with specific color code.

    Precondition

    colorCode must be one ininterval 0..<265

    Declaration

    Swift

    public static func bg(_ colorCode: Int) -> StringStyle

    Parameters

    colorCode

    The specific color code in interval 0..<256

  • Creates a background text true color style with define color code for each color component (red, green and blue).

    Precondition

    red, green and blue must be one ininterval 0..<265

    Declaration

    Swift

    public static func bg(r red: Int, g green: Int, b blue: Int) -> StringStyle

    Parameters

    red

    The color code for red component (in interval 0..<256).

    green

    The color code for green component (in interval 0..<256).

    blue

    The color code for blue component (in interval 0..<256).