This commit is contained in:
Кобелев Андрей Андреевич
2022-08-15 23:06:20 +03:00
commit 4ea1a3802b
532 changed files with 211522 additions and 0 deletions

34
vendor/github.com/logrusorgru/aurora/.gitignore generated vendored Normal file
View File

@ -0,0 +1,34 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
*.out
# coverage
cover.html
# benchcmp
*.cmp

9
vendor/github.com/logrusorgru/aurora/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,9 @@
language: go
go:
- tip
before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
script:
- $HOME/gopath/bin/goveralls -service=travis-ci

8
vendor/github.com/logrusorgru/aurora/AUTHORS.md generated vendored Normal file
View File

@ -0,0 +1,8 @@
AUTHORS
=======
- Konstantin Ivanov @logrusorgru
- Mattias Eriksson @snaggen
- Ousmane Traore @otraore
- Simon Legner @simon04
- Sevenate @sevenate

59
vendor/github.com/logrusorgru/aurora/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,59 @@
Changes
=======
---
16:05:02
Thursday, July 2, 2020
Change license from the WTFPL to the Unlicense due to pkg.go.dev restriction.
---
15:39:40
Wednesday, April 17, 2019
- Bright background and foreground colors
- 8-bit indexed colors `Index`, `BgIndex`
- 24 grayscale colors `Gray`, `BgGray`
- `Yellow` and `BgYellow` methods, mark Brow and BgBrown as deprecated
Following specifications, correct name of the colors are yellow, but
by historical reason they are called brown. Both, the `Yellow` and the
`Brown` methods (including `Bg+`) represents the same colors. The Brown
are leaved for backward compatibility until Go modules production release.
- Additional formats
+ `Faint` that is opposite to the `Bold`
+ `DoublyUnderline`
+ `Fraktur`
+ `Italic`
+ `Underline`
+ `SlowBlink` with `Blink` alias
+ `RapidBlink`
+ `Reverse` that is alias for the `Inverse`
+ `Conceal` with `Hidden` alias
+ `CrossedOut` with `StrikeThrough` alias
+ `Framed`
+ `Encircled`
+ `Overlined`
- Add AUTHORS.md file and change all copyright notices.
- `Reset` method to create clear value. `Reset` method that replaces
`Bleach` method. The `Bleach` method was marked as deprecated.
---
14:25:49
Friday, August 18, 2017
- LICENSE.md changed to LICENSE
- fix email in README.md
- add "no warranty" to README.md
- set proper copyright date
---
16:59:28
Tuesday, November 8, 2016
- Rid out off sync.Pool
- Little optimizations (very little)
- Improved benchmarks
---

24
vendor/github.com/logrusorgru/aurora/LICENSE generated vendored Normal file
View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

314
vendor/github.com/logrusorgru/aurora/README.md generated vendored Normal file
View File

