color

package
v0.0.0-...-110d06e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package color 精简快捷的彩色字体工具包(Linux版本)

Index

Examples

Constants

View Source
const (
	Reset        StyleOrColor = 0 // 重置
	Bold                      = 1 // 加粗
	Faint                     = 2 // 模糊
	Italic                    = 3 // 斜体
	Underline                 = 4 // 下划线
	BlinkSlow                 = 5 // 慢速闪烁
	BlinkRapid                = 6 // 快速闪烁
	ReverseVideo              = 7 // 反白/反向显示
	Concealed                 = 8 // 隐藏/暗格
	CrossedOut                = 9 // 删除

	FontBlack   = 30 // 「字体」黑色
	FontRed     = 31 // 「字体」红色
	FontGreen   = 32 // 「字体」绿色
	FontYellow  = 33 // 「字体」黄色
	FontBlue    = 34 // 「字体」蓝色
	FontMagenta = 35 // 「字体」品红/洋紫
	FontCyan    = 36 // 「字体」青色
	FontWhite   = 37 // 「字体」白色

	BackBlack   = 40 // 「背景」黑色
	BackRed     = 41 // 「背景」红色
	BackGreen   = 42 // 「背景」绿色
	BackYellow  = 43 // 「背景」黄色
	BackBlue    = 44 // 「背景」蓝色
	BackMagenta = 45 // 「背景」品红/洋紫
	BackCyan    = 46 // 「背景」青色
	BackWhite   = 47 // 「背景」白色
)

Variables

This section is empty.

Functions

func Error

func Error(txt string) string

Error ❌

func Failure

func Failure(txt string) string

Failure 🚫

func Info

func Info(txt string) string

Info 🔔

func Success

func Success(txt string) string

Success ✅

func Text

func Text(txt string, params ...StyleOrColor) string

Text 精简快捷的终端彩色打印(仅支持linux)

格式:color.Text("内容",样式,字体色,背景色)
推荐使用: https://github.com/gookit/color
Example
package main

import (
	"fmt"

	"github.com/hollson/gdk/color"
)

func main() {
	fmt.Println(color.Text("仅样式", color.Bold))
	fmt.Println(color.Text("仅字体", color.FontRed))
	fmt.Println(color.Text("仅背景", color.BackCyan))
	fmt.Println(color.Text("字体+背景", color.FontRed, color.BackYellow))
	fmt.Println(color.Text("样式+字体", color.Bold, color.FontBlue))
	fmt.Println(color.Text("样式+背景", color.Bold, color.BackYellow))
	fmt.Println(color.Text("样式+字体+背景", color.Bold, color.FontBlue, color.BackMagenta))
}
Output:

func Warn

func Warn(txt string) string

Warn ⚠️

Types

type StyleOrColor

type StyleOrColor uint8

StyleOrColor 样式/颜色

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL