diff --git a/LICENSES/vendor/github.com/daviddengcn/go-colortext/LICENSE b/LICENSES/vendor/github.com/daviddengcn/go-colortext/LICENSE deleted file mode 100644 index b8a9f54ac2d..00000000000 --- a/LICENSES/vendor/github.com/daviddengcn/go-colortext/LICENSE +++ /dev/null @@ -1,58 +0,0 @@ -= vendor/github.com/daviddengcn/go-colortext licensed under: = - -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. - -= vendor/github.com/daviddengcn/go-colortext/LICENSE a802db7d9a036fb71c12cf20966510dc diff --git a/go.mod b/go.mod index c306fc6afeb..3607c100a41 100644 --- a/go.mod +++ b/go.mod @@ -141,7 +141,6 @@ require ( github.com/coredns/caddy v1.1.1 // indirect github.com/coreos/go-semver v0.3.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/daviddengcn/go-colortext v1.0.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect diff --git a/go.sum b/go.sum index 99f4f7b4ef3..4bd7f2b529d 100644 --- a/go.sum +++ b/go.sum @@ -212,8 +212,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX8ATG8oKsE= -github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/docker v26.1.4+incompatible h1:vuTpXDuoga+Z38m1OZHzl7NKisKWaWlhjQk7IDPSLsU= @@ -297,11 +295,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= -github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1XL80yAn+A= -github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE= -github.com/golangplus/testing v1.0.0 h1:+ZeeiKZENNOMkTTELoSySazi+XaEhVO0mb+eanrSEUQ= -github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cadvisor v0.51.0 h1:BspqSPdZoLKrnvuZNOvM/KiJ/A+RdixwagN20n+2H8k= diff --git a/go.work.sum b/go.work.sum index c2f6a59e338..5e0f094f5a9 100644 --- a/go.work.sum +++ b/go.work.sum @@ -150,8 +150,6 @@ github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNV github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= -github.com/golangplus/bytes v1.0.0 h1:YQKBijBVMsBxIiXT4IEhlKR2zHohjEqPole4umyDX+c= -github.com/golangplus/fmt v1.0.0 h1:FnUKtw86lXIPfBMc3FimNF3+ABcV+aH5F17OOitTN+E= github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVWCNtNq/ewIX7HIKnELmEx2nDP42yskD/pi7QE= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= diff --git a/staging/src/k8s.io/kubectl/go.mod b/staging/src/k8s.io/kubectl/go.mod index acceef78920..2d459e15bd5 100644 --- a/staging/src/k8s.io/kubectl/go.mod +++ b/staging/src/k8s.io/kubectl/go.mod @@ -9,7 +9,6 @@ godebug default=go1.23 require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/chai2010/gettext-go v1.0.2 - github.com/daviddengcn/go-colortext v1.0.0 github.com/distribution/reference v0.6.0 github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f github.com/fatih/camelcase v1.0.0 diff --git a/staging/src/k8s.io/kubectl/go.sum b/staging/src/k8s.io/kubectl/go.sum index d8370812172..b473d0f5d61 100644 --- a/staging/src/k8s.io/kubectl/go.sum +++ b/staging/src/k8s.io/kubectl/go.sum @@ -23,8 +23,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX8ATG8oKsE= -github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= @@ -57,11 +55,6 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= -github.com/golangplus/bytes v1.0.0/go.mod h1:AdRaCFwmc/00ZzELMWb01soso6W1R/++O1XL80yAn+A= -github.com/golangplus/fmt v1.0.0/go.mod h1:zpM0OfbMCjPtd2qkTD/jX2MgiFCqklhSUFyDW44gVQE= -github.com/golangplus/testing v1.0.0 h1:+ZeeiKZENNOMkTTELoSySazi+XaEhVO0mb+eanrSEUQ= -github.com/golangplus/testing v1.0.0/go.mod h1:ZDreixUV3YzhoVraIDyOzHrr76p6NUh6k/pPg/Q3gYA= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/clusterinfo/clusterinfo.go b/staging/src/k8s.io/kubectl/pkg/cmd/clusterinfo/clusterinfo.go index fd491e3ebc5..cb6e3cebf6e 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/clusterinfo/clusterinfo.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/clusterinfo/clusterinfo.go @@ -33,7 +33,6 @@ import ( "k8s.io/kubectl/pkg/util/i18n" "k8s.io/kubectl/pkg/util/templates" - ct "github.com/daviddengcn/go-colortext" "github.com/spf13/cobra" ) @@ -156,12 +155,8 @@ func (o *ClusterInfoOptions) Run() error { } func printService(out io.Writer, name, link string) { - ct.ChangeColor(ct.Green, false, ct.None, false) fmt.Fprint(out, name) - ct.ResetColor() fmt.Fprint(out, " is running at ") - ct.ChangeColor(ct.Yellow, false, ct.None, false) fmt.Fprint(out, link) - ct.ResetColor() fmt.Fprintln(out, "") } diff --git a/vendor/github.com/daviddengcn/go-colortext/.gitignore b/vendor/github.com/daviddengcn/go-colortext/.gitignore deleted file mode 100644 index 00268614f04..00000000000 --- a/vendor/github.com/daviddengcn/go-colortext/.gitignore +++ /dev/null @@ -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 diff --git a/vendor/github.com/daviddengcn/go-colortext/LICENSE b/vendor/github.com/daviddengcn/go-colortext/LICENSE deleted file mode 100644 index 62ca9ee2e4f..00000000000 --- a/vendor/github.com/daviddengcn/go-colortext/LICENSE +++ /dev/null @@ -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. diff --git a/vendor/github.com/daviddengcn/go-colortext/README.md b/vendor/github.com/daviddengcn/go-colortext/README.md deleted file mode 100644 index f7feca87281..00000000000 --- a/vendor/github.com/daviddengcn/go-colortext/README.md +++ /dev/null @@ -1,21 +0,0 @@ -go-colortext package [![GoSearch](http://go-search.org/badge?id=github.com%2Fdaviddengcn%2Fgo-colortext)](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 diff --git a/vendor/github.com/daviddengcn/go-colortext/ct.go b/vendor/github.com/daviddengcn/go-colortext/ct.go deleted file mode 100644 index b0e408e5614..00000000000 --- a/vendor/github.com/daviddengcn/go-colortext/ct.go +++ /dev/null @@ -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) -} diff --git a/vendor/github.com/daviddengcn/go-colortext/ct_ansi.go b/vendor/github.com/daviddengcn/go-colortext/ct_ansi.go deleted file mode 100644 index 12846573513..00000000000 --- a/vendor/github.com/daviddengcn/go-colortext/ct_ansi.go +++ /dev/null @@ -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)) -} diff --git a/vendor/github.com/daviddengcn/go-colortext/ct_win.go b/vendor/github.com/daviddengcn/go-colortext/ct_win.go deleted file mode 100644 index 2b267f458c3..00000000000 --- a/vendor/github.com/daviddengcn/go-colortext/ct_win.go +++ /dev/null @@ -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) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 93d3dd09d15..38d743b0132 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -122,9 +122,6 @@ github.com/cyphar/filepath-securejoin # github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc ## explicit github.com/davecgh/go-spew/spew -# github.com/daviddengcn/go-colortext v1.0.0 -## explicit; go 1.14 -github.com/daviddengcn/go-colortext # github.com/distribution/reference v0.6.0 ## explicit; go 1.20 github.com/distribution/reference