Colorizer 帮助为写入终端的字符串添加颜色。
Colorizer 帮助在字符串打印到终端之前对其进行样式设置。您可以更改文本颜色、文本背景和文本样式。Colorizer 通过扩展 String
结构体来为其添加样式。
要更改文本颜色,请使用 string.f
或 string.foreground
。
print("Red String".f.Red)
print("Blue String".foreground.Blue)
要更改文本背景颜色,请使用 string.b
或 string.background
。
print("I have a white background".b.White)
print("My background color is green".background.Green)
要更改文本背景样式,请使用 string.s
或 string.style
。
print("I am a bold string".s.Bold)
print("I have an underline".style.Underline)
您可以组合前景色、背景色和样式。
print("I am an underlined red on white string".s.Underline.f.Red.b.White)
.package(url: "https://github.com/getGuaka/Colorizer.git", from: "0.0.0"),
MIT