diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-05 22:17:49 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-06 09:12:42 +1000 |
commit | 82022615ddc25ec5bc0631894e32d8dda380eac2 (patch) | |
tree | b609c448557e23d9ce4efbd1eb1e3aee41667f70 /vendor/github.com/gdamore | |
parent | fb395bca6eedfc44afb04ad26005a45e7b7dfea9 (diff) |
bump tcell
Diffstat (limited to 'vendor/github.com/gdamore')
47 files changed, 1140 insertions, 817 deletions
diff --git a/vendor/github.com/gdamore/tcell/v2/README.adoc b/vendor/github.com/gdamore/tcell/v2/README.adoc index 15f390ff3..93af9fdcb 100644 --- a/vendor/github.com/gdamore/tcell/v2/README.adoc +++ b/vendor/github.com/gdamore/tcell/v2/README.adoc @@ -5,7 +5,7 @@ image:https://img.shields.io/travis/gdamore/tcell.svg?label=linux[Linux Status,l image:https://img.shields.io/appveyor/ci/gdamore/tcell.svg?label=windows[Windows Status,link="https://ci.appveyor.com/project/gdamore/tcell"] image:https://img.shields.io/badge/license-APACHE2-blue.svg[Apache License,link="https://github.com/gdamore/tcell/blob/master/LICENSE"] image:https://img.shields.io/badge/godoc-reference-blue.svg[GoDoc,link="https://godoc.org/github.com/gdamore/tcell"] -image:http://goreportcard.com/badge/gdamore/tcell[Go Report Card,link="http://goreportcard.com/report/gdamore/tcell"] +image:https://goreportcard.com/badge/gdamore/tcell[Go Report Card,link="http://goreportcard.com/report/gdamore/tcell"] image:https://img.shields.io/discord/639503822733180969?label=discord[Discord,link="https://discord.gg/urTTxDN"] image:https://codecov.io/gh/gdamore/tcell/branch/master/graph/badge.svg[codecov,link="https://codecov.io/gh/gdamore/tcell"] @@ -51,6 +51,9 @@ Version 1.x remains available using the import `github.com/gdamore/tcell`. * https://github.com/jbaramidze/gonano[gonano] - CLI test editor * https://github.com/tmountain/uchess[uchess] - A UCI chess client for your terminal * https://github.com/a-h/min[min] - A Gemini browser +* https://github.com/noborus/ov[ov] - Terminal pager +* https://github.com/gcla/tmux-wormhole[tmux-wormhole] - A tmux plugin to transfer files with magic wormhole +* https://github.com/anaseto/gruid-tcell[gruid-tcell] - A tcell driver for the grid based UI and game framework gruid. == Pure Go Terminfo Database diff --git a/vendor/github.com/gdamore/tcell/v2/color.go b/vendor/github.com/gdamore/tcell/v2/color.go index 8a13a073a..8e50fa302 100644 --- a/vendor/github.com/gdamore/tcell/v2/color.go +++ b/vendor/github.com/gdamore/tcell/v2/color.go @@ -14,7 +14,10 @@ package tcell -import "strconv" +import ( + ic "image/color" + "strconv" +) // Color represents a color. The low numeric values are the same as used // by ECMA-48, and beyond that XTerm. A 24-bit RGB value may be used by @@ -35,7 +38,7 @@ const ( // system or terminal default may exist. It's also the zero value. ColorDefault Color = 0 - // ColorIsValid is used to indicate the color value is actually + // ColorValid is used to indicate the color value is actually // valid (initialized). This is useful to permit the zero value // to be treated as the default. ColorValid Color = 1 << 32 @@ -1066,4 +1069,13 @@ func GetColor(name string) Color { // PaletteColor creates a color based on the palette index. func PaletteColor(index int) Color { return Color(index) | ColorValid -}
\ No newline at end of file +} + +// FromImageColor converts an image/color.Color into tcell.Color. +// The alpha value is dropped, so it should be tracked separately if it is +// needed. +func FromImageColor(imageColor ic.Color) Color { + r, g, b, _ := imageColor.RGBA() + // NOTE image/color.Color RGB values range is [0, 0xFFFF] as uint32 + return NewRGBColor(int32(r>>8), int32(g>>8), int32(b>>8)) +} diff --git a/vendor/github.com/gdamore/tcell/v2/console_win.go b/vendor/github.com/gdamore/tcell/v2/console_win.go index ce2185313..7c5716039 100644 --- a/vendor/github.com/gdamore/tcell/v2/console_win.go +++ b/vendor/github.com/gdamore/tcell/v2/console_win.go @@ -41,6 +41,7 @@ type cScreen struct { fini bool vten bool truecolor bool + running bool w int h int @@ -265,42 +266,14 @@ func (s *cScreen) Fini() { s.disengage() } -func (s *cScreen) finish() { - s.Lock() - s.style = StyleDefault - s.curx = -1 - s.cury = -1 - s.fini = true - s.vten = false - s.Unlock() - - s.setCursorInfo(&s.ocursor) - s.setInMode(s.oimode) - s.setOutMode(s.oomode) - s.setBufferSize(int(s.oscreen.size.x), int(s.oscreen.size.y)) - s.clearScreen(StyleDefault, false) - s.setCursorPos(0, 0, false) - procSetConsoleTextAttribute.Call( - uintptr(s.out), - uintptr(s.mapStyle(StyleDefault))) - - close(s.quit) - procSetEvent.Call(uintptr(s.cancelflag)) - // Block until scanInput returns; this prevents a race condition on Win 8+ - // which causes syscall.Close to block until another keypress is read. - <-s.scandone - syscall.Close(s.in) - syscall.Close(s.out) -} - func (s *cScreen) disengage() { s.Lock() - stopQ := s.stopQ - if stopQ == nil { + if !s.running { s.Unlock() return } - s.stopQ = nil + s.running = false + stopQ := s.stopQ procSetEvent.Call(uintptr(s.cancelflag)) close(stopQ) s.Unlock() @@ -312,6 +285,7 @@ func (s *cScreen) disengage() { s.setBufferSize(int(s.oscreen.size.x), int(s.oscreen.size.y)) s.clearScreen(StyleDefault, false) s.setCursorPos(0, 0, false) + s.setCursorInfo(&s.ocursor) procSetConsoleTextAttribute.Call( uintptr(s.out), uintptr(s.mapStyle(StyleDefault))) @@ -320,7 +294,7 @@ func (s *cScreen) disengage() { func (s *cScreen) engage() error { s.Lock() defer s.Unlock() - if s.stopQ != nil { + if s.running { return errors.New("already engaged") } s.stopQ = make(chan struct{}) @@ -332,6 +306,7 @@ func (s *cScreen) engage() error { if cf == uintptr(0) { return e } + s.running = true s.cancelflag = syscall.Handle(cf) s.enableMouse(s.mouseEnabled) @@ -370,13 +345,17 @@ func (s *cScreen) PostEvent(ev Event) error { func (s *cScreen) PollEvent() Event { select { - case <-s.quit: + case <-s.stopQ: return nil case ev := <-s.evch: return ev } } +func (s *cScreen) HasPendingEvent() bool { + return len(s.evch) > 0 +} + type cursorInfo struct { size uint32 visible uint32 diff --git a/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go b/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go index df8fc0547..ffe5caf85 100644 --- a/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go +++ b/vendor/github.com/gdamore/tcell/v2/nonblock_bsd.go @@ -17,7 +17,6 @@ package tcell import ( - "os" "syscall" "golang.org/x/sys/unix" @@ -25,26 +24,18 @@ import ( // BSD systems use TIOC style ioctls. -// nonBlocking changes VMIN to 0, and VTIME to 1. This basically ensures that -// we can wake up the input loop. We only want to do this if we are going to interrupt -// that loop. Normally we use VMIN 1 and VTIME 0, which ensures we pick up bytes when -// they come but don't spin burning cycles. -func (t *tScreen) nonBlocking(on bool) { - fd := int(os.Stdin.Fd()) +// tcSetBufParams is used by the tty driver on UNIX systems to configure the +// buffering parameters (minimum character count and minimum wait time in msec.) +func tcSetBufParams(fd int, vMin uint8, vTime uint8) error { + _ = syscall.SetNonblock(fd, true) tio, err := unix.IoctlGetTermios(fd, unix.TIOCGETA) if err != nil { - return + return err } - if on { - tio.Cc[unix.VMIN] = 0 - tio.Cc[unix.VTIME] = 0 - } else { - // block for any output - tio.Cc[unix.VTIME] = 0 - tio.Cc[unix.VMIN] = 1 + tio.Cc[unix.VMIN] = vMin + tio.Cc[unix.VTIME] = vTime + if err = unix.IoctlSetTermios(fd, unix.TIOCSETA, tio); err != nil { + return err } - - _ = syscall.SetNonblock(fd, on) - // We want to set this *right now*. - _ = unix.IoctlSetTermios(fd, unix.TIOCSETA, tio) + return nil } diff --git a/vendor/github.com/gdamore/tcell/v2/nonblock_stub.go b/vendor/github.com/gdamore/tcell/v2/nonblock_stub.go deleted file mode 100644 index 35758c33e..000000000 --- a/vendor/github.com/gdamore/tcell/v2/nonblock_stub.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2021 The TCell Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build plan9 windows js - -package tcell - -func (t *tScreen) nonBlocking(on bool) error { - return nil -}
\ No newline at end of file diff --git a/vendor/github.com/gdamore/tcell/v2/nonblock_unix.go b/vendor/github.com/gdamore/tcell/v2/nonblock_unix.go index c4c374cc9..768128d7a 100644 --- a/vendor/github.com/gdamore/tcell/v2/nonblock_unix.go +++ b/vendor/github.com/gdamore/tcell/v2/nonblock_unix.go @@ -17,36 +17,23 @@ package tcell import ( - "os" "syscall" "golang.org/x/sys/unix" ) -// NB: We might someday wish to move Windows to this model. However, -// that would probably mean sacrificing some of the richer key reporting -// that we can obtain with the console API present on Windows. - -// nonBlocking changes VMIN to 0, and VTIME to 1. This basically ensures that -// we can wake up the input loop. We only want to do this if we are going to interrupt -// that loop. Normally we use VMIN 1 and VTIME 0, which ensures we pick up bytes when -// they come but don't spin burning cycles. -func (t *tScreen) nonBlocking(on bool) { - fd := int(os.Stdin.Fd()) +// tcSetBufParams is used by the tty driver on UNIX systems to configure the +// buffering parameters (minimum character count and minimum wait time in msec.) +func tcSetBufParams(fd int, vMin uint8, vTime uint8) error { + _ = syscall.SetNonblock(fd, true) tio, err := unix.IoctlGetTermios(fd, unix.TCGETS) if err != nil { - return + return err } - if on { - tio.Cc[unix.VMIN] = 0 - tio.Cc[unix.VTIME] = 0 - } else { - // block for any output - tio.Cc[unix.VTIME] = 0 - tio.Cc[unix.VMIN] = 1 + tio.Cc[unix.VMIN] = vMin + tio.Cc[unix.VTIME] = vTime + if err = unix.IoctlSetTermios(fd, unix.TCSETS, tio); err != nil { + return err } - - _ = syscall.SetNonblock(fd, on) - // We want to set this *right now*. - _ = unix.IoctlSetTermios(fd, unix.TCSETS, tio) + return nil } diff --git a/vendor/github.com/gdamore/tcell/v2/screen.go b/vendor/github.com/gdamore/tcell/v2/screen.go index 37d7894dc..2d9a9ad98 100644 --- a/vendor/github.com/gdamore/tcell/v2/screen.go +++ b/vendor/github.com/gdamore/tcell/v2/screen.go @@ -83,6 +83,13 @@ type Screen interface { // Furthermore, this will return nil if the Screen is finalized. PollEvent() Event + // HasPendingEvent returns true if PollEvent would return an event + // without blocking. If the screen is stopped and PollEvent would + // return nil, then the return value from this function is unspecified. + // The purpose of this function is to allow multiple events to be collected + // at once, to minimize screen redraws. + HasPendingEvent() bool + // PostEvent tries to post an event into the event stream. This // can fail if the event queue is full. In that case, the event // is dropped, and ErrEventQFull is returned. @@ -112,7 +119,7 @@ type Screen interface { // EnablePaste enables bracketed paste mode, if supported. EnablePaste() - // DisablePaste() disables bracketed paste mode. + // DisablePaste disables bracketed paste mode. DisablePaste() // HasMouse returns true if the terminal (apparently) supports a @@ -151,7 +158,7 @@ type Screen interface { CharacterSet() string // RegisterRuneFallback adds a fallback for runes that are not - // part of the character set -- for example one coudld register + // part of the character set -- for example one could register // o as a fallback for ΓΈ. This should be done cautiously for // characters that might be displayed ordinarily in language // specific text -- characters that could change the meaning of @@ -162,7 +169,7 @@ type Screen interface { // character set, those are used in preference. Also, standard // fallbacks for graphical characters in the ACSC terminfo string // are registered implicitly. - + // // The display string should be the same width as original rune. // This makes it possible to register two character replacements // for full width East Asian characters, for example. diff --git a/vendor/github.com/gdamore/tcell/v2/simulation.go b/vendor/github.com/gdamore/tcell/v2/simulation.go index 7cb720cb5..468aeebf7 100644 --- a/vendor/github.com/gdamore/tcell/v2/simulation.go +++ b/vendor/github.com/gdamore/tcell/v2/simulation.go @@ -360,6 +360,10 @@ func (s *simscreen) PollEvent() Event { } } +func (s *simscreen) HasPendingEvent() bool { + return len(s.evch) > 0 +} + func (s *simscreen) PostEventWait(ev Event) { s.evch <- ev } diff --git a/vendor/github.com/gdamore/tcell/v2/terminfo/a/aixterm/term.go b/vendor/github.com/gdamore/tcell/v2/terminfo/a/aixterm/term.go index 566df7bff..503c9199e 100644 --- a/vendor/github.com/gdamore/tcell/v2/terminfo/a/aixterm/term.go +++ b/vendor/github.com/gdamore/tcell/v2/terminfo/a/aixterm/term.go @@ -78,5 +78,6 @@ func init() { KeyF36: "\x1b[036q", KeyClear: "\x1b[144q", KeyBacktab: "\x1b[Z", + AutoMargin: true, }) } diff --git a/vendor/github.com/gdamore/tcell/v2/terminfo/a/alacritty/term.go b/vendor/github.com/gdamore/tcell/v2/terminfo/a/alacritty/term.go index e312fc48e..5b9799846 100644 --- a/vendor/github.com/gdamore/tcell/v2/terminfo/a/alacritty/term.go +++ b/vendor/github.com/gdamore/tcell/v2/terminfo/a/alacritty/term.go @@ -8,61 +8,62 @@ func init() { // alacritty terminal emulator terminfo.AddTerminfo(&terminfo.Terminfo{ - Name: "alacritty", - Columns: 80, - Lines: 24, - Colors: 256, - Bell: "\a", - Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b[?1049h\x1b[22;0;0t", - ExitCA: "\x1b[?1049l\x1b[23;0;0t", - ShowCursor: "\x1b[?12l\x1b[?25h", - HideCursor: "\x1b[?25l", - AttrOff: "\x1b(B\x1b[m", - Underline: "\x1b[4m", - Bold: "\x1b[1m", - Dim: "\x1b[2m", - Italic: "\x1b[3m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - EnterKeypad: "\x1b[?1h\x1b=", - ExitKeypad: "\x1b[?1l\x1b>", - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", - ResetFgBg: "\x1b[39;49m", - AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", - EnterAcs: "\x1b(0", - ExitAcs: "\x1b(B", - StrikeThrough:"\x1b[9m", - Mouse: "\x1b[<", - SetCursor: "\x1b[%i%p1%d;%p2%dH", - CursorBack1: "\b", - CursorUp1: "\x1b[A", - KeyUp: "\x1bOA", - KeyDown: "\x1bOB", - KeyRight: "\x1bOC", - KeyLeft: "\x1bOD", - KeyInsert: "\x1b[2~", - KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", - KeyHome: "\x1bOH", - KeyEnd: "\x1bOF", - KeyPgUp: "\x1b[5~", - KeyPgDn: "\x1b[6~", - KeyF1: "\x1bOP", - KeyF2: "\x1bOQ", - KeyF3: "\x1bOR", - KeyF4: "\x1bOS", - KeyF5: "\x1b[15~", - KeyF6: "\x1b[17~", - KeyF7: "\x1b[18~", - KeyF8: "\x1b[19~", - KeyF9: "\x1b[20~", - KeyF10: "\x1b[21~", - KeyF11: "\x1b[23~", - KeyF12: "\x1b[24~", - KeyBacktab: "\x1b[Z", - Modifiers: 1, + Name: "alacritty", + Columns: 80, + Lines: 24, + Colors: 256, + Bell: "\a", + Clear: "\x1b[H\x1b[2J", + EnterCA: "\x1b[?1049h\x1b[22;0;0t", + ExitCA: "\x1b[?1049l\x1b[23;0;0t", + ShowCursor: "\x1b[?12l\x1b[?25h", + HideCursor: "\x1b[?25l", + AttrOff: "\x1b(B\x1b[m", + Underline: "\x1b[4m", + Bold: "\x1b[1m", + Dim: "\x1b[2m", + Italic: "\x1b[3m", + Blink: "\x1b[5m", + Reverse: "\x1b[7m", + EnterKeypad: "\x1b[?1h\x1b=", + ExitKeypad: "\x1b[?1l\x1b>", + SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", + SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", + SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", + ResetFgBg: "\x1b[39;49m", + AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", + EnterAcs: "\x1b(0", + ExitAcs: "\x1b(B", + StrikeThrough: "\x1b[9m", + Mouse: "\x1b[<", + SetCursor: "\x1b[%i%p1%d;%p2%dH", + CursorBack1: "\b", + CursorUp1: "\x1b[A", + KeyUp: "\x1bOA", + KeyDown: "\x1bOB", + KeyRight: "\x1bOC", + KeyLeft: "\x1bOD", + KeyInsert: "\x1b[2~", + KeyDelete: "\x1b[3~", + KeyBackspace: "\u007f", + KeyHome: "\x1bOH", + KeyEnd: "\x1bOF", + KeyPgUp: "\x1b[5~", + KeyPgDn: "\x1b[6~", + KeyF1: "\x1bOP", + KeyF2: "\x1bOQ", + KeyF3: "\x1bOR", + KeyF4: "\x1bOS", + KeyF5: "\x1b[15~", + KeyF6: "\x1b[17~", + KeyF7: "\x1b[18~", + KeyF8: "\x1b[19~", + KeyF9: "\x1b[20~", + KeyF10: "\x1b[21~", + KeyF11: "\x1b[23~", + KeyF12: "\x1b[24~", + KeyBacktab: "\x1b[Z", + Modifiers: 1, + AutoMargin: true, }) } diff --git a/vendor/github.com/gdamore/tcell/v2/terminfo/a/ansi/term.go b/vendor/github.com/gdamore/tcell/v2/terminfo/a/ansi/term.go index 53e4e49ea..5c572fd49 100644 --- a/vendor/github.com/gdamore/tcell/v2/terminfo/a/ansi/term.go |