build: go 1.24
We were running behind and there were quite some deprecations to update. This was mostly in the upstream copy/pasta package but seems quite minimal.
This commit is contained in:
6
vendor/github.com/muesli/termenv/.golangci-soft.yml
generated
vendored
6
vendor/github.com/muesli/termenv/.golangci-soft.yml
generated
vendored
@ -20,10 +20,9 @@ linters:
|
||||
- goconst
|
||||
- godot
|
||||
- godox
|
||||
- gomnd
|
||||
- mnd
|
||||
- gomoddirectives
|
||||
- goprintffuncname
|
||||
- ifshort
|
||||
# - lll
|
||||
- misspell
|
||||
- nakedret
|
||||
@ -35,13 +34,10 @@ linters:
|
||||
|
||||
# disable default linters, they are already enabled in .golangci.yml
|
||||
disable:
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- varcheck
|
||||
|
1
vendor/github.com/muesli/termenv/.golangci.yml
generated
vendored
1
vendor/github.com/muesli/termenv/.golangci.yml
generated
vendored
@ -15,7 +15,6 @@ issues:
|
||||
linters:
|
||||
enable:
|
||||
- bodyclose
|
||||
- exportloopref
|
||||
- goimports
|
||||
- gosec
|
||||
- nilerr
|
||||
|
6
vendor/github.com/muesli/termenv/README.md
generated
vendored
6
vendor/github.com/muesli/termenv/README.md
generated
vendored
@ -307,7 +307,7 @@ termenv.DisableBracketedPaste()
|
||||
|
||||
### Color Support
|
||||
|
||||
- 24-bit (RGB): alacritty, foot, iTerm, kitty, Konsole, st, tmux, vte-based, wezterm, Windows Terminal
|
||||
- 24-bit (RGB): alacritty, foot, iTerm, kitty, Konsole, st, tmux, vte-based, wezterm, Ghostty, Windows Terminal
|
||||
- 8-bit (256): rxvt, screen, xterm, Apple Terminal
|
||||
- 4-bit (16): Linux Console
|
||||
|
||||
@ -350,7 +350,7 @@ You can help improve this list! Check out [how to](ansi_compat.md) and open an i
|
||||
|
||||
| Terminal | Copy to Clipboard (OSC52) | Hyperlinks (OSC8) | Notifications (OSC777) |
|
||||
| ---------------- | :-----------------------: | :---------------: | :--------------------: |
|
||||
| alacritty | ✅ | ❌[^alacritty] | ❌ |
|
||||
| alacritty | ✅ | ✅[^alacritty] | ❌ |
|
||||
| foot | ✅ | ✅ | ✅ |
|
||||
| kitty | ✅ | ✅ | ✅ |
|
||||
| Konsole | ❌[^konsole] | ✅ | ❌ |
|
||||
@ -374,7 +374,7 @@ You can help improve this list! Check out [how to](ansi_compat.md) and open an i
|
||||
[^apple]: OSC52 works with a [workaround](https://github.com/roy2220/osc52pty).
|
||||
[^tmux]: OSC8 is not supported, for more info see [issue#911](https://github.com/tmux/tmux/issues/911).
|
||||
[^screen]: OSC8 is not supported, for more info see [bug#50952](https://savannah.gnu.org/bugs/index.php?50952).
|
||||
[^alacritty]: OSC8 is not supported, for more info see [issue#922](https://github.com/alacritty/alacritty/issues/922).
|
||||
[^alacritty]: OSC8 is supported since [v0.11.0](https://github.com/alacritty/alacritty/releases/tag/v0.11.0)
|
||||
|
||||
</details>
|
||||
|
||||
|
2
vendor/github.com/muesli/termenv/ansicolors.go
generated
vendored
2
vendor/github.com/muesli/termenv/ansicolors.go
generated
vendored
@ -1,6 +1,6 @@
|
||||
package termenv
|
||||
|
||||
// ANSI color codes
|
||||
// ANSI color codes.
|
||||
const (
|
||||
ANSIBlack ANSIColor = iota
|
||||
ANSIRed
|
||||
|
17
vendor/github.com/muesli/termenv/color.go
generated
vendored
17
vendor/github.com/muesli/termenv/color.go
generated
vendored
@ -9,12 +9,10 @@ import (
|
||||
"github.com/lucasb-eyer/go-colorful"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrInvalidColor gets returned when a color is invalid.
|
||||
ErrInvalidColor = errors.New("invalid color")
|
||||
)
|
||||
// ErrInvalidColor gets returned when a color is invalid.
|
||||
var ErrInvalidColor = errors.New("invalid color")
|
||||
|
||||
// Foreground and Background sequence codes
|
||||
// Foreground and Background sequence codes.
|
||||
const (
|
||||
Foreground = "38"
|
||||
Background = "48"
|
||||
@ -73,6 +71,8 @@ func (c NoColor) Sequence(_ bool) string {
|
||||
}
|
||||
|
||||
// Sequence returns the ANSI Sequence for the color.
|
||||
//
|
||||
//nolint:mnd
|
||||
func (c ANSIColor) Sequence(bg bool) string {
|
||||
col := int(c)
|
||||
bgMod := func(c int) int {
|
||||
@ -83,9 +83,9 @@ func (c ANSIColor) Sequence(bg bool) string {
|
||||
}
|
||||
|
||||
if col < 8 {
|
||||
return fmt.Sprintf("%d", bgMod(col)+30)
|
||||
return fmt.Sprintf("%d", bgMod(col)+30) //nolint:mnd
|
||||
}
|
||||
return fmt.Sprintf("%d", bgMod(col-8)+90)
|
||||
return fmt.Sprintf("%d", bgMod(col-8)+90) //nolint:mnd
|
||||
}
|
||||
|
||||
// Sequence returns the ANSI Sequence for the color.
|
||||
@ -108,7 +108,7 @@ func (c RGBColor) Sequence(bg bool) string {
|
||||
if bg {
|
||||
prefix = Background
|
||||
}
|
||||
return fmt.Sprintf("%s;2;%d;%d;%d", prefix, uint8(f.R*255), uint8(f.G*255), uint8(f.B*255))
|
||||
return fmt.Sprintf("%s;2;%d;%d;%d", prefix, uint8(f.R*255), uint8(f.G*255), uint8(f.B*255)) //nolint:mnd
|
||||
}
|
||||
|
||||
func xTermColor(s string) (RGBColor, error) {
|
||||
@ -158,6 +158,7 @@ func ansi256ToANSIColor(c ANSI256Color) ANSIColor {
|
||||
return ANSIColor(r)
|
||||
}
|
||||
|
||||
//nolint:mnd
|
||||
func hexToANSI256Color(c colorful.Color) ANSI256Color {
|
||||
v2ci := func(v float64) int {
|
||||
if v < 48 {
|
||||
|
8
vendor/github.com/muesli/termenv/constants_zos.go
generated
vendored
Normal file
8
vendor/github.com/muesli/termenv/constants_zos.go
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
package termenv
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
tcgetattr = unix.TCGETS
|
||||
tcsetattr = unix.TCSETS
|
||||
)
|
34
vendor/github.com/muesli/termenv/output.go
generated
vendored
34
vendor/github.com/muesli/termenv/output.go
generated
vendored
@ -6,12 +6,12 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
// output is the default global output.
|
||||
output = NewOutput(os.Stdout)
|
||||
)
|
||||
// output is the default global output.
|
||||
var output = NewOutput(os.Stdout)
|
||||
|
||||
// File represents a file descriptor.
|
||||
//
|
||||
// Deprecated: Use *os.File instead.
|
||||
type File interface {
|
||||
io.ReadWriter
|
||||
Fd() uintptr
|
||||
@ -23,7 +23,7 @@ type OutputOption = func(*Output)
|
||||
// Output is a terminal output.
|
||||
type Output struct {
|
||||
Profile
|
||||
tty io.Writer
|
||||
w io.Writer
|
||||
environ Environ
|
||||
|
||||
assumeTTY bool
|
||||
@ -61,10 +61,10 @@ func SetDefaultOutput(o *Output) {
|
||||
output = o
|
||||
}
|
||||
|
||||
// NewOutput returns a new Output for the given file descriptor.
|
||||
func NewOutput(tty io.Writer, opts ...OutputOption) *Output {
|
||||
// NewOutput returns a new Output for the given writer.
|
||||
func NewOutput(w io.Writer, opts ...OutputOption) *Output {
|
||||
o := &Output{
|
||||
tty: tty,
|
||||
w: w,
|
||||
environ: &osEnviron{},
|
||||
Profile: -1,
|
||||
fgSync: &sync.Once{},
|
||||
@ -73,8 +73,8 @@ func NewOutput(tty io.Writer, opts ...OutputOption) *Output {
|
||||
bgColor: NoColor{},
|
||||
}
|
||||
|
||||
if o.tty == nil {
|
||||
o.tty = os.Stdout
|
||||
if o.w == nil {
|
||||
o.w = os.Stdout
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
@ -175,20 +175,28 @@ func (o *Output) BackgroundColor() Color {
|
||||
func (o *Output) HasDarkBackground() bool {
|
||||
c := ConvertToRGB(o.BackgroundColor())
|
||||
_, _, l := c.Hsl()
|
||||
return l < 0.5
|
||||
return l < 0.5 //nolint:mnd
|
||||
}
|
||||
|
||||
// TTY returns the terminal's file descriptor. This may be nil if the output is
|
||||
// not a terminal.
|
||||
//
|
||||
// Deprecated: Use Writer() instead.
|
||||
func (o Output) TTY() File {
|
||||
if f, ok := o.tty.(File); ok {
|
||||
if f, ok := o.w.(File); ok {
|
||||
return f
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Writer returns the underlying writer. This may be of type io.Writer,
|
||||
// io.ReadWriter, or *os.File.
|
||||
func (o Output) Writer() io.Writer {
|
||||
return o.w
|
||||
}
|
||||
|
||||
func (o Output) Write(p []byte) (int, error) {
|
||||
return o.tty.Write(p)
|
||||
return o.w.Write(p) //nolint:wrapcheck
|
||||
}
|
||||
|
||||
// WriteString writes the given string to the output.
|
||||
|
25
vendor/github.com/muesli/termenv/profile.go
generated
vendored
25
vendor/github.com/muesli/termenv/profile.go
generated
vendored
@ -12,16 +12,31 @@ import (
|
||||
type Profile int
|
||||
|
||||
const (
|
||||
// TrueColor, 24-bit color profile
|
||||
// TrueColor, 24-bit color profile.
|
||||
TrueColor = Profile(iota)
|
||||
// ANSI256, 8-bit color profile
|
||||
// ANSI256, 8-bit color profile.
|
||||
ANSI256
|
||||
// ANSI, 4-bit color profile
|
||||
// ANSI, 4-bit color profile.
|
||||
ANSI
|
||||
// Ascii, uncolored profile
|
||||
// Ascii, uncolored profile.
|
||||
Ascii //nolint:revive
|
||||
)
|
||||
|
||||
// Name returns the profile name as a string.
|
||||
func (p Profile) Name() string {
|
||||
switch p {
|
||||
case Ascii:
|
||||
return "Ascii"
|
||||
case ANSI:
|
||||
return "ANSI"
|
||||
case ANSI256:
|
||||
return "ANSI256"
|
||||
case TrueColor:
|
||||
return "TrueColor"
|
||||
}
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
// String returns a new Style.
|
||||
func (p Profile) String(s ...string) Style {
|
||||
return Style{
|
||||
@ -80,7 +95,7 @@ func (p Profile) Color(s string) Color {
|
||||
return nil
|
||||
}
|
||||
|
||||
if i < 16 {
|
||||
if i < 16 { //nolint:mnd
|
||||
c = ANSIColor(i)
|
||||
} else {
|
||||
c = ANSI256Color(i)
|
||||
|
90
vendor/github.com/muesli/termenv/screen.go
generated
vendored
90
vendor/github.com/muesli/termenv/screen.go
generated
vendored
@ -71,234 +71,234 @@ const (
|
||||
|
||||
// Reset the terminal to its default style, removing any active styles.
|
||||
func (o Output) Reset() {
|
||||
fmt.Fprint(o.tty, CSI+ResetSeq+"m")
|
||||
fmt.Fprint(o.w, CSI+ResetSeq+"m") //nolint:errcheck
|
||||
}
|
||||
|
||||
// SetForegroundColor sets the default foreground color.
|
||||
func (o Output) SetForegroundColor(color Color) {
|
||||
fmt.Fprintf(o.tty, OSC+SetForegroundColorSeq, color)
|
||||
fmt.Fprintf(o.w, OSC+SetForegroundColorSeq, color) //nolint:errcheck
|
||||
}
|
||||
|
||||
// SetBackgroundColor sets the default background color.
|
||||
func (o Output) SetBackgroundColor(color Color) {
|
||||
fmt.Fprintf(o.tty, OSC+SetBackgroundColorSeq, color)
|
||||
fmt.Fprintf(o.w, OSC+SetBackgroundColorSeq, color) //nolint:errcheck
|
||||
}
|
||||
|
||||
// SetCursorColor sets the cursor color.
|
||||
func (o Output) SetCursorColor(color Color) {
|
||||
fmt.Fprintf(o.tty, OSC+SetCursorColorSeq, color)
|
||||
fmt.Fprintf(o.w, OSC+SetCursorColorSeq, color) //nolint:errcheck
|
||||
}
|
||||
|
||||
// RestoreScreen restores a previously saved screen state.
|
||||
func (o Output) RestoreScreen() {
|
||||
fmt.Fprint(o.tty, CSI+RestoreScreenSeq)
|
||||
fmt.Fprint(o.w, CSI+RestoreScreenSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// SaveScreen saves the screen state.
|
||||
func (o Output) SaveScreen() {
|
||||
fmt.Fprint(o.tty, CSI+SaveScreenSeq)
|
||||
fmt.Fprint(o.w, CSI+SaveScreenSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// AltScreen switches to the alternate screen buffer. The former view can be
|
||||
// restored with ExitAltScreen().
|
||||
func (o Output) AltScreen() {
|
||||
fmt.Fprint(o.tty, CSI+AltScreenSeq)
|
||||
fmt.Fprint(o.w, CSI+AltScreenSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ExitAltScreen exits the alternate screen buffer and returns to the former
|
||||
// terminal view.
|
||||
func (o Output) ExitAltScreen() {
|
||||
fmt.Fprint(o.tty, CSI+ExitAltScreenSeq)
|
||||
fmt.Fprint(o.w, CSI+ExitAltScreenSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ClearScreen clears the visible portion of the terminal.
|
||||
func (o Output) ClearScreen() {
|
||||
fmt.Fprintf(o.tty, CSI+EraseDisplaySeq, 2)
|
||||
fmt.Fprintf(o.w, CSI+EraseDisplaySeq, 2) //nolint:errcheck,mnd
|
||||
o.MoveCursor(1, 1)
|
||||
}
|
||||
|
||||
// MoveCursor moves the cursor to a given position.
|
||||
func (o Output) MoveCursor(row int, column int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorPositionSeq, row, column)
|
||||
fmt.Fprintf(o.w, CSI+CursorPositionSeq, row, column) //nolint:errcheck
|
||||
}
|
||||
|
||||
// HideCursor hides the cursor.
|
||||
func (o Output) HideCursor() {
|
||||
fmt.Fprint(o.tty, CSI+HideCursorSeq)
|
||||
fmt.Fprint(o.w, CSI+HideCursorSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ShowCursor shows the cursor.
|
||||
func (o Output) ShowCursor() {
|
||||
fmt.Fprint(o.tty, CSI+ShowCursorSeq)
|
||||
fmt.Fprint(o.w, CSI+ShowCursorSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// SaveCursorPosition saves the cursor position.
|
||||
func (o Output) SaveCursorPosition() {
|
||||
fmt.Fprint(o.tty, CSI+SaveCursorPositionSeq)
|
||||
fmt.Fprint(o.w, CSI+SaveCursorPositionSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// RestoreCursorPosition restores a saved cursor position.
|
||||
func (o Output) RestoreCursorPosition() {
|
||||
fmt.Fprint(o.tty, CSI+RestoreCursorPositionSeq)
|
||||
fmt.Fprint(o.w, CSI+RestoreCursorPositionSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// CursorUp moves the cursor up a given number of lines.
|
||||
func (o Output) CursorUp(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorUpSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+CursorUpSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// CursorDown moves the cursor down a given number of lines.
|
||||
func (o Output) CursorDown(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorDownSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+CursorDownSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// CursorForward moves the cursor up a given number of lines.
|
||||
func (o Output) CursorForward(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorForwardSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+CursorForwardSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// CursorBack moves the cursor backwards a given number of cells.
|
||||
func (o Output) CursorBack(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorBackSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+CursorBackSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// CursorNextLine moves the cursor down a given number of lines and places it at
|
||||
// the beginning of the line.
|
||||
func (o Output) CursorNextLine(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorNextLineSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+CursorNextLineSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// CursorPrevLine moves the cursor up a given number of lines and places it at
|
||||
// the beginning of the line.
|
||||
func (o Output) CursorPrevLine(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorPreviousLineSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+CursorPreviousLineSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ClearLine clears the current line.
|
||||
func (o Output) ClearLine() {
|
||||
fmt.Fprint(o.tty, CSI+EraseEntireLineSeq)
|
||||
fmt.Fprint(o.w, CSI+EraseEntireLineSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ClearLineLeft clears the line to the left of the cursor.
|
||||
func (o Output) ClearLineLeft() {
|
||||
fmt.Fprint(o.tty, CSI+EraseLineLeftSeq)
|
||||
fmt.Fprint(o.w, CSI+EraseLineLeftSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ClearLineRight clears the line to the right of the cursor.
|
||||
func (o Output) ClearLineRight() {
|
||||
fmt.Fprint(o.tty, CSI+EraseLineRightSeq)
|
||||
fmt.Fprint(o.w, CSI+EraseLineRightSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ClearLines clears a given number of lines.
|
||||
func (o Output) ClearLines(n int) {
|
||||
clearLine := fmt.Sprintf(CSI+EraseLineSeq, 2)
|
||||
clearLine := fmt.Sprintf(CSI+EraseLineSeq, 2) //nolint:mnd
|
||||
cursorUp := fmt.Sprintf(CSI+CursorUpSeq, 1)
|
||||
fmt.Fprint(o.tty, clearLine+strings.Repeat(cursorUp+clearLine, n))
|
||||
fmt.Fprint(o.w, clearLine+strings.Repeat(cursorUp+clearLine, n)) //nolint:errcheck
|
||||
}
|
||||
|
||||
// ChangeScrollingRegion sets the scrolling region of the terminal.
|
||||
func (o Output) ChangeScrollingRegion(top, bottom int) {
|
||||
fmt.Fprintf(o.tty, CSI+ChangeScrollingRegionSeq, top, bottom)
|
||||
fmt.Fprintf(o.w, CSI+ChangeScrollingRegionSeq, top, bottom) //nolint:errcheck
|
||||
}
|
||||
|
||||
// InsertLines inserts the given number of lines at the top of the scrollable
|
||||
// region, pushing lines below down.
|
||||
func (o Output) InsertLines(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+InsertLineSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+InsertLineSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DeleteLines deletes the given number of lines, pulling any lines in
|
||||
// the scrollable region below up.
|
||||
func (o Output) DeleteLines(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+DeleteLineSeq, n)
|
||||
fmt.Fprintf(o.w, CSI+DeleteLineSeq, n) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableMousePress enables X10 mouse mode. Button press events are sent only.
|
||||
func (o Output) EnableMousePress() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMousePressSeq)
|
||||
fmt.Fprint(o.w, CSI+EnableMousePressSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableMousePress disables X10 mouse mode.
|
||||
func (o Output) DisableMousePress() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMousePressSeq)
|
||||
fmt.Fprint(o.w, CSI+DisableMousePressSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableMouse enables Mouse Tracking mode.
|
||||
func (o Output) EnableMouse() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseSeq)
|
||||
fmt.Fprint(o.w, CSI+EnableMouseSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableMouse disables Mouse Tracking mode.
|
||||
func (o Output) DisableMouse() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseSeq)
|
||||
fmt.Fprint(o.w, CSI+DisableMouseSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableMouseHilite enables Hilite Mouse Tracking mode.
|
||||
func (o Output) EnableMouseHilite() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseHiliteSeq)
|
||||
fmt.Fprint(o.w, CSI+EnableMouseHiliteSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableMouseHilite disables Hilite Mouse Tracking mode.
|
||||
func (o Output) DisableMouseHilite() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseHiliteSeq)
|
||||
fmt.Fprint(o.w, CSI+DisableMouseHiliteSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableMouseCellMotion enables Cell Motion Mouse Tracking mode.
|
||||
func (o Output) EnableMouseCellMotion() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseCellMotionSeq)
|
||||
fmt.Fprint(o.w, CSI+EnableMouseCellMotionSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableMouseCellMotion disables Cell Motion Mouse Tracking mode.
|
||||
func (o Output) DisableMouseCellMotion() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseCellMotionSeq)
|
||||
fmt.Fprint(o.w, CSI+DisableMouseCellMotionSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableMouseAllMotion enables All Motion Mouse mode.
|
||||
func (o Output) EnableMouseAllMotion() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseAllMotionSeq)
|
||||
fmt.Fprint(o.w, CSI+EnableMouseAllMotionSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableMouseAllMotion disables All Motion Mouse mode.
|
||||
func (o Output) DisableMouseAllMotion() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseAllMotionSeq)
|
||||
fmt.Fprint(o.w, CSI+DisableMouseAllMotionSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableMouseExtendedMotion enables Extended Mouse mode (SGR). This should be
|
||||
// enabled in conjunction with EnableMouseCellMotion, and EnableMouseAllMotion.
|
||||
func (o Output) EnableMouseExtendedMode() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseExtendedModeSeq)
|
||||
fmt.Fprint(o.w, CSI+EnableMouseExtendedModeSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableMouseExtendedMotion disables Extended Mouse mode (SGR).
|
||||
func (o Output) DisableMouseExtendedMode() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseExtendedModeSeq)
|
||||
fmt.Fprint(o.w, CSI+DisableMouseExtendedModeSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableMousePixelsMotion enables Pixel Motion Mouse mode (SGR-Pixels). This
|
||||
// should be enabled in conjunction with EnableMouseCellMotion, and
|
||||
// EnableMouseAllMotion.
|
||||
func (o Output) EnableMousePixelsMode() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMousePixelsModeSeq)
|
||||
fmt.Fprint(o.w, CSI+EnableMousePixelsModeSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableMousePixelsMotion disables Pixel Motion Mouse mode (SGR-Pixels).
|
||||
func (o Output) DisableMousePixelsMode() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMousePixelsModeSeq)
|
||||
fmt.Fprint(o.w, CSI+DisableMousePixelsModeSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// SetWindowTitle sets the terminal window title.
|
||||
func (o Output) SetWindowTitle(title string) {
|
||||
fmt.Fprintf(o.tty, OSC+SetWindowTitleSeq, title)
|
||||
fmt.Fprintf(o.w, OSC+SetWindowTitleSeq, title) //nolint:errcheck
|
||||
}
|
||||
|
||||
// EnableBracketedPaste enables bracketed paste.
|
||||
func (o Output) EnableBracketedPaste() {
|
||||
fmt.Fprintf(o.tty, CSI+EnableBracketedPasteSeq)
|
||||
fmt.Fprintf(o.w, CSI+EnableBracketedPasteSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// DisableBracketedPaste disables bracketed paste.
|
||||
func (o Output) DisableBracketedPaste() {
|
||||
fmt.Fprintf(o.tty, CSI+DisableBracketedPasteSeq)
|
||||
fmt.Fprintf(o.w, CSI+DisableBracketedPasteSeq) //nolint:errcheck
|
||||
}
|
||||
|
||||
// Legacy functions.
|
||||
|
4
vendor/github.com/muesli/termenv/style.go
generated
vendored
4
vendor/github.com/muesli/termenv/style.go
generated
vendored
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
"github.com/rivo/uniseg"
|
||||
)
|
||||
|
||||
// Sequence definitions.
|
||||
@ -122,5 +122,5 @@ func (t Style) CrossOut() Style {
|
||||
|
||||
// Width returns the width required to print all runes in Style.
|
||||
func (t Style) Width() int {
|
||||
return runewidth.StringWidth(t.string)
|
||||
return uniseg.StringWidth(t.string)
|
||||
}
|
||||
|
2
vendor/github.com/muesli/termenv/templatehelper.go
generated
vendored
2
vendor/github.com/muesli/termenv/templatehelper.go
generated
vendored
@ -10,6 +10,8 @@ func (o Output) TemplateFuncs() template.FuncMap {
|
||||
}
|
||||
|
||||
// TemplateFuncs contains a few useful template helpers.
|
||||
//
|
||||
//nolint:mnd
|
||||
func TemplateFuncs(p Profile) template.FuncMap {
|
||||
if p == Ascii {
|
||||
return noopTemplateFuncs
|
||||
|
17
vendor/github.com/muesli/termenv/termenv.go
generated
vendored
17
vendor/github.com/muesli/termenv/termenv.go
generated
vendored
@ -2,6 +2,7 @@ package termenv
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
)
|
||||
@ -12,15 +13,15 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
// Escape character
|
||||
// Escape character.
|
||||
ESC = '\x1b'
|
||||
// Bell
|
||||
// Bell.
|
||||
BEL = '\a'
|
||||
// Control Sequence Introducer
|
||||
// Control Sequence Introducer.
|
||||
CSI = string(ESC) + "["
|
||||
// Operating System Command
|
||||
// Operating System Command.
|
||||
OSC = string(ESC) + "]"
|
||||
// String Terminator
|
||||
// String Terminator.
|
||||
ST = string(ESC) + `\`
|
||||
)
|
||||
|
||||
@ -31,11 +32,11 @@ func (o *Output) isTTY() bool {
|
||||
if len(o.environ.Getenv("CI")) > 0 {
|
||||
return false
|
||||
}
|
||||
if o.TTY() == nil {
|
||||
return false
|
||||
if f, ok := o.Writer().(*os.File); ok {
|
||||
return isatty.IsTerminal(f.Fd())
|
||||
}
|
||||
|
||||
return isatty.IsTerminal(o.TTY().Fd())
|
||||
return false
|
||||
}
|
||||
|
||||
// ColorProfile returns the supported color profile:
|
||||
|
4
vendor/github.com/muesli/termenv/termenv_posix.go
generated
vendored
4
vendor/github.com/muesli/termenv/termenv_posix.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || zos
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd zos
|
||||
|
||||
package termenv
|
||||
|
||||
|
36
vendor/github.com/muesli/termenv/termenv_unix.go
generated
vendored
36
vendor/github.com/muesli/termenv/termenv_unix.go
generated
vendored
@ -1,5 +1,5 @@
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
||||
|
||||
package termenv
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// timeout for OSC queries
|
||||
// timeout for OSC queries.
|
||||
OSCTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
@ -50,9 +50,15 @@ func (o *Output) ColorProfile() Profile {
|
||||
}
|
||||
|
||||
switch term {
|
||||
case "xterm-kitty", "wezterm":
|
||||
case
|
||||
"alacritty",
|
||||
"contour",
|
||||
"rio",
|
||||
"wezterm",
|
||||
"xterm-ghostty",
|
||||
"xterm-kitty":
|
||||
return TrueColor
|
||||
case "linux":
|
||||
case "linux", "xterm":
|
||||
return ANSI
|
||||
}
|
||||
|
||||
@ -69,6 +75,7 @@ func (o *Output) ColorProfile() Profile {
|
||||
return Ascii
|
||||
}
|
||||
|
||||
//nolint:mnd
|
||||
func (o Output) foregroundColor() Color {
|
||||
s, err := o.termStatusReport(10)
|
||||
if err == nil {
|
||||
@ -91,6 +98,7 @@ func (o Output) foregroundColor() Color {
|
||||
return ANSIColor(7)
|
||||
}
|
||||
|
||||
//nolint:mnd
|
||||
func (o Output) backgroundColor() Color {
|
||||
s, err := o.termStatusReport(11)
|
||||
if err == nil {
|
||||
@ -117,15 +125,15 @@ func (o *Output) waitForData(timeout time.Duration) error {
|
||||
fd := o.TTY().Fd()
|
||||
tv := unix.NsecToTimeval(int64(timeout))
|
||||
var readfds unix.FdSet
|
||||
readfds.Set(int(fd))
|
||||
readfds.Set(int(fd)) //nolint:gosec
|
||||
|
||||
for {
|
||||
n, err := unix.Select(int(fd)+1, &readfds, nil, nil, &tv)
|
||||
n, err := unix.Select(int(fd)+1, &readfds, nil, nil, &tv) //nolint:gosec
|
||||
if err == unix.EINTR {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
return err //nolint:wrapcheck
|
||||
}
|
||||
if n == 0 {
|
||||
return fmt.Errorf("timeout")
|
||||
@ -147,7 +155,7 @@ func (o *Output) readNextByte() (byte, error) {
|
||||
var b [1]byte
|
||||
n, err := o.TTY().Read(b[:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, err //nolint:wrapcheck
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
@ -215,7 +223,7 @@ func (o *Output) readNextResponse() (response string, isOSC bool, err error) {
|
||||
}
|
||||
|
||||
// both responses have less than 25 bytes, so if we read more, that's an error
|
||||
if len(response) > 25 {
|
||||
if len(response) > 25 { //nolint:mnd
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -227,7 +235,7 @@ func (o Output) termStatusReport(sequence int) (string, error) {
|
||||
// screen/tmux can't support OSC, because they can be connected to multiple
|
||||
// terminals concurrently.
|
||||
term := o.environ.Getenv("TERM")
|
||||
if strings.HasPrefix(term, "screen") || strings.HasPrefix(term, "tmux") {
|
||||
if strings.HasPrefix(term, "screen") || strings.HasPrefix(term, "tmux") || strings.HasPrefix(term, "dumb") {
|
||||
return "", ErrStatusReport
|
||||
}
|
||||
|
||||
@ -237,7 +245,7 @@ func (o Output) termStatusReport(sequence int) (string, error) {
|
||||
}
|
||||
|
||||
if !o.unsafe {
|
||||
fd := int(tty.Fd())
|
||||
fd := int(tty.Fd()) //nolint:gosec
|
||||
// if in background, we can't control the terminal
|
||||
if !isForeground(fd) {
|
||||
return "", ErrStatusReport
|
||||
@ -258,10 +266,10 @@ func (o Output) termStatusReport(sequence int) (string, error) {
|
||||
}
|
||||
|
||||
// first, send OSC query, which is ignored by terminal which do not support it
|
||||
fmt.Fprintf(tty, OSC+"%d;?"+ST, sequence)
|
||||
fmt.Fprintf(tty, OSC+"%d;?"+ST, sequence) //nolint:errcheck
|
||||
|
||||
// then, query cursor position, should be supported by all terminals
|
||||
fmt.Fprintf(tty, CSI+"6n")
|
||||
fmt.Fprintf(tty, CSI+"6n") //nolint:errcheck
|
||||
|
||||
// read the next response
|
||||
res, isOSC, err := o.readNextResponse()
|
||||
|
5
vendor/github.com/muesli/termenv/termenv_windows.go
generated
vendored
5
vendor/github.com/muesli/termenv/termenv_windows.go
generated
vendored
@ -5,6 +5,7 @@ package termenv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
@ -103,8 +104,8 @@ func EnableVirtualTerminalProcessing(o *Output) (restoreFunc func() error, err e
|
||||
}
|
||||
|
||||
// If o is not a tty, then there is nothing to do.
|
||||
tty := o.TTY()
|
||||
if tty == nil {
|
||||
tty, ok := o.Writer().(*os.File)
|
||||
if tty == nil || !ok {
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user