@ -0,0 +1,314 @@
Aurora
======
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/logrusorgru/aurora?tab=doc)
[![Unlicense](https://img.shields.io/badge/license-unlicense-blue.svg)](http://unlicense.org/)
[![Build Status](https://travis-ci.org/logrusorgru/aurora.svg)](https://travis-ci.org/logrusorgru/aurora)
[![Coverage Status](https://coveralls.io/repos/logrusorgru/aurora/badge.svg?branch=master)](https://coveralls.io/r/logrusorgru/aurora?branch=master)
[![GoReportCard](https://goreportcard.com/badge/logrusorgru/aurora)](https://goreportcard.com/report/logrusorgru/aurora)
[![Gitter](https://img.shields.io/badge/chat-on_gitter-46bc99.svg?logo=data:image%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTQiIHdpZHRoPSIxNCI%2BPGcgZmlsbD0iI2ZmZiI%2BPHJlY3QgeD0iMCIgeT0iMyIgd2lkdGg9IjEiIGhlaWdodD0iNSIvPjxyZWN0IHg9IjIiIHk9IjQiIHdpZHRoPSIxIiBoZWlnaHQ9IjciLz48cmVjdCB4PSI0IiB5PSI0IiB3aWR0aD0iMSIgaGVpZ2h0PSI3Ii8%2BPHJlY3QgeD0iNiIgeT0iNCIgd2lkdGg9IjEiIGhlaWdodD0iNCIvPjwvZz48L3N2Zz4%3D&logoWidth=10)](https://gitter.im/logrusorgru/aurora)
Ultimate ANSI colors for Golang. The package supports Printf/Sprintf etc.
![aurora logo](https://github.com/logrusorgru/aurora/blob/master/gopher_aurora.png)
# TOC
- [Installation](#installation)
- [Usage](#usage)
+ [Simple](#simple)
+ [Printf](#printf)
+ [aurora.Sprintf](#aurorasprintf)
+ [Enable/Disable colors](#enabledisable-colors)
- [Chains](#chains)
- [Colorize](#colorize)
- [Grayscale](#grayscale)
- [8-bit colors](#8-bit-colors)
- [Supported Colors & Formats](#supported-colors--formats)
+ [All colors](#all-colors)
+ [Standard and bright colors](#standard-and-bright-colors)
+ [Formats are likely supported](#formats-are-likely-supported)
+ [Formats are likely unsupported](#formats-are-likely-unsupported)
- [Limitations](#limitations)
+ [Windows](#windows)
+ [TTY](#tty)
- [Licensing](#licensing)
# Installation
Get
```
go get -u github.com/logrusorgru/aurora
```
Test
```
go test -cover github.com/logrusorgru/aurora
```
# Usage
### Simple
```go
package main
import (
"fmt"
. "github.com/logrusorgru/aurora"
)
func main() {
fmt.Println("Hello,", Magenta("Aurora"))
fmt.Println(Bold(Cyan("Cya!")))
}
```
![simple png](https://github.com/logrusorgru/aurora/blob/master/simple.png)
### Printf
```go
package main
import (
"fmt"
. "github.com/logrusorgru/aurora"
)
func main() {
fmt.Printf("Got it %d times\n", Green(1240))
fmt.Printf("PI is %+1.2e\n", Cyan(3.14))
}
```
![printf png](https://github.com/logrusorgru/aurora/blob/master/printf.png)
### aurora.Sprintf
```go
package main
import (
"fmt"
. "github.com/logrusorgru/aurora"
)
func main() {
fmt.Println(Sprintf(Magenta("Got it %d times"), Green(1240)))
}
```
![sprintf png](https://github.com/logrusorgru/aurora/blob/master/sprintf.png)
### Enable/Disable colors
```go
package main
import (
"fmt"
"flag"
"github.com/logrusorgru/aurora"
)
// colorizer
var au aurora.Aurora
var colors = flag.Bool("colors", false, "enable or disable colors")
func init() {
flag.Parse()
au = aurora.NewAurora(*colors)
}
func main() {
// use colorizer
fmt.Println(au.Green("Hello"))
}
```
Without flags:
![disable png](https://github.com/logrusorgru/aurora/blob/master/disable.png)
With `-colors` flag:
![enable png](https://github.com/logrusorgru/aurora/blob/master/enable.png)
# Chains
The following samples are equal
```go
x := BgMagenta(Bold(Red("x")))
```
```go
x := Red("x").Bold().BgMagenta()
```
The second is more readable
# Colorize
There is `Colorize` function that allows to choose some colors and
format from a side
```go
func getColors() Color {
// some stuff that returns appropriate colors and format
}
// [...]
func main() {
fmt.Println(Colorize("Greeting", getColors()))
}
```
Less complicated example
```go
x := Colorize("Greeting", GreenFg|GrayBg|BoldFm)
```
Unlike other color functions and methods (such as Red/BgBlue etc)
a `Colorize` clears previous colors
```go
x := Red("x").Colorize(BgGreen) // will be with green background only
```
# Grayscale
```go
fmt.Println(" ",
Gray(1-1, " 00-23 ").BgGray(24-1),
Gray(4-1, " 03-19 ").BgGray(20-1),
Gray(8-1, " 07-15 ").BgGray(16-1),
Gray(12-1, " 11-11 ").BgGray(12-1),
Gray(16-1, " 15-07 ").BgGray(8-1),
Gray(20-1, " 19-03 ").BgGray(4-1),
Gray(24-1, " 23-00 ").BgGray(1-1),
)
```
![grayscale png](https://github.com/logrusorgru/aurora/blob/master/aurora_grayscale.png)
# 8-bit colors
Methods `Index` and `BgIndex` implements 8-bit colors.
| Index/BgIndex | Meaning | Foreground | Background |
| -------------- | --------------- | ---------- | ---------- |
| 0- 7 | standard colors | 30- 37 | 40- 47 |
| 8- 15 | bright colors | 90- 97 | 100-107 |
| 16-231 | 216 colors | 38;5;n | 48;5;n |
| 232-255 | 24 grayscale | 38;5;n | 48;5;n |
# Supported colors & formats
- formats
+ bold (1)
+ faint (2)
+ doubly-underline (21)
+ fraktur (20)
+ italic (3)
+ underline (4)
+ slow blink (5)
+ rapid blink (6)
+ reverse video (7)
+ conceal (8)
+ crossed out (9)
+ framed (51)
+ encircled (52)
+ overlined (53)
- background and foreground colors, including bright
+ black
+ red
+ green
+ yellow (brown)
+ blue
+ magenta
+ cyan
+ white
+ 24 grayscale colors
+ 216 8-bit colors
### All colors
![linux png](https://github.com/logrusorgru/aurora/blob/master/aurora_colors_black.png)
![white png](https://github.com/logrusorgru/aurora/blob/master/aurora_colors_white.png)
### Standard and bright colors
![linux black standard png](https://github.com/logrusorgru/aurora/blob/master/aurora_black_standard.png)
![linux white standard png](https://github.com/logrusorgru/aurora/blob/master/aurora_white_standard.png)
### Formats are likely supported
![formats supported gif](https://github.com/logrusorgru/aurora/blob/master/aurora_formats.gif)
### Formats are likely unsupported
![formats rarely supported png](https://github.com/logrusorgru/aurora/blob/master/aurora_rarely_supported.png)
# Limitations
There is no way to represent `%T` and `%p` with colors using
a standard approach
```go
package main
import (
"fmt"
. "github.com/logrusorgru/aurora"
)
func main() {
r := Red("red")
var i int
fmt.Printf("%T %p\n", r, Green(&i))
}
```
Output will be without colors
```
aurora.value %!p(aurora.value={0xc42000a310 768 0})
```
The obvious workaround is `Red(fmt.Sprintf("%T", some))`
### Windows
The Aurora provides ANSI colors only, so there is no support for Windows. That said, there are workarounds available.
Check out these comments to learn more:
- [Using go-colorable](https://github.com/logrusorgru/aurora/issues/2#issuecomment-299014211).
- [Using registry for Windows 10](https://github.com/logrusorgru/aurora/issues/10#issue-476361247).
### TTY
The Aurora has no internal TTY detectors by design. Take a look
[this comment](https://github.com/logrusorgru/aurora/issues/2#issuecomment-299030108) if you want turn
on colors for a terminal only, and turn them off for a file.
### Licensing
Copyright &copy; 2016-2020 The Aurora Authors. This work is free.
It comes without any warranty, to the extent permitted by applicable
law. You can redistribute it and/or modify it under the terms of the
the Unlicense. See the LICENSE file for more details.

725
vendor/github.com/logrusorgru/aurora/aurora.go generated vendored Normal file
View File

@ -0,0 +1,725 @@
//
// Copyright (c) 2016-2020 The Aurora Authors. All rights reserved.
// This program is free software. It comes without any warranty,
// to the extent permitted by applicable law. You can redistribute
// it and/or modify it under the terms of the Unlicense. See LICENSE
// file for more details or see below.
//
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
//
// Package aurora implements ANSI-colors
package aurora
import (
"fmt"
)
// An Aurora implements colorizer interface.
// It also can be a non-colorizer
type Aurora interface {
// Reset wraps given argument returning Value
// without formats and colors.
Reset(arg interface{}) Value
//
// Formats
//
//
// Bold or increased intensity (1).
Bold(arg interface{}) Value
// Faint, decreased intensity (2).
Faint(arg interface{}) Value
//
// DoublyUnderline or Bold off, double-underline
// per ECMA-48 (21).
DoublyUnderline(arg interface{}) Value
// Fraktur, rarely supported (20).
Fraktur(arg interface{}) Value
//
// Italic, not widely supported, sometimes
// treated as inverse (3).
Italic(arg interface{}) Value
// Underline (4).
Underline(arg interface{}) Value
//
// SlowBlink, blinking less than 150
// per minute (5).
SlowBlink(arg interface{}) Value
// RapidBlink, blinking 150+ per minute,
// not widely supported (6).
RapidBlink(arg interface{}) Value
// Blink is alias for the SlowBlink.
Blink(arg interface{}) Value
//
// Reverse video, swap foreground and
// background colors (7).
Reverse(arg interface{}) Value
// Inverse is alias for the Reverse
Inverse(arg interface{}) Value
//
// Conceal, hidden, not widely supported (8).
Conceal(arg interface{}) Value
// Hidden is alias for the Conceal
Hidden(arg interface{}) Value
//
// CrossedOut, characters legible, but
// marked for deletion (9).
CrossedOut(arg interface{}) Value
// StrikeThrough is alias for the CrossedOut.
StrikeThrough(arg interface{}) Value
//
// Framed (51).
Framed(arg interface{}) Value
// Encircled (52).
Encircled(arg interface{}) Value
//
// Overlined (53).
Overlined(arg interface{}) Value
//
// Foreground colors
//
//
// Black foreground color (30)
Black(arg interface{}) Value
// Red foreground color (31)
Red(arg interface{}) Value
// Green foreground color (32)
Green(arg interface{}) Value
// Yellow foreground color (33)
Yellow(arg interface{}) Value
// Brown foreground color (33)
//
// Deprecated: use Yellow instead, following specification
Brown(arg interface{}) Value
// Blue foreground color (34)
Blue(arg interface{}) Value
// Magenta foreground color (35)
Magenta(arg interface{}) Value
// Cyan foreground color (36)
Cyan(arg interface{}) Value
// White foreground color (37)
White(arg interface{}) Value
//
// Bright foreground colors
//
// BrightBlack foreground color (90)
BrightBlack(arg interface{}) Value
// BrightRed foreground color (91)
BrightRed(arg interface{}) Value
// BrightGreen foreground color (92)
BrightGreen(arg interface{}) Value
// BrightYellow foreground color (93)
BrightYellow(arg interface{}) Value
// BrightBlue foreground color (94)
BrightBlue(arg interface{}) Value
// BrightMagenta foreground color (95)
BrightMagenta(arg interface{}) Value
// BrightCyan foreground color (96)
BrightCyan(arg interface{}) Value
// BrightWhite foreground color (97)
BrightWhite(arg interface{}) Value
//
// Other
//
// Index of pre-defined 8-bit foreground color
// from 0 to 255 (38;5;n).
//
// 0- 7: standard colors (as in ESC [ 3037 m)
// 8- 15: high intensity colors (as in ESC [ 9097 m)
// 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
// 232-255: grayscale from black to white in 24 steps
//
Index(n uint8, arg interface{}) Value
// Gray from 0 to 23.
Gray(n uint8, arg interface{}) Value
//
// Background colors
//
//
// BgBlack background color (40)
BgBlack(arg interface{}) Value
// BgRed background color (41)
BgRed(arg interface{}) Value
// BgGreen background color (42)
BgGreen(arg interface{}) Value
// BgYellow background color (43)
BgYellow(arg interface{}) Value
// BgBrown background color (43)
//
// Deprecated: use BgYellow instead, following specification
BgBrown(arg interface{}) Value
// BgBlue background color (44)
BgBlue(arg interface{}) Value
// BgMagenta background color (45)
BgMagenta(arg interface{}) Value
// BgCyan background color (46)
BgCyan(arg interface{}) Value
// BgWhite background color (47)
BgWhite(arg interface{}) Value
//
// Bright background colors
//
// BgBrightBlack background color (100)
BgBrightBlack(arg interface{}) Value
// BgBrightRed background color (101)
BgBrightRed(arg interface{}) Value
// BgBrightGreen background color (102)
BgBrightGreen(arg interface{}) Value
// BgBrightYellow background color (103)
BgBrightYellow(arg interface{}) Value
// BgBrightBlue background color (104)
BgBrightBlue(arg interface{}) Value
// BgBrightMagenta background color (105)
BgBrightMagenta(arg interface{}) Value
// BgBrightCyan background color (106)
BgBrightCyan(arg interface{}) Value
// BgBrightWhite background color (107)
BgBrightWhite(arg interface{}) Value
//
// Other
//
// BgIndex of 8-bit pre-defined background color
// from 0 to 255 (48;5;n).
//
// 0- 7: standard colors (as in ESC [ 4047 m)
// 8- 15: high intensity colors (as in ESC [100107 m)
// 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
// 232-255: grayscale from black to white in 24 steps
//
BgIndex(n uint8, arg interface{}) Value
// BgGray from 0 to 23.
BgGray(n uint8, arg interface{}) Value
//
// Special
//
// Colorize removes existing colors and
// formats of the argument and applies given.
Colorize(arg interface{}, color Color) Value
//
// Support methods
//
// Sprintf allows to use colored format.
Sprintf(format interface{}, args ...interface{}) string
}
// NewAurora returns a new Aurora interface that
// will support or not support colors depending
// the enableColors argument
func NewAurora(enableColors bool) Aurora {
if enableColors {
return aurora{}
}
return auroraClear{}
}
// no colors
type auroraClear struct{}
func (auroraClear) Reset(arg interface{}) Value { return valueClear{arg} }
func (auroraClear) Bold(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Faint(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) DoublyUnderline(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Fraktur(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Italic(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Underline(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) SlowBlink(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) RapidBlink(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Blink(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Reverse(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Inverse(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Conceal(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Hidden(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) CrossedOut(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) StrikeThrough(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Framed(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Encircled(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Overlined(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Black(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Red(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Green(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Yellow(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Brown(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Blue(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Magenta(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Cyan(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) White(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightBlack(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightRed(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightGreen(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightYellow(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightBlue(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightMagenta(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightCyan(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BrightWhite(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Index(_ uint8, arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Gray(_ uint8, arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBlack(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgRed(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgGreen(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgYellow(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrown(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBlue(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgMagenta(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgCyan(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgWhite(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightBlack(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightRed(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightGreen(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightYellow(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightBlue(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightMagenta(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightCyan(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgBrightWhite(arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgIndex(_ uint8, arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) BgGray(_ uint8, arg interface{}) Value {
return valueClear{arg}
}
func (auroraClear) Colorize(arg interface{}, _ Color) Value {
return valueClear{arg}
}
func (auroraClear) Sprintf(format interface{}, args ...interface{}) string {
if str, ok := format.(string); ok {
return fmt.Sprintf(str, args...)
}
return fmt.Sprintf(fmt.Sprint(format), args...)
}
// colorized
type aurora struct{}
func (aurora) Reset(arg interface{}) Value {
return Reset(arg)
}
func (aurora) Bold(arg interface{}) Value {
return Bold(arg)
}
func (aurora) Faint(arg interface{}) Value {
return Faint(arg)
}
func (aurora) DoublyUnderline(arg interface{}) Value {
return DoublyUnderline(arg)
}
func (aurora) Fraktur(arg interface{}) Value {
return Fraktur(arg)
}
func (aurora) Italic(arg interface{}) Value {
return Italic(arg)
}
func (aurora) Underline(arg interface{}) Value {
return Underline(arg)
}
func (aurora) SlowBlink(arg interface{}) Value {
return SlowBlink(arg)
}
func (aurora) RapidBlink(arg interface{}) Value {
return RapidBlink(arg)
}
func (aurora) Blink(arg interface{}) Value {
return Blink(arg)
}
func (aurora) Reverse(arg interface{}) Value {
return Reverse(arg)
}
func (aurora) Inverse(arg interface{}) Value {
return Inverse(arg)
}
func (aurora) Conceal(arg interface{}) Value {
return Conceal(arg)
}
func (aurora) Hidden(arg interface{}) Value {
return Hidden(arg)
}
func (aurora) CrossedOut(arg interface{}) Value {
return CrossedOut(arg)
}
func (aurora) StrikeThrough(arg interface{}) Value {
return StrikeThrough(arg)
}
func (aurora) Framed(arg interface{}) Value {
return Framed(arg)
}
func (aurora) Encircled(arg interface{}) Value {
return Encircled(arg)
}
func (aurora) Overlined(arg interface{}) Value {
return Overlined(arg)
}
func (aurora) Black(arg interface{}) Value {
return Black(arg)
}
func (aurora) Red(arg interface{}) Value {
return Red(arg)
}
func (aurora) Green(arg interface{}) Value {
return Green(arg)
}
func (aurora) Yellow(arg interface{}) Value {
return Yellow(arg)
}
func (aurora) Brown(arg interface{}) Value {
return Brown(arg)
}
func (aurora) Blue(arg interface{}) Value {
return Blue(arg)
}
func (aurora) Magenta(arg interface{}) Value {
return Magenta(arg)
}
func (aurora) Cyan(arg interface{}) Value {
return Cyan(arg)
}
func (aurora) White(arg interface{}) Value {
return White(arg)
}
func (aurora) BrightBlack(arg interface{}) Value {
return BrightBlack(arg)
}
func (aurora) BrightRed(arg interface{}) Value {
return BrightRed(arg)
}
func (aurora) BrightGreen(arg interface{}) Value {
return BrightGreen(arg)
}
func (aurora) BrightYellow(arg interface{}) Value {
return BrightYellow(arg)
}
func (aurora) BrightBlue(arg interface{}) Value {
return BrightBlue(arg)
}
func (aurora) BrightMagenta(arg interface{}) Value {
return BrightMagenta(arg)
}
func (aurora) BrightCyan(arg interface{}) Value {
return BrightCyan(arg)
}
func (aurora) BrightWhite(arg interface{}) Value {
return BrightWhite(arg)
}
func (aurora) Index(index uint8, arg interface{}) Value {
return Index(index, arg)
}
func (aurora) Gray(n uint8, arg interface{}) Value {
return Gray(n, arg)
}
func (aurora) BgBlack(arg interface{}) Value {
return BgBlack(arg)
}
func (aurora) BgRed(arg interface{}) Value {
return BgRed(arg)
}
func (aurora) BgGreen(arg interface{}) Value {
return BgGreen(arg)
}
func (aurora) BgYellow(arg interface{}) Value {
return BgYellow(arg)
}
func (aurora) BgBrown(arg interface{}) Value {
return BgBrown(arg)
}
func (aurora) BgBlue(arg interface{}) Value {
return BgBlue(arg)
}
func (aurora) BgMagenta(arg interface{}) Value {
return BgMagenta(arg)
}
func (aurora) BgCyan(arg interface{}) Value {
return BgCyan(arg)
}
func (aurora) BgWhite(arg interface{}) Value {
return BgWhite(arg)
}
func (aurora) BgBrightBlack(arg interface{}) Value {
return BgBrightBlack(arg)
}
func (aurora) BgBrightRed(arg interface{}) Value {
return BgBrightRed(arg)
}
func (aurora) BgBrightGreen(arg interface{}) Value {
return BgBrightGreen(arg)
}
func (aurora) BgBrightYellow(arg interface{}) Value {
return BgBrightYellow(arg)
}
func (aurora) BgBrightBlue(arg interface{}) Value {
return BgBrightBlue(arg)
}
func (aurora) BgBrightMagenta(arg interface{}) Value {
return BgBrightMagenta(arg)
}
func (aurora) BgBrightCyan(arg interface{}) Value {
return BgBrightCyan(arg)
}
func (aurora) BgBrightWhite(arg interface{}) Value {
return BgBrightWhite(arg)
}
func (aurora) BgIndex(n uint8, arg interface{}) Value {
return BgIndex(n, arg)
}
func (aurora) BgGray(n uint8, arg interface{}) Value {
return BgGray(n, arg)
}
func (aurora) Colorize(arg interface{}, color Color) Value {
return Colorize(arg, color)
}
func (aurora) Sprintf(format interface{}, args ...interface{}) string {
return Sprintf(format, args...)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
vendor/github.com/logrusorgru/aurora/aurora_formats.gif generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

398
vendor/github.com/logrusorgru/aurora/color.go generated vendored Normal file
View File

@ -0,0 +1,398 @@
//
// Copyright (c) 2016-2020 The Aurora Authors. All rights reserved.
// This program is free software. It comes without any warranty,
// to the extent permitted by applicable law. You can redistribute
// it and/or modify it under the terms of the Unlicense. See LICENSE
// file for more details or see below.
//
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
//
package aurora
// A Color type is a color. It can contain
// one background color, one foreground color
// and a format, including ideogram related
// formats.
type Color uint
/*
Developer note.
The int type is architecture depended and can be
represented as int32 or int64.
Thus, we can use 32-bits only to be fast and
cross-platform.
All supported formats requires 14 bits. It is
first 14 bits.
A foreground color requires 8 bit + 1 bit (presence flag).
And the same for background color.
The Color representations
[ bg 8 bit ] [fg 8 bit ] [ fg/bg 2 bits ] [ fm 14 bits ]
https://play.golang.org/p/fq2zcNstFoF
*/
// Special formats
const (
BoldFm Color = 1 << iota // 1
FaintFm // 2
ItalicFm // 3
UnderlineFm // 4
SlowBlinkFm // 5
RapidBlinkFm // 6
ReverseFm // 7
ConcealFm // 8
CrossedOutFm // 9
FrakturFm // 20
DoublyUnderlineFm // 21 or bold off for some systems
FramedFm // 51
EncircledFm // 52
OverlinedFm // 53
InverseFm = ReverseFm // alias to ReverseFm
BlinkFm = SlowBlinkFm // alias to SlowBlinkFm
HiddenFm = ConcealFm // alias to ConcealFm
StrikeThroughFm = CrossedOutFm // alias to CrossedOutFm
maskFm = BoldFm | FaintFm |
ItalicFm | UnderlineFm |
SlowBlinkFm | RapidBlinkFm |
ReverseFm |
ConcealFm | CrossedOutFm |
FrakturFm | DoublyUnderlineFm |
FramedFm | EncircledFm | OverlinedFm
flagFg Color = 1 << 14 // presence flag (14th bit)
flagBg Color = 1 << 15 // presence flag (15th bit)
shiftFg = 16 // shift for foreground (starting from 16th bit)
shiftBg = 24 // shift for background (starting from 24th bit)
)
// Foreground colors and related formats
const (
// 8 bits
// [ 0; 7] - 30-37
// [ 8; 15] - 90-97
// [ 16; 231] - RGB
// [232; 255] - grayscale
BlackFg Color = (iota << shiftFg) | flagFg // 30, 90
RedFg // 31, 91
GreenFg // 32, 92
YellowFg // 33, 93
BlueFg // 34, 94
MagentaFg // 35, 95
CyanFg // 36, 96
WhiteFg // 37, 97
BrightFg Color = ((1 << 3) << shiftFg) | flagFg // -> 90
// the BrightFg itself doesn't represent
// a color, thus it has not flagFg
// 5 bits
// BrownFg represents brown foreground color.
//
// Deprecated: use YellowFg instead, following specifications
BrownFg = YellowFg
//
maskFg = (0xff << shiftFg) | flagFg
)
// Background colors and related formats
const (
// 8 bits
// [ 0; 7] - 40-47
// [ 8; 15] - 100-107
// [ 16; 231] - RGB
// [232; 255] - grayscale
BlackBg Color = (iota << shiftBg) | flagBg // 40, 100
RedBg // 41, 101
GreenBg // 42, 102
YellowBg // 43, 103
BlueBg // 44, 104
MagentaBg // 45, 105
CyanBg // 46, 106
WhiteBg // 47, 107
BrightBg Color = ((1 << 3) << shiftBg) | flagBg // -> 100
// the BrightBg itself doesn't represent
// a color, thus it has not flagBg
// 5 bits
// BrownBg represents brown foreground color.
//
// Deprecated: use YellowBg instead, following specifications
BrownBg = YellowBg
//
maskBg = (0xff << shiftBg) | flagBg
)
const (
availFlags = "-+# 0"
esc = "\033["
clear = esc + "0m"
)
// IsValid returns true always
//
// Deprecated: don't use this method anymore
func (c Color) IsValid() bool {
return true
}
// Nos returns string like 1;7;31;45. It
// may be an empty string for empty color.
// If the zero is true, then the string
// is prepended with 0;
func (c Color) Nos(zero bool) string {
return string(c.appendNos(make([]byte, 0, 59), zero))
}
func appendCond(bs []byte, cond, semi bool, vals ...byte) []byte {
if !cond {
return bs
}
return appendSemi(bs, semi, vals...)
}
// if the semi is true, then prepend with semicolon
func appendSemi(bs []byte, semi bool, vals ...byte) []byte {
if semi {
bs = append(bs, ';')
}
return append(bs, vals...)
}
func itoa(t byte) string {
var (
a [3]byte
j = 2
)
for i := 0; i < 3; i, j = i+1, j-1 {
a[j] = '0' + t%10
if t = t / 10; t == 0 {
break
}
}
return string(a[j:])
}
func (c Color) appendFg(bs []byte, zero bool) []byte {
if zero || c&maskFm != 0 {
bs = append(bs, ';')
}
// 0- 7 : 30-37
// 8-15 : 90-97
// > 15 : 38;5;val
switch fg := (c & maskFg) >> shiftFg; {
case fg <= 7:
// '3' and the value itself
bs = append(bs, '3', '0'+byte(fg))
case fg <= 15:
// '9' and the value itself
bs = append(bs, '9', '0'+byte(fg&^0x08)) // clear bright flag
default:
bs = append(bs, '3', '8', ';', '5', ';')
bs = append(bs, itoa(byte(fg))...)
}
return bs
}
func (c Color) appendBg(bs []byte, zero bool) []byte {
if zero || c&(maskFm|maskFg) != 0 {
bs = append(bs, ';')
}
// 0- 7 : 40- 47
// 8-15 : 100-107
// > 15 : 48;5;val
switch fg := (c & maskBg) >> shiftBg; {
case fg <= 7:
// '3' and the value itself
bs = append(bs, '4', '0'+byte(fg))
case fg <= 15:
// '1', '0' and the value itself
bs = append(bs, '1', '0', '0'+byte(fg&^0x08)) // clear bright flag
default:
bs = append(bs, '4', '8', ';', '5', ';')
bs = append(bs, itoa(byte(fg))...)
}
return bs
}
func (c Color) appendFm9(bs []byte, zero bool) []byte {
bs = appendCond(bs, c&ItalicFm != 0,
zero || c&(BoldFm|FaintFm) != 0,
'3')
bs = appendCond(bs, c&UnderlineFm != 0,
zero || c&(BoldFm|FaintFm|ItalicFm) != 0,
'4')
// don't combine slow and rapid blink using only
// on of them, preferring slow blink
if c&SlowBlinkFm != 0 {
bs = appendSemi(bs,
zero || c&(BoldFm|FaintFm|ItalicFm|UnderlineFm) != 0,
'5')
} else if c&RapidBlinkFm != 0 {
bs = appendSemi(bs,
zero || c&(BoldFm|FaintFm|ItalicFm|UnderlineFm) != 0,
'6')
}
// including 1-2
const mask6i = BoldFm | FaintFm |
ItalicFm | UnderlineFm |
SlowBlinkFm | RapidBlinkFm
bs = appendCond(bs, c&ReverseFm != 0,
zero || c&(mask6i) != 0,
'7')
bs = appendCond(bs, c&ConcealFm != 0,
zero || c&(mask6i|ReverseFm) != 0,
'8')
bs = appendCond(bs, c&CrossedOutFm != 0,
zero || c&(mask6i|ReverseFm|ConcealFm) != 0,
'9')
return bs
}
// append 1;3;38;5;216 like string that represents ANSI
// color of the Color; the zero argument requires
// appending of '0' before to reset previous format
// and colors
func (c Color) appendNos(bs []byte, zero bool) []byte {
if zero {
bs = append(bs, '0') // reset previous
}
// formats
//
if c&maskFm != 0 {
// 1-2
// don't combine bold and faint using only on of them, preferring bold
if c&BoldFm != 0 {
bs = appendSemi(bs, zero, '1')
} else if c&FaintFm != 0 {
bs = appendSemi(bs, zero, '2')
}
// 3-9
const mask9 = ItalicFm | UnderlineFm |
SlowBlinkFm | RapidBlinkFm |
ReverseFm | ConcealFm | CrossedOutFm
if c&mask9 != 0 {
bs = c.appendFm9(bs, zero)
}
// 20-21
const (
mask21 = FrakturFm | DoublyUnderlineFm
mask9i = BoldFm | FaintFm | mask9
)
if c&mask21 != 0 {
bs = appendCond(bs, c&FrakturFm != 0,
zero || c&mask9i != 0,
'2', '0')
bs = appendCond(bs, c&DoublyUnderlineFm != 0,
zero || c&(mask9i|FrakturFm) != 0,
'2', '1')
}
// 50-53
const (
mask53 = FramedFm | EncircledFm | OverlinedFm
mask21i = mask9i | mask21
)
if c&mask53 != 0 {
bs = appendCond(bs, c&FramedFm != 0,
zero || c&mask21i != 0,
'5', '1')
bs = appendCond(bs, c&EncircledFm != 0,
zero || c&(mask21i|FramedFm) != 0,
'5', '2')
bs = appendCond(bs, c&OverlinedFm != 0,
zero || c&(mask21i|FramedFm|EncircledFm) != 0,
'5', '3')
}
}
// foreground
if c&maskFg != 0 {
bs = c.appendFg(bs, zero)
}
// background
if c&maskBg != 0 {
bs = c.appendBg(bs, zero)
}
return bs
}

BIN
vendor/github.com/logrusorgru/aurora/disable.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

BIN
vendor/github.com/logrusorgru/aurora/enable.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

BIN
vendor/github.com/logrusorgru/aurora/gopher_aurora.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
vendor/github.com/logrusorgru/aurora/printf.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
vendor/github.com/logrusorgru/aurora/simple.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

68
vendor/github.com/logrusorgru/aurora/sprintf.go generated vendored Normal file
View File

@ -0,0 +1,68 @@
//
// Copyright (c) 2016-2020 The Aurora Authors. All rights reserved.
// This program is free software. It comes without any warranty,
// to the extent permitted by applicable law. You can redistribute
// it and/or modify it under the terms of the Unlicense. See LICENSE
// file for more details or see below.
//
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
//
package aurora
import (
"fmt"
)
// Sprintf allows to use Value as format. For example
//
// v := Sprintf(Red("total: +3.5f points"), Blue(3.14))
//
// In this case "total:" and "points" will be red, but
// 3.14 will be blue. But, in another example
//
// v := Sprintf(Red("total: +3.5f points"), 3.14)
//
// full string will be red. And no way to clear 3.14 to
// default format and color
func Sprintf(format interface{}, args ...interface{}) string {
switch ft := format.(type) {
case string:
return fmt.Sprintf(ft, args...)
case Value:
for i, v := range args {
if val, ok := v.(Value); ok {
args[i] = val.setTail(ft.Color())
continue
}
}
return fmt.Sprintf(ft.String(), args...)
}
// unknown type of format (we hope it's a string)
return fmt.Sprintf(fmt.Sprint(format), args...)
}

BIN
vendor/github.com/logrusorgru/aurora/sprintf.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

745
vendor/github.com/logrusorgru/aurora/value.go generated vendored Normal file
View File

@ -0,0 +1,745 @@
//
// Copyright (c) 2016-2020 The Aurora Authors. All rights reserved.
// This program is free software. It comes without any warranty,
// to the extent permitted by applicable law. You can redistribute
// it and/or modify it under the terms of the Unlicense. See LICENSE
// file for more details or see below.
//
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
//
package aurora
import (
"fmt"
"strconv"
"unicode/utf8"
)
// A Value represents any printable value
// with it's color
type Value interface {
// String returns string with colors. If there are any color
// or format the string will be terminated with \033[0m
fmt.Stringer
// Format implements fmt.Formatter interface
fmt.Formatter
// Color returns value's color
Color() Color
// Value returns value's value (welcome to the tautology club)
Value() interface{}
// internals
tail() Color
setTail(Color) Value
// Bleach returns copy of original value without colors
//
// Deprecated: use Reset instead.
Bleach() Value
// Reset colors and formats
Reset() Value
//
// Formats
//
//
// Bold or increased intensity (1).
Bold() Value
// Faint, decreased intensity, reset the Bold (2).
Faint() Value
//
// DoublyUnderline or Bold off, double-underline
// per ECMA-48 (21). It depends.
DoublyUnderline() Value
// Fraktur, rarely supported (20).
Fraktur() Value
//
// Italic, not widely supported, sometimes
// treated as inverse (3).
Italic() Value
// Underline (4).
Underline() Value
//
// SlowBlink, blinking less than 150
// per minute (5).
SlowBlink() Value
// RapidBlink, blinking 150+ per minute,
// not widely supported (6).
RapidBlink() Value
// Blink is alias for the SlowBlink.
Blink() Value
//
// Reverse video, swap foreground and
// background colors (7).
Reverse() Value
// Inverse is alias for the Reverse
Inverse() Value
//
// Conceal, hidden, not widely supported (8).
Conceal() Value
// Hidden is alias for the Conceal
Hidden() Value
//
// CrossedOut, characters legible, but
// marked for deletion (9).
CrossedOut() Value
// StrikeThrough is alias for the CrossedOut.
StrikeThrough() Value
//
// Framed (51).
Framed() Value
// Encircled (52).
Encircled() Value
//
// Overlined (53).
Overlined() Value
//
// Foreground colors
//
//
// Black foreground color (30)
Black() Value
// Red foreground color (31)
Red() Value
// Green foreground color (32)
Green() Value
// Yellow foreground color (33)
Yellow() Value
// Brown foreground color (33)
//
// Deprecated: use Yellow instead, following specification
Brown() Value
// Blue foreground color (34)
Blue() Value
// Magenta foreground color (35)
Magenta() Value
// Cyan foreground color (36)
Cyan() Value
// White foreground color (37)
White() Value
//
// Bright foreground colors
//
// BrightBlack foreground color (90)
BrightBlack() Value
// BrightRed foreground color (91)
BrightRed() Value
// BrightGreen foreground color (92)
BrightGreen() Value
// BrightYellow foreground color (93)
BrightYellow() Value
// BrightBlue foreground color (94)
BrightBlue() Value
// BrightMagenta foreground color (95)
BrightMagenta() Value
// BrightCyan foreground color (96)
BrightCyan() Value
// BrightWhite foreground color (97)
BrightWhite() Value
//
// Other
//
// Index of pre-defined 8-bit foreground color
// from 0 to 255 (38;5;n).
//
// 0- 7: standard colors (as in ESC [ 3037 m)
// 8- 15: high intensity colors (as in ESC [ 9097 m)
// 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
// 232-255: grayscale from black to white in 24 steps
//
Index(n uint8) Value
// Gray from 0 to 24.
Gray(n uint8) Value
//
// Background colors
//
//
// BgBlack background color (40)
BgBlack() Value
// BgRed background color (41)
BgRed() Value
// BgGreen background color (42)
BgGreen() Value
// BgYellow background color (43)
BgYellow() Value
// BgBrown background color (43)
//
// Deprecated: use BgYellow instead, following specification
BgBrown() Value
// BgBlue background color (44)
BgBlue() Value
// BgMagenta background color (45)
BgMagenta() Value
// BgCyan background color (46)
BgCyan() Value
// BgWhite background color (47)
BgWhite() Value
//
// Bright background colors
//
// BgBrightBlack background color (100)
BgBrightBlack() Value
// BgBrightRed background color (101)
BgBrightRed() Value
// BgBrightGreen background color (102)
BgBrightGreen() Value
// BgBrightYellow background color (103)
BgBrightYellow() Value
// BgBrightBlue background color (104)
BgBrightBlue() Value
// BgBrightMagenta background color (105)
BgBrightMagenta() Value
// BgBrightCyan background color (106)
BgBrightCyan() Value
// BgBrightWhite background color (107)
BgBrightWhite() Value
//
// Other
//
// BgIndex of 8-bit pre-defined background color
// from 0 to 255 (48;5;n).
//
// 0- 7: standard colors (as in ESC [ 4047 m)
// 8- 15: high intensity colors (as in ESC [100107 m)
// 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
// 232-255: grayscale from black to white in 24 steps
//
BgIndex(n uint8) Value
// BgGray from 0 to 24.
BgGray(n uint8) Value
//
// Special
//
// Colorize removes existing colors and
// formats of the argument and applies given.
Colorize(color Color) Value
}
// Value without colors
type valueClear struct {
value interface{}
}
func (vc valueClear) String() string { return fmt.Sprint(vc.value) }
func (vc valueClear) Color() Color { return 0 }
func (vc valueClear) Value() interface{} { return vc.value }
func (vc valueClear) tail() Color { return 0 }
func (vc valueClear) setTail(Color) Value { return vc }
func (vc valueClear) Bleach() Value { return vc }
func (vc valueClear) Reset() Value { return vc }
func (vc valueClear) Bold() Value { return vc }
func (vc valueClear) Faint() Value { return vc }
func (vc valueClear) DoublyUnderline() Value { return vc }
func (vc valueClear) Fraktur() Value { return vc }
func (vc valueClear) Italic() Value { return vc }
func (vc valueClear) Underline() Value { return vc }
func (vc valueClear) SlowBlink() Value { return vc }
func (vc valueClear) RapidBlink() Value { return vc }
func (vc valueClear) Blink() Value { return vc }
func (vc valueClear) Reverse() Value { return vc }
func (vc valueClear) Inverse() Value { return vc }
func (vc valueClear) Conceal() Value { return vc }
func (vc valueClear) Hidden() Value { return vc }
func (vc valueClear) CrossedOut() Value { return vc }
func (vc valueClear) StrikeThrough() Value { return vc }
func (vc valueClear) Framed() Value { return vc }
func (vc valueClear) Encircled() Value { return vc }
func (vc valueClear) Overlined() Value { return vc }
func (vc valueClear) Black() Value { return vc }
func (vc valueClear) Red() Value { return vc }
func (vc valueClear) Green() Value { return vc }
func (vc valueClear) Yellow() Value { return vc }
func (vc valueClear) Brown() Value { return vc }
func (vc valueClear) Blue() Value { return vc }
func (vc valueClear) Magenta() Value { return vc }
func (vc valueClear) Cyan() Value { return vc }
func (vc valueClear) White() Value { return vc }
func (vc valueClear) BrightBlack() Value { return vc }
func (vc valueClear) BrightRed() Value { return vc }
func (vc valueClear) BrightGreen() Value { return vc }
func (vc valueClear) BrightYellow() Value { return vc }
func (vc valueClear) BrightBlue() Value { return vc }
func (vc valueClear) BrightMagenta() Value { return vc }
func (vc valueClear) BrightCyan() Value { return vc }
func (vc valueClear) BrightWhite() Value { return vc }
func (vc valueClear) Index(uint8) Value { return vc }
func (vc valueClear) Gray(uint8) Value { return vc }
func (vc valueClear) BgBlack() Value { return vc }
func (vc valueClear) BgRed() Value { return vc }
func (vc valueClear) BgGreen() Value { return vc }
func (vc valueClear) BgYellow() Value { return vc }
func (vc valueClear) BgBrown() Value { return vc }
func (vc valueClear) BgBlue() Value { return vc }
func (vc valueClear) BgMagenta() Value { return vc }
func (vc valueClear) BgCyan() Value { return vc }
func (vc valueClear) BgWhite() Value { return vc }
func (vc valueClear) BgBrightBlack() Value { return vc }
func (vc valueClear) BgBrightRed() Value { return vc }
func (vc valueClear) BgBrightGreen() Value { return vc }
func (vc valueClear) BgBrightYellow() Value { return vc }
func (vc valueClear) BgBrightBlue() Value { return vc }
func (vc valueClear) BgBrightMagenta() Value { return vc }
func (vc valueClear) BgBrightCyan() Value { return vc }
func (vc valueClear) BgBrightWhite() Value { return vc }
func (vc valueClear) BgIndex(uint8) Value { return vc }
func (vc valueClear) BgGray(uint8) Value { return vc }
func (vc valueClear) Colorize(Color) Value { return vc }
func (vc valueClear) Format(s fmt.State, verb rune) {
// it's enough for many cases (%-+020.10f)
// % - 1
// availFlags - 3 (5)
// width - 2
// prec - 3 (.23)
// verb - 1
// --------------
// 10
format := make([]byte, 1, 10)
format[0] = '%'
var f byte
for i := 0; i < len(availFlags); i++ {
if f = availFlags[i]; s.Flag(int(f)) {
format = append(format, f)
}
}
var width, prec int
var ok bool
if width, ok = s.Width(); ok {
format = strconv.AppendInt(format, int64(width), 10)
}
if prec, ok = s.Precision(); ok {
format = append(format, '.')
format = strconv.AppendInt(format, int64(prec), 10)
}
if verb > utf8.RuneSelf {
format = append(format, string(verb)...)
} else {
format = append(format, byte(verb))
}
fmt.Fprintf(s, string(format), vc.value)
}
// Value within colors
type value struct {
value interface{} // value as it
color Color // this color
tailColor Color // tail color
}
func (v value) String() string {
if v.color != 0 {
if v.tailColor != 0 {
return esc + v.color.Nos(true) + "m" +
fmt.Sprint(v.value) +
esc + v.tailColor.Nos(true) + "m"
}
return esc + v.color.Nos(false) + "m" + fmt.Sprint(v.value) + clear
}
return fmt.Sprint(v.value)
}
func (v value) Color() Color { return v.color }
func (v value) Bleach() Value {
v.color, v.tailColor = 0, 0
return v
}
func (v value) Reset() Value {
v.color, v.tailColor = 0, 0
return v
}
func (v value) tail() Color { return v.tailColor }
func (v value) setTail(t Color) Value {
v.tailColor = t
return v
}
func (v value) Value() interface{} { return v.value }
func (v value) Format(s fmt.State, verb rune) {
// it's enough for many cases (%-+020.10f)
// % - 1
// availFlags - 3 (5)
// width - 2
// prec - 3 (.23)
// verb - 1
// --------------
// 10
// +
// \033[ 5
// 0;1;3;4;5;7;8;9;20;21;51;52;53 30
// 38;5;216 8
// 48;5;216 8
// m 1
// +
// \033[0m 7
//
// x2 (possible tail color)
//
// 10 + 59 * 2 = 128
format := make([]byte, 0, 128)
if v.color != 0 {
format = append(format, esc...)
format = v.color.appendNos(format, v.tailColor != 0)
format = append(format, 'm')
}
format = append(format, '%')
var f byte
for i := 0; i < len(availFlags); i++ {
if f = availFlags[i]; s.Flag(int(f)) {
format = append(format, f)
}
}
var width, prec int
var ok bool
if width, ok = s.Width(); ok {
format = strconv.AppendInt(format, int64(width), 10)
}
if prec, ok = s.Precision(); ok {
format = append(format, '.')
format = strconv.AppendInt(format, int64(prec), 10)
}
if verb > utf8.RuneSelf {
format = append(format, string(verb)...)
} else {
format = append(format, byte(verb))
}
if v.color != 0 {
if v.tailColor != 0 {
// set next (previous) format clearing current one
format = append(format, esc...)
format = v.tailColor.appendNos(format, true)
format = append(format, 'm')
} else {
format = append(format, clear...) // just clear
}
}
fmt.Fprintf(s, string(format), v.value)
}
func (v value) Bold() Value {
v.color = (v.color &^ FaintFm) | BoldFm
return v
}
func (v value) Faint() Value {
v.color = (v.color &^ BoldFm) | FaintFm
return v
}
func (v value) DoublyUnderline() Value {
v.color |= DoublyUnderlineFm
return v
}
func (v value) Fraktur() Value {
v.color |= FrakturFm
return v
}
func (v value) Italic() Value {
v.color |= ItalicFm
return v
}
func (v value) Underline() Value {
v.color |= UnderlineFm
return v
}
func (v value) SlowBlink() Value {
v.color = (v.color &^ RapidBlinkFm) | SlowBlinkFm
return v
}
func (v value) RapidBlink() Value {
v.color = (v.color &^ SlowBlinkFm) | RapidBlinkFm
return v
}
func (v value) Blink() Value {
return v.SlowBlink()
}
func (v value) Reverse() Value {
v.color |= ReverseFm
return v
}
func (v value) Inverse() Value {
return v.Reverse()
}
func (v value) Conceal() Value {
v.color |= ConcealFm
return v
}
func (v value) Hidden() Value {
return v.Conceal()
}
func (v value) CrossedOut() Value {
v.color |= CrossedOutFm
return v
}
func (v value) StrikeThrough() Value {
return v.CrossedOut()
}
func (v value) Framed() Value {
v.color |= FramedFm
return v
}
func (v value) Encircled() Value {
v.color |= EncircledFm
return v
}
func (v value) Overlined() Value {
v.color |= OverlinedFm
return v
}
func (v value) Black() Value {
v.color = (v.color &^ maskFg) | BlackFg
return v
}
func (v value) Red() Value {
v.color = (v.color &^ maskFg) | RedFg
return v
}
func (v value) Green() Value {
v.color = (v.color &^ maskFg) | GreenFg
return v
}
func (v value) Yellow() Value {
v.color = (v.color &^ maskFg) | YellowFg
return v
}
func (v value) Brown() Value {
return v.Yellow()
}
func (v value) Blue() Value {
v.color = (v.color &^ maskFg) | BlueFg
return v
}
func (v value) Magenta() Value {
v.color = (v.color &^ maskFg) | MagentaFg
return v
}
func (v value) Cyan() Value {
v.color = (v.color &^ maskFg) | CyanFg
return v
}
func (v value) White() Value {
v.color = (v.color &^ maskFg) | WhiteFg
return v
}
func (v value) BrightBlack() Value {
v.color = (v.color &^ maskFg) | BrightFg | BlackFg
return v
}
func (v value) BrightRed() Value {
v.color = (v.color &^ maskFg) | BrightFg | RedFg
return v
}
func (v value) BrightGreen() Value {
v.color = (v.color &^ maskFg) | BrightFg | GreenFg
return v
}
func (v value) BrightYellow() Value {
v.color = (v.color &^ maskFg) | BrightFg | YellowFg
return v
}
func (v value) BrightBlue() Value {
v.color = (v.color &^ maskFg) | BrightFg | BlueFg
return v
}
func (v value) BrightMagenta() Value {
v.color = (v.color &^ maskFg) | BrightFg | MagentaFg
return v
}
func (v value) BrightCyan() Value {
v.color = (v.color &^ maskFg) | BrightFg | CyanFg
return v
}
func (v value) BrightWhite() Value {
v.color = (v.color &^ maskFg) | BrightFg | WhiteFg
return v
}
func (v value) Index(n uint8) Value {
v.color = (v.color &^ maskFg) | (Color(n) << shiftFg) | flagFg
return v
}
func (v value) Gray(n uint8) Value {
if n > 23 {
n = 23
}
v.color = (v.color &^ maskFg) | (Color(232+n) << shiftFg) | flagFg
return v
}
func (v value) BgBlack() Value {
v.color = (v.color &^ maskBg) | BlackBg
return v
}
func (v value) BgRed() Value {
v.color = (v.color &^ maskBg) | RedBg
return v
}
func (v value) BgGreen() Value {
v.color = (v.color &^ maskBg) | GreenBg
return v
}
func (v value) BgYellow() Value {
v.color = (v.color &^ maskBg) | YellowBg
return v
}
func (v value) BgBrown() Value {
return v.BgYellow()
}
func (v value) BgBlue() Value {
v.color = (v.color &^ maskBg) | BlueBg
return v
}
func (v value) BgMagenta() Value {
v.color = (v.color &^ maskBg) | MagentaBg
return v
}
func (v value) BgCyan() Value {
v.color = (v.color &^ maskBg) | CyanBg
return v
}
func (v value) BgWhite() Value {
v.color = (v.color &^ maskBg) | WhiteBg
return v
}
func (v value) BgBrightBlack() Value {
v.color = (v.color &^ maskBg) | BrightBg | BlackBg
return v
}
func (v value) BgBrightRed() Value {
v.color = (v.color &^ maskBg) | BrightBg | RedBg
return v
}
func (v value) BgBrightGreen() Value {
v.color = (v.color &^ maskBg) | BrightBg | GreenBg
return v
}
func (v value) BgBrightYellow() Value {
v.color = (v.color &^ maskBg) | BrightBg | YellowBg
return v
}
func (v value) BgBrightBlue() Value {
v.color = (v.color &^ maskBg) | BrightBg | BlueBg
return v
}
func (v value) BgBrightMagenta() Value {
v.color = (v.color &^ maskBg) | BrightBg | MagentaBg
return v
}
func (v value) BgBrightCyan() Value {
v.color = (v.color &^ maskBg) | BrightBg | CyanBg
return v
}
func (v value) BgBrightWhite() Value {
v.color = (v.color &^ maskBg) | BrightBg | WhiteBg
return v
}
func (v value) BgIndex(n uint8) Value {
v.color = (v.color &^ maskBg) | (Color(n) << shiftBg) | flagBg
return v
}
func (v value) BgGray(n uint8) Value {
if n > 23 {
n = 23
}
v.color = (v.color &^ maskBg) | (Color(232+n) << shiftBg) | flagBg
return v
}
func (v value) Colorize(color Color) Value {
v.color = color
return v
}

558
vendor/github.com/logrusorgru/aurora/wrap.go generated vendored Normal file
View File

@ -0,0 +1,558 @@
//
// Copyright (c) 2016-2020 The Aurora Authors. All rights reserved.
// This program is free software. It comes without any warranty,
// to the extent permitted by applicable law. You can redistribute
// it and/or modify it under the terms of the Unlicense. See LICENSE
// file for more details or see below.
//
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// For more information, please refer to <http://unlicense.org/>
//
package aurora
// Colorize wraps given value into Value with
// given colors. For example
//
// s := Colorize("some", BlueFg|GreenBg|BoldFm)
//
// returns a Value with blue foreground, green
// background and bold. Unlike functions like
// Red/BgBlue/Bold etc. This function clears
// all previous colors and formats. Thus
//
// s := Colorize(Red("some"), BgBlue)
//
// clears red color from value
func Colorize(arg interface{}, color Color) Value {
if val, ok := arg.(value); ok {
val.color = color
return val
}
return value{arg, color, 0}
}
// Reset wraps given argument returning Value
// without formats and colors.
func Reset(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Reset()
}
return value{value: arg}
}
//
// Formats
//
// Bold or increased intensity (1).
func Bold(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Bold()
}
return value{value: arg, color: BoldFm}
}
// Faint decreases intensity (2).
// The Faint rejects the Bold.
func Faint(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Faint()
}
return value{value: arg, color: FaintFm}
}
// DoublyUnderline or Bold off, double-underline
// per ECMA-48 (21).
func DoublyUnderline(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.DoublyUnderline()
}
return value{value: arg, color: DoublyUnderlineFm}
}
// Fraktur is rarely supported (20).
func Fraktur(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Fraktur()
}
return value{value: arg, color: FrakturFm}
}
// Italic is not widely supported, sometimes
// treated as inverse (3).
func Italic(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Italic()
}
return value{value: arg, color: ItalicFm}
}
// Underline (4).
func Underline(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Underline()
}
return value{value: arg, color: UnderlineFm}
}
// SlowBlink makes text blink less than
// 150 per minute (5).
func SlowBlink(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.SlowBlink()
}
return value{value: arg, color: SlowBlinkFm}
}
// RapidBlink makes text blink 150+ per
// minute. It is not widely supported (6).
func RapidBlink(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.RapidBlink()
}
return value{value: arg, color: RapidBlinkFm}
}
// Blink is alias for the SlowBlink.
func Blink(arg interface{}) Value {
return SlowBlink(arg)
}
// Reverse video, swap foreground and
// background colors (7).
func Reverse(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Reverse()
}
return value{value: arg, color: ReverseFm}
}
// Inverse is alias for the Reverse
func Inverse(arg interface{}) Value {
return Reverse(arg)
}
// Conceal hides text, preserving an ability to select
// the text and copy it. It is not widely supported (8).
func Conceal(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Conceal()
}
return value{value: arg, color: ConcealFm}
}
// Hidden is alias for the Conceal
func Hidden(arg interface{}) Value {
return Conceal(arg)
}
// CrossedOut makes characters legible, but
// marked for deletion (9).
func CrossedOut(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.CrossedOut()
}
return value{value: arg, color: CrossedOutFm}
}
// StrikeThrough is alias for the CrossedOut.
func StrikeThrough(arg interface{}) Value {
return CrossedOut(arg)
}
// Framed (51).
func Framed(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Framed()
}
return value{value: arg, color: FramedFm}
}
// Encircled (52).
func Encircled(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Encircled()
}
return value{value: arg, color: EncircledFm}
}
// Overlined (53).
func Overlined(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Overlined()
}
return value{value: arg, color: OverlinedFm}
}
//
// Foreground colors
//
//
// Black foreground color (30)
func Black(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Black()
}
return value{value: arg, color: BlackFg}
}
// Red foreground color (31)
func Red(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Red()
}
return value{value: arg, color: RedFg}
}
// Green foreground color (32)
func Green(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Green()
}
return value{value: arg, color: GreenFg}
}
// Yellow foreground color (33)
func Yellow(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Yellow()
}
return value{value: arg, color: YellowFg}
}
// Brown foreground color (33)
//
// Deprecated: use Yellow instead, following specification
func Brown(arg interface{}) Value {
return Yellow(arg)
}
// Blue foreground color (34)
func Blue(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Blue()
}
return value{value: arg, color: BlueFg}
}
// Magenta foreground color (35)
func Magenta(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Magenta()
}
return value{value: arg, color: MagentaFg}
}
// Cyan foreground color (36)
func Cyan(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Cyan()
}
return value{value: arg, color: CyanFg}
}
// White foreground color (37)
func White(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.White()
}
return value{value: arg, color: WhiteFg}
}
//
// Bright foreground colors
//
// BrightBlack foreground color (90)
func BrightBlack(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightBlack()
}
return value{value: arg, color: BrightFg | BlackFg}
}
// BrightRed foreground color (91)
func BrightRed(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightRed()
}
return value{value: arg, color: BrightFg | RedFg}
}
// BrightGreen foreground color (92)
func BrightGreen(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightGreen()
}
return value{value: arg, color: BrightFg | GreenFg}
}
// BrightYellow foreground color (93)
func BrightYellow(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightYellow()
}
return value{value: arg, color: BrightFg | YellowFg}
}
// BrightBlue foreground color (94)
func BrightBlue(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightBlue()
}
return value{value: arg, color: BrightFg | BlueFg}
}
// BrightMagenta foreground color (95)
func BrightMagenta(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightMagenta()
}
return value{value: arg, color: BrightFg | MagentaFg}
}
// BrightCyan foreground color (96)
func BrightCyan(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightCyan()
}
return value{value: arg, color: BrightFg | CyanFg}
}
// BrightWhite foreground color (97)
func BrightWhite(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BrightWhite()
}
return value{value: arg, color: BrightFg | WhiteFg}
}
//
// Other
//
// Index of pre-defined 8-bit foreground color
// from 0 to 255 (38;5;n).
//
// 0- 7: standard colors (as in ESC [ 3037 m)
// 8- 15: high intensity colors (as in ESC [ 9097 m)
// 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
// 232-255: grayscale from black to white in 24 steps
//
func Index(n uint8, arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Index(n)
}
return value{value: arg, color: (Color(n) << shiftFg) | flagFg}
}
// Gray from 0 to 24.
func Gray(n uint8, arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.Gray(n)
}
if n > 23 {
n = 23
}
return value{value: arg, color: (Color(232+n) << shiftFg) | flagFg}
}
//
// Background colors
//
//
// BgBlack background color (40)
func BgBlack(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBlack()
}
return value{value: arg, color: BlackBg}
}
// BgRed background color (41)
func BgRed(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgRed()
}
return value{value: arg, color: RedBg}
}
// BgGreen background color (42)
func BgGreen(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgGreen()
}
return value{value: arg, color: GreenBg}
}
// BgYellow background color (43)
func BgYellow(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgYellow()
}
return value{value: arg, color: YellowBg}
}
// BgBrown background color (43)
//
// Deprecated: use BgYellow instead, following specification
func BgBrown(arg interface{}) Value {
return BgYellow(arg)
}
// BgBlue background color (44)
func BgBlue(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBlue()
}
return value{value: arg, color: BlueBg}
}
// BgMagenta background color (45)
func BgMagenta(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgMagenta()
}
return value{value: arg, color: MagentaBg}
}
// BgCyan background color (46)
func BgCyan(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgCyan()
}
return value{value: arg, color: CyanBg}
}
// BgWhite background color (47)
func BgWhite(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgWhite()
}
return value{value: arg, color: WhiteBg}
}
//
// Bright background colors
//
// BgBrightBlack background color (100)
func BgBrightBlack(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightBlack()
}
return value{value: arg, color: BrightBg | BlackBg}
}
// BgBrightRed background color (101)
func BgBrightRed(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightRed()
}
return value{value: arg, color: BrightBg | RedBg}
}
// BgBrightGreen background color (102)
func BgBrightGreen(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightGreen()
}
return value{value: arg, color: BrightBg | GreenBg}
}
// BgBrightYellow background color (103)
func BgBrightYellow(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightYellow()
}
return value{value: arg, color: BrightBg | YellowBg}
}
// BgBrightBlue background color (104)
func BgBrightBlue(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightBlue()
}
return value{value: arg, color: BrightBg | BlueBg}
}
// BgBrightMagenta background color (105)
func BgBrightMagenta(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightMagenta()
}
return value{value: arg, color: BrightBg | MagentaBg}
}
// BgBrightCyan background color (106)
func BgBrightCyan(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightCyan()
}
return value{value: arg, color: BrightBg | CyanBg}
}
// BgBrightWhite background color (107)
func BgBrightWhite(arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgBrightWhite()
}
return value{value: arg, color: BrightBg | WhiteBg}
}
//
// Other
//
// BgIndex of 8-bit pre-defined background color
// from 0 to 255 (48;5;n).
//
// 0- 7: standard colors (as in ESC [ 4047 m)
// 8- 15: high intensity colors (as in ESC [100107 m)
// 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
// 232-255: grayscale from black to white in 24 steps
//
func BgIndex(n uint8, arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgIndex(n)
}
return value{value: arg, color: (Color(n) << shiftBg) | flagBg}
}
// BgGray from 0 to 24.
func BgGray(n uint8, arg interface{}) Value {
if val, ok := arg.(Value); ok {
return val.BgGray(n)
}
if n > 23 {
n = 23
}
return value{value: arg, color: (Color(n+232) << shiftBg) | flagBg}
}