escseq

package
v3.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindEmpty Kind = iota
	KindText
	KindColor
	KindNotColor

	ColorTypeReset       ColorType = iota // \x1b[0m 指定をリセット
	ColorTypeBold                         // \x1b[1m 太字
	ColorTypeDim                          // \x1b[2m 薄く表示
	ColorTypeItalic                       // \x1b[3m イタリック
	ColorTypeUnderline                    // \x1b[4m アンダーライン
	ColorTypeBlink                        // \x1b[5m ブリンク
	ColorTypeSpeedyBlink                  // \x1b[6m 高速ブリンク
	ColorTypeReverse                      // \x1b[7m 文字色と背景色の反転
	ColorTypeHide                         // \x1b[8m 表示を隠す
	ColorTypeDelete                       // \x1b[9m 取り消し
	ColorTypeForeground
	ColorTypeBackground
)

Variables

View Source
var (
	RGBABlack        = RGBA{0, 0, 0, 255}
	RGBARed          = RGBA{255, 0, 0, 255}
	RGBAGreen        = RGBA{0, 255, 0, 255}
	RGBAYellow       = RGBA{255, 255, 0, 255}
	RGBABlue         = RGBA{0, 0, 255, 255}
	RGBAMagenta      = RGBA{255, 0, 255, 255}
	RGBACyan         = RGBA{0, 255, 255, 255}
	RGBALightGray    = RGBA{211, 211, 211, 255}
	RGBADarkGray     = RGBA{169, 169, 169, 255}
	RGBALightRed     = RGBA{255, 144, 144, 255}
	RGBALightGreen   = RGBA{144, 238, 144, 255}
	RGBALightYellow  = RGBA{255, 255, 224, 255}
	RGBALightBlue    = RGBA{173, 216, 230, 255}
	RGBALightMagenta = RGBA{255, 224, 255, 255}
	RGBALightCyan    = RGBA{224, 255, 255, 255}
	RGBAWhite        = RGBA{255, 255, 255, 255}

	StringMap = map[string]RGBA{
		"black":   RGBABlack,
		"red":     RGBARed,
		"green":   RGBAGreen,
		"yellow":  RGBAYellow,
		"blue":    RGBABlue,
		"magenta": RGBAMagenta,
		"cyan":    RGBACyan,
		"white":   RGBAWhite,
	}

	// \x1b[NNm とかの NN に紐づくRGBA色
	// 例: \x1b[30m
	ANSIMap = map[int]RGBA{

		30: RGBABlack,
		31: RGBARed,
		32: RGBAGreen,
		33: RGBAYellow,
		34: RGBABlue,
		35: RGBAMagenta,
		36: RGBACyan,
		37: RGBALightGray,
		90: RGBADarkGray,
		91: RGBALightRed,
		92: RGBALightGreen,
		93: RGBALightYellow,
		94: RGBALightBlue,
		95: RGBALightMagenta,
		96: RGBALightCyan,
		97: RGBAWhite,

		40:  RGBABlack,
		41:  RGBARed,
		42:  RGBAGreen,
		43:  RGBAYellow,
		44:  RGBABlue,
		45:  RGBAMagenta,
		46:  RGBACyan,
		47:  RGBALightGray,
		100: RGBADarkGray,
		101: RGBALightRed,
		102: RGBALightGreen,
		103: RGBALightYellow,
		104: RGBALightBlue,
		105: RGBALightMagenta,
		106: RGBALightCyan,
		107: RGBAWhite,
	}

	// \x1b[38;5;NNNm とかの NNN に紐づくRGBA色
	// 例: \x1b[38;5;114m
	Map256 = map[int]RGBA{}/* 256 elements not displayed */

)
View Source
var (

	// \x1b[Nm とかの N に紐づく色種別
	// 例: \x1b[0m
	AttributeMap = map[int]ColorType{
		0: ColorTypeReset,
		1: ColorTypeBold,
		2: ColorTypeDim,
		3: ColorTypeItalic,
		4: ColorTypeUnderline,
		5: ColorTypeBlink,
		6: ColorTypeSpeedyBlink,
		7: ColorTypeReverse,
		8: ColorTypeHide,
		9: ColorTypeDelete,
	}
)

Functions

func StringWidth

func StringWidth(s []string) (max int)

StringWidth は表示上のテキストの最も幅の長い長さを返却する。

Types

type Color

type Color struct {
	ColorType ColorType
	Color     RGBA
}

type ColorType

type ColorType int // 文字色か背景色か

type Colors

type Colors []Color

func ParseColor

func ParseColor(s string) (colors Colors)

ParseColor は色のエスケープシーケンスを解析してRGBAに変換する。

type Kind

type Kind int // エスケープシーケンスの種類

func Prefix

func Prefix(s string) (k Kind, prefix string, suffix string)

Prefix は文字列の先頭の要素を種類とともに返却と残り部分とともに返す。 エスケープシーケンス系とマッチしたらマッチした部分を返す。 エスケープシーケンス以外の場合は次のエスケープシーケンスが出現するまでを返す。 エスケープシーケンスが出現しない場合はすべての文字列をprefixとして返す。

type RGBA

type RGBA c.RGBA

Jump to

Keyboard shortcuts

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