mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Drop go-colortext and its usage
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
22
vendor/github.com/daviddengcn/go-colortext/.gitignore
generated
vendored
22
vendor/github.com/daviddengcn/go-colortext/.gitignore
generated
vendored
@@ -1,22 +0,0 @@
|
||||
# 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
|
||||
54
vendor/github.com/daviddengcn/go-colortext/LICENSE
generated
vendored
54
vendor/github.com/daviddengcn/go-colortext/LICENSE
generated
vendored
@@ -1,54 +0,0 @@
|
||||
BSD License
|
||||
===========
|
||||
|
||||
Copyright (c) 2016, David Deng
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of go-colortext nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
MIT License
|
||||
===========
|
||||
|
||||
Copyright (c) 2016 David Deng
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
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 OR COPYRIGHT HOLDERS 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.
|
||||
21
vendor/github.com/daviddengcn/go-colortext/README.md
generated
vendored
21
vendor/github.com/daviddengcn/go-colortext/README.md
generated
vendored
@@ -1,21 +0,0 @@
|
||||
go-colortext package [](http://go-search.org/view?id=github.com%2Fdaviddengcn%2Fgo-colortext)
|
||||
====================
|
||||
|
||||
This is a package to change the color of the text and background in the console, working both under Windows and other systems.
|
||||
|
||||
Under Windows, the console APIs are used. Otherwise, ANSI texts are output.
|
||||
|
||||
Docs: http://godoc.org/github.com/daviddengcn/go-colortext ([packages that import ct](http://go-search.org/view?id=github.com%2fdaviddengcn%2fgo-colortext))
|
||||
|
||||
Usage:
|
||||
```go
|
||||
ct.Foreground(Green, false)
|
||||
fmt.Println("Green text starts here...")
|
||||
ct.ChangeColor(Red, true, White, false)
|
||||
fmt.Println(...)
|
||||
ct.ResetColor()
|
||||
```
|
||||
|
||||
LICENSE
|
||||
=======
|
||||
BSD/MIT license
|
||||
53
vendor/github.com/daviddengcn/go-colortext/ct.go
generated
vendored
53
vendor/github.com/daviddengcn/go-colortext/ct.go
generated
vendored
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
ct package provides functions to change the color of console text.
|
||||
|
||||
Under windows platform, the Console API is used. Under other systems, ANSI text mode is used.
|
||||
*/
|
||||
package ct
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Color is the type of color to be set.
|
||||
type Color int
|
||||
|
||||
const (
|
||||
// No change of color
|
||||
None = Color(iota)
|
||||
Black
|
||||
Red
|
||||
Green
|
||||
Yellow
|
||||
Blue
|
||||
Magenta
|
||||
Cyan
|
||||
White
|
||||
)
|
||||
|
||||
// Writer is the io.Writer where ANSI escape codes will be written to
|
||||
var Writer io.Writer = os.Stdout
|
||||
|
||||
// ResetColor resets the foreground and background to original colors
|
||||
func ResetColor() {
|
||||
resetColor()
|
||||
}
|
||||
|
||||
// ChangeColor sets the foreground and background colors. If the value of the color is None,
|
||||
// the corresponding color keeps unchanged.
|
||||
// If fgBright or bgBright is set true, corresponding color use bright color. bgBright may be
|
||||
// ignored in some OS environment.
|
||||
func ChangeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
|
||||
changeColor(fg, fgBright, bg, bgBright)
|
||||
}
|
||||
|
||||
// Foreground changes the foreground color.
|
||||
func Foreground(cl Color, bright bool) {
|
||||
ChangeColor(cl, bright, None, false)
|
||||
}
|
||||
|
||||
// Background changes the background color.
|
||||
func Background(cl Color, bright bool) {
|
||||
ChangeColor(None, false, cl, bright)
|
||||
}
|
||||
51
vendor/github.com/daviddengcn/go-colortext/ct_ansi.go
generated
vendored
51
vendor/github.com/daviddengcn/go-colortext/ct_ansi.go
generated
vendored
@@ -1,51 +0,0 @@
|
||||
// +build !windows
|
||||
|
||||
package ct
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func isDumbTerm() bool {
|
||||
return os.Getenv("TERM") == "dumb"
|
||||
}
|
||||
|
||||
func resetColor() {
|
||||
if isDumbTerm() {
|
||||
return
|
||||
}
|
||||
fmt.Fprint(Writer, "\x1b[0m")
|
||||
}
|
||||
|
||||
func ansiText(fg Color, fgBright bool, bg Color, bgBright bool) string {
|
||||
if fg == None && bg == None {
|
||||
return ""
|
||||
}
|
||||
s := []byte("\x1b[0")
|
||||
if fg != None {
|
||||
s = strconv.AppendUint(append(s, ";"...), 30+(uint64)(fg-Black), 10)
|
||||
if fgBright {
|
||||
s = append(s, ";1"...)
|
||||
}
|
||||
}
|
||||
if bg != None {
|
||||
s = strconv.AppendUint(append(s, ";"...), 40+(uint64)(bg-Black), 10)
|
||||
if bgBright {
|
||||
s = append(s, ";1"...)
|
||||
}
|
||||
}
|
||||
s = append(s, "m"...)
|
||||
return string(s)
|
||||
}
|
||||
|
||||
func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
|
||||
if isDumbTerm() {
|
||||
return
|
||||
}
|
||||
if fg == None && bg == None {
|
||||
return
|
||||
}
|
||||
fmt.Fprint(Writer, ansiText(fg, fgBright, bg, bgBright))
|
||||
}
|
||||
133
vendor/github.com/daviddengcn/go-colortext/ct_win.go
generated
vendored
133
vendor/github.com/daviddengcn/go-colortext/ct_win.go
generated
vendored
@@ -1,133 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package ct
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var fg_colors = []uint16{
|
||||
0,
|
||||
0,
|
||||
foreground_red,
|
||||
foreground_green,
|
||||
foreground_red | foreground_green,
|
||||
foreground_blue,
|
||||
foreground_red | foreground_blue,
|
||||
foreground_green | foreground_blue,
|
||||
foreground_red | foreground_green | foreground_blue}
|
||||
|
||||
var bg_colors = []uint16{
|
||||
0,
|
||||
0,
|
||||
background_red,
|
||||
background_green,
|
||||
background_red | background_green,
|
||||
background_blue,
|
||||
background_red | background_blue,
|
||||
background_green | background_blue,
|
||||
background_red | background_green | background_blue}
|
||||
|
||||
const (
|
||||
foreground_blue = uint16(0x0001)
|
||||
foreground_green = uint16(0x0002)
|
||||
foreground_red = uint16(0x0004)
|
||||
foreground_intensity = uint16(0x0008)
|
||||
background_blue = uint16(0x0010)
|
||||
background_green = uint16(0x0020)
|
||||
background_red = uint16(0x0040)
|
||||
background_intensity = uint16(0x0080)
|
||||
|
||||
foreground_mask = foreground_blue | foreground_green | foreground_red | foreground_intensity
|
||||
background_mask = background_blue | background_green | background_red | background_intensity
|
||||
)
|
||||
|
||||
var (
|
||||
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
|
||||
procGetStdHandle = kernel32.NewProc("GetStdHandle")
|
||||
procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
|
||||
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
|
||||
|
||||
hStdout uintptr
|
||||
initScreenInfo *console_screen_buffer_info
|
||||
)
|
||||
|
||||
func setConsoleTextAttribute(hConsoleOutput uintptr, wAttributes uint16) bool {
|
||||
ret, _, _ := procSetConsoleTextAttribute.Call(
|
||||
hConsoleOutput,
|
||||
uintptr(wAttributes))
|
||||
return ret != 0
|
||||
}
|
||||
|
||||
type coord struct {
|
||||
X, Y int16
|
||||
}
|
||||
|
||||
type small_rect struct {
|
||||
Left, Top, Right, Bottom int16
|
||||
}
|
||||
|
||||
type console_screen_buffer_info struct {
|
||||
DwSize coord
|
||||
DwCursorPosition coord
|
||||
WAttributes uint16
|
||||
SrWindow small_rect
|
||||
DwMaximumWindowSize coord
|
||||
}
|
||||
|
||||
func getConsoleScreenBufferInfo(hConsoleOutput uintptr) *console_screen_buffer_info {
|
||||
var csbi console_screen_buffer_info
|
||||
if ret, _, _ := procGetConsoleScreenBufferInfo.Call(hConsoleOutput, uintptr(unsafe.Pointer(&csbi))); ret == 0 {
|
||||
return nil
|
||||
}
|
||||
return &csbi
|
||||
}
|
||||
|
||||
const (
|
||||
std_output_handle = uint32(-11 & 0xFFFFFFFF)
|
||||
)
|
||||
|
||||
func init() {
|
||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||
|
||||
procGetStdHandle = kernel32.NewProc("GetStdHandle")
|
||||
|
||||
hStdout, _, _ = procGetStdHandle.Call(uintptr(std_output_handle))
|
||||
|
||||
initScreenInfo = getConsoleScreenBufferInfo(hStdout)
|
||||
|
||||
syscall.LoadDLL("")
|
||||
}
|
||||
|
||||
func resetColor() {
|
||||
if initScreenInfo == nil { // No console info - Ex: stdout redirection
|
||||
return
|
||||
}
|
||||
setConsoleTextAttribute(hStdout, initScreenInfo.WAttributes)
|
||||
}
|
||||
|
||||
func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
|
||||
attr := uint16(0)
|
||||
if fg == None || bg == None {
|
||||
cbufinfo := getConsoleScreenBufferInfo(hStdout)
|
||||
if cbufinfo == nil { // No console info - Ex: stdout redirection
|
||||
return
|
||||
}
|
||||
attr = cbufinfo.WAttributes
|
||||
}
|
||||
if fg != None {
|
||||
attr = attr & ^foreground_mask | fg_colors[fg]
|
||||
if fgBright {
|
||||
attr |= foreground_intensity
|
||||
}
|
||||
}
|
||||
if bg != None {
|
||||
attr = attr & ^background_mask | bg_colors[bg]
|
||||
if bgBright {
|
||||
attr |= background_intensity
|
||||
}
|
||||
}
|
||||
setConsoleTextAttribute(hStdout, attr)
|
||||
}
|
||||
Reference in New Issue
Block a user