From e5df1c061356f6a582ad65b8b6fc38ecc4de18be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:56:28 +0000 Subject: [PATCH] Bump github.com/charmbracelet/bubbletea from 0.27.1 to 1.1.0 Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 0.27.1 to 1.1.0. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Changelog](https://github.com/charmbracelet/bubbletea/blob/main/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v0.27.1...v1.1.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- go.mod | 10 +- go.sum | 18 +- .../charmbracelet/bubbletea/focus.go | 9 + .../github.com/charmbracelet/bubbletea/key.go | 7 + .../charmbracelet/bubbletea/key_sequences.go | 12 + .../charmbracelet/bubbletea/nil_renderer.go | 3 + .../charmbracelet/bubbletea/options.go | 9 + .../charmbracelet/bubbletea/renderer.go | 9 + .../charmbracelet/bubbletea/screen.go | 20 + .../bubbletea/standard_renderer.go | 26 + .../github.com/charmbracelet/bubbletea/tea.go | 15 + .../github.com/charmbracelet/bubbletea/tty.go | 9 + .../github.com/charmbracelet/x/ansi/cursor.go | 45 + .../github.com/charmbracelet/x/ansi/kitty.go | 36 +- .../github.com/charmbracelet/x/ansi/mode.go | 21 + .../github.com/charmbracelet/x/ansi/parser.go | 105 +- .../x/ansi/parser/transition_table.go | 16 +- .../charmbracelet/x/ansi/parser_decode.go | 423 +++++ .../charmbracelet/x/ansi/truncate.go | 65 +- .../github.com/charmbracelet/x/ansi/width.go | 50 +- .../github.com/charmbracelet/x/ansi/wrap.go | 175 +- .../github.com/charmbracelet/x/ansi/xterm.go | 17 + .../github.com/charmbracelet/x/input/LICENSE | 21 - .../x/input/cancelreader_other.go | 14 - .../x/input/cancelreader_windows.go | 217 --- .../charmbracelet/x/input/clipboard.go | 9 - .../github.com/charmbracelet/x/input/color.go | 77 - .../charmbracelet/x/input/cursor.go | 10 - .../github.com/charmbracelet/x/input/da1.go | 18 - .../charmbracelet/x/input/driver.go | 129 -- .../charmbracelet/x/input/driver_other.go | 11 - .../charmbracelet/x/input/driver_windows.go | 273 --- .../github.com/charmbracelet/x/input/input.go | 47 - .../github.com/charmbracelet/x/input/key.go | 459 ----- .../github.com/charmbracelet/x/input/kitty.go | 281 --- .../github.com/charmbracelet/x/input/mod.go | 70 - .../github.com/charmbracelet/x/input/mode.go | 12 - .../github.com/charmbracelet/x/input/mouse.go | 248 --- .../github.com/charmbracelet/x/input/parse.go | 836 --------- .../github.com/charmbracelet/x/input/paste.go | 12 - .../github.com/charmbracelet/x/input/seq.go | 45 - .../github.com/charmbracelet/x/input/table.go | 388 ----- .../charmbracelet/x/input/termcap.go | 49 - .../charmbracelet/x/input/terminfo.go | 277 --- .../charmbracelet/x/input/win32input.go | 240 --- .../github.com/charmbracelet/x/input/xterm.go | 40 - .../charmbracelet/x/term/terminal.go | 114 -- .../charmbracelet/x/windows/LICENSE | 21 - .../github.com/charmbracelet/x/windows/doc.go | 3 - .../x/windows/syscall_windows.go | 10 - .../x/windows/zsyscall_windows.go | 55 - vendor/github.com/xo/terminfo/.gitignore | 9 - vendor/github.com/xo/terminfo/LICENSE | 21 - vendor/github.com/xo/terminfo/README.md | 139 -- vendor/github.com/xo/terminfo/caps.go | 31 - vendor/github.com/xo/terminfo/capvals.go | 1525 ----------------- vendor/github.com/xo/terminfo/color.go | 88 - vendor/github.com/xo/terminfo/dec.go | 245 --- vendor/github.com/xo/terminfo/load.go | 64 - vendor/github.com/xo/terminfo/param.go | 405 ----- vendor/github.com/xo/terminfo/stack.go | 48 - vendor/github.com/xo/terminfo/terminfo.go | 479 ------ vendor/modules.txt | 17 +- 63 files changed, 876 insertions(+), 7281 deletions(-) create mode 100644 vendor/github.com/charmbracelet/bubbletea/focus.go create mode 100644 vendor/github.com/charmbracelet/x/ansi/parser_decode.go delete mode 100644 vendor/github.com/charmbracelet/x/input/LICENSE delete mode 100644 vendor/github.com/charmbracelet/x/input/cancelreader_other.go delete mode 100644 vendor/github.com/charmbracelet/x/input/cancelreader_windows.go delete mode 100644 vendor/github.com/charmbracelet/x/input/clipboard.go delete mode 100644 vendor/github.com/charmbracelet/x/input/color.go delete mode 100644 vendor/github.com/charmbracelet/x/input/cursor.go delete mode 100644 vendor/github.com/charmbracelet/x/input/da1.go delete mode 100644 vendor/github.com/charmbracelet/x/input/driver.go delete mode 100644 vendor/github.com/charmbracelet/x/input/driver_other.go delete mode 100644 vendor/github.com/charmbracelet/x/input/driver_windows.go delete mode 100644 vendor/github.com/charmbracelet/x/input/input.go delete mode 100644 vendor/github.com/charmbracelet/x/input/key.go delete mode 100644 vendor/github.com/charmbracelet/x/input/kitty.go delete mode 100644 vendor/github.com/charmbracelet/x/input/mod.go delete mode 100644 vendor/github.com/charmbracelet/x/input/mode.go delete mode 100644 vendor/github.com/charmbracelet/x/input/mouse.go delete mode 100644 vendor/github.com/charmbracelet/x/input/parse.go delete mode 100644 vendor/github.com/charmbracelet/x/input/paste.go delete mode 100644 vendor/github.com/charmbracelet/x/input/seq.go delete mode 100644 vendor/github.com/charmbracelet/x/input/table.go delete mode 100644 vendor/github.com/charmbracelet/x/input/termcap.go delete mode 100644 vendor/github.com/charmbracelet/x/input/terminfo.go delete mode 100644 vendor/github.com/charmbracelet/x/input/win32input.go delete mode 100644 vendor/github.com/charmbracelet/x/input/xterm.go delete mode 100644 vendor/github.com/charmbracelet/x/windows/LICENSE delete mode 100644 vendor/github.com/charmbracelet/x/windows/doc.go delete mode 100644 vendor/github.com/charmbracelet/x/windows/syscall_windows.go delete mode 100644 vendor/github.com/charmbracelet/x/windows/zsyscall_windows.go delete mode 100644 vendor/github.com/xo/terminfo/.gitignore delete mode 100644 vendor/github.com/xo/terminfo/LICENSE delete mode 100644 vendor/github.com/xo/terminfo/README.md delete mode 100644 vendor/github.com/xo/terminfo/caps.go delete mode 100644 vendor/github.com/xo/terminfo/capvals.go delete mode 100644 vendor/github.com/xo/terminfo/color.go delete mode 100644 vendor/github.com/xo/terminfo/dec.go delete mode 100644 vendor/github.com/xo/terminfo/load.go delete mode 100644 vendor/github.com/xo/terminfo/param.go delete mode 100644 vendor/github.com/xo/terminfo/stack.go delete mode 100644 vendor/github.com/xo/terminfo/terminfo.go diff --git a/go.mod b/go.mod index 9cd6f49..0f83f63 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.0 require ( github.com/atotto/clipboard v0.1.4 - github.com/charmbracelet/bubbletea v0.27.1 + github.com/charmbracelet/bubbletea v1.1.0 github.com/spf13/cobra v1.8.1 github.com/tobischo/gokeepasslib/v3 v3.6.0 golang.org/x/term v0.23.0 @@ -13,10 +13,8 @@ require ( require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/charmbracelet/lipgloss v0.13.0 // indirect - github.com/charmbracelet/x/ansi v0.1.4 // indirect - github.com/charmbracelet/x/input v0.1.3 // indirect - github.com/charmbracelet/x/term v0.1.1 // indirect - github.com/charmbracelet/x/windows v0.1.2 // indirect + github.com/charmbracelet/x/ansi v0.2.3 // indirect + github.com/charmbracelet/x/term v0.2.0 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -29,8 +27,8 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/tobischo/argon2 v0.1.0 // indirect - github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect golang.org/x/crypto v0.25.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.16.0 // indirect diff --git a/go.sum b/go.sum index 7ed2f2d..f044f2e 100644 --- a/go.sum +++ b/go.sum @@ -2,18 +2,14 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= -github.com/charmbracelet/bubbletea v0.27.1 h1:/yhaJKX52pxG4jZVKCNWj/oq0QouPdXycriDRA6m6r8= -github.com/charmbracelet/bubbletea v0.27.1/go.mod h1:xc4gm5yv+7tbniEvQ0naiG9P3fzYhk16cTgDZQQW6YE= +github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c= +github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= -github.com/charmbracelet/x/ansi v0.1.4 h1:IEU3D6+dWwPSgZ6HBH+v6oUuZ/nVawMiWj5831KfiLM= -github.com/charmbracelet/x/ansi v0.1.4/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/input v0.1.3 h1:oy4TMhyGQsYs/WWJwu1ELUMFnjiUAXwtDf048fHbCkg= -github.com/charmbracelet/x/input v0.1.3/go.mod h1:1gaCOyw1KI9e2j00j/BBZ4ErzRZqa05w0Ghn83yIhKU= -github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= -github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw= -github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg= -github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= +github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqosGDEY= +github.com/charmbracelet/x/ansi v0.2.3/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= +github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -53,8 +49,6 @@ github.com/tobischo/argon2 v0.1.0 h1:mwAx/9DK/4rP0xzNifb/XMAf43dU3eG1B3aeF88qu4Y github.com/tobischo/argon2 v0.1.0/go.mod h1:4NLmLFwhWPbT66nRZNgcktV/mibJ6fESoeEp43h9GRw= github.com/tobischo/gokeepasslib/v3 v3.6.0 h1:7SVV7WNvW8EGb0UYETj2IwjbgfqKEmij2gUnndXSIxk= github.com/tobischo/gokeepasslib/v3 v3.6.0/go.mod h1:/T7C3zga6hsbLoLIzNN8wQ5OpeYEF81mEuUYF0CciA8= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= diff --git a/vendor/github.com/charmbracelet/bubbletea/focus.go b/vendor/github.com/charmbracelet/bubbletea/focus.go new file mode 100644 index 0000000..4d34bea --- /dev/null +++ b/vendor/github.com/charmbracelet/bubbletea/focus.go @@ -0,0 +1,9 @@ +package tea + +// FocusMsg represents a terminal focus message. +// This occurs when the terminal gains focus. +type FocusMsg struct{} + +// BlurMsg represents a terminal blur message. +// This occurs when the terminal loses focus. +type BlurMsg struct{} diff --git a/vendor/github.com/charmbracelet/bubbletea/key.go b/vendor/github.com/charmbracelet/bubbletea/key.go index 89a588a..ab4792a 100644 --- a/vendor/github.com/charmbracelet/bubbletea/key.go +++ b/vendor/github.com/charmbracelet/bubbletea/key.go @@ -628,6 +628,13 @@ func detectOneMsg(b []byte, canHaveMoreData bool) (w int, msg Msg) { } } + // Detect focus events. + var foundRF bool + foundRF, w, msg = detectReportFocus(b) + if foundRF { + return w, msg + } + // Detect bracketed paste. var foundbp bool foundbp, w, msg = detectBracketedPaste(b) diff --git a/vendor/github.com/charmbracelet/bubbletea/key_sequences.go b/vendor/github.com/charmbracelet/bubbletea/key_sequences.go index 4ba0f79..15483ef 100644 --- a/vendor/github.com/charmbracelet/bubbletea/key_sequences.go +++ b/vendor/github.com/charmbracelet/bubbletea/key_sequences.go @@ -117,3 +117,15 @@ func detectBracketedPaste(input []byte) (hasBp bool, width int, msg Msg) { return true, inputLen, KeyMsg(k) } + +// detectReportFocus detects a focus report sequence. +// nolint: gomnd +func detectReportFocus(input []byte) (hasRF bool, width int, msg Msg) { + switch { + case bytes.Equal(input, []byte("\x1b[I")): + return true, 3, FocusMsg{} + case bytes.Equal(input, []byte("\x1b[O")): + return true, 3, BlurMsg{} + } + return false, 0, nil +} diff --git a/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go b/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go index f4a83b6..0bc4a17 100644 --- a/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go +++ b/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go @@ -23,3 +23,6 @@ func (n nilRenderer) enableMouseSGRMode() {} func (n nilRenderer) disableMouseSGRMode() {} func (n nilRenderer) bracketedPasteActive() bool { return false } func (n nilRenderer) setWindowTitle(_ string) {} +func (n nilRenderer) reportFocus() bool { return false } +func (n nilRenderer) enableReportFocus() {} +func (n nilRenderer) disableReportFocus() {} diff --git a/vendor/github.com/charmbracelet/bubbletea/options.go b/vendor/github.com/charmbracelet/bubbletea/options.go index a810fe1..4a56fc8 100644 --- a/vendor/github.com/charmbracelet/bubbletea/options.go +++ b/vendor/github.com/charmbracelet/bubbletea/options.go @@ -234,3 +234,12 @@ func WithFPS(fps int) ProgramOption { p.fps = fps } } + +// WithReportFocus enables reporting when the terminal gains and lost focus. +// +// You can then check for FocusMsg and BlurMsg in your model's Update method. +func WithReportFocus() ProgramOption { + return func(p *Program) { + p.startupOptions |= withReportFocus + } +} diff --git a/vendor/github.com/charmbracelet/bubbletea/renderer.go b/vendor/github.com/charmbracelet/bubbletea/renderer.go index de3936e..9eb7943 100644 --- a/vendor/github.com/charmbracelet/bubbletea/renderer.go +++ b/vendor/github.com/charmbracelet/bubbletea/renderer.go @@ -70,6 +70,15 @@ type renderer interface { // setWindowTitle sets the terminal window title. setWindowTitle(string) + + // reportFocus returns whether reporting focus events is enabled. + reportFocus() bool + + // enableReportFocus reports focus events to the program. + enableReportFocus() + + // disableReportFocus stops reporting focus events to the program. + disableReportFocus() } // repaintMsg forces a full repaint. diff --git a/vendor/github.com/charmbracelet/bubbletea/screen.go b/vendor/github.com/charmbracelet/bubbletea/screen.go index 6256c15..dfec48f 100644 --- a/vendor/github.com/charmbracelet/bubbletea/screen.go +++ b/vendor/github.com/charmbracelet/bubbletea/screen.go @@ -144,6 +144,26 @@ func DisableBracketedPaste() Msg { // disableBracketedPasteMsg with DisableBracketedPaste. type disableBracketedPasteMsg struct{} +// enableReportFocusMsg is an internal message that signals to enable focus +// reporting. You can send an enableReportFocusMsg with EnableReportFocus. +type enableReportFocusMsg struct{} + +// EnableReportFocus is a special command that tells the Bubble Tea program to +// report focus events to the program. +func EnableReportFocus() Msg { + return enableReportFocusMsg{} +} + +// disableReportFocusMsg is an internal message that signals to disable focus +// reporting. You can send an disableReportFocusMsg with DisableReportFocus. +type disableReportFocusMsg struct{} + +// DisableReportFocus is a special command that tells the Bubble Tea program to +// stop reporting focus events to the program. +func DisableReportFocus() Msg { + return disableReportFocusMsg{} +} + // EnterAltScreen enters the alternate screen buffer, which consumes the entire // terminal window. ExitAltScreen will return the terminal to its former state. // diff --git a/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go b/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go index f81920d..59448e1 100644 --- a/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go +++ b/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go @@ -47,6 +47,9 @@ type standardRenderer struct { // whether or not we're currently using bracketed paste bpActive bool + // reportingFocus whether reporting focus events is enabled + reportingFocus bool + // renderer dimensions; usually the size of the window width int height int @@ -458,6 +461,29 @@ func (r *standardRenderer) bracketedPasteActive() bool { return r.bpActive } +func (r *standardRenderer) enableReportFocus() { + r.mtx.Lock() + defer r.mtx.Unlock() + + r.execute(ansi.EnableReportFocus) + r.reportingFocus = true +} + +func (r *standardRenderer) disableReportFocus() { + r.mtx.Lock() + defer r.mtx.Unlock() + + r.execute(ansi.DisableReportFocus) + r.reportingFocus = false +} + +func (r *standardRenderer) reportFocus() bool { + r.mtx.Lock() + defer r.mtx.Unlock() + + return r.reportingFocus +} + // setWindowTitle sets the terminal window title. func (r *standardRenderer) setWindowTitle(title string) { r.execute(ansi.SetWindowTitle(title)) diff --git a/vendor/github.com/charmbracelet/bubbletea/tea.go b/vendor/github.com/charmbracelet/bubbletea/tea.go index 62cd641..5ed9707 100644 --- a/vendor/github.com/charmbracelet/bubbletea/tea.go +++ b/vendor/github.com/charmbracelet/bubbletea/tea.go @@ -97,6 +97,7 @@ const ( // feature is on by default. withoutCatchPanics withoutBracketedPaste + withReportFocus ) // channelHandlers manages the series of channels returned by various processes. @@ -167,6 +168,7 @@ type Program struct { ignoreSignals uint32 bpWasActive bool // was the bracketed paste mode active before releasing the terminal? + reportFocus bool // was focus reporting active before releasing the terminal? filter func(Model, Msg) Msg @@ -390,6 +392,12 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { case disableBracketedPasteMsg: p.renderer.disableBracketedPaste() + case enableReportFocusMsg: + p.renderer.enableReportFocus() + + case disableReportFocusMsg: + p.renderer.disableReportFocus() + case execMsg: // NB: this blocks. p.exec(msg.cmd, msg.fn) @@ -542,6 +550,9 @@ func (p *Program) Run() (Model, error) { p.renderer.enableMouseAllMotion() p.renderer.enableMouseSGRMode() } + if p.startupOptions&withReportFocus != 0 { + p.renderer.enableReportFocus() + } // Start the renderer. p.renderer.start() @@ -694,6 +705,7 @@ func (p *Program) ReleaseTerminal() error { p.renderer.stop() p.altScreenWasActive = p.renderer.altScreen() p.bpWasActive = p.renderer.bracketedPasteActive() + p.reportFocus = p.renderer.reportFocus() } return p.restoreTerminalState() @@ -723,6 +735,9 @@ func (p *Program) RestoreTerminal() error { if p.bpWasActive { p.renderer.enableBracketedPaste() } + if p.reportFocus { + p.renderer.enableReportFocus() + } // If the output is a terminal, it may have been resized while another // process was at the foreground, in which case we may not have received diff --git a/vendor/github.com/charmbracelet/bubbletea/tty.go b/vendor/github.com/charmbracelet/bubbletea/tty.go index ed469ad..0250778 100644 --- a/vendor/github.com/charmbracelet/bubbletea/tty.go +++ b/vendor/github.com/charmbracelet/bubbletea/tty.go @@ -23,6 +23,11 @@ func (p *Program) suspend() { } func (p *Program) initTerminal() error { + if _, ok := p.renderer.(*nilRenderer); ok { + // No need to initialize the terminal if we're not rendering + return nil + } + if err := p.initInput(); err != nil { return err } @@ -39,6 +44,10 @@ func (p *Program) restoreTerminalState() error { p.renderer.showCursor() p.disableMouse() + if p.renderer.reportFocus() { + p.renderer.disableReportFocus() + } + if p.renderer.altScreen() { p.renderer.exitAltScreen() diff --git a/vendor/github.com/charmbracelet/x/ansi/cursor.go b/vendor/github.com/charmbracelet/x/ansi/cursor.go index 5f010fd..ec1fc4d 100644 --- a/vendor/github.com/charmbracelet/x/ansi/cursor.go +++ b/vendor/github.com/charmbracelet/x/ansi/cursor.go @@ -188,3 +188,48 @@ const SaveCursorPosition = "\x1b[s" // // See: https://vt100.net/docs/vt510-rm/SCORC.html const RestoreCursorPosition = "\x1b[u" + +// SetCursorStyle (DECSCUSR) returns a sequence for changing the cursor style. +// +// CSI Ps SP q +// +// Where Ps is the cursor style: +// +// 0: Blinking block +// 1: Blinking block (default) +// 2: Steady block +// 3: Blinking underline +// 4: Steady underline +// 5: Blinking bar (xterm) +// 6: Steady bar (xterm) +// +// See: https://vt100.net/docs/vt510-rm/DECSCUSR.html +// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81 +func SetCursorStyle(style int) string { + if style < 0 { + style = 0 + } + return "\x1b[" + strconv.Itoa(style) + " q" +} + +// SetPointerShape returns a sequence for changing the mouse pointer cursor +// shape. Use "default" for the default pointer shape. +// +// OSC 22 ; Pt ST +// OSC 22 ; Pt BEL +// +// Where Pt is the pointer shape name. The name can be anything that the +// operating system can understand. Some common names are: +// +// - copy +// - crosshair +// - default +// - ew-resize +// - n-resize +// - text +// - wait +// +// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands +func SetPointerShape(shape string) string { + return "\x1b]22;" + shape + "\x07" +} diff --git a/vendor/github.com/charmbracelet/x/ansi/kitty.go b/vendor/github.com/charmbracelet/x/ansi/kitty.go index 5bf8981..c56d8d1 100644 --- a/vendor/github.com/charmbracelet/x/ansi/kitty.go +++ b/vendor/github.com/charmbracelet/x/ansi/kitty.go @@ -8,11 +8,11 @@ const ( KittyDisambiguateEscapeCodes = 1 << iota KittyReportEventTypes KittyReportAlternateKeys - KittyReportAllKeys + KittyReportAllKeysAsEscapeCodes KittyReportAssociatedKeys KittyAllFlags = KittyDisambiguateEscapeCodes | KittyReportEventTypes | - KittyReportAlternateKeys | KittyReportAllKeys | KittyReportAssociatedKeys + KittyReportAlternateKeys | KittyReportAllKeysAsEscapeCodes | KittyReportAssociatedKeys ) // RequestKittyKeyboard is a sequence to request the terminal Kitty keyboard @@ -21,9 +21,41 @@ const ( // See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/ const RequestKittyKeyboard = "\x1b[?u" +// KittyKeyboard returns a sequence to request keyboard enhancements from the terminal. +// The flags argument is a bitmask of the Kitty keyboard protocol flags. While +// mode specifies how the flags should be interpreted. +// +// Possible values for flags mask: +// +// 1: Disambiguate escape codes +// 2: Report event types +// 4: Report alternate keys +// 8: Report all keys as escape codes +// 16: Report associated text +// +// Possible values for mode: +// +// 1: Set given flags and unset all others +// 2: Set given flags and keep existing flags unchanged +// 3: Unset given flags and keep existing flags unchanged +// +// See https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement +func KittyKeyboard(flags, mode int) string { + return "\x1b[=" + strconv.Itoa(flags) + ";" + strconv.Itoa(mode) + "u" +} + // PushKittyKeyboard returns a sequence to push the given flags to the terminal // Kitty Keyboard stack. // +// Possible values for flags mask: +// +// 0: Disable all features +// 1: Disambiguate escape codes +// 2: Report event types +// 4: Report alternate keys +// 8: Report all keys as escape codes +// 16: Report associated text +// // CSI > flags u // // See https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement diff --git a/vendor/github.com/charmbracelet/x/ansi/mode.go b/vendor/github.com/charmbracelet/x/ansi/mode.go index 4c39e78..7d25ddc 100644 --- a/vendor/github.com/charmbracelet/x/ansi/mode.go +++ b/vendor/github.com/charmbracelet/x/ansi/mode.go @@ -80,6 +80,15 @@ const ( RequestMouseAllMotion = "\x1b[?1003$p" ) +// Report Focus is a mode that makes the terminal report focus-in and focus-out events. +// +// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-FocusIn_FocusOut +const ( + EnableReportFocus = "\x1b[?1004h" + DisableReportFocus = "\x1b[?1004l" + RequestReportFocus = "\x1b[?1004$p" +) + // SGR Mouse Extension is a mode that determines whether the mouse reports events // formatted with SGR parameters. // @@ -121,6 +130,18 @@ const ( RequestSyncdOutput = "\x1b[?2026$p" ) +// Grapheme Clustering Mode is a mode that determines whether the terminal +// should look for grapheme clusters instead of single runes in the rendered +// text. This makes the terminal properly render combining characters such as +// emojis. +// +// See: https://github.com/contour-terminal/terminal-unicode-core +const ( + EnableGraphemeClustering = "\x1b[?2027h" + DisableGraphemeClustering = "\x1b[?2027l" + RequestGraphemeClustering = "\x1b[?2027$p" +) + // Win32Input is a mode that determines whether input is processed by the // Win32 console and Conpty. // diff --git a/vendor/github.com/charmbracelet/x/ansi/parser.go b/vendor/github.com/charmbracelet/x/ansi/parser.go index 4595b51..63654c0 100644 --- a/vendor/github.com/charmbracelet/x/ansi/parser.go +++ b/vendor/github.com/charmbracelet/x/ansi/parser.go @@ -2,6 +2,7 @@ package ansi import ( "unicode/utf8" + "unsafe" "github.com/charmbracelet/x/ansi/parser" ) @@ -34,20 +35,20 @@ type Parser struct { // ParamsLen keeps track of the number of parameters. // This is limited by the size of the Params buffer. + // + // This is also used when collecting UTF-8 runes to keep track of the + // number of rune bytes collected. ParamsLen int // Cmd contains the raw command along with the private marker and // intermediate bytes of the sequence. // The first lower byte contains the command byte, the next byte contains // the private marker, and the next byte contains the intermediate byte. + // + // This is also used when collecting UTF-8 runes treating it as a slice of + // 4 bytes. Cmd int - // RuneLen keeps track of the number of bytes collected for a UTF-8 rune. - RuneLen int - - // RuneBuf contains the bytes collected for a UTF-8 rune. - RuneBuf [utf8.MaxRune]byte - // State is the current state of the parser. State byte } @@ -56,13 +57,13 @@ type Parser struct { // If dataSize is zero, the underlying data buffer will be unlimited and will // grow as needed. func NewParser(paramsSize, dataSize int) *Parser { - s := &Parser{ - Params: make([]int, paramsSize), - Data: make([]byte, dataSize), - } + s := new(Parser) if dataSize <= 0 { + dataSize = 0 s.DataLen = -1 } + s.Params = make([]int, paramsSize) + s.Data = make([]byte, dataSize) return s } @@ -79,7 +80,13 @@ func (p *Parser) clear() { } p.ParamsLen = 0 p.Cmd = 0 - p.RuneLen = 0 +} + +// clearCmd clears the parser command, params len and data len. +func (p *Parser) clearCmd() { + p.Cmd = 0 + p.ParamsLen = 0 + p.DataLen = 0 } // StateName returns the name of the current state. @@ -106,37 +113,40 @@ func (p *Parser) Advance(dispatcher ParserDispatcher, b byte, more bool) parser. } func (p *Parser) collectRune(b byte) { - if p.RuneLen < utf8.UTFMax { - p.RuneBuf[p.RuneLen] = b - p.RuneLen++ + if p.ParamsLen >= utf8.UTFMax { + return } + + shift := p.ParamsLen * 8 + p.Cmd &^= 0xff << shift + p.Cmd |= int(b) << shift + p.ParamsLen++ } func (p *Parser) advanceUtf8(dispatcher ParserDispatcher, b byte) parser.Action { // Collect UTF-8 rune bytes. p.collectRune(b) - rw := utf8ByteLen(p.RuneBuf[0]) + rw := utf8ByteLen(byte(p.Cmd & 0xff)) if rw == -1 { // We panic here because the first byte comes from the state machine, // if this panics, it means there is a bug in the state machine! panic("invalid rune") // unreachable } - if p.RuneLen < rw { - return parser.NoneAction + if p.ParamsLen < rw { + return parser.CollectAction } - // We have enough bytes to decode the rune - bts := p.RuneBuf[:rw] - r, _ := utf8.DecodeRune(bts) + // We have enough bytes to decode the rune using unsafe + r, _ := utf8.DecodeRune((*[utf8.UTFMax]byte)(unsafe.Pointer(&p.Cmd))[:rw]) if dispatcher != nil { dispatcher(Rune(r)) } p.State = parser.GroundState - p.RuneLen = 0 + p.ParamsLen = 0 - return parser.NoneAction + return parser.PrintAction } func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action { @@ -149,16 +159,15 @@ func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action { // EscapeState. However, the parser state is not cleared in this case and // we need to clear it here before dispatching the esc sequence. if p.State != state { - switch p.State { - case parser.EscapeState: - p.performAction(d, parser.ClearAction, b) + if p.State == parser.EscapeState { + p.performAction(d, parser.ClearAction, state, b) } if action == parser.PutAction && p.State == parser.DcsEntryState && state == parser.DcsStringState { // XXX: This is a special case where we need to start collecting // non-string parameterized data i.e. doesn't follow the ECMA-48 § // 5.4.1 string parameters format. - p.performAction(d, parser.StartAction, 0) + p.performAction(d, parser.StartAction, state, 0) } } @@ -166,34 +175,34 @@ func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action { switch { case b == ESC && p.State == parser.EscapeState: // Two ESCs in a row - p.performAction(d, parser.ExecuteAction, b) + p.performAction(d, parser.ExecuteAction, state, b) if !more { // Two ESCs at the end of the buffer - p.performAction(d, parser.ExecuteAction, b) + p.performAction(d, parser.ExecuteAction, state, b) } case b == ESC && !more: // Last byte is an ESC - p.performAction(d, parser.ExecuteAction, b) + p.performAction(d, parser.ExecuteAction, state, b) case p.State == parser.EscapeState && b == 'P' && !more: // ESC P (DCS) at the end of the buffer - p.performAction(d, parser.DispatchAction, b) + p.performAction(d, parser.DispatchAction, state, b) case p.State == parser.EscapeState && b == 'X' && !more: // ESC X (SOS) at the end of the buffer - p.performAction(d, parser.DispatchAction, b) + p.performAction(d, parser.DispatchAction, state, b) case p.State == parser.EscapeState && b == '[' && !more: // ESC [ (CSI) at the end of the buffer - p.performAction(d, parser.DispatchAction, b) + p.performAction(d, parser.DispatchAction, state, b) case p.State == parser.EscapeState && b == ']' && !more: // ESC ] (OSC) at the end of the buffer - p.performAction(d, parser.DispatchAction, b) + p.performAction(d, parser.DispatchAction, state, b) case p.State == parser.EscapeState && b == '^' && !more: // ESC ^ (PM) at the end of the buffer - p.performAction(d, parser.DispatchAction, b) + p.performAction(d, parser.DispatchAction, state, b) case p.State == parser.EscapeState && b == '_' && !more: // ESC _ (APC) at the end of the buffer - p.performAction(d, parser.DispatchAction, b) + p.performAction(d, parser.DispatchAction, state, b) default: - p.performAction(d, action, b) + p.performAction(d, action, state, b) } p.State = state @@ -201,7 +210,7 @@ func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action { return action } -func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action, b byte) { +func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action, state parser.State, b byte) { switch action { case parser.IgnoreAction: break @@ -210,9 +219,7 @@ func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action p.clear() case parser.PrintAction: - if utf8ByteLen(b) > 1 { - p.collectRune(b) - } else if dispatcher != nil { + if dispatcher != nil { dispatcher(Rune(b)) } @@ -228,10 +235,16 @@ func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action p.Cmd |= int(b) << parser.MarkerShift case parser.CollectAction: - // Collect intermediate bytes - // we only store the last intermediate byte - p.Cmd &^= 0xff << parser.IntermedShift - p.Cmd |= int(b) << parser.IntermedShift + if state == parser.Utf8State { + // Reset the UTF-8 counter + p.ParamsLen = 0 + p.collectRune(b) + } else { + // Collect intermediate bytes + // we only store the last intermediate byte + p.Cmd &^= 0xff << parser.IntermedShift + p.Cmd |= int(b) << parser.IntermedShift + } case parser.ParamAction: // Collect parameters @@ -260,8 +273,8 @@ func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action } case parser.StartAction: - if p.DataLen < 0 { - p.Data = make([]byte, 0) + if p.DataLen < 0 && p.Data != nil { + p.Data = p.Data[:0] } else { p.DataLen = 0 } diff --git a/vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go b/vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go index febde15..5d368eb 100644 --- a/vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go +++ b/vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go @@ -81,6 +81,9 @@ func r(start, end byte) []byte { // - We don't ignore 0x3A (':') when building Csi and Dcs parameters and // instead use it to denote sub-parameters. // - Support dispatching SosPmApc sequences. +// - The DEL (0x7F) character is executed in the Ground state. +// - The DEL (0x7F) character is collected in the DcsPassthrough string state. +// - The ST C1 control character (0x9C) is executed and not ignored. func GenerateTransitionTable() TransitionTable { table := NewTransitionTable(DefaultTableSize) table.SetDefault(NoneAction, GroundState) @@ -91,7 +94,7 @@ func GenerateTransitionTable() TransitionTable { table.AddMany([]byte{0x18, 0x1a, 0x99, 0x9a}, state, ExecuteAction, GroundState) table.AddRange(0x80, 0x8F, state, ExecuteAction, GroundState) table.AddRange(0x90, 0x97, state, ExecuteAction, GroundState) - table.AddOne(0x9C, state, IgnoreAction, GroundState) + table.AddOne(0x9C, state, ExecuteAction, GroundState) // Anywhere -> Escape table.AddOne(0x1B, state, ClearAction, EscapeState) // Anywhere -> SosStringState @@ -107,16 +110,17 @@ func GenerateTransitionTable() TransitionTable { // Anywhere -> OscString table.AddOne(0x9D, state, StartAction, OscStringState) // Anywhere -> Utf8 - table.AddRange(0xC2, 0xDF, state, PrintAction, Utf8State) // UTF8 2 byte sequence - table.AddRange(0xE0, 0xEF, state, PrintAction, Utf8State) // UTF8 3 byte sequence - table.AddRange(0xF0, 0xF4, state, PrintAction, Utf8State) // UTF8 4 byte sequence + table.AddRange(0xC2, 0xDF, state, CollectAction, Utf8State) // UTF8 2 byte sequence + table.AddRange(0xE0, 0xEF, state, CollectAction, Utf8State) // UTF8 3 byte sequence + table.AddRange(0xF0, 0xF4, state, CollectAction, Utf8State) // UTF8 4 byte sequence } // Ground table.AddRange(0x00, 0x17, GroundState, ExecuteAction, GroundState) table.AddOne(0x19, GroundState, ExecuteAction, GroundState) table.AddRange(0x1C, 0x1F, GroundState, ExecuteAction, GroundState) - table.AddRange(0x20, 0x7F, GroundState, PrintAction, GroundState) + table.AddRange(0x20, 0x7E, GroundState, PrintAction, GroundState) + table.AddOne(0x7F, GroundState, ExecuteAction, GroundState) // EscapeIntermediate table.AddRange(0x00, 0x17, EscapeIntermediateState, ExecuteAction, EscapeIntermediateState) @@ -209,7 +213,7 @@ func GenerateTransitionTable() TransitionTable { table.AddOne(0x19, DcsStringState, PutAction, DcsStringState) table.AddRange(0x1C, 0x1F, DcsStringState, PutAction, DcsStringState) table.AddRange(0x20, 0x7E, DcsStringState, PutAction, DcsStringState) - table.AddOne(0x7F, DcsStringState, IgnoreAction, DcsStringState) + table.AddOne(0x7F, DcsStringState, PutAction, DcsStringState) table.AddRange(0x80, 0xFF, DcsStringState, PutAction, DcsStringState) // Allow Utf8 characters by extending the printable range from 0x7F to 0xFF // ST, CAN, SUB, and ESC terminate the sequence table.AddOne(0x1B, DcsStringState, DispatchAction, EscapeState) diff --git a/vendor/github.com/charmbracelet/x/ansi/parser_decode.go b/vendor/github.com/charmbracelet/x/ansi/parser_decode.go new file mode 100644 index 0000000..76688d0 --- /dev/null +++ b/vendor/github.com/charmbracelet/x/ansi/parser_decode.go @@ -0,0 +1,423 @@ +package ansi + +import ( + "bytes" + "strings" + "unicode/utf8" + + "github.com/charmbracelet/x/ansi/parser" + "github.com/rivo/uniseg" +) + +// State represents the state of the ANSI escape sequence parser used by +// [DecodeSequence]. +type State = byte + +// ANSI escape sequence states used by [DecodeSequence]. +const ( + NormalState State = iota + MarkerState + ParamsState + IntermedState + EscapeState + StringState +) + +// DecodeSequence decodes the first ANSI escape sequence or a printable +// grapheme from the given data. It returns the sequence slice, the number of +// bytes read, the cell width for each sequence, and the new state. +// +// The cell width will always be 0 for control and escape sequences, 1 for +// ASCII printable characters, and the number of cells other Unicode characters +// occupy. It uses the uniseg package to calculate the width of Unicode +// graphemes and characters. This means it will always do grapheme clustering +// (mode 2027). +// +// Passing a non-nil [*Parser] as the last argument will allow the decoder to +// collect sequence parameters, data, and commands. The parser cmd will have +// the packed command value that contains intermediate and marker characters. +// In the case of a OSC sequence, the cmd will be the OSC command number. Use +// [Cmd] and [Param] types to unpack command intermediates and markers as well +// as parameters. +// +// Zero [p.Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the +// validity of other data sequences, OSC, DCS, etc, will require checking for +// the returned sequence terminator bytes such as ST (ESC \\) and BEL). +// +// We store the command byte in [p.Cmd] in the most significant byte, the +// marker byte in the next byte, and the intermediate byte in the least +// significant byte. This is done to avoid using a struct to store the command +// and its intermediates and markers. The command byte is always the least +// significant byte i.e. [p.Cmd & 0xff]. Use the [Cmd] type to unpack the +// command, intermediate, and marker bytes. Note that we only collect the last +// marker character and intermediate byte. +// +// The [p.Params] slice will contain the parameters of the sequence. Any +// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type +// to unpack the parameters. +// +// Example: +// +// var state byte // the initial state is always zero [NormalState] +// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional) +// input := []byte("\x1b[31mHello, World!\x1b[0m") +// for len(input) > 0 { +// seq, width, n, newState := DecodeSequence(input, state, p) +// log.Printf("seq: %q, width: %d", seq, width) +// state = newState +// input = input[n:] +// } +func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width int, n int, newState byte) { + for i := 0; i < len(b); i++ { + c := b[i] + + switch state { + case NormalState: + switch c { + case ESC: + if p != nil { + if len(p.Params) > 0 { + p.Params[0] = parser.MissingParam + } + p.Cmd = 0 + p.ParamsLen = 0 + p.DataLen = 0 + } + state = EscapeState + continue + case CSI, DCS: + if p != nil { + if len(p.Params) > 0 { + p.Params[0] = parser.MissingParam + } + p.Cmd = 0 + p.ParamsLen = 0 + p.DataLen = 0 + } + state = MarkerState + continue + case OSC, APC, SOS, PM: + if p != nil { + p.Cmd = parser.MissingCommand + p.DataLen = 0 + } + state = StringState + continue + } + + if p != nil { + p.DataLen = 0 + p.ParamsLen = 0 + p.Cmd = 0 + } + if c > US && c < DEL { + // ASCII printable characters + return b[i : i+1], 1, 1, NormalState + } + + if c <= US || c == DEL || c < 0xC0 { + // C0 & C1 control characters & DEL + return b[i : i+1], 0, 1, NormalState + } + + if utf8.RuneStart(c) { + seq, _, width, _ = FirstGraphemeCluster(b, -1) + i += len(seq) + return b[:i], width, i, NormalState + } + + // Invalid UTF-8 sequence + return b[:i], 0, i, NormalState + case MarkerState: + if c >= '<' && c <= '?' { + if p != nil { + // We only collect the last marker character. + p.Cmd &^= 0xff << parser.MarkerShift + p.Cmd |= int(c) << parser.MarkerShift + } + break + } + + state = ParamsState + fallthrough + case ParamsState: + if c >= '0' && c <= '9' { + if p != nil { + if p.Params[p.ParamsLen] == parser.MissingParam { + p.Params[p.ParamsLen] = 0 + } + + p.Params[p.ParamsLen] *= 10 + p.Params[p.ParamsLen] += int(c - '0') + } + break + } + + if c == ':' { + if p != nil { + p.Params[p.ParamsLen] |= parser.HasMoreFlag + } + } + + if c == ';' || c == ':' { + if p != nil { + p.ParamsLen++ + if p.ParamsLen < len(p.Params) { + p.Params[p.ParamsLen] = parser.MissingParam + } + } + break + } + + state = IntermedState + fallthrough + case IntermedState: + if c >= ' ' && c <= '/' { + if p != nil { + p.Cmd &^= 0xff << parser.IntermedShift + p.Cmd |= int(c) << parser.IntermedShift + } + break + } + + state = NormalState + if c >= '@' && c <= '~' { + if p != nil { + // Increment the last parameter + if p.ParamsLen > 0 && p.ParamsLen < len(p.Params)-1 || + p.ParamsLen == 0 && len(p.Params) > 0 && p.Params[0] != parser.MissingParam { + p.ParamsLen++ + } + + p.Cmd &^= 0xff + p.Cmd |= int(c) + } + + if HasDcsPrefix(b) { + // Continue to collect DCS data + if p != nil { + p.DataLen = 0 + } + state = StringState + continue + } + + return b[:i+1], 0, i + 1, state + } + + // Invalid CSI/DCS sequence + return b[:i], 0, i, NormalState + case EscapeState: + switch c { + case '[', 'P': + if p != nil { + if len(p.Params) > 0 { + p.Params[0] = parser.MissingParam + } + p.ParamsLen = 0 + p.Cmd = 0 + } + state = MarkerState + continue + case ']', 'X', '^', '_': + if p != nil { + p.Cmd = parser.MissingCommand + p.DataLen = 0 + } + state = StringState + continue + } + + if c >= ' ' && c <= '/' { + if p != nil { + p.Cmd &^= 0xff << parser.IntermedShift + p.Cmd |= int(c) << parser.IntermedShift + } + continue + } else if c >= '0' && c <= '~' { + if p != nil { + p.Cmd &^= 0xff + p.Cmd |= int(c) + } + return b[:i+1], 0, i + 1, NormalState + } + + // Invalid escape sequence + return b[:i], 0, i, NormalState + case StringState: + switch c { + case BEL: + if HasOscPrefix(b) { + return b[:i+1], 0, i + 1, NormalState + } + case CAN, SUB: + // Cancel the sequence + return b[:i], 0, i, NormalState + case ST: + return b[:i+1], 0, i + 1, NormalState + case ESC: + if HasStPrefix(b[i:]) { + // End of string 7-bit (ST) + return b[:i+2], 0, i + 2, NormalState + } + + // Otherwise, cancel the sequence + return b[:i], 0, i, NormalState + } + + if p != nil && p.DataLen < len(p.Data) { + p.Data[p.DataLen] = c + p.DataLen++ + + // Parse the OSC command number + if c == ';' && p.Cmd == parser.MissingCommand && HasOscPrefix(b) { + for j := 0; j < p.DataLen; j++ { + d := p.Data[j] + if d < '0' || d > '9' { + break + } + if p.Cmd == parser.MissingCommand { + p.Cmd = 0 + } + p.Cmd *= 10 + p.Cmd += int(d - '0') + } + } + } + } + } + + return b, 0, len(b), state +} + +// Index returns the index of the first occurrence of the given byte slice in +// the data. It returns -1 if the byte slice is not found. +func Index[T string | []byte](data, b T) int { + switch data := any(data).(type) { + case string: + return strings.Index(data, string(b)) + case []byte: + return bytes.Index(data, []byte(b)) + } + panic("unreachable") +} + +// Equal returns true if the given byte slices are equal. +func Equal[T string | []byte](a, b T) bool { + return string(a) == string(b) +} + +// HasPrefix returns true if the given byte slice has prefix. +func HasPrefix[T string | []byte](b, prefix T) bool { + return len(b) >= len(prefix) && Equal(b[0:len(prefix)], prefix) +} + +// HasSuffix returns true if the given byte slice has suffix. +func HasSuffix[T string | []byte](b, suffix T) bool { + return len(b) >= len(suffix) && Equal(b[len(b)-len(suffix):], suffix) +} + +// HasCsiPrefix returns true if the given byte slice has a CSI prefix. +func HasCsiPrefix[T string | []byte](b T) bool { + return (len(b) > 0 && b[0] == CSI) || + (len(b) > 1 && b[0] == ESC && b[1] == '[') +} + +// HasOscPrefix returns true if the given byte slice has an OSC prefix. +func HasOscPrefix[T string | []byte](b T) bool { + return (len(b) > 0 && b[0] == OSC) || + (len(b) > 1 && b[0] == ESC && b[1] == ']') +} + +// HasApcPrefix returns true if the given byte slice has an APC prefix. +func HasApcPrefix[T string | []byte](b T) bool { + return (len(b) > 0 && b[0] == APC) || + (len(b) > 1 && b[0] == ESC && b[1] == '_') +} + +// HasDcsPrefix returns true if the given byte slice has a DCS prefix. +func HasDcsPrefix[T string | []byte](b T) bool { + return (len(b) > 0 && b[0] == DCS) || + (len(b) > 1 && b[0] == ESC && b[1] == 'P') +} + +// HasSosPrefix returns true if the given byte slice has a SOS prefix. +func HasSosPrefix[T string | []byte](b T) bool { + return (len(b) > 0 && b[0] == SOS) || + (len(b) > 1 && b[0] == ESC && b[1] == 'X') +} + +// HasPmPrefix returns true if the given byte slice has a PM prefix. +func HasPmPrefix[T string | []byte](b T) bool { + return (len(b) > 0 && b[0] == PM) || + (len(b) > 1 && b[0] == ESC && b[1] == '^') +} + +// HasStPrefix returns true if the given byte slice has a ST prefix. +func HasStPrefix[T string | []byte](b T) bool { + return (len(b) > 0 && b[0] == ST) || + (len(b) > 1 && b[0] == ESC && b[1] == '\\') +} + +// HasEscPrefix returns true if the given byte slice has an ESC prefix. +func HasEscPrefix[T string | []byte](b T) bool { + return len(b) > 0 && b[0] == ESC +} + +// FirstGraphemeCluster returns the first grapheme cluster in the given string or byte slice. +// This is a syntactic sugar function that wraps +// uniseg.FirstGraphemeClusterInString and uniseg.FirstGraphemeCluster. +func FirstGraphemeCluster[T string | []byte](b T, state int) (T, T, int, int) { + switch b := any(b).(type) { + case string: + cluster, rest, width, newState := uniseg.FirstGraphemeClusterInString(b, state) + return T(cluster), T(rest), width, newState + case []byte: + cluster, rest, width, newState := uniseg.FirstGraphemeCluster(b, state) + return T(cluster), T(rest), width, newState + } + panic("unreachable") +} + +// Cmd represents a sequence command. This is used to pack/unpack a sequence +// command with its intermediate and marker characters. Those are commonly +// found in CSI and DCS sequences. +type Cmd int + +// Marker returns the marker byte of the CSI sequence. +// This is always gonna be one of the following '<' '=' '>' '?' and in the +// range of 0x3C-0x3F. +// Zero is returned if the sequence does not have a marker. +func (c Cmd) Marker() int { + return parser.Marker(int(c)) +} + +// Intermediate returns the intermediate byte of the CSI sequence. +// An intermediate byte is in the range of 0x20-0x2F. This includes these +// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+', +// ',', '-', '.', '/'. +// Zero is returned if the sequence does not have an intermediate byte. +func (c Cmd) Intermediate() int { + return parser.Intermediate(int(c)) +} + +// Command returns the command byte of the CSI sequence. +func (c Cmd) Command() int { + return parser.Command(int(c)) +} + +// Param represents a sequence parameter. Sequence parameters with +// sub-parameters are packed with the HasMoreFlag set. This is used to unpack +// the parameters from a CSI and DCS sequences. +type Param int + +// Param returns the parameter at the given index. +// It returns -1 if the parameter does not exist. +func (s Param) Param() int { + return int(s) & parser.ParamMask +} + +// HasMore returns true if the parameter has more sub-parameters. +func (s Param) HasMore() bool { + return int(s)&parser.HasMoreFlag != 0 +} diff --git a/vendor/github.com/charmbracelet/x/ansi/truncate.go b/vendor/github.com/charmbracelet/x/ansi/truncate.go index 11ee112..db0782c 100644 --- a/vendor/github.com/charmbracelet/x/ansi/truncate.go +++ b/vendor/github.com/charmbracelet/x/ansi/truncate.go @@ -26,7 +26,6 @@ func Truncate(s string, length int, tail string) string { var buf bytes.Buffer curWidth := 0 ignoring := false - gstate := -1 pstate := parser.GroundState // initial state b := []byte(s) i := 0 @@ -38,44 +37,40 @@ func Truncate(s string, length int, tail string) string { // collect ANSI escape codes until we reach the end of string. for i < len(b) { state, action := parser.Table.Transition(pstate, b[i]) + if state == parser.Utf8State { + // This action happens when we transition to the Utf8State. + var width int + cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) - switch action { - case parser.PrintAction: - if utf8ByteLen(b[i]) > 1 { - // This action happens when we transition to the Utf8State. - var width int - cluster, _, width, gstate = uniseg.FirstGraphemeCluster(b[i:], gstate) - - // increment the index by the length of the cluster - i += len(cluster) - - // Are we ignoring? Skip to the next byte - if ignoring { - continue - } - - // Is this gonna be too wide? - // If so write the tail and stop collecting. - if curWidth+width > length && !ignoring { - ignoring = true - buf.WriteString(tail) - } - - if curWidth+width > length { - continue - } - - curWidth += width - for _, r := range cluster { - buf.WriteByte(r) - } - - gstate = -1 // reset grapheme state otherwise, width calculation might be off - // Done collecting, now we're back in the ground state. - pstate = parser.GroundState + // increment the index by the length of the cluster + i += len(cluster) + + // Are we ignoring? Skip to the next byte + if ignoring { + continue + } + + // Is this gonna be too wide? + // If so write the tail and stop collecting. + if curWidth+width > length && !ignoring { + ignoring = true + buf.WriteString(tail) + } + + if curWidth+width > length { continue } + curWidth += width + buf.Write(cluster) + + // Done collecting, now we're back in the ground state. + pstate = parser.GroundState + continue + } + + switch action { + case parser.PrintAction: // Is this gonna be too wide? // If so write the tail and stop collecting. if curWidth >= length && !ignoring { diff --git a/vendor/github.com/charmbracelet/x/ansi/width.go b/vendor/github.com/charmbracelet/x/ansi/width.go index 119f193..80890e4 100644 --- a/vendor/github.com/charmbracelet/x/ansi/width.go +++ b/vendor/github.com/charmbracelet/x/ansi/width.go @@ -19,13 +19,7 @@ func Strip(s string) string { // This implements a subset of the Parser to only collect runes and // printable characters. for i := 0; i < len(s); i++ { - var state, action byte - if pstate != parser.Utf8State { - state, action = parser.Table.Transition(pstate, s[i]) - } - - switch { - case pstate == parser.Utf8State: + if pstate == parser.Utf8State { // During this state, collect rw bytes to form a valid rune in the // buffer. After getting all the rune bytes into the buffer, // transition to GroundState and reset the counters. @@ -37,16 +31,19 @@ func Strip(s string) string { pstate = parser.GroundState ri = 0 rw = 0 - case action == parser.PrintAction: - // This action happens when we transition to the Utf8State. - if w := utf8ByteLen(s[i]); w > 1 { - rw = w + continue + } + + state, action := parser.Table.Transition(pstate, s[i]) + switch action { + case parser.CollectAction: + if state == parser.Utf8State { + // This action happens when we transition to the Utf8State. + rw = utf8ByteLen(s[i]) buf.WriteByte(s[i]) ri++ - break } - fallthrough - case action == parser.ExecuteAction: + case parser.PrintAction, parser.ExecuteAction: // collects printable ASCII and non-printable characters buf.WriteByte(s[i]) } @@ -71,7 +68,6 @@ func StringWidth(s string) int { } var ( - gstate = -1 pstate = parser.GroundState // initial state cluster string width int @@ -79,21 +75,17 @@ func StringWidth(s string) int { for i := 0; i < len(s); i++ { state, action := parser.Table.Transition(pstate, s[i]) - switch action { - case parser.PrintAction: - if utf8ByteLen(s[i]) > 1 { - var w int - cluster, _, w, gstate = uniseg.FirstGraphemeClusterInString(s[i:], gstate) - width += w - i += len(cluster) - 1 - pstate = parser.GroundState - continue - } + if state == parser.Utf8State { + var w int + cluster, _, w, _ = uniseg.FirstGraphemeClusterInString(s[i:], -1) + width += w + i += len(cluster) - 1 + pstate = parser.GroundState + continue + } + + if action == parser.PrintAction { width++ - fallthrough - default: - // Reset uniseg state when we're not in a printable state. - gstate = -1 } pstate = state diff --git a/vendor/github.com/charmbracelet/x/ansi/wrap.go b/vendor/github.com/charmbracelet/x/ansi/wrap.go index 9aa9b64..2cab5ce 100644 --- a/vendor/github.com/charmbracelet/x/ansi/wrap.go +++ b/vendor/github.com/charmbracelet/x/ansi/wrap.go @@ -27,7 +27,6 @@ func Hardwrap(s string, limit int, preserveSpace bool) string { buf bytes.Buffer curWidth int forceNewline bool - gstate = -1 pstate = parser.GroundState // initial state b = []byte(s) ) @@ -40,33 +39,30 @@ func Hardwrap(s string, limit int, preserveSpace bool) string { i := 0 for i < len(b) { state, action := parser.Table.Transition(pstate, b[i]) + if state == parser.Utf8State { + var width int + cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) + i += len(cluster) - switch action { - case parser.PrintAction: - if utf8ByteLen(b[i]) > 1 { - var width int - cluster, _, width, gstate = uniseg.FirstGraphemeCluster(b[i:], gstate) - i += len(cluster) - - if curWidth+width > limit { - addNewline() - } - if !preserveSpace && curWidth == 0 && len(cluster) <= 4 { - // Skip spaces at the beginning of a line - if r, _ := utf8.DecodeRune(cluster); r != utf8.RuneError && unicode.IsSpace(r) { - pstate = parser.GroundState - continue - } + if curWidth+width > limit { + addNewline() + } + if !preserveSpace && curWidth == 0 && len(cluster) <= 4 { + // Skip spaces at the beginning of a line + if r, _ := utf8.DecodeRune(cluster); r != utf8.RuneError && unicode.IsSpace(r) { + pstate = parser.GroundState + continue } - - buf.Write(cluster) - curWidth += width - gstate = -1 // reset grapheme state otherwise, width calculation might be off - pstate = parser.GroundState - continue } - fallthrough - case parser.ExecuteAction: + + buf.Write(cluster) + curWidth += width + pstate = parser.GroundState + continue + } + + switch action { + case parser.PrintAction, parser.ExecuteAction: if b[i] == '\n' { addNewline() forceNewline = false @@ -122,7 +118,6 @@ func Wordwrap(s string, limit int, breakpoints string) string { space bytes.Buffer curWidth int wordLen int - gstate = -1 pstate = parser.GroundState // initial state b = []byte(s) ) @@ -154,37 +149,35 @@ func Wordwrap(s string, limit int, breakpoints string) string { i := 0 for i < len(b) { state, action := parser.Table.Transition(pstate, b[i]) + if state == parser.Utf8State { + var width int + cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) + i += len(cluster) - switch action { - case parser.PrintAction: - if utf8ByteLen(b[i]) > 1 { - var width int - cluster, _, width, gstate = uniseg.FirstGraphemeCluster(b[i:], gstate) - i += len(cluster) - - r, _ := utf8.DecodeRune(cluster) - if r != utf8.RuneError && unicode.IsSpace(r) && r != nbsp { - addWord() - space.WriteRune(r) - } else if bytes.ContainsAny(cluster, breakpoints) { - addSpace() - addWord() - buf.Write(cluster) - curWidth++ - } else { - word.Write(cluster) - wordLen += width - if curWidth+space.Len()+wordLen > limit && - wordLen < limit { - addNewline() - } + r, _ := utf8.DecodeRune(cluster) + if r != utf8.RuneError && unicode.IsSpace(r) && r != nbsp { + addWord() + space.WriteRune(r) + } else if bytes.ContainsAny(cluster, breakpoints) { + addSpace() + addWord() + buf.Write(cluster) + curWidth++ + } else { + word.Write(cluster) + wordLen += width + if curWidth+space.Len()+wordLen > limit && + wordLen < limit { + addNewline() } - - pstate = parser.GroundState - continue } - fallthrough - case parser.ExecuteAction: + + pstate = parser.GroundState + continue + } + + switch action { + case parser.PrintAction, parser.ExecuteAction: r := rune(b[i]) switch { case r == '\n': @@ -251,9 +244,8 @@ func Wrap(s string, limit int, breakpoints string) string { buf bytes.Buffer word bytes.Buffer space bytes.Buffer - curWidth int // written width of the line - wordLen int // word buffer len without ANSI escape codes - gstate = -1 + curWidth int // written width of the line + wordLen int // word buffer len without ANSI escape codes pstate = parser.GroundState // initial state b = []byte(s) ) @@ -285,49 +277,46 @@ func Wrap(s string, limit int, breakpoints string) string { i := 0 for i < len(b) { state, action := parser.Table.Transition(pstate, b[i]) + if state == parser.Utf8State { + var width int + cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) + i += len(cluster) - switch action { - case parser.PrintAction: - if utf8ByteLen(b[i]) > 1 { - var width int - cluster, _, width, gstate = uniseg.FirstGraphemeCluster(b[i:], gstate) - i += len(cluster) - - r, _ := utf8.DecodeRune(cluster) - switch { - case r != utf8.RuneError && unicode.IsSpace(r) && r != nbsp: // nbsp is a non-breaking space - addWord() - space.WriteRune(r) - case bytes.ContainsAny(cluster, breakpoints): - addSpace() - if curWidth+wordLen+width > limit { - word.Write(cluster) - wordLen += width - } else { - addWord() - buf.Write(cluster) - curWidth += width - } - default: - if wordLen+width > limit { - // Hardwrap the word if it's too long - addWord() - } - + r, _ := utf8.DecodeRune(cluster) + switch { + case r != utf8.RuneError && unicode.IsSpace(r) && r != nbsp: // nbsp is a non-breaking space + addWord() + space.WriteRune(r) + case bytes.ContainsAny(cluster, breakpoints): + addSpace() + if curWidth+wordLen+width > limit { word.Write(cluster) wordLen += width - - if curWidth+wordLen+space.Len() > limit { - addNewline() - } + } else { + addWord() + buf.Write(cluster) + curWidth += width + } + default: + if wordLen+width > limit { + // Hardwrap the word if it's too long + addWord() } - pstate = parser.GroundState - continue + word.Write(cluster) + wordLen += width + + if curWidth+wordLen+space.Len() > limit { + addNewline() + } } - fallthrough - case parser.ExecuteAction: + pstate = parser.GroundState + continue + } + + switch action { + case parser.PrintAction, parser.ExecuteAction: switch r := rune(b[i]); { case r == '\n': if wordLen == 0 { diff --git a/vendor/github.com/charmbracelet/x/ansi/xterm.go b/vendor/github.com/charmbracelet/x/ansi/xterm.go index e2eb10a..f87712a 100644 --- a/vendor/github.com/charmbracelet/x/ansi/xterm.go +++ b/vendor/github.com/charmbracelet/x/ansi/xterm.go @@ -1,5 +1,22 @@ package ansi +import "strconv" + +// ModifyOtherKeys returns a sequence that sets XTerm modifyOtherKeys mode. +// The mode argument specifies the mode to set. +// +// 0: Disable modifyOtherKeys mode. +// 1: Enable modifyOtherKeys mode 1. +// 2: Enable modifyOtherKeys mode 2. +// +// CSI > 4 ; mode m +// +// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ +// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys +func ModifyOtherKeys(mode int) string { + return "\x1b[>4;" + strconv.Itoa(mode) + "m" +} + // DisableModifyOtherKeys disables the modifyOtherKeys mode. // // CSI > 4 ; 0 m diff --git a/vendor/github.com/charmbracelet/x/input/LICENSE b/vendor/github.com/charmbracelet/x/input/LICENSE deleted file mode 100644 index 65a5654..0000000 --- a/vendor/github.com/charmbracelet/x/input/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Charmbracelet, Inc. - -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/charmbracelet/x/input/cancelreader_other.go b/vendor/github.com/charmbracelet/x/input/cancelreader_other.go deleted file mode 100644 index ef0a2a0..0000000 --- a/vendor/github.com/charmbracelet/x/input/cancelreader_other.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build !windows -// +build !windows - -package input - -import ( - "io" - - "github.com/muesli/cancelreader" -) - -func newCancelreader(r io.Reader) (cancelreader.CancelReader, error) { - return cancelreader.NewReader(r) -} diff --git a/vendor/github.com/charmbracelet/x/input/cancelreader_windows.go b/vendor/github.com/charmbracelet/x/input/cancelreader_windows.go deleted file mode 100644 index 8e50211..0000000 --- a/vendor/github.com/charmbracelet/x/input/cancelreader_windows.go +++ /dev/null @@ -1,217 +0,0 @@ -//go:build windows -// +build windows - -package input - -import ( - "fmt" - "io" - "os" - "sync" - "time" - - "github.com/erikgeiser/coninput" - "github.com/muesli/cancelreader" - "golang.org/x/sys/windows" -) - -type conInputReader struct { - cancelMixin - - conin windows.Handle - cancelEvent windows.Handle - - originalMode uint32 - - // blockingReadSignal is used to signal that a blocking read is in progress. - blockingReadSignal chan struct{} -} - -var _ cancelreader.CancelReader = &conInputReader{} - -func newCancelreader(r io.Reader) (cancelreader.CancelReader, error) { - fallback := func(io.Reader) (cancelreader.CancelReader, error) { - return cancelreader.NewReader(r) - } - - var dummy uint32 - if f, ok := r.(cancelreader.File); !ok || f.Fd() != os.Stdin.Fd() || - // If data was piped to the standard input, it does not emit events - // anymore. We can detect this if the console mode cannot be set anymore, - // in this case, we fallback to the default cancelreader implementation. - windows.GetConsoleMode(windows.Handle(f.Fd()), &dummy) != nil { - return fallback(r) - } - - conin, err := coninput.NewStdinHandle() - if err != nil { - return fallback(r) - } - - originalMode, err := prepareConsole(conin, - windows.ENABLE_MOUSE_INPUT, - windows.ENABLE_WINDOW_INPUT, - windows.ENABLE_EXTENDED_FLAGS, - ) - if err != nil { - return nil, fmt.Errorf("failed to prepare console input: %w", err) - } - - cancelEvent, err := windows.CreateEvent(nil, 0, 0, nil) - if err != nil { - return nil, fmt.Errorf("create stop event: %w", err) - } - - return &conInputReader{ - conin: conin, - cancelEvent: cancelEvent, - originalMode: originalMode, - blockingReadSignal: make(chan struct{}, 1), - }, nil -} - -// Cancel implements cancelreader.CancelReader. -func (r *conInputReader) Cancel() bool { - r.setCanceled() - - select { - case r.blockingReadSignal <- struct{}{}: - err := windows.SetEvent(r.cancelEvent) - if err != nil { - return false - } - <-r.blockingReadSignal - case <-time.After(100 * time.Millisecond): - // Read() hangs in a GetOverlappedResult which is likely due to - // WaitForMultipleObjects returning without input being available - // so we cannot cancel this ongoing read. - return false - } - - return true -} - -// Close implements cancelreader.CancelReader. -func (r *conInputReader) Close() error { - err := windows.CloseHandle(r.cancelEvent) - if err != nil { - return fmt.Errorf("closing cancel event handle: %w", err) - } - - if r.originalMode != 0 { - err := windows.SetConsoleMode(r.conin, r.originalMode) - if err != nil { - return fmt.Errorf("reset console mode: %w", err) - } - } - - return nil -} - -// Read implements cancelreader.CancelReader. -func (r *conInputReader) Read(data []byte) (n int, err error) { - if r.isCanceled() { - return 0, cancelreader.ErrCanceled - } - - err = waitForInput(r.conin, r.cancelEvent) - if err != nil { - return 0, err - } - - if r.isCanceled() { - return 0, cancelreader.ErrCanceled - } - - r.blockingReadSignal <- struct{}{} - n, err = overlappedReader(r.conin).Read(data) - <-r.blockingReadSignal - - return -} - -func prepareConsole(input windows.Handle, modes ...uint32) (originalMode uint32, err error) { - err = windows.GetConsoleMode(input, &originalMode) - if err != nil { - return 0, fmt.Errorf("get console mode: %w", err) - } - - newMode := coninput.AddInputModes(0, modes...) - - err = windows.SetConsoleMode(input, newMode) - if err != nil { - return 0, fmt.Errorf("set console mode: %w", err) - } - - return originalMode, nil -} - -func waitForInput(conin, cancel windows.Handle) error { - event, err := windows.WaitForMultipleObjects([]windows.Handle{conin, cancel}, false, windows.INFINITE) - switch { - case windows.WAIT_OBJECT_0 <= event && event < windows.WAIT_OBJECT_0+2: - if event == windows.WAIT_OBJECT_0+1 { - return cancelreader.ErrCanceled - } - - if event == windows.WAIT_OBJECT_0 { - return nil - } - - return fmt.Errorf("unexpected wait object is ready: %d", event-windows.WAIT_OBJECT_0) - case windows.WAIT_ABANDONED <= event && event < windows.WAIT_ABANDONED+2: - return fmt.Errorf("abandoned") - case event == uint32(windows.WAIT_TIMEOUT): - return fmt.Errorf("timeout") - case event == windows.WAIT_FAILED: - return fmt.Errorf("failed") - default: - return fmt.Errorf("unexpected error: %w", err) - } -} - -// cancelMixin represents a goroutine-safe cancelation status. -type cancelMixin struct { - unsafeCanceled bool - lock sync.Mutex -} - -func (c *cancelMixin) setCanceled() { - c.lock.Lock() - defer c.lock.Unlock() - - c.unsafeCanceled = true -} - -func (c *cancelMixin) isCanceled() bool { - c.lock.Lock() - defer c.lock.Unlock() - - return c.unsafeCanceled -} - -type overlappedReader windows.Handle - -// Read performs an overlapping read fom a windows.Handle. -func (r overlappedReader) Read(data []byte) (int, error) { - hevent, err := windows.CreateEvent(nil, 0, 0, nil) - if err != nil { - return 0, fmt.Errorf("create event: %w", err) - } - - overlapped := windows.Overlapped{HEvent: hevent} - - var n uint32 - - err = windows.ReadFile(windows.Handle(r), data, &n, &overlapped) - if err != nil && err != windows.ERROR_IO_PENDING { - return int(n), err - } - - err = windows.GetOverlappedResult(windows.Handle(r), &overlapped, &n, true) - if err != nil { - return int(n), nil - } - - return int(n), nil -} diff --git a/vendor/github.com/charmbracelet/x/input/clipboard.go b/vendor/github.com/charmbracelet/x/input/clipboard.go deleted file mode 100644 index c1c9fbe..0000000 --- a/vendor/github.com/charmbracelet/x/input/clipboard.go +++ /dev/null @@ -1,9 +0,0 @@ -package input - -// ClipboardEvent is a clipboard read event. -type ClipboardEvent string - -// String returns the string representation of the clipboard event. -func (e ClipboardEvent) String() string { - return string(e) -} diff --git a/vendor/github.com/charmbracelet/x/input/color.go b/vendor/github.com/charmbracelet/x/input/color.go deleted file mode 100644 index 309e8c9..0000000 --- a/vendor/github.com/charmbracelet/x/input/color.go +++ /dev/null @@ -1,77 +0,0 @@ -package input - -import ( - "fmt" - "image/color" - "strconv" - "strings" -) - -// ForegroundColorEvent represents a foreground color change event. -type ForegroundColorEvent struct{ color.Color } - -// String implements fmt.Stringer. -func (e ForegroundColorEvent) String() string { - return colorToHex(e) -} - -// BackgroundColorEvent represents a background color change event. -type BackgroundColorEvent struct{ color.Color } - -// String implements fmt.Stringer. -func (e BackgroundColorEvent) String() string { - return colorToHex(e) -} - -// CursorColorEvent represents a cursor color change event. -type CursorColorEvent struct{ color.Color } - -// String implements fmt.Stringer. -func (e CursorColorEvent) String() string { - return colorToHex(e) -} - -type shiftable interface { - ~uint | ~uint16 | ~uint32 | ~uint64 -} - -func shift[T shiftable](x T) T { - if x > 0xff { - x >>= 8 - } - return x -} - -func colorToHex(c color.Color) string { - r, g, b, _ := c.RGBA() - return fmt.Sprintf("#%02x%02x%02x", shift(r), shift(g), shift(b)) -} - -func xParseColor(s string) color.Color { - switch { - case strings.HasPrefix(s, "rgb:"): - parts := strings.Split(s[4:], "/") - if len(parts) != 3 { - return color.Black - } - - r, _ := strconv.ParseUint(parts[0], 16, 32) - g, _ := strconv.ParseUint(parts[1], 16, 32) - b, _ := strconv.ParseUint(parts[2], 16, 32) - - return color.RGBA{uint8(shift(r)), uint8(shift(g)), uint8(shift(b)), 255} - case strings.HasPrefix(s, "rgba:"): - parts := strings.Split(s[5:], "/") - if len(parts) != 4 { - return color.Black - } - - r, _ := strconv.ParseUint(parts[0], 16, 32) - g, _ := strconv.ParseUint(parts[1], 16, 32) - b, _ := strconv.ParseUint(parts[2], 16, 32) - a, _ := strconv.ParseUint(parts[3], 16, 32) - - return color.RGBA{uint8(shift(r)), uint8(shift(g)), uint8(shift(b)), uint8(shift(a))} - } - return color.Black -} diff --git a/vendor/github.com/charmbracelet/x/input/cursor.go b/vendor/github.com/charmbracelet/x/input/cursor.go deleted file mode 100644 index c5d0fbb..0000000 --- a/vendor/github.com/charmbracelet/x/input/cursor.go +++ /dev/null @@ -1,10 +0,0 @@ -package input - -// CursorPositionEvent represents a cursor position event. -type CursorPositionEvent struct { - // Row is the row number. - Row int - - // Column is the column number. - Column int -} diff --git a/vendor/github.com/charmbracelet/x/input/da1.go b/vendor/github.com/charmbracelet/x/input/da1.go deleted file mode 100644 index d7529d5..0000000 --- a/vendor/github.com/charmbracelet/x/input/da1.go +++ /dev/null @@ -1,18 +0,0 @@ -package input - -import "github.com/charmbracelet/x/ansi" - -// PrimaryDeviceAttributesEvent represents a primary device attributes event. -type PrimaryDeviceAttributesEvent []uint - -func parsePrimaryDevAttrs(csi *ansi.CsiSequence) Event { - // Primary Device Attributes - da1 := make(PrimaryDeviceAttributesEvent, len(csi.Params)) - csi.Range(func(i int, p int, hasMore bool) bool { - if !hasMore { - da1[i] = uint(p) - } - return true - }) - return da1 -} diff --git a/vendor/github.com/charmbracelet/x/input/driver.go b/vendor/github.com/charmbracelet/x/input/driver.go deleted file mode 100644 index 5492b34..0000000 --- a/vendor/github.com/charmbracelet/x/input/driver.go +++ /dev/null @@ -1,129 +0,0 @@ -package input - -import ( - "bytes" - "io" - "unicode/utf8" - - "github.com/erikgeiser/coninput" - "github.com/muesli/cancelreader" -) - -// Driver represents an ANSI terminal input Driver. -// It reads input events and parses ANSI sequences from the terminal input -// buffer. -type Driver struct { - rd cancelreader.CancelReader - table map[string]Key // table is a lookup table for key sequences. - - term string // term is the terminal name $TERM. - - // paste is the bracketed paste mode buffer. - // When nil, bracketed paste mode is disabled. - paste []byte - - buf [256]byte // do we need a larger buffer? - - // prevMouseState keeps track of the previous mouse state to determine mouse - // up button events. - prevMouseState coninput.ButtonState // nolint: unused - - // lastWinsizeEvent keeps track of the last window size event to prevent - // multiple size events from firing. - lastWinsizeEvent coninput.WindowBufferSizeEventRecord // nolint: unused - - flags int // control the behavior of the driver. -} - -// NewDriver returns a new ANSI input driver. -// This driver uses ANSI control codes compatible with VT100/VT200 terminals, -// and XTerm. It supports reading Terminfo databases to overwrite the default -// key sequences. -func NewDriver(r io.Reader, term string, flags int) (*Driver, error) { - d := new(Driver) - cr, err := newCancelreader(r) - if err != nil { - return nil, err - } - - d.rd = cr - d.table = buildKeysTable(flags, term) - d.term = term - d.flags = flags - return d, nil -} - -// Cancel cancels the underlying reader. -func (d *Driver) Cancel() bool { - return d.rd.Cancel() -} - -// Close closes the underlying reader. -func (d *Driver) Close() error { - return d.rd.Close() -} - -func (d *Driver) readEvents() (e []Event, err error) { - nb, err := d.rd.Read(d.buf[:]) - if err != nil { - return nil, err - } - - buf := d.buf[:nb] - - // Lookup table first - if bytes.HasPrefix(buf, []byte{'\x1b'}) { - if k, ok := d.table[string(buf)]; ok { - e = append(e, KeyPressEvent(k)) - return - } - } - - var i int - for i < len(buf) { - nb, ev := ParseSequence(buf[i:]) - - // Handle bracketed-paste - if d.paste != nil { - if _, ok := ev.(PasteEndEvent); !ok { - d.paste = append(d.paste, buf[i]) - i++ - continue - } - } - - switch ev.(type) { - case UnknownCsiEvent, UnknownSs3Event, UnknownEvent: - // If the sequence is not recognized by the parser, try looking it up. - if k, ok := d.table[string(buf[i:i+nb])]; ok { - ev = KeyPressEvent(k) - } - case PasteStartEvent: - d.paste = []byte{} - case PasteEndEvent: - // Decode the captured data into runes. - var paste []rune - for len(d.paste) > 0 { - r, w := utf8.DecodeRune(d.paste) - if r != utf8.RuneError { - paste = append(paste, r) - } - d.paste = d.paste[w:] - } - d.paste = nil // reset the buffer - e = append(e, PasteEvent(paste)) - case nil: - i++ - continue - } - - if mevs, ok := ev.(MultiEvent); ok { - e = append(e, []Event(mevs)...) - } else { - e = append(e, ev) - } - i += nb - } - - return -} diff --git a/vendor/github.com/charmbracelet/x/input/driver_other.go b/vendor/github.com/charmbracelet/x/input/driver_other.go deleted file mode 100644 index 7092aa3..0000000 --- a/vendor/github.com/charmbracelet/x/input/driver_other.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !windows -// +build !windows - -package input - -// ReadEvents reads input events from the terminal. -// -// It reads the events available in the input buffer and returns them. -func (d *Driver) ReadEvents() ([]Event, error) { - return d.readEvents() -} diff --git a/vendor/github.com/charmbracelet/x/input/driver_windows.go b/vendor/github.com/charmbracelet/x/input/driver_windows.go deleted file mode 100644 index bba13e8..0000000 --- a/vendor/github.com/charmbracelet/x/input/driver_windows.go +++ /dev/null @@ -1,273 +0,0 @@ -//go:build windows -// +build windows - -package input - -import ( - "errors" - "fmt" - "unicode/utf16" - - "github.com/charmbracelet/x/ansi" - termwindows "github.com/charmbracelet/x/windows" - "github.com/erikgeiser/coninput" - "golang.org/x/sys/windows" -) - -// ReadEvents reads input events from the terminal. -// -// It reads the events available in the input buffer and returns them. -func (d *Driver) ReadEvents() ([]Event, error) { - events, err := d.handleConInput(coninput.ReadConsoleInput) - if errors.Is(err, errNotConInputReader) { - return d.readEvents() - } - return events, err -} - -var errNotConInputReader = fmt.Errorf("handleConInput: not a conInputReader") - -func (d *Driver) handleConInput( - finput func(windows.Handle, []coninput.InputRecord) (uint32, error), -) ([]Event, error) { - cc, ok := d.rd.(*conInputReader) - if !ok { - return nil, errNotConInputReader - } - - // read up to 256 events, this is to allow for sequences events reported as - // key events. - var events [256]coninput.InputRecord - _, err := finput(cc.conin, events[:]) - if err != nil { - return nil, fmt.Errorf("read coninput events: %w", err) - } - - var evs []Event - for _, event := range events { - if e := parseConInputEvent(event, &d.prevMouseState, &d.lastWinsizeEvent); e != nil { - evs = append(evs, e) - } - } - - return d.detectConInputQuerySequences(evs), nil -} - -// Using ConInput API, Windows Terminal responds to sequence query events with -// KEY_EVENT_RECORDs so we need to collect them and parse them as a single -// sequence. -// Is this a hack? -func (d *Driver) detectConInputQuerySequences(events []Event) []Event { - var newEvents []Event - start, end := -1, -1 - -loop: - for i, e := range events { - switch e := e.(type) { - case KeyPressEvent: - switch e.Rune { - case ansi.ESC, ansi.CSI, ansi.OSC, ansi.DCS, ansi.APC: - // start of a sequence - if start == -1 { - start = i - } - } - default: - break loop - } - end = i - } - - if start == -1 || end <= start { - return events - } - - var seq []byte - for i := start; i <= end; i++ { - switch e := events[i].(type) { - case KeyPressEvent: - seq = append(seq, byte(e.Rune)) - } - } - - n, seqevent := ParseSequence(seq) - switch seqevent.(type) { - case UnknownEvent: - // We're not interested in unknown events - default: - if start+n > len(events) { - return events - } - newEvents = events[:start] - newEvents = append(newEvents, seqevent) - newEvents = append(newEvents, events[start+n:]...) - return d.detectConInputQuerySequences(newEvents) - } - - return events -} - -func parseConInputEvent(event coninput.InputRecord, ps *coninput.ButtonState, ws *coninput.WindowBufferSizeEventRecord) Event { - switch e := event.Unwrap().(type) { - case coninput.KeyEventRecord: - event := parseWin32InputKeyEvent(e.VirtualKeyCode, e.VirtualScanCode, - e.Char, e.KeyDown, e.ControlKeyState, e.RepeatCount) - - var key Key - switch event := event.(type) { - case KeyPressEvent: - key = Key(event) - case KeyReleaseEvent: - key = Key(event) - default: - return nil - } - - // If the key is not printable, return the event as is - // (e.g. function keys, arrows, etc.) - // Otherwise, try to translate it to a rune based on the active keyboard - // layout. - if key.Rune == 0 { - return event - } - - // Always use US layout for translation - // This is to follow the behavior of the Kitty Keyboard base layout - // feature :eye_roll: - // https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-language-pack-default-values?view=windows-11 - const usLayout = 0x409 - - // Translate key to rune - var keyState [256]byte - var utf16Buf [16]uint16 - const dontChangeKernelKeyboardLayout = 0x4 - ret := termwindows.ToUnicodeEx( - uint32(e.VirtualKeyCode), - uint32(e.VirtualScanCode), - &keyState[0], - &utf16Buf[0], - int32(len(utf16Buf)), - dontChangeKernelKeyboardLayout, - usLayout, - ) - - // -1 indicates a dead key - // 0 indicates no translation for this key - if ret < 1 { - return event - } - - runes := utf16.Decode(utf16Buf[:ret]) - if len(runes) != 1 { - // Key doesn't translate to a single rune - return event - } - - key.baseRune = runes[0] - if e.KeyDown { - return KeyPressEvent(key) - } - - return KeyReleaseEvent(key) - - case coninput.WindowBufferSizeEventRecord: - if e != *ws { - *ws = e - return WindowSizeEvent{ - Width: int(e.Size.X), - Height: int(e.Size.Y), - } - } - case coninput.MouseEventRecord: - mevent := mouseEvent(*ps, e) - *ps = e.ButtonState - return mevent - case coninput.FocusEventRecord, coninput.MenuEventRecord: - // ignore - } - return nil -} - -func mouseEventButton(p, s coninput.ButtonState) (button MouseButton, isRelease bool) { - btn := p ^ s - if btn&s == 0 { - isRelease = true - } - - if btn == 0 { - switch { - case s&coninput.FROM_LEFT_1ST_BUTTON_PRESSED > 0: - button = MouseLeft - case s&coninput.FROM_LEFT_2ND_BUTTON_PRESSED > 0: - button = MouseMiddle - case s&coninput.RIGHTMOST_BUTTON_PRESSED > 0: - button = MouseRight - case s&coninput.FROM_LEFT_3RD_BUTTON_PRESSED > 0: - button = MouseBackward - case s&coninput.FROM_LEFT_4TH_BUTTON_PRESSED > 0: - button = MouseForward - } - return - } - - switch btn { - case coninput.FROM_LEFT_1ST_BUTTON_PRESSED: // left button - button = MouseLeft - case coninput.RIGHTMOST_BUTTON_PRESSED: // right button - button = MouseRight - case coninput.FROM_LEFT_2ND_BUTTON_PRESSED: // middle button - button = MouseMiddle - case coninput.FROM_LEFT_3RD_BUTTON_PRESSED: // unknown (possibly mouse backward) - button = MouseBackward - case coninput.FROM_LEFT_4TH_BUTTON_PRESSED: // unknown (possibly mouse forward) - button = MouseForward - } - - return -} - -func mouseEvent(p coninput.ButtonState, e coninput.MouseEventRecord) (ev Event) { - var mod KeyMod - var isRelease bool - if e.ControlKeyState.Contains(coninput.LEFT_ALT_PRESSED | coninput.RIGHT_ALT_PRESSED) { - mod |= ModAlt - } - if e.ControlKeyState.Contains(coninput.LEFT_CTRL_PRESSED | coninput.RIGHT_CTRL_PRESSED) { - mod |= ModCtrl - } - if e.ControlKeyState.Contains(coninput.SHIFT_PRESSED) { - mod |= ModShift - } - m := Mouse{ - X: int(e.MousePositon.X), - Y: int(e.MousePositon.Y), - Mod: mod, - } - switch e.EventFlags { - case coninput.CLICK, coninput.DOUBLE_CLICK: - m.Button, isRelease = mouseEventButton(p, e.ButtonState) - case coninput.MOUSE_WHEELED: - if e.WheelDirection > 0 { - m.Button = MouseWheelUp - } else { - m.Button = MouseWheelDown - } - case coninput.MOUSE_HWHEELED: - if e.WheelDirection > 0 { - m.Button = MouseWheelRight - } else { - m.Button = MouseWheelLeft - } - case coninput.MOUSE_MOVED: - m.Button, _ = mouseEventButton(p, e.ButtonState) - return MouseMotionEvent(m) - } - - if isWheel(m.Button) { - return MouseWheelEvent(m) - } else if isRelease { - return MouseReleaseEvent(m) - } - - return MouseClickEvent(m) -} diff --git a/vendor/github.com/charmbracelet/x/input/input.go b/vendor/github.com/charmbracelet/x/input/input.go deleted file mode 100644 index b29df6b..0000000 --- a/vendor/github.com/charmbracelet/x/input/input.go +++ /dev/null @@ -1,47 +0,0 @@ -package input - -import ( - "fmt" - "strings" -) - -var ( - // ErrUnknownEvent is returned when an unknown event is encountered. - ErrUnknownEvent = fmt.Errorf("unknown event") - - // ErrEmpty is returned when the event buffer is empty. - ErrEmpty = fmt.Errorf("empty event buffer") -) - -// Event represents a terminal input event. -type Event interface{} - -// UnknownEvent represents an unknown event. -type UnknownEvent string - -// String implements fmt.Stringer. -func (e UnknownEvent) String() string { - return fmt.Sprintf("%q", string(e)) -} - -// WindowSizeEvent represents a window resize event. -type WindowSizeEvent struct { - Width, Height int -} - -// String implements fmt.Stringer. -func (e WindowSizeEvent) String() string { - return fmt.Sprintf("resize: %dx%d", e.Width, e.Height) -} - -// MultiEvent represents multiple events. -type MultiEvent []Event - -// String implements fmt.Stringer. -func (e MultiEvent) String() string { - var sb strings.Builder - for _, ev := range e { - sb.WriteString(fmt.Sprintf("%v\n", ev)) - } - return sb.String() -} diff --git a/vendor/github.com/charmbracelet/x/input/key.go b/vendor/github.com/charmbracelet/x/input/key.go deleted file mode 100644 index 3161734..0000000 --- a/vendor/github.com/charmbracelet/x/input/key.go +++ /dev/null @@ -1,459 +0,0 @@ -package input - -// KeySym is a keyboard symbol. -type KeySym int - -// Symbol constants. -const ( - KeyNone KeySym = iota - - // Special names in C0 - - KeyBackspace - KeyTab - KeyEnter - KeyEscape - - // Special names in G0 - - KeySpace - KeyDelete - - // Special keys - - KeyUp - KeyDown - KeyRight - KeyLeft - KeyBegin - KeyFind - KeyInsert - KeySelect - KeyPgUp - KeyPgDown - KeyHome - KeyEnd - - // Keypad keys - - KeyKpEnter - KeyKpEqual - KeyKpMultiply - KeyKpPlus - KeyKpComma - KeyKpMinus - KeyKpDecimal - KeyKpDivide - KeyKp0 - KeyKp1 - KeyKp2 - KeyKp3 - KeyKp4 - KeyKp5 - KeyKp6 - KeyKp7 - KeyKp8 - KeyKp9 - - // The following are keys defined in the Kitty keyboard protocol. - // TODO: Investigate the names of these keys - KeyKpSep - KeyKpUp - KeyKpDown - KeyKpLeft - KeyKpRight - KeyKpPgUp - KeyKpPgDown - KeyKpHome - KeyKpEnd - KeyKpInsert - KeyKpDelete - KeyKpBegin - - // Function keys - - KeyF1 - KeyF2 - KeyF3 - KeyF4 - KeyF5 - KeyF6 - KeyF7 - KeyF8 - KeyF9 - KeyF10 - KeyF11 - KeyF12 - KeyF13 - KeyF14 - KeyF15 - KeyF16 - KeyF17 - KeyF18 - KeyF19 - KeyF20 - KeyF21 - KeyF22 - KeyF23 - KeyF24 - KeyF25 - KeyF26 - KeyF27 - KeyF28 - KeyF29 - KeyF30 - KeyF31 - KeyF32 - KeyF33 - KeyF34 - KeyF35 - KeyF36 - KeyF37 - KeyF38 - KeyF39 - KeyF40 - KeyF41 - KeyF42 - KeyF43 - KeyF44 - KeyF45 - KeyF46 - KeyF47 - KeyF48 - KeyF49 - KeyF50 - KeyF51 - KeyF52 - KeyF53 - KeyF54 - KeyF55 - KeyF56 - KeyF57 - KeyF58 - KeyF59 - KeyF60 - KeyF61 - KeyF62 - KeyF63 - - // The following are keys defined in the Kitty keyboard protocol. - // TODO: Investigate the names of these keys - - KeyCapsLock - KeyScrollLock - KeyNumLock - KeyPrintScreen - KeyPause - KeyMenu - - KeyMediaPlay - KeyMediaPause - KeyMediaPlayPause - KeyMediaReverse - KeyMediaStop - KeyMediaFastForward - KeyMediaRewind - KeyMediaNext - KeyMediaPrev - KeyMediaRecord - - KeyLowerVol - KeyRaiseVol - KeyMute - - KeyLeftShift - KeyLeftAlt - KeyLeftCtrl - KeyLeftSuper - KeyLeftHyper - KeyLeftMeta - KeyRightShift - KeyRightAlt - KeyRightCtrl - KeyRightSuper - KeyRightHyper - KeyRightMeta - KeyIsoLevel3Shift - KeyIsoLevel5Shift -) - -// Key represents a key event. -type Key struct { - // Sym is a special key, like enter, tab, backspace, and so on. - Sym KeySym - - // Rune is the actual character received. If the user presses shift+a, the - // Rune will be 'A'. - Rune rune - - // AltRune is the actual, unshifted key pressed by the user. For example, - // if the user presses shift+a, or caps lock is on, the AltRune will be - // 'a'. - // - // In the case of non-latin keyboards, like Arabic, AltRune is the - // unshifted key on the keyboard. - // - // This is only available with the Kitty Keyboard Protocol or the Windows - // Console API. - AltRune rune - - // baseRune is the key pressed according to the standard PC-101 key layout. - // On internaltional keyboards, this is the key that would be pressed if - // the keyboard was set to US layout. - // - // For example, if the user presses 'q' on a French AZERTY keyboard, the - // baseRune will be 'q'. - // - // This is only available with the Kitty Keyboard Protocol or the Windows - // Console API. - baseRune rune - - // Mod is a modifier key, like ctrl, alt, and so on. - Mod KeyMod - - // IsRepeat indicates whether the key is being held down and sending events - // repeatedly. - // - // This is only available with the Kitty Keyboard Protocol or the Windows - // Console API. - IsRepeat bool -} - -// KeyPressEvent represents a key press event. -type KeyPressEvent Key - -// String implements fmt.Stringer and is quite useful for matching key -// events. For details, on what this returns see [Key.String]. -func (k KeyPressEvent) String() string { - return Key(k).String() -} - -// KeyReleaseEvent represents a key release event. -type KeyReleaseEvent Key - -// String implements fmt.Stringer and is quite useful for matching complex key -// events. For details, on what this returns see [Key.String]. -func (k KeyReleaseEvent) String() string { - return Key(k).String() -} - -// String implements fmt.Stringer and is used to convert a key to a string. -// While less type safe than looking at the individual fields, it will usually -// be more convenient and readable to use this method when matching against -// keys. -// -// Note that modifier keys are always printed in the following order: -// - ctrl -// - alt -// - shift -// - meta -// - hyper -// - super -// -// For example, you'll always see "ctrl+shift+alt+a" and never -// "shift+ctrl+alt+a". -func (k Key) String() string { - var s string - if k.Mod.HasCtrl() && k.Sym != KeyLeftCtrl && k.Sym != KeyRightCtrl { - s += "ctrl+" - } - if k.Mod.HasAlt() && k.Sym != KeyLeftAlt && k.Sym != KeyRightAlt { - s += "alt+" - } - if k.Mod.HasShift() && k.Sym != KeyLeftShift && k.Sym != KeyRightShift { - s += "shift+" - } - if k.Mod.HasMeta() && k.Sym != KeyLeftMeta && k.Sym != KeyRightMeta { - s += "meta+" - } - if k.Mod.HasHyper() && k.Sym != KeyLeftHyper && k.Sym != KeyRightHyper { - s += "hyper+" - } - if k.Mod.HasSuper() && k.Sym != KeyLeftSuper && k.Sym != KeyRightSuper { - s += "super+" - } - - runeStr := func(r rune) string { - // Space is the only invisible printable character. - if r == ' ' { - return "space" - } - return string(r) - } - if k.baseRune != 0 { - // If a baseRune is present, use it to represent a key using the standard - // PC-101 key layout. - s += runeStr(k.baseRune) - } else if k.AltRune != 0 { - // Otherwise, use the AltRune aka the non-shifted one if present. - s += runeStr(k.AltRune) - } else if k.Rune != 0 { - // Else, just print the rune. - s += runeStr(k.Rune) - } else { - s += k.Sym.String() - } - return s -} - -// String implements fmt.Stringer and prints the string representation of a of -// a Symbol key. -func (k KeySym) String() string { - s, ok := keySymString[k] - if !ok { - return "unknown" - } - return s -} - -var keySymString = map[KeySym]string{ - KeyEnter: "enter", - KeyTab: "tab", - KeyBackspace: "backspace", - KeyEscape: "esc", - KeySpace: "space", - KeyUp: "up", - KeyDown: "down", - KeyLeft: "left", - KeyRight: "right", - KeyBegin: "begin", - KeyFind: "find", - KeyInsert: "insert", - KeyDelete: "delete", - KeySelect: "select", - KeyPgUp: "pgup", - KeyPgDown: "pgdown", - KeyHome: "home", - KeyEnd: "end", - KeyKpEnter: "kpenter", - KeyKpEqual: "kpequal", - KeyKpMultiply: "kpmul", - KeyKpPlus: "kpplus", - KeyKpComma: "kpcomma", - KeyKpMinus: "kpminus", - KeyKpDecimal: "kpperiod", - KeyKpDivide: "kpdiv", - KeyKp0: "kp0", - KeyKp1: "kp1", - KeyKp2: "kp2", - KeyKp3: "kp3", - KeyKp4: "kp4", - KeyKp5: "kp5", - KeyKp6: "kp6", - KeyKp7: "kp7", - KeyKp8: "kp8", - KeyKp9: "kp9", - - // Kitty keyboard extension - KeyKpSep: "kpsep", - KeyKpUp: "kpup", - KeyKpDown: "kpdown", - KeyKpLeft: "kpleft", - KeyKpRight: "kpright", - KeyKpPgUp: "kppgup", - KeyKpPgDown: "kppgdown", - KeyKpHome: "kphome", - KeyKpEnd: "kpend", - KeyKpInsert: "kpinsert", - KeyKpDelete: "kpdelete", - KeyKpBegin: "kpbegin", - - KeyF1: "f1", - KeyF2: "f2", - KeyF3: "f3", - KeyF4: "f4", - KeyF5: "f5", - KeyF6: "f6", - KeyF7: "f7", - KeyF8: "f8", - KeyF9: "f9", - KeyF10: "f10", - KeyF11: "f11", - KeyF12: "f12", - KeyF13: "f13", - KeyF14: "f14", - KeyF15: "f15", - KeyF16: "f16", - KeyF17: "f17", - KeyF18: "f18", - KeyF19: "f19", - KeyF20: "f20", - KeyF21: "f21", - KeyF22: "f22", - KeyF23: "f23", - KeyF24: "f24", - KeyF25: "f25", - KeyF26: "f26", - KeyF27: "f27", - KeyF28: "f28", - KeyF29: "f29", - KeyF30: "f30", - KeyF31: "f31", - KeyF32: "f32", - KeyF33: "f33", - KeyF34: "f34", - KeyF35: "f35", - KeyF36: "f36", - KeyF37: "f37", - KeyF38: "f38", - KeyF39: "f39", - KeyF40: "f40", - KeyF41: "f41", - KeyF42: "f42", - KeyF43: "f43", - KeyF44: "f44", - KeyF45: "f45", - KeyF46: "f46", - KeyF47: "f47", - KeyF48: "f48", - KeyF49: "f49", - KeyF50: "f50", - KeyF51: "f51", - KeyF52: "f52", - KeyF53: "f53", - KeyF54: "f54", - KeyF55: "f55", - KeyF56: "f56", - KeyF57: "f57", - KeyF58: "f58", - KeyF59: "f59", - KeyF60: "f60", - KeyF61: "f61", - KeyF62: "f62", - KeyF63: "f63", - - // Kitty keyboard extension - KeyCapsLock: "capslock", - KeyScrollLock: "scrolllock", - KeyNumLock: "numlock", - KeyPrintScreen: "printscreen", - KeyPause: "pause", - KeyMenu: "menu", - KeyMediaPlay: "mediaplay", - KeyMediaPause: "mediapause", - KeyMediaPlayPause: "mediaplaypause", - KeyMediaReverse: "mediareverse", - KeyMediaStop: "mediastop", - KeyMediaFastForward: "mediafastforward", - KeyMediaRewind: "mediarewind", - KeyMediaNext: "medianext", - KeyMediaPrev: "mediaprev", - KeyMediaRecord: "mediarecord", - KeyLowerVol: "lowervol", - KeyRaiseVol: "raisevol", - KeyMute: "mute", - KeyLeftShift: "leftshift", - KeyLeftAlt: "leftalt", - KeyLeftCtrl: "leftctrl", - KeyLeftSuper: "leftsuper", - KeyLeftHyper: "lefthyper", - KeyLeftMeta: "leftmeta", - KeyRightShift: "rightshift", - KeyRightAlt: "rightalt", - KeyRightCtrl: "rightctrl", - KeyRightSuper: "rightsuper", - KeyRightHyper: "righthyper", - KeyRightMeta: "rightmeta", - KeyIsoLevel3Shift: "isolevel3shift", - KeyIsoLevel5Shift: "isolevel5shift", -} diff --git a/vendor/github.com/charmbracelet/x/input/kitty.go b/vendor/github.com/charmbracelet/x/input/kitty.go deleted file mode 100644 index 22920f3..0000000 --- a/vendor/github.com/charmbracelet/x/input/kitty.go +++ /dev/null @@ -1,281 +0,0 @@ -package input - -import ( - "unicode" - "unicode/utf8" - - "github.com/charmbracelet/x/ansi" -) - -// KittyKeyboardEvent represents Kitty keyboard progressive enhancement flags. -type KittyKeyboardEvent int - -// IsDisambiguateEscapeCodes returns true if the DisambiguateEscapeCodes flag is set. -func (e KittyKeyboardEvent) IsDisambiguateEscapeCodes() bool { - return e&ansi.KittyDisambiguateEscapeCodes != 0 -} - -// IsReportEventTypes returns true if the ReportEventTypes flag is set. -func (e KittyKeyboardEvent) IsReportEventTypes() bool { - return e&ansi.KittyReportEventTypes != 0 -} - -// IsReportAlternateKeys returns true if the ReportAlternateKeys flag is set. -func (e KittyKeyboardEvent) IsReportAlternateKeys() bool { - return e&ansi.KittyReportAlternateKeys != 0 -} - -// IsReportAllKeys returns true if the ReportAllKeys flag is set. -func (e KittyKeyboardEvent) IsReportAllKeys() bool { - return e&ansi.KittyReportAllKeys != 0 -} - -// IsReportAssociatedKeys returns true if the ReportAssociatedKeys flag is set. -func (e KittyKeyboardEvent) IsReportAssociatedKeys() bool { - return e&ansi.KittyReportAssociatedKeys != 0 -} - -// Kitty Clipboard Control Sequences -var kittyKeyMap = map[int]KeySym{ - ansi.BS: KeyBackspace, - ansi.HT: KeyTab, - ansi.CR: KeyEnter, - ansi.ESC: KeyEscape, - ansi.DEL: KeyBackspace, - - 57344: KeyEscape, - 57345: KeyEnter, - 57346: KeyTab, - 57347: KeyBackspace, - 57348: KeyInsert, - 57349: KeyDelete, - 57350: KeyLeft, - 57351: KeyRight, - 57352: KeyUp, - 57353: KeyDown, - 57354: KeyPgUp, - 57355: KeyPgDown, - 57356: KeyHome, - 57357: KeyEnd, - 57358: KeyCapsLock, - 57359: KeyScrollLock, - 57360: KeyNumLock, - 57361: KeyPrintScreen, - 57362: KeyPause, - 57363: KeyMenu, - 57364: KeyF1, - 57365: KeyF2, - 57366: KeyF3, - 57367: KeyF4, - 57368: KeyF5, - 57369: KeyF6, - 57370: KeyF7, - 57371: KeyF8, - 57372: KeyF9, - 57373: KeyF10, - 57374: KeyF11, - 57375: KeyF12, - 57376: KeyF13, - 57377: KeyF14, - 57378: KeyF15, - 57379: KeyF16, - 57380: KeyF17, - 57381: KeyF18, - 57382: KeyF19, - 57383: KeyF20, - 57384: KeyF21, - 57385: KeyF22, - 57386: KeyF23, - 57387: KeyF24, - 57388: KeyF25, - 57389: KeyF26, - 57390: KeyF27, - 57391: KeyF28, - 57392: KeyF29, - 57393: KeyF30, - 57394: KeyF31, - 57395: KeyF32, - 57396: KeyF33, - 57397: KeyF34, - 57398: KeyF35, - 57399: KeyKp0, - 57400: KeyKp1, - 57401: KeyKp2, - 57402: KeyKp3, - 57403: KeyKp4, - 57404: KeyKp5, - 57405: KeyKp6, - 57406: KeyKp7, - 57407: KeyKp8, - 57408: KeyKp9, - 57409: KeyKpDecimal, - 57410: KeyKpDivide, - 57411: KeyKpMultiply, - 57412: KeyKpMinus, - 57413: KeyKpPlus, - 57414: KeyKpEnter, - 57415: KeyKpEqual, - 57416: KeyKpSep, - 57417: KeyKpLeft, - 57418: KeyKpRight, - 57419: KeyKpUp, - 57420: KeyKpDown, - 57421: KeyKpPgUp, - 57422: KeyKpPgDown, - 57423: KeyKpHome, - 57424: KeyKpEnd, - 57425: KeyKpInsert, - 57426: KeyKpDelete, - 57427: KeyKpBegin, - 57428: KeyMediaPlay, - 57429: KeyMediaPause, - 57430: KeyMediaPlayPause, - 57431: KeyMediaReverse, - 57432: KeyMediaStop, - 57433: KeyMediaFastForward, - 57434: KeyMediaRewind, - 57435: KeyMediaNext, - 57436: KeyMediaPrev, - 57437: KeyMediaRecord, - 57438: KeyLowerVol, - 57439: KeyRaiseVol, - 57440: KeyMute, - 57441: KeyLeftShift, - 57442: KeyLeftCtrl, - 57443: KeyLeftAlt, - 57444: KeyLeftSuper, - 57445: KeyLeftHyper, - 57446: KeyLeftMeta, - 57447: KeyRightShift, - 57448: KeyRightCtrl, - 57449: KeyRightAlt, - 57450: KeyRightSuper, - 57451: KeyRightHyper, - 57452: KeyRightMeta, - 57453: KeyIsoLevel3Shift, - 57454: KeyIsoLevel5Shift, -} - -const ( - kittyShift = 1 << iota - kittyAlt - kittyCtrl - kittySuper - kittyHyper - kittyMeta - kittyCapsLock - kittyNumLock -) - -func fromKittyMod(mod int) KeyMod { - var m KeyMod - if mod&kittyShift != 0 { - m |= ModShift - } - if mod&kittyAlt != 0 { - m |= ModAlt - } - if mod&kittyCtrl != 0 { - m |= ModCtrl - } - if mod&kittySuper != 0 { - m |= ModSuper - } - if mod&kittyHyper != 0 { - m |= ModHyper - } - if mod&kittyMeta != 0 { - m |= ModMeta - } - if mod&kittyCapsLock != 0 { - m |= ModCapsLock - } - if mod&kittyNumLock != 0 { - m |= ModNumLock - } - return m -} - -// parseKittyKeyboard parses a Kitty Keyboard Protocol sequence. -// -// In `CSI u`, this is parsed as: -// -// CSI codepoint ; modifiers u -// codepoint: ASCII Dec value -// -// The Kitty Keyboard Protocol extends this with optional components that can be -// enabled progressively. The full sequence is parsed as: -// -// CSI unicode-key-code:alternate-key-codes ; modifiers:event-type ; text-as-codepoints u -// -// See https://sw.kovidgoyal.net/kitty/keyboard-protocol/ -func parseKittyKeyboard(csi *ansi.CsiSequence) Event { - var isRelease bool - key := Key{} - - if params := csi.Subparams(0); len(params) > 0 { - code := params[0] - if sym, ok := kittyKeyMap[code]; ok { - key.Sym = sym - } else { - r := rune(code) - if !utf8.ValidRune(r) { - r = utf8.RuneError - } - - key.Rune = r - - // alternate key reporting - switch len(params) { - case 3: - // shifted key + base key - if b := rune(params[2]); unicode.IsPrint(b) { - // XXX: When alternate key reporting is enabled, the protocol - // can return 3 things, the unicode codepoint of the key, - // the shifted codepoint of the key, and the standard - // PC-101 key layout codepoint. - // This is useful to create an unambiguous mapping of keys - // when using a different language layout. - key.baseRune = b - } - fallthrough - case 2: - // shifted key - if s := rune(params[1]); unicode.IsPrint(s) { - // XXX: We swap keys here because we want the shifted key - // to be the Rune that is returned by the event. - // For example, shift+a should produce "A" not "a". - // In such a case, we set AltRune to the original key "a" - // and Rune to "A". - key.AltRune = key.Rune - key.Rune = s - } - } - } - } - if params := csi.Subparams(1); len(params) > 0 { - mod := params[0] - if mod > 1 { - key.Mod = fromKittyMod(mod - 1) - } - if len(params) > 1 { - switch params[1] { - case 2: - key.IsRepeat = true - case 3: - isRelease = true - } - } - } - // TODO: Associated keys are not support yet. - // if params := csi.Subparams(2); len(params) > 0 { - // r := rune(params[0]) - // if unicode.IsPrint(r) { - // key.AltRune = r - // } - // } - if isRelease { - return KeyReleaseEvent(key) - } - return KeyPressEvent(key) -} diff --git a/vendor/github.com/charmbracelet/x/input/mod.go b/vendor/github.com/charmbracelet/x/input/mod.go deleted file mode 100644 index 3c91aa5..0000000 --- a/vendor/github.com/charmbracelet/x/input/mod.go +++ /dev/null @@ -1,70 +0,0 @@ -package input - -// KeyMod represents modifier keys. -type KeyMod uint16 - -// Modifier keys. -const ( - ModShift KeyMod = 1 << iota - ModAlt - ModCtrl - ModMeta - - // These modifiers are used with the Kitty protocol. - // XXX: Meta and Super are swapped in the Kitty protocol, - // this is to preserve compatibility with XTerm modifiers. - - ModHyper - ModSuper // Windows/Command keys - - // These are key lock states. - - ModCapsLock - ModNumLock - ModScrollLock // Defined in Windows API only -) - -// HasShift reports whether the Shift modifier is set. -func (m KeyMod) HasShift() bool { - return m&ModShift != 0 -} - -// HasAlt reports whether the Alt modifier is set. -func (m KeyMod) HasAlt() bool { - return m&ModAlt != 0 -} - -// HasCtrl reports whether the Ctrl modifier is set. -func (m KeyMod) HasCtrl() bool { - return m&ModCtrl != 0 -} - -// HasMeta reports whether the Meta modifier is set. -func (m KeyMod) HasMeta() bool { - return m&ModMeta != 0 -} - -// HasHyper reports whether the Hyper modifier is set. -func (m KeyMod) HasHyper() bool { - return m&ModHyper != 0 -} - -// HasSuper reports whether the Super modifier is set. -func (m KeyMod) HasSuper() bool { - return m&ModSuper != 0 -} - -// HasCapsLock reports whether the CapsLock key is enabled. -func (m KeyMod) HasCapsLock() bool { - return m&ModCapsLock != 0 -} - -// HasNumLock reports whether the NumLock key is enabled. -func (m KeyMod) HasNumLock() bool { - return m&ModNumLock != 0 -} - -// HasScrollLock reports whether the ScrollLock key is enabled. -func (m KeyMod) HasScrollLock() bool { - return m&ModScrollLock != 0 -} diff --git a/vendor/github.com/charmbracelet/x/input/mode.go b/vendor/github.com/charmbracelet/x/input/mode.go deleted file mode 100644 index e838e68..0000000 --- a/vendor/github.com/charmbracelet/x/input/mode.go +++ /dev/null @@ -1,12 +0,0 @@ -package input - -// ReportModeEvent represents a report mode event for sequence DECRPM. -// -// See: https://vt100.net/docs/vt510-rm/DECRPM.html -type ReportModeEvent struct { - // Mode is the mode number. - Mode int - - // Value is the mode value. - Value int -} diff --git a/vendor/github.com/charmbracelet/x/input/mouse.go b/vendor/github.com/charmbracelet/x/input/mouse.go deleted file mode 100644 index 99e6de5..0000000 --- a/vendor/github.com/charmbracelet/x/input/mouse.go +++ /dev/null @@ -1,248 +0,0 @@ -package input - -import ( - "regexp" - - "github.com/charmbracelet/x/ansi" -) - -// MouseButton represents the button that was pressed during a mouse event. -type MouseButton byte - -// Mouse event buttons -// -// This is based on X11 mouse button codes. -// -// 1 = left button -// 2 = middle button (pressing the scroll wheel) -// 3 = right button -// 4 = turn scroll wheel up -// 5 = turn scroll wheel down -// 6 = push scroll wheel left -// 7 = push scroll wheel right -// 8 = 4th button (aka browser backward button) -// 9 = 5th button (aka browser forward button) -// 10 -// 11 -// -// Other buttons are not supported. -const ( - MouseNone MouseButton = iota - MouseLeft - MouseMiddle - MouseRight - MouseWheelUp - MouseWheelDown - MouseWheelLeft - MouseWheelRight - MouseBackward - MouseForward - MouseExtra1 - MouseExtra2 -) - -var mouseButtons = map[MouseButton]string{ - MouseNone: "none", - MouseLeft: "left", - MouseMiddle: "middle", - MouseRight: "right", - MouseWheelUp: "wheelup", - MouseWheelDown: "wheeldown", - MouseWheelLeft: "wheelleft", - MouseWheelRight: "wheelright", - MouseBackward: "backward", - MouseForward: "forward", - MouseExtra1: "button10", - MouseExtra2: "button11", -} - -// Mouse represents a Mouse event. -type Mouse struct { - X, Y int - Button MouseButton - Mod KeyMod -} - -// String implements fmt.Stringer. -func (m Mouse) String() (s string) { - if m.Mod.HasCtrl() { - s += "ctrl+" - } - if m.Mod.HasAlt() { - s += "alt+" - } - if m.Mod.HasShift() { - s += "shift+" - } - - str, ok := mouseButtons[m.Button] - if !ok { - s += "unknown" - } else if str != "none" { // motion events don't have a button - s += str - } - - return s -} - -// MouseClickEvent represents a mouse button click event. -type MouseClickEvent Mouse - -// String implements fmt.Stringer. -func (e MouseClickEvent) String() string { - return Mouse(e).String() -} - -// MouseReleaseEvent represents a mouse button release event. -type MouseReleaseEvent Mouse - -// String implements fmt.Stringer. -func (e MouseReleaseEvent) String() string { - return Mouse(e).String() -} - -// MouseWheelEvent represents a mouse wheel event. -type MouseWheelEvent Mouse - -// String implements fmt.Stringer. -func (e MouseWheelEvent) String() string { - return Mouse(e).String() -} - -// MouseMotionEvent represents a mouse motion event. -type MouseMotionEvent Mouse - -// String implements fmt.Stringer. -func (e MouseMotionEvent) String() string { - m := Mouse(e) - if m.Button != 0 { - return m.String() + "+motion" - } - return m.String() + "motion" -} - -var mouseSGRRegex = regexp.MustCompile(`(\d+);(\d+);(\d+)([Mm])`) - -// Parse SGR-encoded mouse events; SGR extended mouse events. SGR mouse events -// look like: -// -// ESC [ < Cb ; Cx ; Cy (M or m) -// -// where: -// -// Cb is the encoded button code -// Cx is the x-coordinate of the mouse -// Cy is the y-coordinate of the mouse -// M is for button press, m is for button release -// -// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates -func parseSGRMouseEvent(csi *ansi.CsiSequence) Event { - x := csi.Param(1) - y := csi.Param(2) - release := csi.Command() == 'm' - mod, btn, _, isMotion := parseMouseButton(csi.Param(0)) - - // (1,1) is the upper left. We subtract 1 to normalize it to (0,0). - x-- - y-- - - m := Mouse{X: x, Y: y, Button: btn, Mod: mod} - - // Wheel buttons don't have release events - // Motion can be reported as a release event in some terminals (Windows Terminal) - if isWheel(m.Button) { - return MouseWheelEvent(m) - } else if !isMotion && release { - return MouseReleaseEvent(m) - } else if isMotion { - return MouseMotionEvent(m) - } - return MouseClickEvent(m) -} - -const x10MouseByteOffset = 32 - -// Parse X10-encoded mouse events; the simplest kind. The last release of X10 -// was December 1986, by the way. The original X10 mouse protocol limits the Cx -// and Cy coordinates to 223 (=255-032). -// -// X10 mouse events look like: -// -// ESC [M Cb Cx Cy -// -// See: http://www.xfree86.org/current/ctlseqs.html#Mouse%20Tracking -func parseX10MouseEvent(buf []byte) Event { - v := buf[3:6] - b := int(v[0]) - if b >= x10MouseByteOffset { - // XXX: b < 32 should be impossible, but we're being defensive. - b -= x10MouseByteOffset - } - - mod, btn, isRelease, isMotion := parseMouseButton(b) - - // (1,1) is the upper left. We subtract 1 to normalize it to (0,0). - x := int(v[1]) - x10MouseByteOffset - 1 - y := int(v[2]) - x10MouseByteOffset - 1 - - m := Mouse{X: x, Y: y, Button: btn, Mod: mod} - if isWheel(m.Button) { - return MouseWheelEvent(m) - } else if isMotion { - return MouseMotionEvent(m) - } else if isRelease { - return MouseReleaseEvent(m) - } - return MouseClickEvent(m) -} - -// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates -func parseMouseButton(b int) (mod KeyMod, btn MouseButton, isRelease bool, isMotion bool) { - // mouse bit shifts - const ( - bitShift = 0b0000_0100 - bitAlt = 0b0000_1000 - bitCtrl = 0b0001_0000 - bitMotion = 0b0010_0000 - bitWheel = 0b0100_0000 - bitAdd = 0b1000_0000 // additional buttons 8-11 - - bitsMask = 0b0000_0011 - ) - - // Modifiers - if b&bitAlt != 0 { - mod |= ModAlt - } - if b&bitCtrl != 0 { - mod |= ModCtrl - } - if b&bitShift != 0 { - mod |= ModShift - } - - if b&bitAdd != 0 { - btn = MouseBackward + MouseButton(b&bitsMask) - } else if b&bitWheel != 0 { - btn = MouseWheelUp + MouseButton(b&bitsMask) - } else { - btn = MouseLeft + MouseButton(b&bitsMask) - // X10 reports a button release as 0b0000_0011 (3) - if b&bitsMask == bitsMask { - btn = MouseNone - isRelease = true - } - } - - // Motion bit doesn't get reported for wheel events. - if b&bitMotion != 0 && !isWheel(btn) { - isMotion = true - } - - return -} - -// isWheel returns true if the mouse event is a wheel event. -func isWheel(btn MouseButton) bool { - return btn >= MouseWheelUp && btn <= MouseWheelRight -} diff --git a/vendor/github.com/charmbracelet/x/input/parse.go b/vendor/github.com/charmbracelet/x/input/parse.go deleted file mode 100644 index d5b8721..0000000 --- a/vendor/github.com/charmbracelet/x/input/parse.go +++ /dev/null @@ -1,836 +0,0 @@ -package input - -import ( - "encoding/base64" - "strings" - "unicode/utf8" - - "github.com/charmbracelet/x/ansi" - "github.com/charmbracelet/x/ansi/parser" - "github.com/erikgeiser/coninput" -) - -// Flags to control the behavior of the parser. -const ( - // When this flag is set, the driver will treat both Ctrl+Space and Ctrl+@ - // as the same key sequence. - // - // Historically, the ANSI specs generate NUL (0x00) on both the Ctrl+Space - // and Ctrl+@ key sequences. This flag allows the driver to treat both as - // the same key sequence. - FlagCtrlAt = 1 << iota - - // When this flag is set, the driver will treat the Tab key and Ctrl+I as - // the same key sequence. - // - // Historically, the ANSI specs generate HT (0x09) on both the Tab key and - // Ctrl+I. This flag allows the driver to treat both as the same key - // sequence. - FlagCtrlI - - // When this flag is set, the driver will treat the Enter key and Ctrl+M as - // the same key sequence. - // - // Historically, the ANSI specs generate CR (0x0D) on both the Enter key - // and Ctrl+M. This flag allows the driver to treat both as the same key - FlagCtrlM - - // When this flag is set, the driver will treat Escape and Ctrl+[ as - // the same key sequence. - // - // Historically, the ANSI specs generate ESC (0x1B) on both the Escape key - // and Ctrl+[. This flag allows the driver to treat both as the same key - // sequence. - FlagCtrlOpenBracket - - // When this flag is set, the driver will send a BS (0x08 byte) character - // instead of a DEL (0x7F byte) character when the Backspace key is - // pressed. - // - // The VT100 terminal has both a Backspace and a Delete key. The VT220 - // terminal dropped the Backspace key and replaced it with the Delete key. - // Both terminals send a DEL character when the Delete key is pressed. - // Modern terminals and PCs later readded the Delete key but used a - // different key sequence, and the Backspace key was standardized to send a - // DEL character. - FlagBackspace - - // When this flag is set, the driver will recognize the Find key instead of - // treating it as a Home key. - // - // The Find key was part of the VT220 keyboard, and is no longer used in - // modern day PCs. - FlagFind - - // When this flag is set, the driver will recognize the Select key instead - // of treating it as a End key. - // - // The Symbol key was part of the VT220 keyboard, and is no longer used in - // modern day PCs. - FlagSelect - - // When this flag is set, the driver will use Terminfo databases to - // overwrite the default key sequences. - FlagTerminfo - - // When this flag is set, the driver will preserve function keys (F13-F63) - // as symbols. - // - // Since these keys are not part of today's standard 20th century keyboard, - // we treat them as F1-F12 modifier keys i.e. ctrl/shift/alt + Fn combos. - // Key definitions come from Terminfo, this flag is only useful when - // FlagTerminfo is not set. - FlagFKeys -) - -var flags int - -// SetFlags sets the flags for the parser. -// This will control the behavior of ParseSequence. -func SetFlags(f int) { - flags = f -} - -// ParseSequence finds the first recognized event sequence and returns it along -// with its length. -// -// It will return zero and nil no sequence is recognized or when the buffer is -// empty. If a sequence is not supported, an UnknownEvent is returned. -func ParseSequence(buf []byte) (n int, e Event) { - if len(buf) == 0 { - return 0, nil - } - - switch b := buf[0]; b { - case ansi.ESC: - if len(buf) == 1 { - // Escape key - return 1, KeyPressEvent{Sym: KeyEscape} - } - - switch b := buf[1]; b { - case 'O': // Esc-prefixed SS3 - return parseSs3(buf) - case 'P': // Esc-prefixed DCS - return parseDcs(buf) - case '[': // Esc-prefixed CSI - return parseCsi(buf) - case ']': // Esc-prefixed OSC - return parseOsc(buf) - case '_': // Esc-prefixed APC - return parseApc(buf) - default: - n, e := ParseSequence(buf[1:]) - if k, ok := e.(KeyPressEvent); ok && !k.Mod.HasAlt() { - k.Mod |= ModAlt - return n + 1, k - } - - // Not a key sequence, nor an alt modified key sequence. In that - // case, just report a single escape key. - return 1, KeyPressEvent{Sym: KeyEscape} - } - case ansi.SS3: - return parseSs3(buf) - case ansi.DCS: - return parseDcs(buf) - case ansi.CSI: - return parseCsi(buf) - case ansi.OSC: - return parseOsc(buf) - case ansi.APC: - return parseApc(buf) - default: - if b <= ansi.US || b == ansi.DEL || b == ansi.SP { - return 1, parseControl(b) - } else if b >= ansi.PAD && b <= ansi.APC { - // C1 control code - // UTF-8 never starts with a C1 control code - // Encode these as Ctrl+Alt+ - return 1, KeyPressEvent{Rune: rune(b) - 0x40, Mod: ModCtrl | ModAlt} - } - return parseUtf8(buf) - } -} - -func parseCsi(b []byte) (int, Event) { - if len(b) == 2 && b[0] == ansi.ESC { - // short cut if this is an alt+[ key - return 2, KeyPressEvent{Rune: rune(b[1]), Mod: ModAlt} - } - - var csi ansi.CsiSequence - var params [parser.MaxParamsSize]int - var paramsLen int - - var i int - if b[i] == ansi.CSI || b[i] == ansi.ESC { - i++ - } - if i < len(b) && b[i-1] == ansi.ESC && b[i] == '[' { - i++ - } - - // Initial CSI byte - if i < len(b) && b[i] >= '<' && b[i] <= '?' { - csi.Cmd |= int(b[i]) << parser.MarkerShift - } - - // Scan parameter bytes in the range 0x30-0x3F - var j int - for j = 0; i < len(b) && paramsLen < len(params) && b[i] >= 0x30 && b[i] <= 0x3F; i, j = i+1, j+1 { - if b[i] >= '0' && b[i] <= '9' { - if params[paramsLen] == parser.MissingParam { - params[paramsLen] = 0 - } - params[paramsLen] *= 10 - params[paramsLen] += int(b[i]) - '0' - } - if b[i] == ':' { - params[paramsLen] |= parser.HasMoreFlag - } - if b[i] == ';' || b[i] == ':' { - paramsLen++ - if paramsLen < len(params) { - // Don't overflow the params slice - params[paramsLen] = parser.MissingParam - } - } - } - - if j > 0 && paramsLen < len(params) { - // has parameters - paramsLen++ - } - - // Scan intermediate bytes in the range 0x20-0x2F - var intermed byte - for ; i < len(b) && b[i] >= 0x20 && b[i] <= 0x2F; i++ { - intermed = b[i] - } - - // Set the intermediate byte - csi.Cmd |= int(intermed) << parser.IntermedShift - - // Scan final byte in the range 0x40-0x7E - if i >= len(b) || b[i] < 0x40 || b[i] > 0x7E { - // Special case for URxvt keys - // CSI $ is an invalid sequence, but URxvt uses it for - // shift modified keys. - if b[i-1] == '$' { - n, ev := parseCsi(append(b[:i-1], '~')) - if k, ok := ev.(KeyPressEvent); ok { - k.Mod |= ModShift - return n, k - } - } - return i, UnknownEvent(b[:i-1]) - } - - // Add the final byte - csi.Cmd |= int(b[i]) - i++ - - csi.Params = params[:paramsLen] - marker, cmd := csi.Marker(), csi.Command() - switch marker { - case '?': - switch cmd { - case 'y': - switch intermed { - case '$': - // Report Mode (DECRPM) - if paramsLen != 2 { - return i, UnknownCsiEvent(b[:i]) - } - return i, ReportModeEvent{Mode: csi.Param(0), Value: csi.Param(1)} - } - case 'c': - // Primary Device Attributes - return i, parsePrimaryDevAttrs(&csi) - case 'u': - // Kitty keyboard flags - if param := csi.Param(0); param != -1 { - return i, KittyKeyboardEvent(param) - } - case 'R': - // This report may return a third parameter representing the page - // number, but we don't really need it. - if paramsLen >= 2 { - return i, CursorPositionEvent{Row: csi.Param(0), Column: csi.Param(1)} - } - } - return i, UnknownCsiEvent(b[:i]) - case '<': - switch cmd { - case 'm', 'M': - // Handle SGR mouse - if paramsLen != 3 { - return i, UnknownCsiEvent(b[:i]) - } - return i, parseSGRMouseEvent(&csi) - default: - return i, UnknownCsiEvent(b[:i]) - } - case '>': - switch cmd { - case 'm': - // XTerm modifyOtherKeys - if paramsLen != 2 || csi.Param(0) != 4 { - return i, UnknownCsiEvent(b[:i]) - } - - return i, ModifyOtherKeysEvent(csi.Param(1)) - default: - return i, UnknownCsiEvent(b[:i]) - } - case '=': - // We don't support any of these yet - return i, UnknownCsiEvent(b[:i]) - } - - switch cmd := csi.Command(); cmd { - case 'R': - // Cursor position report OR modified F3 - if paramsLen == 0 { - return i, KeyPressEvent{Sym: KeyF3} - } else if paramsLen != 2 { - break - } - - // XXX: We cannot differentiate between cursor position report and - // CSI 1 ; R (which is modified F3) when the cursor is at the - // row 1. In this case, we report a modified F3 event since it's more - // likely to be the case than the cursor being at the first row. - // - // For a non ambiguous cursor position report, use - // [ansi.RequestExtendedCursorPosition] (DECXCPR) instead. - if csi.Param(0) != 1 { - return i, CursorPositionEvent{Row: csi.Param(0), Column: csi.Param(1)} - } - - fallthrough - case 'a', 'b', 'c', 'd', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'P', 'Q', 'S', 'Z': - var k KeyPressEvent - switch cmd { - case 'a', 'b', 'c', 'd': - k = KeyPressEvent{Sym: KeyUp + KeySym(cmd-'a'), Mod: ModShift} - case 'A', 'B', 'C', 'D': - k = KeyPressEvent{Sym: KeyUp + KeySym(cmd-'A')} - case 'E': - k = KeyPressEvent{Sym: KeyBegin} - case 'F': - k = KeyPressEvent{Sym: KeyEnd} - case 'H': - k = KeyPressEvent{Sym: KeyHome} - case 'P', 'Q', 'R', 'S': - k = KeyPressEvent{Sym: KeyF1 + KeySym(cmd-'P')} - case 'Z': - k = KeyPressEvent{Sym: KeyTab, Mod: ModShift} - } - if paramsLen > 1 && csi.Param(0) == 1 { - // CSI 1 ; A - if paramsLen > 1 { - k.Mod |= KeyMod(csi.Param(1) - 1) - } - } - return i, k - case 'M': - // Handle X10 mouse - if i+3 > len(b) { - return i, UnknownCsiEvent(b[:i]) - } - return i + 3, parseX10MouseEvent(append(b[:i], b[i:i+3]...)) - case 'y': - // Report Mode (DECRPM) - if paramsLen != 2 { - return i, UnknownCsiEvent(b[:i]) - } - return i, ReportModeEvent{Mode: csi.Param(0), Value: csi.Param(1)} - case 'u': - // Kitty keyboard protocol & CSI u (fixterms) - if paramsLen == 0 { - return i, UnknownCsiEvent(b[:i]) - } - return i, parseKittyKeyboard(&csi) - case '_': - // Win32 Input Mode - if paramsLen != 6 { - return i, UnknownCsiEvent(b[:i]) - } - - rc := uint16(csi.Param(5)) - if rc == 0 { - rc = 1 - } - - event := parseWin32InputKeyEvent( - coninput.VirtualKeyCode(csi.Param(0)), // Vk wVirtualKeyCode - coninput.VirtualKeyCode(csi.Param(1)), // Sc wVirtualScanCode - rune(csi.Param(2)), // Uc UnicodeChar - csi.Param(3) == 1, // Kd bKeyDown - coninput.ControlKeyState(csi.Param(4)), // Cs dwControlKeyState - rc, // Rc wRepeatCount - ) - - if event == nil { - return i, UnknownCsiEvent(b[:]) - } - - return i, event - case '@', '^', '~': - if paramsLen == 0 { - return i, UnknownCsiEvent(b[:i]) - } - - param := csi.Param(0) - switch cmd { - case '~': - switch param { - case 27: - // XTerm modifyOtherKeys 2 - if paramsLen != 3 { - return i, UnknownCsiEvent(b[:i]) - } - return i, parseXTermModifyOtherKeys(&csi) - case 200: - // bracketed-paste start - return i, PasteStartEvent{} - case 201: - // bracketed-paste end - return i, PasteEndEvent{} - } - } - - switch param { - case 1, 2, 3, 4, 5, 6, 7, 8: - fallthrough - case 11, 12, 13, 14, 15: - fallthrough - case 17, 18, 19, 20, 21, 23, 24, 25, 26: - fallthrough - case 28, 29, 31, 32, 33, 34: - var k KeyPressEvent - switch param { - case 1: - if flags&FlagFind != 0 { - k = KeyPressEvent{Sym: KeyFind} - } else { - k = KeyPressEvent{Sym: KeyHome} - } - case 2: - k = KeyPressEvent{Sym: KeyInsert} - case 3: - k = KeyPressEvent{Sym: KeyDelete} - case 4: - if flags&FlagSelect != 0 { - k = KeyPressEvent{Sym: KeySelect} - } else { - k = KeyPressEvent{Sym: KeyEnd} - } - case 5: - k = KeyPressEvent{Sym: KeyPgUp} - case 6: - k = KeyPressEvent{Sym: KeyPgDown} - case 7: - k = KeyPressEvent{Sym: KeyHome} - case 8: - k = KeyPressEvent{Sym: KeyEnd} - case 11, 12, 13, 14, 15: - k = KeyPressEvent{Sym: KeyF1 + KeySym(param-11)} - case 17, 18, 19, 20, 21: - k = KeyPressEvent{Sym: KeyF6 + KeySym(param-17)} - case 23, 24, 25, 26: - k = KeyPressEvent{Sym: KeyF11 + KeySym(param-23)} - case 28, 29: - k = KeyPressEvent{Sym: KeyF15 + KeySym(param-28)} - case 31, 32, 33, 34: - k = KeyPressEvent{Sym: KeyF17 + KeySym(param-31)} - } - - // modifiers - if paramsLen > 1 { - k.Mod |= KeyMod(csi.Param(1) - 1) - } - - // Handle URxvt weird keys - switch cmd { - case '^': - k.Mod |= ModCtrl - case '@': - k.Mod |= ModCtrl | ModShift - } - - return i, k - } - } - return i, UnknownCsiEvent(b[:i]) -} - -// parseSs3 parses a SS3 sequence. -// See https://vt100.net/docs/vt220-rm/chapter4.html#S4.4.4.2 -func parseSs3(b []byte) (int, Event) { - if len(b) == 2 && b[0] == ansi.ESC { - // short cut if this is an alt+O key - return 2, KeyPressEvent{Rune: rune(b[1]), Mod: ModAlt} - } - - var i int - if b[i] == ansi.SS3 || b[i] == ansi.ESC { - i++ - } - if i < len(b) && b[i-1] == ansi.ESC && b[i] == 'O' { - i++ - } - - // Scan numbers from 0-9 - var mod int - for ; i < len(b) && b[i] >= '0' && b[i] <= '9'; i++ { - mod *= 10 - mod += int(b[i]) - '0' - } - - // Scan a GL character - // A GL character is a single byte in the range 0x21-0x7E - // See https://vt100.net/docs/vt220-rm/chapter2.html#S2.3.2 - if i >= len(b) || b[i] < 0x21 || b[i] > 0x7E { - return i, UnknownEvent(b[:i]) - } - - // GL character(s) - gl := b[i] - i++ - - var k KeyPressEvent - switch gl { - case 'a', 'b', 'c', 'd': - k = KeyPressEvent{Sym: KeyUp + KeySym(gl-'a'), Mod: ModCtrl} - case 'A', 'B', 'C', 'D': - k = KeyPressEvent{Sym: KeyUp + KeySym(gl-'A')} - case 'E': - k = KeyPressEvent{Sym: KeyBegin} - case 'F': - k = KeyPressEvent{Sym: KeyEnd} - case 'H': - k = KeyPressEvent{Sym: KeyHome} - case 'P', 'Q', 'R', 'S': - k = KeyPressEvent{Sym: KeyF1 + KeySym(gl-'P')} - case 'M': - k = KeyPressEvent{Sym: KeyKpEnter} - case 'X': - k = KeyPressEvent{Sym: KeyKpEqual} - case 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y': - k = KeyPressEvent{Sym: KeyKpMultiply + KeySym(gl-'j')} - default: - return i, UnknownSs3Event(b[:i]) - } - - // Handle weird SS3 Func - if mod > 0 { - k.Mod |= KeyMod(mod - 1) - } - - return i, k -} - -func parseOsc(b []byte) (int, Event) { - if len(b) == 2 && b[0] == ansi.ESC { - // short cut if this is an alt+] key - return 2, KeyPressEvent{Rune: rune(b[1]), Mod: ModAlt} - } - - var i int - if b[i] == ansi.OSC || b[i] == ansi.ESC { - i++ - } - if i < len(b) && b[i-1] == ansi.ESC && b[i] == ']' { - i++ - } - - // Parse OSC command - // An OSC sequence is terminated by a BEL, ESC, or ST character - var start, end int - cmd := -1 - for ; i < len(b) && b[i] >= '0' && b[i] <= '9'; i++ { - if cmd == -1 { - cmd = 0 - } else { - cmd *= 10 - } - cmd += int(b[i]) - '0' - } - - if i < len(b) && b[i] == ';' { - // mark the start of the sequence data - i++ - start = i - } - - for ; i < len(b); i++ { - // advance to the end of the sequence - if b[i] == ansi.BEL || b[i] == ansi.ESC || b[i] == ansi.ST { - break - } - } - - if i >= len(b) { - return i, UnknownEvent(b[:i]) - } - - end = i // end of the sequence data - i++ - - // Check 7-bit ST (string terminator) character - if i < len(b) && b[i-1] == ansi.ESC && b[i] == '\\' { - i++ - } - - if end <= start { - return i, UnknownOscEvent(b[:i]) - } - - data := string(b[start:end]) - switch cmd { - case 10: - return i, ForegroundColorEvent{xParseColor(data)} - case 11: - return i, BackgroundColorEvent{xParseColor(data)} - case 12: - return i, CursorColorEvent{xParseColor(data)} - case 52: - parts := strings.Split(data, ";") - if len(parts) == 0 { - return i, ClipboardEvent("") - } - b64 := parts[len(parts)-1] - bts, err := base64.StdEncoding.DecodeString(b64) - if err != nil { - return i, ClipboardEvent("") - } - return i, ClipboardEvent(bts) - default: - return i, UnknownOscEvent(b[:i]) - } -} - -// parseStTerminated parses a control sequence that gets terminated by a ST character. -func parseStTerminated(intro8, intro7 byte) func([]byte) (int, Event) { - return func(b []byte) (int, Event) { - var i int - if b[i] == intro8 || b[i] == ansi.ESC { - i++ - } - if i < len(b) && b[i-1] == ansi.ESC && b[i] == intro7 { - i++ - } - - // Scan control sequence - // Most common control sequence is terminated by a ST character - // ST is a 7-bit string terminator character is (ESC \) - // nolint: revive - for ; i < len(b) && b[i] != ansi.ST && b[i] != ansi.ESC; i++ { - } - - if i >= len(b) { - switch intro8 { - case ansi.DCS: - return i, UnknownDcsEvent(b[:i]) - case ansi.APC: - return i, UnknownApcEvent(b[:i]) - default: - return i, UnknownEvent(b[:i]) - } - } - i++ - - // Check 7-bit ST (string terminator) character - if i < len(b) && b[i-1] == ansi.ESC && b[i] == '\\' { - i++ - } - - switch intro8 { - case ansi.DCS: - return i, UnknownDcsEvent(b[:i]) - case ansi.APC: - return i, UnknownApcEvent(b[:i]) - default: - return i, UnknownEvent(b[:i]) - } - } -} - -func parseDcs(b []byte) (int, Event) { - if len(b) == 2 && b[0] == ansi.ESC { - // short cut if this is an alt+P key - return 2, KeyPressEvent{Rune: rune(b[1]), Mod: ModAlt} - } - - var params [16]int - var paramsLen int - var dcs ansi.DcsSequence - - // DCS sequences are introduced by DCS (0x90) or ESC P (0x1b 0x50) - var i int - if b[i] == ansi.DCS || b[i] == ansi.ESC { - i++ - } - if i < len(b) && b[i-1] == ansi.ESC && b[i] == 'P' { - i++ - } - - // initial DCS byte - if i < len(b) && b[i] >= '<' && b[i] <= '?' { - dcs.Cmd |= int(b[i]) << parser.MarkerShift - } - - // Scan parameter bytes in the range 0x30-0x3F - var j int - for j = 0; i < len(b) && paramsLen < len(params) && b[i] >= 0x30 && b[i] <= 0x3F; i, j = i+1, j+1 { - if b[i] >= '0' && b[i] <= '9' { - if params[paramsLen] == parser.MissingParam { - params[paramsLen] = 0 - } - params[paramsLen] *= 10 - params[paramsLen] += int(b[i]) - '0' - } - if b[i] == ':' { - params[paramsLen] |= parser.HasMoreFlag - } - if b[i] == ';' || b[i] == ':' { - paramsLen++ - if paramsLen < len(params) { - // Don't overflow the params slice - params[paramsLen] = parser.MissingParam - } - } - } - - if j > 0 && paramsLen < len(params) { - // has parameters - paramsLen++ - } - - // Scan intermediate bytes in the range 0x20-0x2F - var intermed byte - for j := 0; i < len(b) && b[i] >= 0x20 && b[i] <= 0x2F; i, j = i+1, j+1 { - intermed = b[i] - } - - // set intermediate byte - dcs.Cmd |= int(intermed) << parser.IntermedShift - - // Scan final byte in the range 0x40-0x7E - if i >= len(b) || b[i] < 0x40 || b[i] > 0x7E { - return i, UnknownEvent(b[:i]) - } - - // Add the final byte - dcs.Cmd |= int(b[i]) - i++ - - start := i // start of the sequence data - for ; i < len(b); i++ { - if b[i] == ansi.ST || b[i] == ansi.ESC { - break - } - } - - if i >= len(b) { - return i, UnknownEvent(b[:i]) - } - - end := i // end of the sequence data - i++ - - // Check 7-bit ST (string terminator) character - if i < len(b) && b[i-1] == ansi.ESC && b[i] == '\\' { - i++ - } - - dcs.Params = params[:paramsLen] - switch cmd := dcs.Command(); cmd { - case 'r': - switch dcs.Intermediate() { - case '+': - // XTGETTCAP responses - switch param := dcs.Param(0); param { - case 0, 1: - tc := parseTermcap(b[start:end]) - // XXX: some terminals like KiTTY report invalid responses with - // their queries i.e. sending a query for "Tc" using "\x1bP+q5463\x1b\\" - // returns "\x1bP0+r5463\x1b\\". - // The specs says that invalid responses should be in the form of - // DCS 0 + r ST "\x1bP0+r\x1b\\" - // - // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands - tc.IsValid = param == 1 - return i, tc - } - } - } - - return i, UnknownDcsEvent(b[:i]) -} - -func parseApc(b []byte) (int, Event) { - if len(b) == 2 && b[0] == ansi.ESC { - // short cut if this is an alt+_ key - return 2, KeyPressEvent{Rune: rune(b[1]), Mod: ModAlt} - } - - // APC sequences are introduced by APC (0x9f) or ESC _ (0x1b 0x5f) - return parseStTerminated(ansi.APC, '_')(b) -} - -func parseUtf8(b []byte) (int, Event) { - r, rw := utf8.DecodeRune(b) - if r <= ansi.US || r == ansi.DEL || r == ansi.SP { - // Control codes get handled by parseControl - return 1, parseControl(byte(r)) - } else if r == utf8.RuneError { - return 1, UnknownEvent(b[0]) - } - return rw, KeyPressEvent{Rune: r} -} - -func parseControl(b byte) Event { - switch b { - case ansi.NUL: - if flags&FlagCtrlAt != 0 { - return KeyPressEvent{Rune: '@', Mod: ModCtrl} - } - return KeyPressEvent{Rune: ' ', Sym: KeySpace, Mod: ModCtrl} - case ansi.BS: - return KeyPressEvent{Rune: 'h', Mod: ModCtrl} - case ansi.HT: - if flags&FlagCtrlI != 0 { - return KeyPressEvent{Rune: 'i', Mod: ModCtrl} - } - return KeyPressEvent{Sym: KeyTab} - case ansi.CR: - if flags&FlagCtrlM != 0 { - return KeyPressEvent{Rune: 'm', Mod: ModCtrl} - } - return KeyPressEvent{Sym: KeyEnter} - case ansi.ESC: - if flags&FlagCtrlOpenBracket != 0 { - return KeyPressEvent{Rune: '[', Mod: ModCtrl} - } - return KeyPressEvent{Sym: KeyEscape} - case ansi.DEL: - if flags&FlagBackspace != 0 { - return KeyPressEvent{Sym: KeyDelete} - } - return KeyPressEvent{Sym: KeyBackspace} - case ansi.SP: - return KeyPressEvent{Sym: KeySpace, Rune: ' '} - default: - if b >= ansi.SOH && b <= ansi.SUB { - // Use lower case letters for control codes - return KeyPressEvent{Rune: rune(b + 0x60), Mod: ModCtrl} - } else if b >= ansi.FS && b <= ansi.US { - return KeyPressEvent{Rune: rune(b + 0x40), Mod: ModCtrl} - } - return UnknownEvent(b) - } -} diff --git a/vendor/github.com/charmbracelet/x/input/paste.go b/vendor/github.com/charmbracelet/x/input/paste.go deleted file mode 100644 index 079d3cb..0000000 --- a/vendor/github.com/charmbracelet/x/input/paste.go +++ /dev/null @@ -1,12 +0,0 @@ -package input - -// PasteEvent is an event that is emitted when a terminal receives pasted text -// using bracketed-paste. -type PasteEvent string - -// PasteStartEvent is an event that is emitted when a terminal enters -// bracketed-paste mode. -type PasteStartEvent struct{} - -// PasteEvent is an event that is emitted when a terminal receives pasted text. -type PasteEndEvent struct{} diff --git a/vendor/github.com/charmbracelet/x/input/seq.go b/vendor/github.com/charmbracelet/x/input/seq.go deleted file mode 100644 index 460e12b..0000000 --- a/vendor/github.com/charmbracelet/x/input/seq.go +++ /dev/null @@ -1,45 +0,0 @@ -package input - -import ( - "fmt" -) - -// UnknownCsiEvent represents an unknown CSI sequence event. -type UnknownCsiEvent string - -// String implements fmt.Stringer. -func (e UnknownCsiEvent) String() string { - return fmt.Sprintf("%q", string(e)) -} - -// UnknownOscEvent represents an unknown OSC sequence event. -type UnknownOscEvent string - -// String implements fmt.Stringer. -func (e UnknownOscEvent) String() string { - return fmt.Sprintf("%q", string(e)) -} - -// UnknownDcsEvent represents an unknown DCS sequence event. -type UnknownDcsEvent string - -// String implements fmt.Stringer. -func (e UnknownDcsEvent) String() string { - return fmt.Sprintf("%q", string(e)) -} - -// UnknownApcEvent represents an unknown APC sequence event. -type UnknownApcEvent string - -// String implements fmt.Stringer. -func (e UnknownApcEvent) String() string { - return fmt.Sprintf("%q", string(e)) -} - -// UnknownSs3Event represents an unknown SS3 sequence event. -type UnknownSs3Event string - -// String implements fmt.Stringer. -func (e UnknownSs3Event) String() string { - return fmt.Sprintf("%q", string(e)) -} diff --git a/vendor/github.com/charmbracelet/x/input/table.go b/vendor/github.com/charmbracelet/x/input/table.go deleted file mode 100644 index 022d1ad..0000000 --- a/vendor/github.com/charmbracelet/x/input/table.go +++ /dev/null @@ -1,388 +0,0 @@ -package input - -import ( - "strconv" - - "github.com/charmbracelet/x/ansi" -) - -func buildKeysTable(flags int, term string) map[string]Key { - nul := Key{Rune: ' ', Sym: KeySpace, Mod: ModCtrl} // ctrl+@ or ctrl+space - if flags&FlagCtrlAt != 0 { - nul = Key{Rune: '@', Mod: ModCtrl} - } - - tab := Key{Sym: KeyTab} // ctrl+i or tab - if flags&FlagCtrlI != 0 { - tab = Key{Rune: 'i', Mod: ModCtrl} - } - - enter := Key{Sym: KeyEnter} // ctrl+m or enter - if flags&FlagCtrlM != 0 { - enter = Key{Rune: 'm', Mod: ModCtrl} - } - - esc := Key{Sym: KeyEscape} // ctrl+[ or escape - if flags&FlagCtrlOpenBracket != 0 { - esc = Key{Rune: '[', Mod: ModCtrl} // ctrl+[ or escape - } - - del := Key{Sym: KeyBackspace} - if flags&FlagBackspace != 0 { - del.Sym = KeyDelete - } - - find := Key{Sym: KeyHome} - if flags&FlagFind != 0 { - find.Sym = KeyFind - } - - sel := Key{Sym: KeyEnd} - if flags&FlagSelect != 0 { - sel.Sym = KeySelect - } - - // The following is a table of key sequences and their corresponding key - // events based on the VT100/VT200 terminal specs. - // - // See: https://vt100.net/docs/vt100-ug/chapter3.html#S3.2 - // See: https://vt100.net/docs/vt220-rm/chapter3.html - // - // XXX: These keys may be overwritten by other options like XTerm or - // Terminfo. - table := map[string]Key{ - // C0 control characters - string(byte(ansi.NUL)): nul, - string(byte(ansi.SOH)): {Rune: 'a', Mod: ModCtrl}, - string(byte(ansi.STX)): {Rune: 'b', Mod: ModCtrl}, - string(byte(ansi.ETX)): {Rune: 'c', Mod: ModCtrl}, - string(byte(ansi.EOT)): {Rune: 'd', Mod: ModCtrl}, - string(byte(ansi.ENQ)): {Rune: 'e', Mod: ModCtrl}, - string(byte(ansi.ACK)): {Rune: 'f', Mod: ModCtrl}, - string(byte(ansi.BEL)): {Rune: 'g', Mod: ModCtrl}, - string(byte(ansi.BS)): {Rune: 'h', Mod: ModCtrl}, - string(byte(ansi.HT)): tab, - string(byte(ansi.LF)): {Rune: 'j', Mod: ModCtrl}, - string(byte(ansi.VT)): {Rune: 'k', Mod: ModCtrl}, - string(byte(ansi.FF)): {Rune: 'l', Mod: ModCtrl}, - string(byte(ansi.CR)): enter, - string(byte(ansi.SO)): {Rune: 'n', Mod: ModCtrl}, - string(byte(ansi.SI)): {Rune: 'o', Mod: ModCtrl}, - string(byte(ansi.DLE)): {Rune: 'p', Mod: ModCtrl}, - string(byte(ansi.DC1)): {Rune: 'q', Mod: ModCtrl}, - string(byte(ansi.DC2)): {Rune: 'r', Mod: ModCtrl}, - string(byte(ansi.DC3)): {Rune: 's', Mod: ModCtrl}, - string(byte(ansi.DC4)): {Rune: 't', Mod: ModCtrl}, - string(byte(ansi.NAK)): {Rune: 'u', Mod: ModCtrl}, - string(byte(ansi.SYN)): {Rune: 'v', Mod: ModCtrl}, - string(byte(ansi.ETB)): {Rune: 'w', Mod: ModCtrl}, - string(byte(ansi.CAN)): {Rune: 'x', Mod: ModCtrl}, - string(byte(ansi.EM)): {Rune: 'y', Mod: ModCtrl}, - string(byte(ansi.SUB)): {Rune: 'z', Mod: ModCtrl}, - string(byte(ansi.ESC)): esc, - string(byte(ansi.FS)): {Rune: '\\', Mod: ModCtrl}, - string(byte(ansi.GS)): {Rune: ']', Mod: ModCtrl}, - string(byte(ansi.RS)): {Rune: '^', Mod: ModCtrl}, - string(byte(ansi.US)): {Rune: '_', Mod: ModCtrl}, - - // Special keys in G0 - string(byte(ansi.SP)): {Sym: KeySpace, Rune: ' '}, - string(byte(ansi.DEL)): del, - - // Special keys - - "\x1b[Z": {Sym: KeyTab, Mod: ModShift}, - - "\x1b[1~": find, - "\x1b[2~": {Sym: KeyInsert}, - "\x1b[3~": {Sym: KeyDelete}, - "\x1b[4~": sel, - "\x1b[5~": {Sym: KeyPgUp}, - "\x1b[6~": {Sym: KeyPgDown}, - "\x1b[7~": {Sym: KeyHome}, - "\x1b[8~": {Sym: KeyEnd}, - - // Normal mode - "\x1b[A": {Sym: KeyUp}, - "\x1b[B": {Sym: KeyDown}, - "\x1b[C": {Sym: KeyRight}, - "\x1b[D": {Sym: KeyLeft}, - "\x1b[E": {Sym: KeyBegin}, - "\x1b[F": {Sym: KeyEnd}, - "\x1b[H": {Sym: KeyHome}, - "\x1b[P": {Sym: KeyF1}, - "\x1b[Q": {Sym: KeyF2}, - "\x1b[R": {Sym: KeyF3}, - "\x1b[S": {Sym: KeyF4}, - - // Application Cursor Key Mode (DECCKM) - "\x1bOA": {Sym: KeyUp}, - "\x1bOB": {Sym: KeyDown}, - "\x1bOC": {Sym: KeyRight}, - "\x1bOD": {Sym: KeyLeft}, - "\x1bOE": {Sym: KeyBegin}, - "\x1bOF": {Sym: KeyEnd}, - "\x1bOH": {Sym: KeyHome}, - "\x1bOP": {Sym: KeyF1}, - "\x1bOQ": {Sym: KeyF2}, - "\x1bOR": {Sym: KeyF3}, - "\x1bOS": {Sym: KeyF4}, - - // Keypad Application Mode (DECKPAM) - - "\x1bOM": {Sym: KeyKpEnter}, - "\x1bOX": {Sym: KeyKpEqual}, - "\x1bOj": {Sym: KeyKpMultiply}, - "\x1bOk": {Sym: KeyKpPlus}, - "\x1bOl": {Sym: KeyKpComma}, - "\x1bOm": {Sym: KeyKpMinus}, - "\x1bOn": {Sym: KeyKpDecimal}, - "\x1bOo": {Sym: KeyKpDivide}, - "\x1bOp": {Sym: KeyKp0}, - "\x1bOq": {Sym: KeyKp1}, - "\x1bOr": {Sym: KeyKp2}, - "\x1bOs": {Sym: KeyKp3}, - "\x1bOt": {Sym: KeyKp4}, - "\x1bOu": {Sym: KeyKp5}, - "\x1bOv": {Sym: KeyKp6}, - "\x1bOw": {Sym: KeyKp7}, - "\x1bOx": {Sym: KeyKp8}, - "\x1bOy": {Sym: KeyKp9}, - - // Function keys - - "\x1b[11~": {Sym: KeyF1}, - "\x1b[12~": {Sym: KeyF2}, - "\x1b[13~": {Sym: KeyF3}, - "\x1b[14~": {Sym: KeyF4}, - "\x1b[15~": {Sym: KeyF5}, - "\x1b[17~": {Sym: KeyF6}, - "\x1b[18~": {Sym: KeyF7}, - "\x1b[19~": {Sym: KeyF8}, - "\x1b[20~": {Sym: KeyF9}, - "\x1b[21~": {Sym: KeyF10}, - "\x1b[23~": {Sym: KeyF11}, - "\x1b[24~": {Sym: KeyF12}, - "\x1b[25~": {Sym: KeyF13}, - "\x1b[26~": {Sym: KeyF14}, - "\x1b[28~": {Sym: KeyF15}, - "\x1b[29~": {Sym: KeyF16}, - "\x1b[31~": {Sym: KeyF17}, - "\x1b[32~": {Sym: KeyF18}, - "\x1b[33~": {Sym: KeyF19}, - "\x1b[34~": {Sym: KeyF20}, - } - - // CSI ~ sequence keys - csiTildeKeys := map[string]Key{ - "1": find, "2": {Sym: KeyInsert}, - "3": {Sym: KeyDelete}, "4": sel, - "5": {Sym: KeyPgUp}, "6": {Sym: KeyPgDown}, - "7": {Sym: KeyHome}, "8": {Sym: KeyEnd}, - // There are no 9 and 10 keys - "11": {Sym: KeyF1}, "12": {Sym: KeyF2}, - "13": {Sym: KeyF3}, "14": {Sym: KeyF4}, - "15": {Sym: KeyF5}, "17": {Sym: KeyF6}, - "18": {Sym: KeyF7}, "19": {Sym: KeyF8}, - "20": {Sym: KeyF9}, "21": {Sym: KeyF10}, - "23": {Sym: KeyF11}, "24": {Sym: KeyF12}, - "25": {Sym: KeyF13}, "26": {Sym: KeyF14}, - "28": {Sym: KeyF15}, "29": {Sym: KeyF16}, - "31": {Sym: KeyF17}, "32": {Sym: KeyF18}, - "33": {Sym: KeyF19}, "34": {Sym: KeyF20}, - } - - // URxvt keys - // See https://manpages.ubuntu.com/manpages/trusty/man7/urxvt.7.html#key%20codes - table["\x1b[a"] = Key{Sym: KeyUp, Mod: ModShift} - table["\x1b[b"] = Key{Sym: KeyDown, Mod: ModShift} - table["\x1b[c"] = Key{Sym: KeyRight, Mod: ModShift} - table["\x1b[d"] = Key{Sym: KeyLeft, Mod: ModShift} - table["\x1bOa"] = Key{Sym: KeyUp, Mod: ModCtrl} - table["\x1bOb"] = Key{Sym: KeyDown, Mod: ModCtrl} - table["\x1bOc"] = Key{Sym: KeyRight, Mod: ModCtrl} - table["\x1bOd"] = Key{Sym: KeyLeft, Mod: ModCtrl} - // TODO: invistigate if shift-ctrl arrow keys collide with DECCKM keys i.e. - // "\x1bOA", "\x1bOB", "\x1bOC", "\x1bOD" - - // URxvt modifier CSI ~ keys - for k, v := range csiTildeKeys { - key := v - // Normal (no modifier) already defined part of VT100/VT200 - // Shift modifier - key.Mod = ModShift - table["\x1b["+k+"$"] = key - // Ctrl modifier - key.Mod = ModCtrl - table["\x1b["+k+"^"] = key - // Shift-Ctrl modifier - key.Mod = ModShift | ModCtrl - table["\x1b["+k+"@"] = key - } - - // URxvt F keys - // Note: Shift + F1-F10 generates F11-F20. - // This means Shift + F1 and Shift + F2 will generate F11 and F12, the same - // applies to Ctrl + Shift F1 & F2. - // - // P.S. Don't like this? Blame URxvt, configure your terminal to use - // different escapes like XTerm, or switch to a better terminal ¯\_(ツ)_/¯ - // - // See https://manpages.ubuntu.com/manpages/trusty/man7/urxvt.7.html#key%20codes - table["\x1b[23$"] = Key{Sym: KeyF11, Mod: ModShift} - table["\x1b[24$"] = Key{Sym: KeyF12, Mod: ModShift} - table["\x1b[25$"] = Key{Sym: KeyF13, Mod: ModShift} - table["\x1b[26$"] = Key{Sym: KeyF14, Mod: ModShift} - table["\x1b[28$"] = Key{Sym: KeyF15, Mod: ModShift} - table["\x1b[29$"] = Key{Sym: KeyF16, Mod: ModShift} - table["\x1b[31$"] = Key{Sym: KeyF17, Mod: ModShift} - table["\x1b[32$"] = Key{Sym: KeyF18, Mod: ModShift} - table["\x1b[33$"] = Key{Sym: KeyF19, Mod: ModShift} - table["\x1b[34$"] = Key{Sym: KeyF20, Mod: ModShift} - table["\x1b[11^"] = Key{Sym: KeyF1, Mod: ModCtrl} - table["\x1b[12^"] = Key{Sym: KeyF2, Mod: ModCtrl} - table["\x1b[13^"] = Key{Sym: KeyF3, Mod: ModCtrl} - table["\x1b[14^"] = Key{Sym: KeyF4, Mod: ModCtrl} - table["\x1b[15^"] = Key{Sym: KeyF5, Mod: ModCtrl} - table["\x1b[17^"] = Key{Sym: KeyF6, Mod: ModCtrl} - table["\x1b[18^"] = Key{Sym: KeyF7, Mod: ModCtrl} - table["\x1b[19^"] = Key{Sym: KeyF8, Mod: ModCtrl} - table["\x1b[20^"] = Key{Sym: KeyF9, Mod: ModCtrl} - table["\x1b[21^"] = Key{Sym: KeyF10, Mod: ModCtrl} - table["\x1b[23^"] = Key{Sym: KeyF11, Mod: ModCtrl} - table["\x1b[24^"] = Key{Sym: KeyF12, Mod: ModCtrl} - table["\x1b[25^"] = Key{Sym: KeyF13, Mod: ModCtrl} - table["\x1b[26^"] = Key{Sym: KeyF14, Mod: ModCtrl} - table["\x1b[28^"] = Key{Sym: KeyF15, Mod: ModCtrl} - table["\x1b[29^"] = Key{Sym: KeyF16, Mod: ModCtrl} - table["\x1b[31^"] = Key{Sym: KeyF17, Mod: ModCtrl} - table["\x1b[32^"] = Key{Sym: KeyF18, Mod: ModCtrl} - table["\x1b[33^"] = Key{Sym: KeyF19, Mod: ModCtrl} - table["\x1b[34^"] = Key{Sym: KeyF20, Mod: ModCtrl} - table["\x1b[23@"] = Key{Sym: KeyF11, Mod: ModShift | ModCtrl} - table["\x1b[24@"] = Key{Sym: KeyF12, Mod: ModShift | ModCtrl} - table["\x1b[25@"] = Key{Sym: KeyF13, Mod: ModShift | ModCtrl} - table["\x1b[26@"] = Key{Sym: KeyF14, Mod: ModShift | ModCtrl} - table["\x1b[28@"] = Key{Sym: KeyF15, Mod: ModShift | ModCtrl} - table["\x1b[29@"] = Key{Sym: KeyF16, Mod: ModShift | ModCtrl} - table["\x1b[31@"] = Key{Sym: KeyF17, Mod: ModShift | ModCtrl} - table["\x1b[32@"] = Key{Sym: KeyF18, Mod: ModShift | ModCtrl} - table["\x1b[33@"] = Key{Sym: KeyF19, Mod: ModShift | ModCtrl} - table["\x1b[34@"] = Key{Sym: KeyF20, Mod: ModShift | ModCtrl} - - // Register Alt + combinations - // XXX: this must come after URxvt but before XTerm keys to register URxvt - // keys with alt modifier - tmap := map[string]Key{} - for seq, key := range table { - key := key - key.Mod |= ModAlt - tmap["\x1b"+seq] = key - } - for seq, key := range tmap { - table[seq] = key - } - - // XTerm modifiers - // These are offset by 1 to be compatible with our Mod type. - // See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys - modifiers := []KeyMod{ - ModShift, // 1 - ModAlt, // 2 - ModShift | ModAlt, // 3 - ModCtrl, // 4 - ModShift | ModCtrl, // 5 - ModAlt | ModCtrl, // 6 - ModShift | ModAlt | ModCtrl, // 7 - ModMeta, // 8 - ModMeta | ModShift, // 9 - ModMeta | ModAlt, // 10 - ModMeta | ModShift | ModAlt, // 11 - ModMeta | ModCtrl, // 12 - ModMeta | ModShift | ModCtrl, // 13 - ModMeta | ModAlt | ModCtrl, // 14 - ModMeta | ModShift | ModAlt | ModCtrl, // 15 - } - - // SS3 keypad function keys - ss3FuncKeys := map[string]Key{ - // These are defined in XTerm - // Taken from Foot keymap.h and XTerm modifyOtherKeys - // https://codeberg.org/dnkl/foot/src/branch/master/keymap.h - "M": {Sym: KeyKpEnter}, "X": {Sym: KeyKpEqual}, - "j": {Sym: KeyKpMultiply}, "k": {Sym: KeyKpPlus}, - "l": {Sym: KeyKpComma}, "m": {Sym: KeyKpMinus}, - "n": {Sym: KeyKpDecimal}, "o": {Sym: KeyKpDivide}, - "p": {Sym: KeyKp0}, "q": {Sym: KeyKp1}, - "r": {Sym: KeyKp2}, "s": {Sym: KeyKp3}, - "t": {Sym: KeyKp4}, "u": {Sym: KeyKp5}, - "v": {Sym: KeyKp6}, "w": {Sym: KeyKp7}, - "x": {Sym: KeyKp8}, "y": {Sym: KeyKp9}, - } - - // XTerm keys - csiFuncKeys := map[string]Key{ - "A": {Sym: KeyUp}, "B": {Sym: KeyDown}, - "C": {Sym: KeyRight}, "D": {Sym: KeyLeft}, - "E": {Sym: KeyBegin}, "F": {Sym: KeyEnd}, - "H": {Sym: KeyHome}, "P": {Sym: KeyF1}, - "Q": {Sym: KeyF2}, "R": {Sym: KeyF3}, - "S": {Sym: KeyF4}, - } - - // CSI 27 ; ; ~ keys defined in XTerm modifyOtherKeys - modifyOtherKeys := map[int]Key{ - ansi.BS: {Sym: KeyBackspace}, - ansi.HT: {Sym: KeyTab}, - ansi.CR: {Sym: KeyEnter}, - ansi.ESC: {Sym: KeyEscape}, - ansi.DEL: {Sym: KeyBackspace}, - } - - for _, m := range modifiers { - // XTerm modifier offset +1 - xtermMod := strconv.Itoa(int(m) + 1) - - // CSI 1 ; - for k, v := range csiFuncKeys { - // Functions always have a leading 1 param - seq := "\x1b[1;" + xtermMod + k - key := v - key.Mod = m - table[seq] = key - } - // SS3 - for k, v := range ss3FuncKeys { - seq := "\x1bO" + xtermMod + k - key := v - key.Mod = m - table[seq] = key - } - // CSI ; ~ - for k, v := range csiTildeKeys { - seq := "\x1b[" + k + ";" + xtermMod + "~" - key := v - key.Mod = m - table[seq] = key - } - // CSI 27 ; ; ~ - for k, v := range modifyOtherKeys { - code := strconv.Itoa(k) - seq := "\x1b[27;" + xtermMod + ";" + code + "~" - key := v - key.Mod = m - table[seq] = key - } - } - - // Register terminfo keys - // XXX: this might override keys already registered in table - if flags&FlagTerminfo != 0 { - titable := buildTerminfoKeys(flags, term) - for seq, key := range titable { - table[seq] = key - } - } - - return table -} diff --git a/vendor/github.com/charmbracelet/x/input/termcap.go b/vendor/github.com/charmbracelet/x/input/termcap.go deleted file mode 100644 index 82045b1..0000000 --- a/vendor/github.com/charmbracelet/x/input/termcap.go +++ /dev/null @@ -1,49 +0,0 @@ -package input - -import ( - "bytes" - "encoding/hex" -) - -// TermcapEvent represents a Termcap response event. Termcap responses are -// generated by the terminal in response to RequestTermcap (XTGETTCAP) -// requests. -// -// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands -type TermcapEvent struct { - Values map[string]string - IsValid bool -} - -func parseTermcap(data []byte) TermcapEvent { - // XTGETTCAP - if len(data) == 0 { - return TermcapEvent{} - } - - tc := TermcapEvent{Values: make(map[string]string)} - split := bytes.Split(data, []byte{';'}) - for _, s := range split { - parts := bytes.SplitN(s, []byte{'='}, 2) - if len(parts) == 0 { - return TermcapEvent{} - } - - name, err := hex.DecodeString(string(parts[0])) - if err != nil || len(name) == 0 { - continue - } - - var value []byte - if len(parts) > 1 { - value, err = hex.DecodeString(string(parts[1])) - if err != nil { - continue - } - } - - tc.Values[string(name)] = string(value) - } - - return tc -} diff --git a/vendor/github.com/charmbracelet/x/input/terminfo.go b/vendor/github.com/charmbracelet/x/input/terminfo.go deleted file mode 100644 index d5a702a..0000000 --- a/vendor/github.com/charmbracelet/x/input/terminfo.go +++ /dev/null @@ -1,277 +0,0 @@ -package input - -import ( - "strings" - - "github.com/xo/terminfo" -) - -func buildTerminfoKeys(flags int, term string) map[string]Key { - table := make(map[string]Key) - ti, _ := terminfo.Load(term) - if ti == nil { - return table - } - - tiTable := defaultTerminfoKeys(flags) - - // Default keys - for name, seq := range ti.StringCapsShort() { - if !strings.HasPrefix(name, "k") || len(seq) == 0 { - continue - } - - if k, ok := tiTable[name]; ok { - table[string(seq)] = k - } - } - - // Extended keys - for name, seq := range ti.ExtStringCapsShort() { - if !strings.HasPrefix(name, "k") || len(seq) == 0 { - continue - } - - if k, ok := tiTable[name]; ok { - table[string(seq)] = k - } - } - - return table -} - -// This returns a map of terminfo keys to key events. It's a mix of ncurses -// terminfo default and user-defined key capabilities. -// Upper-case caps that are defined in the default terminfo database are -// - kNXT -// - kPRV -// - kHOM -// - kEND -// - kDC -// - kIC -// - kLFT -// - kRIT -// -// See https://man7.org/linux/man-pages/man5/terminfo.5.html -// See https://github.com/mirror/ncurses/blob/master/include/Caps-ncurses -func defaultTerminfoKeys(flags int) map[string]Key { - keys := map[string]Key{ - "kcuu1": {Sym: KeyUp}, - "kUP": {Sym: KeyUp, Mod: ModShift}, - "kUP3": {Sym: KeyUp, Mod: ModAlt}, - "kUP4": {Sym: KeyUp, Mod: ModShift | ModAlt}, - "kUP5": {Sym: KeyUp, Mod: ModCtrl}, - "kUP6": {Sym: KeyUp, Mod: ModShift | ModCtrl}, - "kUP7": {Sym: KeyUp, Mod: ModAlt | ModCtrl}, - "kUP8": {Sym: KeyUp, Mod: ModShift | ModAlt | ModCtrl}, - "kcud1": {Sym: KeyDown}, - "kDN": {Sym: KeyDown, Mod: ModShift}, - "kDN3": {Sym: KeyDown, Mod: ModAlt}, - "kDN4": {Sym: KeyDown, Mod: ModShift | ModAlt}, - "kDN5": {Sym: KeyDown, Mod: ModCtrl}, - "kDN7": {Sym: KeyDown, Mod: ModAlt | ModCtrl}, - "kDN6": {Sym: KeyDown, Mod: ModShift | ModCtrl}, - "kDN8": {Sym: KeyDown, Mod: ModShift | ModAlt | ModCtrl}, - "kcub1": {Sym: KeyLeft}, - "kLFT": {Sym: KeyLeft, Mod: ModShift}, - "kLFT3": {Sym: KeyLeft, Mod: ModAlt}, - "kLFT4": {Sym: KeyLeft, Mod: ModShift | ModAlt}, - "kLFT5": {Sym: KeyLeft, Mod: ModCtrl}, - "kLFT6": {Sym: KeyLeft, Mod: ModShift | ModCtrl}, - "kLFT7": {Sym: KeyLeft, Mod: ModAlt | ModCtrl}, - "kLFT8": {Sym: KeyLeft, Mod: ModShift | ModAlt | ModCtrl}, - "kcuf1": {Sym: KeyRight}, - "kRIT": {Sym: KeyRight, Mod: ModShift}, - "kRIT3": {Sym: KeyRight, Mod: ModAlt}, - "kRIT4": {Sym: KeyRight, Mod: ModShift | ModAlt}, - "kRIT5": {Sym: KeyRight, Mod: ModCtrl}, - "kRIT6": {Sym: KeyRight, Mod: ModShift | ModCtrl}, - "kRIT7": {Sym: KeyRight, Mod: ModAlt | ModCtrl}, - "kRIT8": {Sym: KeyRight, Mod: ModShift | ModAlt | ModCtrl}, - "kich1": {Sym: KeyInsert}, - "kIC": {Sym: KeyInsert, Mod: ModShift}, - "kIC3": {Sym: KeyInsert, Mod: ModAlt}, - "kIC4": {Sym: KeyInsert, Mod: ModShift | ModAlt}, - "kIC5": {Sym: KeyInsert, Mod: ModCtrl}, - "kIC6": {Sym: KeyInsert, Mod: ModShift | ModCtrl}, - "kIC7": {Sym: KeyInsert, Mod: ModAlt | ModCtrl}, - "kIC8": {Sym: KeyInsert, Mod: ModShift | ModAlt | ModCtrl}, - "kdch1": {Sym: KeyDelete}, - "kDC": {Sym: KeyDelete, Mod: ModShift}, - "kDC3": {Sym: KeyDelete, Mod: ModAlt}, - "kDC4": {Sym: KeyDelete, Mod: ModShift | ModAlt}, - "kDC5": {Sym: KeyDelete, Mod: ModCtrl}, - "kDC6": {Sym: KeyDelete, Mod: ModShift | ModCtrl}, - "kDC7": {Sym: KeyDelete, Mod: ModAlt | ModCtrl}, - "kDC8": {Sym: KeyDelete, Mod: ModShift | ModAlt | ModCtrl}, - "khome": {Sym: KeyHome}, - "kHOM": {Sym: KeyHome, Mod: ModShift}, - "kHOM3": {Sym: KeyHome, Mod: ModAlt}, - "kHOM4": {Sym: KeyHome, Mod: ModShift | ModAlt}, - "kHOM5": {Sym: KeyHome, Mod: ModCtrl}, - "kHOM6": {Sym: KeyHome, Mod: ModShift | ModCtrl}, - "kHOM7": {Sym: KeyHome, Mod: ModAlt | ModCtrl}, - "kHOM8": {Sym: KeyHome, Mod: ModShift | ModAlt | ModCtrl}, - "kend": {Sym: KeyEnd}, - "kEND": {Sym: KeyEnd, Mod: ModShift}, - "kEND3": {Sym: KeyEnd, Mod: ModAlt}, - "kEND4": {Sym: KeyEnd, Mod: ModShift | ModAlt}, - "kEND5": {Sym: KeyEnd, Mod: ModCtrl}, - "kEND6": {Sym: KeyEnd, Mod: ModShift | ModCtrl}, - "kEND7": {Sym: KeyEnd, Mod: ModAlt | ModCtrl}, - "kEND8": {Sym: KeyEnd, Mod: ModShift | ModAlt | ModCtrl}, - "kpp": {Sym: KeyPgUp}, - "kprv": {Sym: KeyPgUp}, - "kPRV": {Sym: KeyPgUp, Mod: ModShift}, - "kPRV3": {Sym: KeyPgUp, Mod: ModAlt}, - "kPRV4": {Sym: KeyPgUp, Mod: ModShift | ModAlt}, - "kPRV5": {Sym: KeyPgUp, Mod: ModCtrl}, - "kPRV6": {Sym: KeyPgUp, Mod: ModShift | ModCtrl}, - "kPRV7": {Sym: KeyPgUp, Mod: ModAlt | ModCtrl}, - "kPRV8": {Sym: KeyPgUp, Mod: ModShift | ModAlt | ModCtrl}, - "knp": {Sym: KeyPgDown}, - "knxt": {Sym: KeyPgDown}, - "kNXT": {Sym: KeyPgDown, Mod: ModShift}, - "kNXT3": {Sym: KeyPgDown, Mod: ModAlt}, - "kNXT4": {Sym: KeyPgDown, Mod: ModShift | ModAlt}, - "kNXT5": {Sym: KeyPgDown, Mod: ModCtrl}, - "kNXT6": {Sym: KeyPgDown, Mod: ModShift | ModCtrl}, - "kNXT7": {Sym: KeyPgDown, Mod: ModAlt | ModCtrl}, - "kNXT8": {Sym: KeyPgDown, Mod: ModShift | ModAlt | ModCtrl}, - - "kbs": {Sym: KeyBackspace}, - "kcbt": {Sym: KeyTab, Mod: ModShift}, - - // Function keys - // This only includes the first 12 function keys. The rest are treated - // as modifiers of the first 12. - // Take a look at XTerm modifyFunctionKeys - // - // XXX: To use unambiguous function keys, use fixterms or kitty clipboard. - // - // See https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyFunctionKeys - // See https://invisible-island.net/xterm/terminfo.html - - "kf1": {Sym: KeyF1}, - "kf2": {Sym: KeyF2}, - "kf3": {Sym: KeyF3}, - "kf4": {Sym: KeyF4}, - "kf5": {Sym: KeyF5}, - "kf6": {Sym: KeyF6}, - "kf7": {Sym: KeyF7}, - "kf8": {Sym: KeyF8}, - "kf9": {Sym: KeyF9}, - "kf10": {Sym: KeyF10}, - "kf11": {Sym: KeyF11}, - "kf12": {Sym: KeyF12}, - "kf13": {Sym: KeyF1, Mod: ModShift}, - "kf14": {Sym: KeyF2, Mod: ModShift}, - "kf15": {Sym: KeyF3, Mod: ModShift}, - "kf16": {Sym: KeyF4, Mod: ModShift}, - "kf17": {Sym: KeyF5, Mod: ModShift}, - "kf18": {Sym: KeyF6, Mod: ModShift}, - "kf19": {Sym: KeyF7, Mod: ModShift}, - "kf20": {Sym: KeyF8, Mod: ModShift}, - "kf21": {Sym: KeyF9, Mod: ModShift}, - "kf22": {Sym: KeyF10, Mod: ModShift}, - "kf23": {Sym: KeyF11, Mod: ModShift}, - "kf24": {Sym: KeyF12, Mod: ModShift}, - "kf25": {Sym: KeyF1, Mod: ModCtrl}, - "kf26": {Sym: KeyF2, Mod: ModCtrl}, - "kf27": {Sym: KeyF3, Mod: ModCtrl}, - "kf28": {Sym: KeyF4, Mod: ModCtrl}, - "kf29": {Sym: KeyF5, Mod: ModCtrl}, - "kf30": {Sym: KeyF6, Mod: ModCtrl}, - "kf31": {Sym: KeyF7, Mod: ModCtrl}, - "kf32": {Sym: KeyF8, Mod: ModCtrl}, - "kf33": {Sym: KeyF9, Mod: ModCtrl}, - "kf34": {Sym: KeyF10, Mod: ModCtrl}, - "kf35": {Sym: KeyF11, Mod: ModCtrl}, - "kf36": {Sym: KeyF12, Mod: ModCtrl}, - "kf37": {Sym: KeyF1, Mod: ModShift | ModCtrl}, - "kf38": {Sym: KeyF2, Mod: ModShift | ModCtrl}, - "kf39": {Sym: KeyF3, Mod: ModShift | ModCtrl}, - "kf40": {Sym: KeyF4, Mod: ModShift | ModCtrl}, - "kf41": {Sym: KeyF5, Mod: ModShift | ModCtrl}, - "kf42": {Sym: KeyF6, Mod: ModShift | ModCtrl}, - "kf43": {Sym: KeyF7, Mod: ModShift | ModCtrl}, - "kf44": {Sym: KeyF8, Mod: ModShift | ModCtrl}, - "kf45": {Sym: KeyF9, Mod: ModShift | ModCtrl}, - "kf46": {Sym: KeyF10, Mod: ModShift | ModCtrl}, - "kf47": {Sym: KeyF11, Mod: ModShift | ModCtrl}, - "kf48": {Sym: KeyF12, Mod: ModShift | ModCtrl}, - "kf49": {Sym: KeyF1, Mod: ModAlt}, - "kf50": {Sym: KeyF2, Mod: ModAlt}, - "kf51": {Sym: KeyF3, Mod: ModAlt}, - "kf52": {Sym: KeyF4, Mod: ModAlt}, - "kf53": {Sym: KeyF5, Mod: ModAlt}, - "kf54": {Sym: KeyF6, Mod: ModAlt}, - "kf55": {Sym: KeyF7, Mod: ModAlt}, - "kf56": {Sym: KeyF8, Mod: ModAlt}, - "kf57": {Sym: KeyF9, Mod: ModAlt}, - "kf58": {Sym: KeyF10, Mod: ModAlt}, - "kf59": {Sym: KeyF11, Mod: ModAlt}, - "kf60": {Sym: KeyF12, Mod: ModAlt}, - "kf61": {Sym: KeyF1, Mod: ModShift | ModAlt}, - "kf62": {Sym: KeyF2, Mod: ModShift | ModAlt}, - "kf63": {Sym: KeyF3, Mod: ModShift | ModAlt}, - } - - // Preserve F keys from F13 to F63 instead of using them for F-keys - // modifiers. - if flags&FlagFKeys != 0 { - keys["kf13"] = Key{Sym: KeyF13} - keys["kf14"] = Key{Sym: KeyF14} - keys["kf15"] = Key{Sym: KeyF15} - keys["kf16"] = Key{Sym: KeyF16} - keys["kf17"] = Key{Sym: KeyF17} - keys["kf18"] = Key{Sym: KeyF18} - keys["kf19"] = Key{Sym: KeyF19} - keys["kf20"] = Key{Sym: KeyF20} - keys["kf21"] = Key{Sym: KeyF21} - keys["kf22"] = Key{Sym: KeyF22} - keys["kf23"] = Key{Sym: KeyF23} - keys["kf24"] = Key{Sym: KeyF24} - keys["kf25"] = Key{Sym: KeyF25} - keys["kf26"] = Key{Sym: KeyF26} - keys["kf27"] = Key{Sym: KeyF27} - keys["kf28"] = Key{Sym: KeyF28} - keys["kf29"] = Key{Sym: KeyF29} - keys["kf30"] = Key{Sym: KeyF30} - keys["kf31"] = Key{Sym: KeyF31} - keys["kf32"] = Key{Sym: KeyF32} - keys["kf33"] = Key{Sym: KeyF33} - keys["kf34"] = Key{Sym: KeyF34} - keys["kf35"] = Key{Sym: KeyF35} - keys["kf36"] = Key{Sym: KeyF36} - keys["kf37"] = Key{Sym: KeyF37} - keys["kf38"] = Key{Sym: KeyF38} - keys["kf39"] = Key{Sym: KeyF39} - keys["kf40"] = Key{Sym: KeyF40} - keys["kf41"] = Key{Sym: KeyF41} - keys["kf42"] = Key{Sym: KeyF42} - keys["kf43"] = Key{Sym: KeyF43} - keys["kf44"] = Key{Sym: KeyF44} - keys["kf45"] = Key{Sym: KeyF45} - keys["kf46"] = Key{Sym: KeyF46} - keys["kf47"] = Key{Sym: KeyF47} - keys["kf48"] = Key{Sym: KeyF48} - keys["kf49"] = Key{Sym: KeyF49} - keys["kf50"] = Key{Sym: KeyF50} - keys["kf51"] = Key{Sym: KeyF51} - keys["kf52"] = Key{Sym: KeyF52} - keys["kf53"] = Key{Sym: KeyF53} - keys["kf54"] = Key{Sym: KeyF54} - keys["kf55"] = Key{Sym: KeyF55} - keys["kf56"] = Key{Sym: KeyF56} - keys["kf57"] = Key{Sym: KeyF57} - keys["kf58"] = Key{Sym: KeyF58} - keys["kf59"] = Key{Sym: KeyF59} - keys["kf60"] = Key{Sym: KeyF60} - keys["kf61"] = Key{Sym: KeyF61} - keys["kf62"] = Key{Sym: KeyF62} - keys["kf63"] = Key{Sym: KeyF63} - } - - return keys -} diff --git a/vendor/github.com/charmbracelet/x/input/win32input.go b/vendor/github.com/charmbracelet/x/input/win32input.go deleted file mode 100644 index a8d5f4b..0000000 --- a/vendor/github.com/charmbracelet/x/input/win32input.go +++ /dev/null @@ -1,240 +0,0 @@ -package input - -import ( - "unicode" - - "github.com/erikgeiser/coninput" -) - -func parseWin32InputKeyEvent(vkc coninput.VirtualKeyCode, _ coninput.VirtualKeyCode, r rune, keyDown bool, cks coninput.ControlKeyState, repeatCount uint16) Event { - var key Key - isCtrl := cks.Contains(coninput.LEFT_CTRL_PRESSED | coninput.RIGHT_CTRL_PRESSED) - switch vkc { - case coninput.VK_SHIFT: - // We currently ignore these keys when they are pressed alone. - return nil - case coninput.VK_MENU: - if cks.Contains(coninput.LEFT_ALT_PRESSED) { - key = Key{Sym: KeyLeftAlt} - } else if cks.Contains(coninput.RIGHT_ALT_PRESSED) { - key = Key{Sym: KeyRightAlt} - } else if !keyDown { - return nil - } - case coninput.VK_CONTROL: - if cks.Contains(coninput.LEFT_CTRL_PRESSED) { - key = Key{Sym: KeyLeftCtrl} - } else if cks.Contains(coninput.RIGHT_CTRL_PRESSED) { - key = Key{Sym: KeyRightCtrl} - } else if !keyDown { - return nil - } - case coninput.VK_CAPITAL: - key = Key{Sym: KeyCapsLock} - default: - var ok bool - key, ok = vkKeyEvent[vkc] - if !ok { - if isCtrl { - key = vkCtrlRune(key, r, vkc) - } else { - key = Key{Rune: r} - } - } - } - - if isCtrl { - key.Mod |= ModCtrl - } - if cks.Contains(coninput.LEFT_ALT_PRESSED | coninput.RIGHT_ALT_PRESSED) { - key.Mod |= ModAlt - } - if cks.Contains(coninput.SHIFT_PRESSED) { - key.Mod |= ModShift - } - if cks.Contains(coninput.CAPSLOCK_ON) { - key.Mod |= ModCapsLock - } - if cks.Contains(coninput.NUMLOCK_ON) { - key.Mod |= ModNumLock - } - if cks.Contains(coninput.SCROLLLOCK_ON) { - key.Mod |= ModScrollLock - } - - // Use the unshifted key - if cks.Contains(coninput.SHIFT_PRESSED ^ coninput.CAPSLOCK_ON) { - key.AltRune = unicode.ToUpper(key.Rune) - } else { - key.AltRune = unicode.ToLower(key.Rune) - } - - var e Event = KeyPressEvent(key) - key.IsRepeat = repeatCount > 1 - if !keyDown { - e = KeyReleaseEvent(key) - } - - if repeatCount <= 1 { - return e - } - - var kevents []Event - for i := 0; i < int(repeatCount); i++ { - kevents = append(kevents, e) - } - - return MultiEvent(kevents) -} - -var vkKeyEvent = map[coninput.VirtualKeyCode]Key{ - coninput.VK_RETURN: {Sym: KeyEnter}, - coninput.VK_BACK: {Sym: KeyBackspace}, - coninput.VK_TAB: {Sym: KeyTab}, - coninput.VK_ESCAPE: {Sym: KeyEscape}, - coninput.VK_SPACE: {Sym: KeySpace, Rune: ' '}, - coninput.VK_UP: {Sym: KeyUp}, - coninput.VK_DOWN: {Sym: KeyDown}, - coninput.VK_RIGHT: {Sym: KeyRight}, - coninput.VK_LEFT: {Sym: KeyLeft}, - coninput.VK_HOME: {Sym: KeyHome}, - coninput.VK_END: {Sym: KeyEnd}, - coninput.VK_PRIOR: {Sym: KeyPgUp}, - coninput.VK_NEXT: {Sym: KeyPgDown}, - coninput.VK_DELETE: {Sym: KeyDelete}, - coninput.VK_SELECT: {Sym: KeySelect}, - coninput.VK_SNAPSHOT: {Sym: KeyPrintScreen}, - coninput.VK_INSERT: {Sym: KeyInsert}, - coninput.VK_LWIN: {Sym: KeyLeftSuper}, - coninput.VK_RWIN: {Sym: KeyRightSuper}, - coninput.VK_APPS: {Sym: KeyMenu}, - coninput.VK_NUMPAD0: {Sym: KeyKp0}, - coninput.VK_NUMPAD1: {Sym: KeyKp1}, - coninput.VK_NUMPAD2: {Sym: KeyKp2}, - coninput.VK_NUMPAD3: {Sym: KeyKp3}, - coninput.VK_NUMPAD4: {Sym: KeyKp4}, - coninput.VK_NUMPAD5: {Sym: KeyKp5}, - coninput.VK_NUMPAD6: {Sym: KeyKp6}, - coninput.VK_NUMPAD7: {Sym: KeyKp7}, - coninput.VK_NUMPAD8: {Sym: KeyKp8}, - coninput.VK_NUMPAD9: {Sym: KeyKp9}, - coninput.VK_MULTIPLY: {Sym: KeyKpMultiply}, - coninput.VK_ADD: {Sym: KeyKpPlus}, - coninput.VK_SEPARATOR: {Sym: KeyKpComma}, - coninput.VK_SUBTRACT: {Sym: KeyKpMinus}, - coninput.VK_DECIMAL: {Sym: KeyKpDecimal}, - coninput.VK_DIVIDE: {Sym: KeyKpDivide}, - coninput.VK_F1: {Sym: KeyF1}, - coninput.VK_F2: {Sym: KeyF2}, - coninput.VK_F3: {Sym: KeyF3}, - coninput.VK_F4: {Sym: KeyF4}, - coninput.VK_F5: {Sym: KeyF5}, - coninput.VK_F6: {Sym: KeyF6}, - coninput.VK_F7: {Sym: KeyF7}, - coninput.VK_F8: {Sym: KeyF8}, - coninput.VK_F9: {Sym: KeyF9}, - coninput.VK_F10: {Sym: KeyF10}, - coninput.VK_F11: {Sym: KeyF11}, - coninput.VK_F12: {Sym: KeyF12}, - coninput.VK_F13: {Sym: KeyF13}, - coninput.VK_F14: {Sym: KeyF14}, - coninput.VK_F15: {Sym: KeyF15}, - coninput.VK_F16: {Sym: KeyF16}, - coninput.VK_F17: {Sym: KeyF17}, - coninput.VK_F18: {Sym: KeyF18}, - coninput.VK_F19: {Sym: KeyF19}, - coninput.VK_F20: {Sym: KeyF20}, - coninput.VK_F21: {Sym: KeyF21}, - coninput.VK_F22: {Sym: KeyF22}, - coninput.VK_F23: {Sym: KeyF23}, - coninput.VK_F24: {Sym: KeyF24}, - coninput.VK_NUMLOCK: {Sym: KeyNumLock}, - coninput.VK_SCROLL: {Sym: KeyScrollLock}, - coninput.VK_LSHIFT: {Sym: KeyLeftShift}, - coninput.VK_RSHIFT: {Sym: KeyRightShift}, - coninput.VK_LCONTROL: {Sym: KeyLeftCtrl}, - coninput.VK_RCONTROL: {Sym: KeyRightCtrl}, - coninput.VK_LMENU: {Sym: KeyLeftAlt}, - coninput.VK_RMENU: {Sym: KeyRightAlt}, - coninput.VK_OEM_4: {Rune: '['}, - // TODO: add more keys -} - -func vkCtrlRune(k Key, r rune, kc coninput.VirtualKeyCode) Key { - switch r { - case '@': - k.Rune = '@' - case '\x01': - k.Rune = 'a' - case '\x02': - k.Rune = 'b' - case '\x03': - k.Rune = 'c' - case '\x04': - k.Rune = 'd' - case '\x05': - k.Rune = 'e' - case '\x06': - k.Rune = 'f' - case '\a': - k.Rune = 'g' - case '\b': - k.Rune = 'h' - case '\t': - k.Rune = 'i' - case '\n': - k.Rune = 'j' - case '\v': - k.Rune = 'k' - case '\f': - k.Rune = 'l' - case '\r': - k.Rune = 'm' - case '\x0e': - k.Rune = 'n' - case '\x0f': - k.Rune = 'o' - case '\x10': - k.Rune = 'p' - case '\x11': - k.Rune = 'q' - case '\x12': - k.Rune = 'r' - case '\x13': - k.Rune = 's' - case '\x14': - k.Rune = 't' - case '\x15': - k.Rune = 'u' - case '\x16': - k.Rune = 'v' - case '\x17': - k.Rune = 'w' - case '\x18': - k.Rune = 'x' - case '\x19': - k.Rune = 'y' - case '\x1a': - k.Rune = 'z' - case '\x1b': - k.Rune = ']' - case '\x1c': - k.Rune = '\\' - case '\x1f': - k.Rune = '_' - } - - switch kc { - case coninput.VK_OEM_4: - k.Rune = '[' - } - - // https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes - if k.Rune == 0 && - (kc >= 0x30 && kc <= 0x39) || - (kc >= 0x41 && kc <= 0x5a) { - k.Rune = rune(kc) - } - - return k -} diff --git a/vendor/github.com/charmbracelet/x/input/xterm.go b/vendor/github.com/charmbracelet/x/input/xterm.go deleted file mode 100644 index 00a6751..0000000 --- a/vendor/github.com/charmbracelet/x/input/xterm.go +++ /dev/null @@ -1,40 +0,0 @@ -package input - -import ( - "github.com/charmbracelet/x/ansi" -) - -func parseXTermModifyOtherKeys(csi *ansi.CsiSequence) Event { - // XTerm modify other keys starts with ESC [ 27 ; ; ~ - mod := KeyMod(csi.Param(1) - 1) - r := rune(csi.Param(2)) - - switch r { - case ansi.BS: - return KeyPressEvent{Mod: mod, Sym: KeyBackspace} - case ansi.HT: - return KeyPressEvent{Mod: mod, Sym: KeyTab} - case ansi.CR: - return KeyPressEvent{Mod: mod, Sym: KeyEnter} - case ansi.ESC: - return KeyPressEvent{Mod: mod, Sym: KeyEscape} - case ansi.DEL: - return KeyPressEvent{Mod: mod, Sym: KeyBackspace} - } - - // CSI 27 ; ; ~ keys defined in XTerm modifyOtherKeys - return KeyPressEvent{ - Mod: mod, - Rune: r, - } -} - -// ModifyOtherKeysEvent represents a modifyOtherKeys event. -// -// 0: disable -// 1: enable mode 1 -// 2: enable mode 2 -// -// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ -// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys -type ModifyOtherKeysEvent uint8 diff --git a/vendor/github.com/charmbracelet/x/term/terminal.go b/vendor/github.com/charmbracelet/x/term/terminal.go index 09d83f9..8963163 100644 --- a/vendor/github.com/charmbracelet/x/term/terminal.go +++ b/vendor/github.com/charmbracelet/x/term/terminal.go @@ -1,12 +1,7 @@ package term import ( - "image/color" "io" - "time" - - "github.com/charmbracelet/x/ansi" - "github.com/charmbracelet/x/input" ) // File represents a file that has a file descriptor and can be read from, @@ -15,112 +10,3 @@ type File interface { io.ReadWriteCloser Fd() uintptr } - -// QueryBackgroundColor queries the terminal for the background color. -// If the terminal does not support querying the background color, nil is -// returned. -// -// Note: you will need to set the input to raw mode before calling this -// function. -// -// state, _ := term.MakeRaw(in.Fd()) -// defer term.Restore(in.Fd(), state) -func QueryBackgroundColor(in io.Reader, out io.Writer) (c color.Color, err error) { - // nolint: errcheck - err = QueryTerminal(in, out, defaultQueryTimeout, - func(events []input.Event) bool { - for _, e := range events { - switch e := e.(type) { - case input.BackgroundColorEvent: - c = e.Color - continue // we need to consume the next DA1 event - case input.PrimaryDeviceAttributesEvent: - return false - } - } - return true - }, ansi.RequestBackgroundColor+ansi.RequestPrimaryDeviceAttributes) - return -} - -// QueryKittyKeyboard returns the enabled Kitty keyboard protocol options. -// -1 means the terminal does not support the feature. -// -// Note: you will need to set the input to raw mode before calling this -// function. -// -// state, _ := term.MakeRaw(in.Fd()) -// defer term.Restore(in.Fd(), state) -func QueryKittyKeyboard(in io.Reader, out io.Writer) (flags int, err error) { - flags = -1 - // nolint: errcheck - err = QueryTerminal(in, out, defaultQueryTimeout, - func(events []input.Event) bool { - for _, e := range events { - switch event := e.(type) { - case input.KittyKeyboardEvent: - flags = int(event) - continue // we need to consume the next DA1 event - case input.PrimaryDeviceAttributesEvent: - return false - } - } - return true - }, ansi.RequestKittyKeyboard+ansi.RequestPrimaryDeviceAttributes) - return -} - -const defaultQueryTimeout = time.Second * 2 - -// QueryTerminalFilter is a function that filters input events using a type -// switch. If false is returned, the QueryTerminal function will stop reading -// input. -type QueryTerminalFilter func(events []input.Event) bool - -// QueryTerminal queries the terminal for support of various features and -// returns a list of response events. -// Most of the time, you will need to set stdin to raw mode before calling this -// function. -// Note: This function will block until the terminal responds or the timeout -// is reached. -func QueryTerminal( - in io.Reader, - out io.Writer, - timeout time.Duration, - filter QueryTerminalFilter, - query string, -) error { - rd, err := input.NewDriver(in, "", 0) - if err != nil { - return err - } - - defer rd.Close() // nolint: errcheck - - done := make(chan struct{}, 1) - defer close(done) - go func() { - select { - case <-done: - case <-time.After(timeout): - rd.Cancel() - } - }() - - if _, err := io.WriteString(out, query); err != nil { - return err - } - - for { - events, err := rd.ReadEvents() - if err != nil { - return err - } - - if !filter(events) { - break - } - } - - return nil -} diff --git a/vendor/github.com/charmbracelet/x/windows/LICENSE b/vendor/github.com/charmbracelet/x/windows/LICENSE deleted file mode 100644 index 65a5654..0000000 --- a/vendor/github.com/charmbracelet/x/windows/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Charmbracelet, Inc. - -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/charmbracelet/x/windows/doc.go b/vendor/github.com/charmbracelet/x/windows/doc.go deleted file mode 100644 index b385246..0000000 --- a/vendor/github.com/charmbracelet/x/windows/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -package windows - -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall_windows.go diff --git a/vendor/github.com/charmbracelet/x/windows/syscall_windows.go b/vendor/github.com/charmbracelet/x/windows/syscall_windows.go deleted file mode 100644 index f57cbd9..0000000 --- a/vendor/github.com/charmbracelet/x/windows/syscall_windows.go +++ /dev/null @@ -1,10 +0,0 @@ -package windows - -import "golang.org/x/sys/windows" - -var NewLazySystemDLL = windows.NewLazySystemDLL - -type Handle = windows.Handle - -//sys GetKeyboardLayout(threadId uint32) (hkl Handle) = user32.GetKeyboardLayout -//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx diff --git a/vendor/github.com/charmbracelet/x/windows/zsyscall_windows.go b/vendor/github.com/charmbracelet/x/windows/zsyscall_windows.go deleted file mode 100644 index a58f460..0000000 --- a/vendor/github.com/charmbracelet/x/windows/zsyscall_windows.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by 'go generate'; DO NOT EDIT. - -package windows - -import ( - "syscall" - "unsafe" -) - -var _ unsafe.Pointer - -// Do the interface allocations only once for common -// Errno values. -const ( - errnoERROR_IO_PENDING = 997 -) - -var ( - errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) - errERROR_EINVAL error = syscall.EINVAL -) - -// errnoErr returns common boxed Errno values, to prevent -// allocations at runtime. -func errnoErr(e syscall.Errno) error { - switch e { - case 0: - return errERROR_EINVAL - case errnoERROR_IO_PENDING: - return errERROR_IO_PENDING - } - // TODO: add more here, after collecting data on the common - // error values see on Windows. (perhaps when running - // all.bat?) - return e -} - -var ( - moduser32 = NewLazySystemDLL("user32.dll") - - procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") - procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") -) - -func GetKeyboardLayout(threadId uint32) (hkl Handle) { - r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(threadId), 0, 0) - hkl = Handle(r0) - return -} - -func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { - r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) - ret = int32(r0) - return -} diff --git a/vendor/github.com/xo/terminfo/.gitignore b/vendor/github.com/xo/terminfo/.gitignore deleted file mode 100644 index 368e0c0..0000000 --- a/vendor/github.com/xo/terminfo/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -/.cache/ - -/cmd/infocmp/infocmp -/cmd/infocmp/.out/ - -/infocmp -/.out/ - -*.txt diff --git a/vendor/github.com/xo/terminfo/LICENSE b/vendor/github.com/xo/terminfo/LICENSE deleted file mode 100644 index 197dadb..0000000 --- a/vendor/github.com/xo/terminfo/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Anmol Sethi - -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/xo/terminfo/README.md b/vendor/github.com/xo/terminfo/README.md deleted file mode 100644 index e5002d2..0000000 --- a/vendor/github.com/xo/terminfo/README.md +++ /dev/null @@ -1,139 +0,0 @@ -# About terminfo [![GoDoc][1]][2] - -Package `terminfo` provides a pure-Go implementation of reading information -from the terminfo database. - -`terminfo` is meant as a replacement for `ncurses` in simple Go programs. - -## Installing - -Install in the usual Go way: - -```sh -$ go get -u github.com/xo/terminfo -``` - -## Using - -Please see the [GoDoc API listing][2] for more information on using `terminfo`. - -```go -// _examples/simple/main.go -package main - -import ( - "bytes" - "fmt" - "log" - "os" - "os/signal" - "strings" - "sync" - "syscall" - - "github.com/xo/terminfo" -) - -func main() { - //r := rand.New(nil) - - // load terminfo - ti, err := terminfo.LoadFromEnv() - if err != nil { - log.Fatal(err) - } - - // cleanup - defer func() { - err := recover() - termreset(ti) - if err != nil { - log.Fatal(err) - } - }() - - terminit(ti) - termtitle(ti, "simple example!") - termputs(ti, 3, 3, "Ctrl-C to exit") - maxColors := termcolors(ti) - if maxColors > 256 { - maxColors = 256 - } - for i := 0; i < maxColors; i++ { - termputs(ti, 5+i/16, 5+i%16, ti.Colorf(i, 0, "█")) - } - - // wait for signal - sigs := make(chan os.Signal, 1) - signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) - <-sigs -} - -// terminit initializes the special CA mode on the terminal, and makes the -// cursor invisible. -func terminit(ti *terminfo.Terminfo) { - buf := new(bytes.Buffer) - // set the cursor invisible - ti.Fprintf(buf, terminfo.CursorInvisible) - // enter special mode - ti.Fprintf(buf, terminfo.EnterCaMode) - // clear the screen - ti.Fprintf(buf, terminfo.ClearScreen) - os.Stdout.Write(buf.Bytes()) -} - -// termreset is the inverse of terminit. -func termreset(ti *terminfo.Terminfo) { - buf := new(bytes.Buffer) - ti.Fprintf(buf, terminfo.ExitCaMode) - ti.Fprintf(buf, terminfo.CursorNormal) - os.Stdout.Write(buf.Bytes()) -} - -// termputs puts a string at row, col, interpolating v. -func termputs(ti *terminfo.Terminfo, row, col int, s string, v ...interface{}) { - buf := new(bytes.Buffer) - ti.Fprintf(buf, terminfo.CursorAddress, row, col) - fmt.Fprintf(buf, s, v...) - os.Stdout.Write(buf.Bytes()) -} - -// sl is the status line terminfo. -var sl *terminfo.Terminfo - -// termtitle sets the window title. -func termtitle(ti *terminfo.Terminfo, s string) { - var once sync.Once - once.Do(func() { - if ti.Has(terminfo.HasStatusLine) { - return - } - // load the sl xterm if terminal is an xterm or has COLORTERM - if strings.Contains(strings.ToLower(os.Getenv("TERM")), "xterm") || os.Getenv("COLORTERM") == "truecolor" { - sl, _ = terminfo.Load("xterm+sl") - } - }) - if sl != nil { - ti = sl - } - if !ti.Has(terminfo.HasStatusLine) { - return - } - buf := new(bytes.Buffer) - ti.Fprintf(buf, terminfo.ToStatusLine) - fmt.Fprint(buf, s) - ti.Fprintf(buf, terminfo.FromStatusLine) - os.Stdout.Write(buf.Bytes()) -} - -// termcolors returns the maximum colors available for the terminal. -func termcolors(ti *terminfo.Terminfo) int { - if colors := ti.Num(terminfo.MaxColors); colors > 0 { - return colors - } - return int(terminfo.ColorLevelBasic) -} -``` - -[1]: https://godoc.org/github.com/xo/terminfo?status.svg -[2]: https://godoc.org/github.com/xo/terminfo diff --git a/vendor/github.com/xo/terminfo/caps.go b/vendor/github.com/xo/terminfo/caps.go deleted file mode 100644 index e5e1d41..0000000 --- a/vendor/github.com/xo/terminfo/caps.go +++ /dev/null @@ -1,31 +0,0 @@ -package terminfo - -// BoolCapName returns the bool capability name. -func BoolCapName(i int) string { - return boolCapNames[2*i] -} - -// BoolCapNameShort returns the short bool capability name. -func BoolCapNameShort(i int) string { - return boolCapNames[2*i+1] -} - -// NumCapName returns the num capability name. -func NumCapName(i int) string { - return numCapNames[2*i] -} - -// NumCapNameShort returns the short num capability name. -func NumCapNameShort(i int) string { - return numCapNames[2*i+1] -} - -// StringCapName returns the string capability name. -func StringCapName(i int) string { - return stringCapNames[2*i] -} - -// StringCapNameShort returns the short string capability name. -func StringCapNameShort(i int) string { - return stringCapNames[2*i+1] -} diff --git a/vendor/github.com/xo/terminfo/capvals.go b/vendor/github.com/xo/terminfo/capvals.go deleted file mode 100644 index 0c2274e..0000000 --- a/vendor/github.com/xo/terminfo/capvals.go +++ /dev/null @@ -1,1525 +0,0 @@ -package terminfo - -// Code generated by gen.go. DO NOT EDIT. -// Bool capabilities. -const ( - // The AutoLeftMargin [auto_left_margin, bw] bool capability indicates cub1 wraps from column 0 to last column. - AutoLeftMargin = iota - // The AutoRightMargin [auto_right_margin, am] bool capability indicates terminal has automatic margins. - AutoRightMargin - // The NoEscCtlc [no_esc_ctlc, xsb] bool capability indicates beehive (f1=escape, f2=ctrl C). - NoEscCtlc - // The CeolStandoutGlitch [ceol_standout_glitch, xhp] bool capability indicates standout not erased by overwriting (hp). - CeolStandoutGlitch - // The EatNewlineGlitch [eat_newline_glitch, xenl] bool capability indicates newline ignored after 80 cols (concept). - EatNewlineGlitch - // The EraseOverstrike [erase_overstrike, eo] bool capability indicates can erase overstrikes with a blank. - EraseOverstrike - // The GenericType [generic_type, gn] bool capability indicates generic line type. - GenericType - // The HardCopy [hard_copy, hc] bool capability indicates hardcopy terminal. - HardCopy - // The HasMetaKey [has_meta_key, km] bool capability indicates Has a meta key (i.e., sets 8th-bit). - HasMetaKey - // The HasStatusLine [has_status_line, hs] bool capability indicates has extra status line. - HasStatusLine - // The InsertNullGlitch [insert_null_glitch, in] bool capability indicates insert mode distinguishes nulls. - InsertNullGlitch - // The MemoryAbove [memory_above, da] bool capability indicates display may be retained above the screen. - MemoryAbove - // The MemoryBelow [memory_below, db] bool capability indicates display may be retained below the screen. - MemoryBelow - // The MoveInsertMode [move_insert_mode, mir] bool capability indicates safe to move while in insert mode. - MoveInsertMode - // The MoveStandoutMode [move_standout_mode, msgr] bool capability indicates safe to move while in standout mode. - MoveStandoutMode - // The OverStrike [over_strike, os] bool capability indicates terminal can overstrike. - OverStrike - // The StatusLineEscOk [status_line_esc_ok, eslok] bool capability indicates escape can be used on the status line. - StatusLineEscOk - // The DestTabsMagicSmso [dest_tabs_magic_smso, xt] bool capability indicates tabs destructive, magic so char (t1061). - DestTabsMagicSmso - // The TildeGlitch [tilde_glitch, hz] bool capability indicates cannot print ~'s (Hazeltine). - TildeGlitch - // The TransparentUnderline [transparent_underline, ul] bool capability indicates underline character overstrikes. - TransparentUnderline - // The XonXoff [xon_xoff, xon] bool capability indicates terminal uses xon/xoff handshaking. - XonXoff - // The NeedsXonXoff [needs_xon_xoff, nxon] bool capability indicates padding will not work, xon/xoff required. - NeedsXonXoff - // The PrtrSilent [prtr_silent, mc5i] bool capability indicates printer will not echo on screen. - PrtrSilent - // The HardCursor [hard_cursor, chts] bool capability indicates cursor is hard to see. - HardCursor - // The NonRevRmcup [non_rev_rmcup, nrrmc] bool capability indicates smcup does not reverse rmcup. - NonRevRmcup - // The NoPadChar [no_pad_char, npc] bool capability indicates pad character does not exist. - NoPadChar - // The NonDestScrollRegion [non_dest_scroll_region, ndscr] bool capability indicates scrolling region is non-destructive. - NonDestScrollRegion - // The CanChange [can_change, ccc] bool capability indicates terminal can re-define existing colors. - CanChange - // The BackColorErase [back_color_erase, bce] bool capability indicates screen erased with background color. - BackColorErase - // The HueLightnessSaturation [hue_lightness_saturation, hls] bool capability indicates terminal uses only HLS color notation (Tektronix). - HueLightnessSaturation - // The ColAddrGlitch [col_addr_glitch, xhpa] bool capability indicates only positive motion for hpa/mhpa caps. - ColAddrGlitch - // The CrCancelsMicroMode [cr_cancels_micro_mode, crxm] bool capability indicates using cr turns off micro mode. - CrCancelsMicroMode - // The HasPrintWheel [has_print_wheel, daisy] bool capability indicates printer needs operator to change character set. - HasPrintWheel - // The RowAddrGlitch [row_addr_glitch, xvpa] bool capability indicates only positive motion for vpa/mvpa caps. - RowAddrGlitch - // The SemiAutoRightMargin [semi_auto_right_margin, sam] bool capability indicates printing in last column causes cr. - SemiAutoRightMargin - // The CpiChangesRes [cpi_changes_res, cpix] bool capability indicates changing character pitch changes resolution. - CpiChangesRes - // The LpiChangesRes [lpi_changes_res, lpix] bool capability indicates changing line pitch changes resolution. - LpiChangesRes - // The BackspacesWithBs [backspaces_with_bs, OTbs] bool capability indicates uses ^H to move left. - BackspacesWithBs - // The CrtNoScrolling [crt_no_scrolling, OTns] bool capability indicates crt cannot scroll. - CrtNoScrolling - // The NoCorrectlyWorkingCr [no_correctly_working_cr, OTnc] bool capability indicates no way to go to start of line. - NoCorrectlyWorkingCr - // The GnuHasMetaKey [gnu_has_meta_key, OTMT] bool capability indicates has meta key. - GnuHasMetaKey - // The LinefeedIsNewline [linefeed_is_newline, OTNL] bool capability indicates move down with \n. - LinefeedIsNewline - // The HasHardwareTabs [has_hardware_tabs, OTpt] bool capability indicates has 8-char tabs invoked with ^I. - HasHardwareTabs - // The ReturnDoesClrEol [return_does_clr_eol, OTxr] bool capability indicates return clears the line. - ReturnDoesClrEol -) - -// Num capabilities. -const ( - // The Columns [columns, cols] num capability is number of columns in a line. - Columns = iota - // The InitTabs [init_tabs, it] num capability is tabs initially every # spaces. - InitTabs - // The Lines [lines, lines] num capability is number of lines on screen or page. - Lines - // The LinesOfMemory [lines_of_memory, lm] num capability is lines of memory if > line. 0 means varies. - LinesOfMemory - // The MagicCookieGlitch [magic_cookie_glitch, xmc] num capability is number of blank characters left by smso or rmso. - MagicCookieGlitch - // The PaddingBaudRate [padding_baud_rate, pb] num capability is lowest baud rate where padding needed. - PaddingBaudRate - // The VirtualTerminal [virtual_terminal, vt] num capability is virtual terminal number (CB/unix). - VirtualTerminal - // The WidthStatusLine [width_status_line, wsl] num capability is number of columns in status line. - WidthStatusLine - // The NumLabels [num_labels, nlab] num capability is number of labels on screen. - NumLabels - // The LabelHeight [label_height, lh] num capability is rows in each label. - LabelHeight - // The LabelWidth [label_width, lw] num capability is columns in each label. - LabelWidth - // The MaxAttributes [max_attributes, ma] num capability is maximum combined attributes terminal can handle. - MaxAttributes - // The MaximumWindows [maximum_windows, wnum] num capability is maximum number of definable windows. - MaximumWindows - // The MaxColors [max_colors, colors] num capability is maximum number of colors on screen. - MaxColors - // The MaxPairs [max_pairs, pairs] num capability is maximum number of color-pairs on the screen. - MaxPairs - // The NoColorVideo [no_color_video, ncv] num capability is video attributes that cannot be used with colors. - NoColorVideo - // The BufferCapacity [buffer_capacity, bufsz] num capability is numbers of bytes buffered before printing. - BufferCapacity - // The DotVertSpacing [dot_vert_spacing, spinv] num capability is spacing of pins vertically in pins per inch. - DotVertSpacing - // The DotHorzSpacing [dot_horz_spacing, spinh] num capability is spacing of dots horizontally in dots per inch. - DotHorzSpacing - // The MaxMicroAddress [max_micro_address, maddr] num capability is maximum value in micro_..._address. - MaxMicroAddress - // The MaxMicroJump [max_micro_jump, mjump] num capability is maximum value in parm_..._micro. - MaxMicroJump - // The MicroColSize [micro_col_size, mcs] num capability is character step size when in micro mode. - MicroColSize - // The MicroLineSize [micro_line_size, mls] num capability is line step size when in micro mode. - MicroLineSize - // The NumberOfPins [number_of_pins, npins] num capability is numbers of pins in print-head. - NumberOfPins - // The OutputResChar [output_res_char, orc] num capability is horizontal resolution in units per line. - OutputResChar - // The OutputResLine [output_res_line, orl] num capability is vertical resolution in units per line. - OutputResLine - // The OutputResHorzInch [output_res_horz_inch, orhi] num capability is horizontal resolution in units per inch. - OutputResHorzInch - // The OutputResVertInch [output_res_vert_inch, orvi] num capability is vertical resolution in units per inch. - OutputResVertInch - // The PrintRate [print_rate, cps] num capability is print rate in characters per second. - PrintRate - // The WideCharSize [wide_char_size, widcs] num capability is character step size when in double wide mode. - WideCharSize - // The Buttons [buttons, btns] num capability is number of buttons on mouse. - Buttons - // The BitImageEntwining [bit_image_entwining, bitwin] num capability is number of passes for each bit-image row. - BitImageEntwining - // The BitImageType [bit_image_type, bitype] num capability is type of bit-image device. - BitImageType - // The MagicCookieGlitchUl [magic_cookie_glitch_ul, OTug] num capability is number of blanks left by ul. - MagicCookieGlitchUl - // The CarriageReturnDelay [carriage_return_delay, OTdC] num capability is pad needed for CR. - CarriageReturnDelay - // The NewLineDelay [new_line_delay, OTdN] num capability is pad needed for LF. - NewLineDelay - // The BackspaceDelay [backspace_delay, OTdB] num capability is padding required for ^H. - BackspaceDelay - // The HorizontalTabDelay [horizontal_tab_delay, OTdT] num capability is padding required for ^I. - HorizontalTabDelay - // The NumberOfFunctionKeys [number_of_function_keys, OTkn] num capability is count of function keys. - NumberOfFunctionKeys -) - -// String capabilities. -const ( - // The BackTab [back_tab, cbt] string capability is the back tab (P). - BackTab = iota - // The Bell [bell, bel] string capability is the audible signal (bell) (P). - Bell - // The CarriageReturn [carriage_return, cr] string capability is the carriage return (P*) (P*). - CarriageReturn - // The ChangeScrollRegion [change_scroll_region, csr] string capability is the change region to line #1 to line #2 (P). - ChangeScrollRegion - // The ClearAllTabs [clear_all_tabs, tbc] string capability is the clear all tab stops (P). - ClearAllTabs - // The ClearScreen [clear_screen, clear] string capability is the clear screen and home cursor (P*). - ClearScreen - // The ClrEol [clr_eol, el] string capability is the clear to end of line (P). - ClrEol - // The ClrEos [clr_eos, ed] string capability is the clear to end of screen (P*). - ClrEos - // The ColumnAddress [column_address, hpa] string capability is the horizontal position #1, absolute (P). - ColumnAddress - // The CommandCharacter [command_character, cmdch] string capability is the terminal settable cmd character in prototype !?. - CommandCharacter - // The CursorAddress [cursor_address, cup] string capability is the move to row #1 columns #2. - CursorAddress - // The CursorDown [cursor_down, cud1] string capability is the down one line. - CursorDown - // The CursorHome [cursor_home, home] string capability is the home cursor (if no cup). - CursorHome - // The CursorInvisible [cursor_invisible, civis] string capability is the make cursor invisible. - CursorInvisible - // The CursorLeft [cursor_left, cub1] string capability is the move left one space. - CursorLeft - // The CursorMemAddress [cursor_mem_address, mrcup] string capability is the memory relative cursor addressing, move to row #1 columns #2. - CursorMemAddress - // The CursorNormal [cursor_normal, cnorm] string capability is the make cursor appear normal (undo civis/cvvis). - CursorNormal - // The CursorRight [cursor_right, cuf1] string capability is the non-destructive space (move right one space). - CursorRight - // The CursorToLl [cursor_to_ll, ll] string capability is the last line, first column (if no cup). - CursorToLl - // The CursorUp [cursor_up, cuu1] string capability is the up one line. - CursorUp - // The CursorVisible [cursor_visible, cvvis] string capability is the make cursor very visible. - CursorVisible - // The DeleteCharacter [delete_character, dch1] string capability is the delete character (P*). - DeleteCharacter - // The DeleteLine [delete_line, dl1] string capability is the delete line (P*). - DeleteLine - // The DisStatusLine [dis_status_line, dsl] string capability is the disable status line. - DisStatusLine - // The DownHalfLine [down_half_line, hd] string capability is the half a line down. - DownHalfLine - // The EnterAltCharsetMode [enter_alt_charset_mode, smacs] string capability is the start alternate character set (P). - EnterAltCharsetMode - // The EnterBlinkMode [enter_blink_mode, blink] string capability is the turn on blinking. - EnterBlinkMode - // The EnterBoldMode [enter_bold_mode, bold] string capability is the turn on bold (extra bright) mode. - EnterBoldMode - // The EnterCaMode [enter_ca_mode, smcup] string capability is the string to start programs using cup. - EnterCaMode - // The EnterDeleteMode [enter_delete_mode, smdc] string capability is the enter delete mode. - EnterDeleteMode - // The EnterDimMode [enter_dim_mode, dim] string capability is the turn on half-bright mode. - EnterDimMode - // The EnterInsertMode [enter_insert_mode, smir] string capability is the enter insert mode. - EnterInsertMode - // The EnterSecureMode [enter_secure_mode, invis] string capability is the turn on blank mode (characters invisible). - EnterSecureMode - // The EnterProtectedMode [enter_protected_mode, prot] string capability is the turn on protected mode. - EnterProtectedMode - // The EnterReverseMode [enter_reverse_mode, rev] string capability is the turn on reverse video mode. - EnterReverseMode - // The EnterStandoutMode [enter_standout_mode, smso] string capability is the begin standout mode. - EnterStandoutMode - // The EnterUnderlineMode [enter_underline_mode, smul] string capability is the begin underline mode. - EnterUnderlineMode - // The EraseChars [erase_chars, ech] string capability is the erase #1 characters (P). - EraseChars - // The ExitAltCharsetMode [exit_alt_charset_mode, rmacs] string capability is the end alternate character set (P). - ExitAltCharsetMode - // The ExitAttributeMode [exit_attribute_mode, sgr0] string capability is the turn off all attributes. - ExitAttributeMode - // The ExitCaMode [exit_ca_mode, rmcup] string capability is the strings to end programs using cup. - ExitCaMode - // The ExitDeleteMode [exit_delete_mode, rmdc] string capability is the end delete mode. - ExitDeleteMode - // The ExitInsertMode [exit_insert_mode, rmir] string capability is the exit insert mode. - ExitInsertMode - // The ExitStandoutMode [exit_standout_mode, rmso] string capability is the exit standout mode. - ExitStandoutMode - // The ExitUnderlineMode [exit_underline_mode, rmul] string capability is the exit underline mode. - ExitUnderlineMode - // The FlashScreen [flash_screen, flash] string capability is the visible bell (may not move cursor). - FlashScreen - // The FormFeed [form_feed, ff] string capability is the hardcopy terminal page eject (P*). - FormFeed - // The FromStatusLine [from_status_line, fsl] string capability is the return from status line. - FromStatusLine - // The Init1string [init_1string, is1] string capability is the initialization string. - Init1string - // The Init2string [init_2string, is2] string capability is the initialization string. - Init2string - // The Init3string [init_3string, is3] string capability is the initialization string. - Init3string - // The InitFile [init_file, if] string capability is the name of initialization file. - InitFile - // The InsertCharacter [insert_character, ich1] string capability is the insert character (P). - InsertCharacter - // The InsertLine [insert_line, il1] string capability is the insert line (P*). - InsertLine - // The InsertPadding [insert_padding, ip] string capability is the insert padding after inserted character. - InsertPadding - // The KeyBackspace [key_backspace, kbs] string capability is the backspace key. - KeyBackspace - // The KeyCatab [key_catab, ktbc] string capability is the clear-all-tabs key. - KeyCatab - // The KeyClear [key_clear, kclr] string capability is the clear-screen or erase key. - KeyClear - // The KeyCtab [key_ctab, kctab] string capability is the clear-tab key. - KeyCtab - // The KeyDc [key_dc, kdch1] string capability is the delete-character key. - KeyDc - // The KeyDl [key_dl, kdl1] string capability is the delete-line key. - KeyDl - // The KeyDown [key_down, kcud1] string capability is the down-arrow key. - KeyDown - // The KeyEic [key_eic, krmir] string capability is the sent by rmir or smir in insert mode. - KeyEic - // The KeyEol [key_eol, kel] string capability is the clear-to-end-of-line key. - KeyEol - // The KeyEos [key_eos, ked] string capability is the clear-to-end-of-screen key. - KeyEos - // The KeyF0 [key_f0, kf0] string capability is the F0 function key. - KeyF0 - // The KeyF1 [key_f1, kf1] string capability is the F1 function key. - KeyF1 - // The KeyF10 [key_f10, kf10] string capability is the F10 function key. - KeyF10 - // The KeyF2 [key_f2, kf2] string capability is the F2 function key. - KeyF2 - // The KeyF3 [key_f3, kf3] string capability is the F3 function key. - KeyF3 - // The KeyF4 [key_f4, kf4] string capability is the F4 function key. - KeyF4 - // The KeyF5 [key_f5, kf5] string capability is the F5 function key. - KeyF5 - // The KeyF6 [key_f6, kf6] string capability is the F6 function key. - KeyF6 - // The KeyF7 [key_f7, kf7] string capability is the F7 function key. - KeyF7 - // The KeyF8 [key_f8, kf8] string capability is the F8 function key. - KeyF8 - // The KeyF9 [key_f9, kf9] string capability is the F9 function key. - KeyF9 - // The KeyHome [key_home, khome] string capability is the home key. - KeyHome - // The KeyIc [key_ic, kich1] string capability is the insert-character key. - KeyIc - // The KeyIl [key_il, kil1] string capability is the insert-line key. - KeyIl - // The KeyLeft [key_left, kcub1] string capability is the left-arrow key. - KeyLeft - // The KeyLl [key_ll, kll] string capability is the lower-left key (home down). - KeyLl - // The KeyNpage [key_npage, knp] string capability is the next-page key. - KeyNpage - // The KeyPpage [key_ppage, kpp] string capability is the previous-page key. - KeyPpage - // The KeyRight [key_right, kcuf1] string capability is the right-arrow key. - KeyRight - // The KeySf [key_sf, kind] string capability is the scroll-forward key. - KeySf - // The KeySr [key_sr, kri] string capability is the scroll-backward key. - KeySr - // The KeyStab [key_stab, khts] string capability is the set-tab key. - KeyStab - // The KeyUp [key_up, kcuu1] string capability is the up-arrow key. - KeyUp - // The KeypadLocal [keypad_local, rmkx] string capability is the leave 'keyboard_transmit' mode. - KeypadLocal - // The KeypadXmit [keypad_xmit, smkx] string capability is the enter 'keyboard_transmit' mode. - KeypadXmit - // The LabF0 [lab_f0, lf0] string capability is the label on function key f0 if not f0. - LabF0 - // The LabF1 [lab_f1, lf1] string capability is the label on function key f1 if not f1. - LabF1 - // The LabF10 [lab_f10, lf10] string capability is the label on function key f10 if not f10. - LabF10 - // The LabF2 [lab_f2, lf2] string capability is the label on function key f2 if not f2. - LabF2 - // The LabF3 [lab_f3, lf3] string capability is the label on function key f3 if not f3. - LabF3 - // The LabF4 [lab_f4, lf4] string capability is the label on function key f4 if not f4. - LabF4 - // The LabF5 [lab_f5, lf5] string capability is the label on function key f5 if not f5. - LabF5 - // The LabF6 [lab_f6, lf6] string capability is the label on function key f6 if not f6. - LabF6 - // The LabF7 [lab_f7, lf7] string capability is the label on function key f7 if not f7. - LabF7 - // The LabF8 [lab_f8, lf8] string capability is the label on function key f8 if not f8. - LabF8 - // The LabF9 [lab_f9, lf9] string capability is the label on function key f9 if not f9. - LabF9 - // The MetaOff [meta_off, rmm] string capability is the turn off meta mode. - MetaOff - // The MetaOn [meta_on, smm] string capability is the turn on meta mode (8th-bit on). - MetaOn - // The Newline [newline, nel] string capability is the newline (behave like cr followed by lf). - Newline - // The PadChar [pad_char, pad] string capability is the padding char (instead of null). - PadChar - // The ParmDch [parm_dch, dch] string capability is the delete #1 characters (P*). - ParmDch - // The ParmDeleteLine [parm_delete_line, dl] string capability is the delete #1 lines (P*). - ParmDeleteLine - // The ParmDownCursor [parm_down_cursor, cud] string capability is the down #1 lines (P*). - ParmDownCursor - // The ParmIch [parm_ich, ich] string capability is the insert #1 characters (P*). - ParmIch - // The ParmIndex [parm_index, indn] string capability is the scroll forward #1 lines (P). - ParmIndex - // The ParmInsertLine [parm_insert_line, il] string capability is the insert #1 lines (P*). - ParmInsertLine - // The ParmLeftCursor [parm_left_cursor, cub] string capability is the move #1 characters to the left (P). - ParmLeftCursor - // The ParmRightCursor [parm_right_cursor, cuf] string capability is the move #1 characters to the right (P*). - ParmRightCursor - // The ParmRindex [parm_rindex, rin] string capability is the scroll back #1 lines (P). - ParmRindex - // The ParmUpCursor [parm_up_cursor, cuu] string capability is the up #1 lines (P*). - ParmUpCursor - // The PkeyKey [pkey_key, pfkey] string capability is the program function key #1 to type string #2. - PkeyKey - // The PkeyLocal [pkey_local, pfloc] string capability is the program function key #1 to execute string #2. - PkeyLocal - // The PkeyXmit [pkey_xmit, pfx] string capability is the program function key #1 to transmit string #2. - PkeyXmit - // The PrintScreen [print_screen, mc0] string capability is the print contents of screen. - PrintScreen - // The PrtrOff [prtr_off, mc4] string capability is the turn off printer. - PrtrOff - // The PrtrOn [prtr_on, mc5] string capability is the turn on printer. - PrtrOn - // The RepeatChar [repeat_char, rep] string capability is the repeat char #1 #2 times (P*). - RepeatChar - // The Reset1string [reset_1string, rs1] string capability is the reset string. - Reset1string - // The Reset2string [reset_2string, rs2] string capability is the reset string. - Reset2string - // The Reset3string [reset_3string, rs3] string capability is the reset string. - Reset3string - // The ResetFile [reset_file, rf] string capability is the name of reset file. - ResetFile - // The RestoreCursor [restore_cursor, rc] string capability is the restore cursor to position of last save_cursor. - RestoreCursor - // The RowAddress [row_address, vpa] string capability is the vertical position #1 absolute (P). - RowAddress - // The SaveCursor [save_cursor, sc] string capability is the save current cursor position (P). - SaveCursor - // The ScrollForward [scroll_forward, ind] string capability is the scroll text up (P). - ScrollForward - // The ScrollReverse [scroll_reverse, ri] string capability is the scroll text down (P). - ScrollReverse - // The SetAttributes [set_attributes, sgr] string capability is the define video attributes #1-#9 (PG9). - SetAttributes - // The SetTab [set_tab, hts] string capability is the set a tab in every row, current columns. - SetTab - // The SetWindow [set_window, wind] string capability is the current window is lines #1-#2 cols #3-#4. - SetWindow - // The Tab [tab, ht] string capability is the tab to next 8-space hardware tab stop. - Tab - // The ToStatusLine [to_status_line, tsl] string capability is the move to status line, column #1. - ToStatusLine - // The UnderlineChar [underline_char, uc] string capability is the underline char and move past it. - UnderlineChar - // The UpHalfLine [up_half_line, hu] string capability is the half a line up. - UpHalfLine - // The InitProg [init_prog, iprog] string capability is the path name of program for initialization. - InitProg - // The KeyA1 [key_a1, ka1] string capability is the upper left of keypad. - KeyA1 - // The KeyA3 [key_a3, ka3] string capability is the upper right of keypad. - KeyA3 - // The KeyB2 [key_b2, kb2] string capability is the center of keypad. - KeyB2 - // The KeyC1 [key_c1, kc1] string capability is the lower left of keypad. - KeyC1 - // The KeyC3 [key_c3, kc3] string capability is the lower right of keypad. - KeyC3 - // The PrtrNon [prtr_non, mc5p] string capability is the turn on printer for #1 bytes. - PrtrNon - // The CharPadding [char_padding, rmp] string capability is the like ip but when in insert mode. - CharPadding - // The AcsChars [acs_chars, acsc] string capability is the graphics charset pairs, based on vt100. - AcsChars - // The PlabNorm [plab_norm, pln] string capability is the program label #1 to show string #2. - PlabNorm - // The KeyBtab [key_btab, kcbt] string capability is the back-tab key. - KeyBtab - // The EnterXonMode [enter_xon_mode, smxon] string capability is the turn on xon/xoff handshaking. - EnterXonMode - // The ExitXonMode [exit_xon_mode, rmxon] string capability is the turn off xon/xoff handshaking. - ExitXonMode - // The EnterAmMode [enter_am_mode, smam] string capability is the turn on automatic margins. - EnterAmMode - // The ExitAmMode [exit_am_mode, rmam] string capability is the turn off automatic margins. - ExitAmMode - // The XonCharacter [xon_character, xonc] string capability is the XON character. - XonCharacter - // The XoffCharacter [xoff_character, xoffc] string capability is the XOFF character. - XoffCharacter - // The EnaAcs [ena_acs, enacs] string capability is the enable alternate char set. - EnaAcs - // The LabelOn [label_on, smln] string capability is the turn on soft labels. - LabelOn - // The LabelOff [label_off, rmln] string capability is the turn off soft labels. - LabelOff - // The KeyBeg [key_beg, kbeg] string capability is the begin key. - KeyBeg - // The KeyCancel [key_cancel, kcan] string capability is the cancel key. - KeyCancel - // The KeyClose [key_close, kclo] string capability is the close key. - KeyClose - // The KeyCommand [key_command, kcmd] string capability is the command key. - KeyCommand - // The KeyCopy [key_copy, kcpy] string capability is the copy key. - KeyCopy - // The KeyCreate [key_create, kcrt] string capability is the create key. - KeyCreate - // The KeyEnd [key_end, kend] string capability is the end key. - KeyEnd - // The KeyEnter [key_enter, kent] string capability is the enter/send key. - KeyEnter - // The KeyExit [key_exit, kext] string capability is the exit key. - KeyExit - // The KeyFind [key_find, kfnd] string capability is the find key. - KeyFind - // The KeyHelp [key_help, khlp] string capability is the help key. - KeyHelp - // The KeyMark [key_mark, kmrk] string capability is the mark key. - KeyMark - // The KeyMessage [key_message, kmsg] string capability is the message key. - KeyMessage - // The KeyMove [key_move, kmov] string capability is the move key. - KeyMove - // The KeyNext [key_next, knxt] string capability is the next key. - KeyNext - // The KeyOpen [key_open, kopn] string capability is the open key. - KeyOpen - // The KeyOptions [key_options, kopt] string capability is the options key. - KeyOptions - // The KeyPrevious [key_previous, kprv] string capability is the previous key. - KeyPrevious - // The KeyPrint [key_print, kprt] string capability is the print key. - KeyPrint - // The KeyRedo [key_redo, krdo] string capability is the redo key. - KeyRedo - // The KeyReference [key_reference, kref] string capability is the reference key. - KeyReference - // The KeyRefresh [key_refresh, krfr] string capability is the refresh key. - KeyRefresh - // The KeyReplace [key_replace, krpl] string capability is the replace key. - KeyReplace - // The KeyRestart [key_restart, krst] string capability is the restart key. - KeyRestart - // The KeyResume [key_resume, kres] string capability is the resume key. - KeyResume - // The KeySave [key_save, ksav] string capability is the save key. - KeySave - // The KeySuspend [key_suspend, kspd] string capability is the suspend key. - KeySuspend - // The KeyUndo [key_undo, kund] string capability is the undo key. - KeyUndo - // The KeySbeg [key_sbeg, kBEG] string capability is the shifted begin key. - KeySbeg - // The KeyScancel [key_scancel, kCAN] string capability is the shifted cancel key. - KeyScancel - // The KeyScommand [key_scommand, kCMD] string capability is the shifted command key. - KeyScommand - // The KeyScopy [key_scopy, kCPY] string capability is the shifted copy key. - KeyScopy - // The KeyScreate [key_screate, kCRT] string capability is the shifted create key. - KeyScreate - // The KeySdc [key_sdc, kDC] string capability is the shifted delete-character key. - KeySdc - // The KeySdl [key_sdl, kDL] string capability is the shifted delete-line key. - KeySdl - // The KeySelect [key_select, kslt] string capability is the select key. - KeySelect - // The KeySend [key_send, kEND] string capability is the shifted end key. - KeySend - // The KeySeol [key_seol, kEOL] string capability is the shifted clear-to-end-of-line key. - KeySeol - // The KeySexit [key_sexit, kEXT] string capability is the shifted exit key. - KeySexit - // The KeySfind [key_sfind, kFND] string capability is the shifted find key. - KeySfind - // The KeyShelp [key_shelp, kHLP] string capability is the shifted help key. - KeyShelp - // The KeyShome [key_shome, kHOM] string capability is the shifted home key. - KeyShome - // The KeySic [key_sic, kIC] string capability is the shifted insert-character key. - KeySic - // The KeySleft [key_sleft, kLFT] string capability is the shifted left-arrow key. - KeySleft - // The KeySmessage [key_smessage, kMSG] string capability is the shifted message key. - KeySmessage - // The KeySmove [key_smove, kMOV] string capability is the shifted move key. - KeySmove - // The KeySnext [key_snext, kNXT] string capability is the shifted next key. - KeySnext - // The KeySoptions [key_soptions, kOPT] string capability is the shifted options key. - KeySoptions - // The KeySprevious [key_sprevious, kPRV] string capability is the shifted previous key. - KeySprevious - // The KeySprint [key_sprint, kPRT] string capability is the shifted print key. - KeySprint - // The KeySredo [key_sredo, kRDO] string capability is the shifted redo key. - KeySredo - // The KeySreplace [key_sreplace, kRPL] string capability is the shifted replace key. - KeySreplace - // The KeySright [key_sright, kRIT] string capability is the shifted right-arrow key. - KeySright - // The KeySrsume [key_srsume, kRES] string capability is the shifted resume key. - KeySrsume - // The KeySsave [key_ssave, kSAV] string capability is the shifted save key. - KeySsave - // The KeySsuspend [key_ssuspend, kSPD] string capability is the shifted suspend key. - KeySsuspend - // The KeySundo [key_sundo, kUND] string capability is the shifted undo key. - KeySundo - // The ReqForInput [req_for_input, rfi] string capability is the send next input char (for ptys). - ReqForInput - // The KeyF11 [key_f11, kf11] string capability is the F11 function key. - KeyF11 - // The KeyF12 [key_f12, kf12] string capability is the F12 function key. - KeyF12 - // The KeyF13 [key_f13, kf13] string capability is the F13 function key. - KeyF13 - // The KeyF14 [key_f14, kf14] string capability is the F14 function key. - KeyF14 - // The KeyF15 [key_f15, kf15] string capability is the F15 function key. - KeyF15 - // The KeyF16 [key_f16, kf16] string capability is the F16 function key. - KeyF16 - // The KeyF17 [key_f17, kf17] string capability is the F17 function key. - KeyF17 - // The KeyF18 [key_f18, kf18] string capability is the F18 function key. - KeyF18 - // The KeyF19 [key_f19, kf19] string capability is the F19 function key. - KeyF19 - // The KeyF20 [key_f20, kf20] string capability is the F20 function key. - KeyF20 - // The KeyF21 [key_f21, kf21] string capability is the F21 function key. - KeyF21 - // The KeyF22 [key_f22, kf22] string capability is the F22 function key. - KeyF22 - // The KeyF23 [key_f23, kf23] string capability is the F23 function key. - KeyF23 - // The KeyF24 [key_f24, kf24] string capability is the F24 function key. - KeyF24 - // The KeyF25 [key_f25, kf25] string capability is the F25 function key. - KeyF25 - // The KeyF26 [key_f26, kf26] string capability is the F26 function key. - KeyF26 - // The KeyF27 [key_f27, kf27] string capability is the F27 function key. - KeyF27 - // The KeyF28 [key_f28, kf28] string capability is the F28 function key. - KeyF28 - // The KeyF29 [key_f29, kf29] string capability is the F29 function key. - KeyF29 - // The KeyF30 [key_f30, kf30] string capability is the F30 function key. - KeyF30 - // The KeyF31 [key_f31, kf31] string capability is the F31 function key. - KeyF31 - // The KeyF32 [key_f32, kf32] string capability is the F32 function key. - KeyF32 - // The KeyF33 [key_f33, kf33] string capability is the F33 function key. - KeyF33 - // The KeyF34 [key_f34, kf34] string capability is the F34 function key. - KeyF34 - // The KeyF35 [key_f35, kf35] string capability is the F35 function key. - KeyF35 - // The KeyF36 [key_f36, kf36] string capability is the F36 function key. - KeyF36 - // The KeyF37 [key_f37, kf37] string capability is the F37 function key. - KeyF37 - // The KeyF38 [key_f38, kf38] string capability is the F38 function key. - KeyF38 - // The KeyF39 [key_f39, kf39] string capability is the F39 function key. - KeyF39 - // The KeyF40 [key_f40, kf40] string capability is the F40 function key. - KeyF40 - // The KeyF41 [key_f41, kf41] string capability is the F41 function key. - KeyF41 - // The KeyF42 [key_f42, kf42] string capability is the F42 function key. - KeyF42 - // The KeyF43 [key_f43, kf43] string capability is the F43 function key. - KeyF43 - // The KeyF44 [key_f44, kf44] string capability is the F44 function key. - KeyF44 - // The KeyF45 [key_f45, kf45] string capability is the F45 function key. - KeyF45 - // The KeyF46 [key_f46, kf46] string capability is the F46 function key. - KeyF46 - // The KeyF47 [key_f47, kf47] string capability is the F47 function key. - KeyF47 - // The KeyF48 [key_f48, kf48] string capability is the F48 function key. - KeyF48 - // The KeyF49 [key_f49, kf49] string capability is the F49 function key. - KeyF49 - // The KeyF50 [key_f50, kf50] string capability is the F50 function key. - KeyF50 - // The KeyF51 [key_f51, kf51] string capability is the F51 function key. - KeyF51 - // The KeyF52 [key_f52, kf52] string capability is the F52 function key. - KeyF52 - // The KeyF53 [key_f53, kf53] string capability is the F53 function key. - KeyF53 - // The KeyF54 [key_f54, kf54] string capability is the F54 function key. - KeyF54 - // The KeyF55 [key_f55, kf55] string capability is the F55 function key. - KeyF55 - // The KeyF56 [key_f56, kf56] string capability is the F56 function key. - KeyF56 - // The KeyF57 [key_f57, kf57] string capability is the F57 function key. - KeyF57 - // The KeyF58 [key_f58, kf58] string capability is the F58 function key. - KeyF58 - // The KeyF59 [key_f59, kf59] string capability is the F59 function key. - KeyF59 - // The KeyF60 [key_f60, kf60] string capability is the F60 function key. - KeyF60 - // The KeyF61 [key_f61, kf61] string capability is the F61 function key. - KeyF61 - // The KeyF62 [key_f62, kf62] string capability is the F62 function key. - KeyF62 - // The KeyF63 [key_f63, kf63] string capability is the F63 function key. - KeyF63 - // The ClrBol [clr_bol, el1] string capability is the Clear to beginning of line. - ClrBol - // The ClearMargins [clear_margins, mgc] string capability is the clear right and left soft margins. - ClearMargins - // The SetLeftMargin [set_left_margin, smgl] string capability is the set left soft margin at current column. (ML is not in BSD termcap). - SetLeftMargin - // The SetRightMargin [set_right_margin, smgr] string capability is the set right soft margin at current column. - SetRightMargin - // The LabelFormat [label_format, fln] string capability is the label format. - LabelFormat - // The SetClock [set_clock, sclk] string capability is the set clock, #1 hrs #2 mins #3 secs. - SetClock - // The DisplayClock [display_clock, dclk] string capability is the display clock. - DisplayClock - // The RemoveClock [remove_clock, rmclk] string capability is the remove clock. - RemoveClock - // The CreateWindow [create_window, cwin] string capability is the define a window #1 from #2,#3 to #4,#5. - CreateWindow - // The GotoWindow [goto_window, wingo] string capability is the go to window #1. - GotoWindow - // The Hangup [hangup, hup] string capability is the hang-up phone. - Hangup - // The DialPhone [dial_phone, dial] string capability is the dial number #1. - DialPhone - // The QuickDial [quick_dial, qdial] string capability is the dial number #1 without checking. - QuickDial - // The Tone [tone, tone] string capability is the select touch tone dialing. - Tone - // The Pulse [pulse, pulse] string capability is the select pulse dialing. - Pulse - // The FlashHook [flash_hook, hook] string capability is the flash switch hook. - FlashHook - // The FixedPause [fixed_pause, pause] string capability is the pause for 2-3 seconds. - FixedPause - // The WaitTone [wait_tone, wait] string capability is the wait for dial-tone. - WaitTone - // The User0 [user0, u0] string capability is the User string #0. - User0 - // The User1 [user1, u1] string capability is the User string #1. - User1 - // The User2 [user2, u2] string capability is the User string #2. - User2 - // The User3 [user3, u3] string capability is the User string #3. - User3 - // The User4 [user4, u4] string capability is the User string #4. - User4 - // The User5 [user5, u5] string capability is the User string #5. - User5 - // The User6 [user6, u6] string capability is the User string #6. - User6 - // The User7 [user7, u7] string capability is the User string #7. - User7 - // The User8 [user8, u8] string capability is the User string #8. - User8 - // The User9 [user9, u9] string capability is the User string #9. - User9 - // The OrigPair [orig_pair, op] string capability is the Set default pair to its original value. - OrigPair - // The OrigColors [orig_colors, oc] string capability is the Set all color pairs to the original ones. - OrigColors - // The InitializeColor [initialize_color, initc] string capability is the initialize color #1 to (#2,#3,#4). - InitializeColor - // The InitializePair [initialize_pair, initp] string capability is the Initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7). - InitializePair - // The SetColorPair [set_color_pair, scp] string capability is the Set current color pair to #1. - SetColorPair - // The SetForeground [set_foreground, setf] string capability is the Set foreground color #1. - SetForeground - // The SetBackground [set_background, setb] string capability is the Set background color #1. - SetBackground - // The ChangeCharPitch [change_char_pitch, cpi] string capability is the Change number of characters per inch to #1. - ChangeCharPitch - // The ChangeLinePitch [change_line_pitch, lpi] string capability is the Change number of lines per inch to #1. - ChangeLinePitch - // The ChangeResHorz [change_res_horz, chr] string capability is the Change horizontal resolution to #1. - ChangeResHorz - // The ChangeResVert [change_res_vert, cvr] string capability is the Change vertical resolution to #1. - ChangeResVert - // The DefineChar [define_char, defc] string capability is the Define a character #1, #2 dots wide, descender #3. - DefineChar - // The EnterDoublewideMode [enter_doublewide_mode, swidm] string capability is the Enter double-wide mode. - EnterDoublewideMode - // The EnterDraftQuality [enter_draft_quality, sdrfq] string capability is the Enter draft-quality mode. - EnterDraftQuality - // The EnterItalicsMode [enter_italics_mode, sitm] string capability is the Enter italic mode. - EnterItalicsMode - // The EnterLeftwardMode [enter_leftward_mode, slm] string capability is the Start leftward carriage motion. - EnterLeftwardMode - // The EnterMicroMode [enter_micro_mode, smicm] string capability is the Start micro-motion mode. - EnterMicroMode - // The EnterNearLetterQuality [enter_near_letter_quality, snlq] string capability is the Enter NLQ mode. - EnterNearLetterQuality - // The EnterNormalQuality [enter_normal_quality, snrmq] string capability is the Enter normal-quality mode. - EnterNormalQuality - // The EnterShadowMode [enter_shadow_mode, sshm] string capability is the Enter shadow-print mode. - EnterShadowMode - // The EnterSubscriptMode [enter_subscript_mode, ssubm] string capability is the Enter subscript mode. - EnterSubscriptMode - // The EnterSuperscriptMode [enter_superscript_mode, ssupm] string capability is the Enter superscript mode. - EnterSuperscriptMode - // The EnterUpwardMode [enter_upward_mode, sum] string capability is the Start upward carriage motion. - EnterUpwardMode - // The ExitDoublewideMode [exit_doublewide_mode, rwidm] string capability is the End double-wide mode. - ExitDoublewideMode - // The ExitItalicsMode [exit_italics_mode, ritm] string capability is the End italic mode. - ExitItalicsMode - // The ExitLeftwardMode [exit_leftward_mode, rlm] string capability is the End left-motion mode. - ExitLeftwardMode - // The ExitMicroMode [exit_micro_mode, rmicm] string capability is the End micro-motion mode. - ExitMicroMode - // The ExitShadowMode [exit_shadow_mode, rshm] string capability is the End shadow-print mode. - ExitShadowMode - // The ExitSubscriptMode [exit_subscript_mode, rsubm] string capability is the End subscript mode. - ExitSubscriptMode - // The ExitSuperscriptMode [exit_superscript_mode, rsupm] string capability is the End superscript mode. - ExitSuperscriptMode - // The ExitUpwardMode [exit_upward_mode, rum] string capability is the End reverse character motion. - ExitUpwardMode - // The MicroColumnAddress [micro_column_address, mhpa] string capability is the Like column_address in micro mode. - MicroColumnAddress - // The MicroDown [micro_down, mcud1] string capability is the Like cursor_down in micro mode. - MicroDown - // The MicroLeft [micro_left, mcub1] string capability is the Like cursor_left in micro mode. - MicroLeft - // The MicroRight [micro_right, mcuf1] string capability is the Like cursor_right in micro mode. - MicroRight - // The MicroRowAddress [micro_row_address, mvpa] string capability is the Like row_address #1 in micro mode. - MicroRowAddress - // The MicroUp [micro_up, mcuu1] string capability is the Like cursor_up in micro mode. - MicroUp - // The OrderOfPins [order_of_pins, porder] string capability is the Match software bits to print-head pins. - OrderOfPins - // The ParmDownMicro [parm_down_micro, mcud] string capability is the Like parm_down_cursor in micro mode. - ParmDownMicro - // The ParmLeftMicro [parm_left_micro, mcub] string capability is the Like parm_left_cursor in micro mode. - ParmLeftMicro - // The ParmRightMicro [parm_right_micro, mcuf] string capability is the Like parm_right_cursor in micro mode. - ParmRightMicro - // The ParmUpMicro [parm_up_micro, mcuu] string capability is the Like parm_up_cursor in micro mode. - ParmUpMicro - // The SelectCharSet [select_char_set, scs] string capability is the Select character set, #1. - SelectCharSet - // The SetBottomMargin [set_bottom_margin, smgb] string capability is the Set bottom margin at current line. - SetBottomMargin - // The SetBottomMarginParm [set_bottom_margin_parm, smgbp] string capability is the Set bottom margin at line #1 or (if smgtp is not given) #2 lines from bottom. - SetBottomMarginParm - // The SetLeftMarginParm [set_left_margin_parm, smglp] string capability is the Set left (right) margin at column #1. - SetLeftMarginParm - // The SetRightMarginParm [set_right_margin_parm, smgrp] string capability is the Set right margin at column #1. - SetRightMarginParm - // The SetTopMargin [set_top_margin, smgt] string capability is the Set top margin at current line. - SetTopMargin - // The SetTopMarginParm [set_top_margin_parm, smgtp] string capability is the Set top (bottom) margin at row #1. - SetTopMarginParm - // The StartBitImage [start_bit_image, sbim] string capability is the Start printing bit image graphics. - StartBitImage - // The StartCharSetDef [start_char_set_def, scsd] string capability is the Start character set definition #1, with #2 characters in the set. - StartCharSetDef - // The StopBitImage [stop_bit_image, rbim] string capability is the Stop printing bit image graphics. - StopBitImage - // The StopCharSetDef [stop_char_set_def, rcsd] string capability is the End definition of character set #1. - StopCharSetDef - // The SubscriptCharacters [subscript_characters, subcs] string capability is the List of subscriptable characters. - SubscriptCharacters - // The SuperscriptCharacters [superscript_characters, supcs] string capability is the List of superscriptable characters. - SuperscriptCharacters - // The TheseCauseCr [these_cause_cr, docr] string capability is the Printing any of these characters causes CR. - TheseCauseCr - // The ZeroMotion [zero_motion, zerom] string capability is the No motion for subsequent character. - ZeroMotion - // The CharSetNames [char_set_names, csnm] string capability is the Produce #1'th item from list of character set names. - CharSetNames - // The KeyMouse [key_mouse, kmous] string capability is the Mouse event has occurred. - KeyMouse - // The MouseInfo [mouse_info, minfo] string capability is the Mouse status information. - MouseInfo - // The ReqMousePos [req_mouse_pos, reqmp] string capability is the Request mouse position. - ReqMousePos - // The GetMouse [get_mouse, getm] string capability is the Curses should get button events, parameter #1 not documented. - GetMouse - // The SetAForeground [set_a_foreground, setaf] string capability is the Set foreground color to #1, using ANSI escape. - SetAForeground - // The SetABackground [set_a_background, setab] string capability is the Set background color to #1, using ANSI escape. - SetABackground - // The PkeyPlab [pkey_plab, pfxl] string capability is the Program function key #1 to type string #2 and show string #3. - PkeyPlab - // The DeviceType [device_type, devt] string capability is the Indicate language/codeset support. - DeviceType - // The CodeSetInit [code_set_init, csin] string capability is the Init sequence for multiple codesets. - CodeSetInit - // The Set0DesSeq [set0_des_seq, s0ds] string capability is the Shift to codeset 0 (EUC set 0, ASCII). - Set0DesSeq - // The Set1DesSeq [set1_des_seq, s1ds] string capability is the Shift to codeset 1. - Set1DesSeq - // The Set2DesSeq [set2_des_seq, s2ds] string capability is the Shift to codeset 2. - Set2DesSeq - // The Set3DesSeq [set3_des_seq, s3ds] string capability is the Shift to codeset 3. - Set3DesSeq - // The SetLrMargin [set_lr_margin, smglr] string capability is the Set both left and right margins to #1, #2. (ML is not in BSD termcap). - SetLrMargin - // The SetTbMargin [set_tb_margin, smgtb] string capability is the Sets both top and bottom margins to #1, #2. - SetTbMargin - // The BitImageRepeat [bit_image_repeat, birep] string capability is the Repeat bit image cell #1 #2 times. - BitImageRepeat - // The BitImageNewline [bit_image_newline, binel] string capability is the Move to next row of the bit image. - BitImageNewline - // The BitImageCarriageReturn [bit_image_carriage_return, bicr] string capability is the Move to beginning of same row. - BitImageCarriageReturn - // The ColorNames [color_names, colornm] string capability is the Give name for color #1. - ColorNames - // The DefineBitImageRegion [define_bit_image_region, defbi] string capability is the Define rectangular bit image region. - DefineBitImageRegion - // The EndBitImageRegion [end_bit_image_region, endbi] string capability is the End a bit-image region. - EndBitImageRegion - // The SetColorBand [set_color_band, setcolor] string capability is the Change to ribbon color #1. - SetColorBand - // The SetPageLength [set_page_length, slines] string capability is the Set page length to #1 lines. - SetPageLength - // The DisplayPcChar [display_pc_char, dispc] string capability is the Display PC character #1. - DisplayPcChar - // The EnterPcCharsetMode [enter_pc_charset_mode, smpch] string capability is the Enter PC character display mode. - EnterPcCharsetMode - // The ExitPcCharsetMode [exit_pc_charset_mode, rmpch] string capability is the Exit PC character display mode. - ExitPcCharsetMode - // The EnterScancodeMode [enter_scancode_mode, smsc] string capability is the Enter PC scancode mode. - EnterScancodeMode - // The ExitScancodeMode [exit_scancode_mode, rmsc] string capability is the Exit PC scancode mode. - ExitScancodeMode - // The PcTermOptions [pc_term_options, pctrm] string capability is the PC terminal options. - PcTermOptions - // The ScancodeEscape [scancode_escape, scesc] string capability is the Escape for scancode emulation. - ScancodeEscape - // The AltScancodeEsc [alt_scancode_esc, scesa] string capability is the Alternate escape for scancode emulation. - AltScancodeEsc - // The EnterHorizontalHlMode [enter_horizontal_hl_mode, ehhlm] string capability is the Enter horizontal highlight mode. - EnterHorizontalHlMode - // The EnterLeftHlMode [enter_left_hl_mode, elhlm] string capability is the Enter left highlight mode. - EnterLeftHlMode - // The EnterLowHlMode [enter_low_hl_mode, elohlm] string capability is the Enter low highlight mode. - EnterLowHlMode - // The EnterRightHlMode [enter_right_hl_mode, erhlm] string capability is the Enter right highlight mode. - EnterRightHlMode - // The EnterTopHlMode [enter_top_hl_mode, ethlm] string capability is the Enter top highlight mode. - EnterTopHlMode - // The EnterVerticalHlMode [enter_vertical_hl_mode, evhlm] string capability is the Enter vertical highlight mode. - EnterVerticalHlMode - // The SetAAttributes [set_a_attributes, sgr1] string capability is the Define second set of video attributes #1-#6. - SetAAttributes - // The SetPglenInch [set_pglen_inch, slength] string capability is the Set page length to #1 hundredth of an inch (some implementations use sL for termcap). - SetPglenInch - // The TermcapInit2 [termcap_init2, OTi2] string capability is the secondary initialization string. - TermcapInit2 - // The TermcapReset [termcap_reset, OTrs] string capability is the terminal reset string. - TermcapReset - // The LinefeedIfNotLf [linefeed_if_not_lf, OTnl] string capability is the use to move down. - LinefeedIfNotLf - // The BackspaceIfNotBs [backspace_if_not_bs, OTbc] string capability is the move left, if not ^H. - BackspaceIfNotBs - // The OtherNonFunctionKeys [other_non_function_keys, OTko] string capability is the list of self-mapped keycaps. - OtherNonFunctionKeys - // The ArrowKeyMap [arrow_key_map, OTma] string capability is the map motion-keys for vi version 2. - ArrowKeyMap - // The AcsUlcorner [acs_ulcorner, OTG2] string capability is the single upper left. - AcsUlcorner - // The AcsLlcorner [acs_llcorner, OTG3] string capability is the single lower left. - AcsLlcorner - // The AcsUrcorner [acs_urcorner, OTG1] string capability is the single upper right. - AcsUrcorner - // The AcsLrcorner [acs_lrcorner, OTG4] string capability is the single lower right. - AcsLrcorner - // The AcsLtee [acs_ltee, OTGR] string capability is the tee pointing right. - AcsLtee - // The AcsRtee [acs_rtee, OTGL] string capability is the tee pointing left. - AcsRtee - // The AcsBtee [acs_btee, OTGU] string capability is the tee pointing up. - AcsBtee - // The AcsTtee [acs_ttee, OTGD] string capability is the tee pointing down. - AcsTtee - // The AcsHline [acs_hline, OTGH] string capability is the single horizontal line. - AcsHline - // The AcsVline [acs_vline, OTGV] string capability is the single vertical line. - AcsVline - // The AcsPlus [acs_plus, OTGC] string capability is the single intersection. - AcsPlus - // The MemoryLock [memory_lock, meml] string capability is the lock memory above cursor. - MemoryLock - // The MemoryUnlock [memory_unlock, memu] string capability is the unlock memory. - MemoryUnlock - // The BoxChars1 [box_chars_1, box1] string capability is the box characters primary set. - BoxChars1 -) -const ( - // CapCountBool is the count of bool capabilities. - CapCountBool = ReturnDoesClrEol + 1 - // CapCountNum is the count of num capabilities. - CapCountNum = NumberOfFunctionKeys + 1 - // CapCountString is the count of string capabilities. - CapCountString = BoxChars1 + 1 -) - -// boolCapNames are the bool term cap names. -var boolCapNames = [...]string{ - "auto_left_margin", "bw", - "auto_right_margin", "am", - "no_esc_ctlc", "xsb", - "ceol_standout_glitch", "xhp", - "eat_newline_glitch", "xenl", - "erase_overstrike", "eo", - "generic_type", "gn", - "hard_copy", "hc", - "has_meta_key", "km", - "has_status_line", "hs", - "insert_null_glitch", "in", - "memory_above", "da", - "memory_below", "db", - "move_insert_mode", "mir", - "move_standout_mode", "msgr", - "over_strike", "os", - "status_line_esc_ok", "eslok", - "dest_tabs_magic_smso", "xt", - "tilde_glitch", "hz", - "transparent_underline", "ul", - "xon_xoff", "xon", - "needs_xon_xoff", "nxon", - "prtr_silent", "mc5i", - "hard_cursor", "chts", - "non_rev_rmcup", "nrrmc", - "no_pad_char", "npc", - "non_dest_scroll_region", "ndscr", - "can_change", "ccc", - "back_color_erase", "bce", - "hue_lightness_saturation", "hls", - "col_addr_glitch", "xhpa", - "cr_cancels_micro_mode", "crxm", - "has_print_wheel", "daisy", - "row_addr_glitch", "xvpa", - "semi_auto_right_margin", "sam", - "cpi_changes_res", "cpix", - "lpi_changes_res", "lpix", - "backspaces_with_bs", "OTbs", - "crt_no_scrolling", "OTns", - "no_correctly_working_cr", "OTnc", - "gnu_has_meta_key", "OTMT", - "linefeed_is_newline", "OTNL", - "has_hardware_tabs", "OTpt", - "return_does_clr_eol", "OTxr", -} - -// numCapNames are the num term cap names. -var numCapNames = [...]string{ - "columns", "cols", - "init_tabs", "it", - "lines", "lines", - "lines_of_memory", "lm", - "magic_cookie_glitch", "xmc", - "padding_baud_rate", "pb", - "virtual_terminal", "vt", - "width_status_line", "wsl", - "num_labels", "nlab", - "label_height", "lh", - "label_width", "lw", - "max_attributes", "ma", - "maximum_windows", "wnum", - "max_colors", "colors", - "max_pairs", "pairs", - "no_color_video", "ncv", - "buffer_capacity", "bufsz", - "dot_vert_spacing", "spinv", - "dot_horz_spacing", "spinh", - "max_micro_address", "maddr", - "max_micro_jump", "mjump", - "micro_col_size", "mcs", - "micro_line_size", "mls", - "number_of_pins", "npins", - "output_res_char", "orc", - "output_res_line", "orl", - "output_res_horz_inch", "orhi", - "output_res_vert_inch", "orvi", - "print_rate", "cps", - "wide_char_size", "widcs", - "buttons", "btns", - "bit_image_entwining", "bitwin", - "bit_image_type", "bitype", - "magic_cookie_glitch_ul", "OTug", - "carriage_return_delay", "OTdC", - "new_line_delay", "OTdN", - "backspace_delay", "OTdB", - "horizontal_tab_delay", "OTdT", - "number_of_function_keys", "OTkn", -} - -// stringCapNames are the string term cap names. -var stringCapNames = [...]string{ - "back_tab", "cbt", - "bell", "bel", - "carriage_return", "cr", - "change_scroll_region", "csr", - "clear_all_tabs", "tbc", - "clear_screen", "clear", - "clr_eol", "el", - "clr_eos", "ed", - "column_address", "hpa", - "command_character", "cmdch", - "cursor_address", "cup", - "cursor_down", "cud1", - "cursor_home", "home", - "cursor_invisible", "civis", - "cursor_left", "cub1", - "cursor_mem_address", "mrcup", - "cursor_normal", "cnorm", - "cursor_right", "cuf1", - "cursor_to_ll", "ll", - "cursor_up", "cuu1", - "cursor_visible", "cvvis", - "delete_character", "dch1", - "delete_line", "dl1", - "dis_status_line", "dsl", - "down_half_line", "hd", - "enter_alt_charset_mode", "smacs", - "enter_blink_mode", "blink", - "enter_bold_mode", "bold", - "enter_ca_mode", "smcup", - "enter_delete_mode", "smdc", - "enter_dim_mode", "dim", - "enter_insert_mode", "smir", - "enter_secure_mode", "invis", - "enter_protected_mode", "prot", - "enter_reverse_mode", "rev", - "enter_standout_mode", "smso", - "enter_underline_mode", "smul", - "erase_chars", "ech", - "exit_alt_charset_mode", "rmacs", - "exit_attribute_mode", "sgr0", - "exit_ca_mode", "rmcup", - "exit_delete_mode", "rmdc", - "exit_insert_mode", "rmir", - "exit_standout_mode", "rmso", - "exit_underline_mode", "rmul", - "flash_screen", "flash", - "form_feed", "ff", - "from_status_line", "fsl", - "init_1string", "is1", - "init_2string", "is2", - "init_3string", "is3", - "init_file", "if", - "insert_character", "ich1", - "insert_line", "il1", - "insert_padding", "ip", - "key_backspace", "kbs", - "key_catab", "ktbc", - "key_clear", "kclr", - "key_ctab", "kctab", - "key_dc", "kdch1", - "key_dl", "kdl1", - "key_down", "kcud1", - "key_eic", "krmir", - "key_eol", "kel", - "key_eos", "ked", - "key_f0", "kf0", - "key_f1", "kf1", - "key_f10", "kf10", - "key_f2", "kf2", - "key_f3", "kf3", - "key_f4", "kf4", - "key_f5", "kf5", - "key_f6", "kf6", - "key_f7", "kf7", - "key_f8", "kf8", - "key_f9", "kf9", - "key_home", "khome", - "key_ic", "kich1", - "key_il", "kil1", - "key_left", "kcub1", - "key_ll", "kll", - "key_npage", "knp", - "key_ppage", "kpp", - "key_right", "kcuf1", - "key_sf", "kind", - "key_sr", "kri", - "key_stab", "khts", - "key_up", "kcuu1", - "keypad_local", "rmkx", - "keypad_xmit", "smkx", - "lab_f0", "lf0", - "lab_f1", "lf1", - "lab_f10", "lf10", - "lab_f2", "lf2", - "lab_f3", "lf3", - "lab_f4", "lf4", - "lab_f5", "lf5", - "lab_f6", "lf6", - "lab_f7", "lf7", - "lab_f8", "lf8", - "lab_f9", "lf9", - "meta_off", "rmm", - "meta_on", "smm", - "newline", "nel", - "pad_char", "pad", - "parm_dch", "dch", - "parm_delete_line", "dl", - "parm_down_cursor", "cud", - "parm_ich", "ich", - "parm_index", "indn", - "parm_insert_line", "il", - "parm_left_cursor", "cub", - "parm_right_cursor", "cuf", - "parm_rindex", "rin", - "parm_up_cursor", "cuu", - "pkey_key", "pfkey", - "pkey_local", "pfloc", - "pkey_xmit", "pfx", - "print_screen", "mc0", - "prtr_off", "mc4", - "prtr_on", "mc5", - "repeat_char", "rep", - "reset_1string", "rs1", - "reset_2string", "rs2", - "reset_3string", "rs3", - "reset_file", "rf", - "restore_cursor", "rc", - "row_address", "vpa", - "save_cursor", "sc", - "scroll_forward", "ind", - "scroll_reverse", "ri", - "set_attributes", "sgr", - "set_tab", "hts", - "set_window", "wind", - "tab", "ht", - "to_status_line", "tsl", - "underline_char", "uc", - "up_half_line", "hu", - "init_prog", "iprog", - "key_a1", "ka1", - "key_a3", "ka3", - "key_b2", "kb2", - "key_c1", "kc1", - "key_c3", "kc3", - "prtr_non", "mc5p", - "char_padding", "rmp", - "acs_chars", "acsc", - "plab_norm", "pln", - "key_btab", "kcbt", - "enter_xon_mode", "smxon", - "exit_xon_mode", "rmxon", - "enter_am_mode", "smam", - "exit_am_mode", "rmam", - "xon_character", "xonc", - "xoff_character", "xoffc", - "ena_acs", "enacs", - "label_on", "smln", - "label_off", "rmln", - "key_beg", "kbeg", - "key_cancel", "kcan", - "key_close", "kclo", - "key_command", "kcmd", - "key_copy", "kcpy", - "key_create", "kcrt", - "key_end", "kend", - "key_enter", "kent", - "key_exit", "kext", - "key_find", "kfnd", - "key_help", "khlp", - "key_mark", "kmrk", - "key_message", "kmsg", - "key_move", "kmov", - "key_next", "knxt", - "key_open", "kopn", - "key_options", "kopt", - "key_previous", "kprv", - "key_print", "kprt", - "key_redo", "krdo", - "key_reference", "kref", - "key_refresh", "krfr", - "key_replace", "krpl", - "key_restart", "krst", - "key_resume", "kres", - "key_save", "ksav", - "key_suspend", "kspd", - "key_undo", "kund", - "key_sbeg", "kBEG", - "key_scancel", "kCAN", - "key_scommand", "kCMD", - "key_scopy", "kCPY", - "key_screate", "kCRT", - "key_sdc", "kDC", - "key_sdl", "kDL", - "key_select", "kslt", - "key_send", "kEND", - "key_seol", "kEOL", - "key_sexit", "kEXT", - "key_sfind", "kFND", - "key_shelp", "kHLP", - "key_shome", "kHOM", - "key_sic", "kIC", - "key_sleft", "kLFT", - "key_smessage", "kMSG", - "key_smove", "kMOV", - "key_snext", "kNXT", - "key_soptions", "kOPT", - "key_sprevious", "kPRV", - "key_sprint", "kPRT", - "key_sredo", "kRDO", - "key_sreplace", "kRPL", - "key_sright", "kRIT", - "key_srsume", "kRES", - "key_ssave", "kSAV", - "key_ssuspend", "kSPD", - "key_sundo", "kUND", - "req_for_input", "rfi", - "key_f11", "kf11", - "key_f12", "kf12", - "key_f13", "kf13", - "key_f14", "kf14", - "key_f15", "kf15", - "key_f16", "kf16", - "key_f17", "kf17", - "key_f18", "kf18", - "key_f19", "kf19", - "key_f20", "kf20", - "key_f21", "kf21", - "key_f22", "kf22", - "key_f23", "kf23", - "key_f24", "kf24", - "key_f25", "kf25", - "key_f26", "kf26", - "key_f27", "kf27", - "key_f28", "kf28", - "key_f29", "kf29", - "key_f30", "kf30", - "key_f31", "kf31", - "key_f32", "kf32", - "key_f33", "kf33", - "key_f34", "kf34", - "key_f35", "kf35", - "key_f36", "kf36", - "key_f37", "kf37", - "key_f38", "kf38", - "key_f39", "kf39", - "key_f40", "kf40", - "key_f41", "kf41", - "key_f42", "kf42", - "key_f43", "kf43", - "key_f44", "kf44", - "key_f45", "kf45", - "key_f46", "kf46", - "key_f47", "kf47", - "key_f48", "kf48", - "key_f49", "kf49", - "key_f50", "kf50", - "key_f51", "kf51", - "key_f52", "kf52", - "key_f53", "kf53", - "key_f54", "kf54", - "key_f55", "kf55", - "key_f56", "kf56", - "key_f57", "kf57", - "key_f58", "kf58", - "key_f59", "kf59", - "key_f60", "kf60", - "key_f61", "kf61", - "key_f62", "kf62", - "key_f63", "kf63", - "clr_bol", "el1", - "clear_margins", "mgc", - "set_left_margin", "smgl", - "set_right_margin", "smgr", - "label_format", "fln", - "set_clock", "sclk", - "display_clock", "dclk", - "remove_clock", "rmclk", - "create_window", "cwin", - "goto_window", "wingo", - "hangup", "hup", - "dial_phone", "dial", - "quick_dial", "qdial", - "tone", "tone", - "pulse", "pulse", - "flash_hook", "hook", - "fixed_pause", "pause", - "wait_tone", "wait", - "user0", "u0", - "user1", "u1", - "user2", "u2", - "user3", "u3", - "user4", "u4", - "user5", "u5", - "user6", "u6", - "user7", "u7", - "user8", "u8", - "user9", "u9", - "orig_pair", "op", - "orig_colors", "oc", - "initialize_color", "initc", - "initialize_pair", "initp", - "set_color_pair", "scp", - "set_foreground", "setf", - "set_background", "setb", - "change_char_pitch", "cpi", - "change_line_pitch", "lpi", - "change_res_horz", "chr", - "change_res_vert", "cvr", - "define_char", "defc", - "enter_doublewide_mode", "swidm", - "enter_draft_quality", "sdrfq", - "enter_italics_mode", "sitm", - "enter_leftward_mode", "slm", - "enter_micro_mode", "smicm", - "enter_near_letter_quality", "snlq", - "enter_normal_quality", "snrmq", - "enter_shadow_mode", "sshm", - "enter_subscript_mode", "ssubm", - "enter_superscript_mode", "ssupm", - "enter_upward_mode", "sum", - "exit_doublewide_mode", "rwidm", - "exit_italics_mode", "ritm", - "exit_leftward_mode", "rlm", - "exit_micro_mode", "rmicm", - "exit_shadow_mode", "rshm", - "exit_subscript_mode", "rsubm", - "exit_superscript_mode", "rsupm", - "exit_upward_mode", "rum", - "micro_column_address", "mhpa", - "micro_down", "mcud1", - "micro_left", "mcub1", - "micro_right", "mcuf1", - "micro_row_address", "mvpa", - "micro_up", "mcuu1", - "order_of_pins", "porder", - "parm_down_micro", "mcud", - "parm_left_micro", "mcub", - "parm_right_micro", "mcuf", - "parm_up_micro", "mcuu", - "select_char_set", "scs", - "set_bottom_margin", "smgb", - "set_bottom_margin_parm", "smgbp", - "set_left_margin_parm", "smglp", - "set_right_margin_parm", "smgrp", - "set_top_margin", "smgt", - "set_top_margin_parm", "smgtp", - "start_bit_image", "sbim", - "start_char_set_def", "scsd", - "stop_bit_image", "rbim", - "stop_char_set_def", "rcsd", - "subscript_characters", "subcs", - "superscript_characters", "supcs", - "these_cause_cr", "docr", - "zero_motion", "zerom", - "char_set_names", "csnm", - "key_mouse", "kmous", - "mouse_info", "minfo", - "req_mouse_pos", "reqmp", - "get_mouse", "getm", - "set_a_foreground", "setaf", - "set_a_background", "setab", - "pkey_plab", "pfxl", - "device_type", "devt", - "code_set_init", "csin", - "set0_des_seq", "s0ds", - "set1_des_seq", "s1ds", - "set2_des_seq", "s2ds", - "set3_des_seq", "s3ds", - "set_lr_margin", "smglr", - "set_tb_margin", "smgtb", - "bit_image_repeat", "birep", - "bit_image_newline", "binel", - "bit_image_carriage_return", "bicr", - "color_names", "colornm", - "define_bit_image_region", "defbi", - "end_bit_image_region", "endbi", - "set_color_band", "setcolor", - "set_page_length", "slines", - "display_pc_char", "dispc", - "enter_pc_charset_mode", "smpch", - "exit_pc_charset_mode", "rmpch", - "enter_scancode_mode", "smsc", - "exit_scancode_mode", "rmsc", - "pc_term_options", "pctrm", - "scancode_escape", "scesc", - "alt_scancode_esc", "scesa", - "enter_horizontal_hl_mode", "ehhlm", - "enter_left_hl_mode", "elhlm", - "enter_low_hl_mode", "elohlm", - "enter_right_hl_mode", "erhlm", - "enter_top_hl_mode", "ethlm", - "enter_vertical_hl_mode", "evhlm", - "set_a_attributes", "sgr1", - "set_pglen_inch", "slength", - "termcap_init2", "OTi2", - "termcap_reset", "OTrs", - "linefeed_if_not_lf", "OTnl", - "backspace_if_not_bs", "OTbc", - "other_non_function_keys", "OTko", - "arrow_key_map", "OTma", - "acs_ulcorner", "OTG2", - "acs_llcorner", "OTG3", - "acs_urcorner", "OTG1", - "acs_lrcorner", "OTG4", - "acs_ltee", "OTGR", - "acs_rtee", "OTGL", - "acs_btee", "OTGU", - "acs_ttee", "OTGD", - "acs_hline", "OTGH", - "acs_vline", "OTGV", - "acs_plus", "OTGC", - "memory_lock", "meml", - "memory_unlock", "memu", - "box_chars_1", "box1", -} diff --git a/vendor/github.com/xo/terminfo/color.go b/vendor/github.com/xo/terminfo/color.go deleted file mode 100644 index 76c439f..0000000 --- a/vendor/github.com/xo/terminfo/color.go +++ /dev/null @@ -1,88 +0,0 @@ -package terminfo - -import ( - "os" - "strconv" - "strings" -) - -// ColorLevel is the color level supported by a terminal. -type ColorLevel uint - -// ColorLevel values. -const ( - ColorLevelNone ColorLevel = iota - ColorLevelBasic - ColorLevelHundreds - ColorLevelMillions -) - -// String satisfies the Stringer interface. -func (c ColorLevel) String() string { - switch c { - case ColorLevelBasic: - return "basic" - case ColorLevelHundreds: - return "hundreds" - case ColorLevelMillions: - return "millions" - } - return "none" -} - -// ChromaFormatterName returns the github.com/alecthomas/chroma compatible -// formatter name for the color level. -func (c ColorLevel) ChromaFormatterName() string { - switch c { - case ColorLevelBasic: - return "terminal" - case ColorLevelHundreds: - return "terminal256" - case ColorLevelMillions: - return "terminal16m" - } - return "noop" -} - -// ColorLevelFromEnv returns the color level COLORTERM, FORCE_COLOR, -// TERM_PROGRAM, or determined from the TERM environment variable. -func ColorLevelFromEnv() (ColorLevel, error) { - // check for overriding environment variables - colorTerm, termProg, forceColor := os.Getenv("COLORTERM"), os.Getenv("TERM_PROGRAM"), os.Getenv("FORCE_COLOR") - switch { - case strings.Contains(colorTerm, "truecolor") || strings.Contains(colorTerm, "24bit") || termProg == "Hyper": - return ColorLevelMillions, nil - case colorTerm != "" || forceColor != "": - return ColorLevelBasic, nil - case termProg == "Apple_Terminal": - return ColorLevelHundreds, nil - case termProg == "iTerm.app": - ver := os.Getenv("TERM_PROGRAM_VERSION") - if ver == "" { - return ColorLevelHundreds, nil - } - i, err := strconv.Atoi(strings.Split(ver, ".")[0]) - if err != nil { - return ColorLevelNone, ErrInvalidTermProgramVersion - } - if i == 3 { - return ColorLevelMillions, nil - } - return ColorLevelHundreds, nil - } - // otherwise determine from TERM's max_colors capability - if term := os.Getenv("TERM"); term != "" { - ti, err := Load(term) - if err != nil { - return ColorLevelNone, err - } - v, ok := ti.Nums[MaxColors] - switch { - case !ok || v <= 16: - return ColorLevelNone, nil - case ok && v >= 256: - return ColorLevelHundreds, nil - } - } - return ColorLevelBasic, nil -} diff --git a/vendor/github.com/xo/terminfo/dec.go b/vendor/github.com/xo/terminfo/dec.go deleted file mode 100644 index dacc88e..0000000 --- a/vendor/github.com/xo/terminfo/dec.go +++ /dev/null @@ -1,245 +0,0 @@ -package terminfo - -import ( - "sort" -) - -const ( - // maxFileLength is the max file length. - maxFileLength = 4096 - // magic is the file magic for terminfo files. - magic = 0o432 - // magicExtended is the file magic for terminfo files with the extended - // number format. - magicExtended = 0o1036 -) - -// header fields. -const ( - fieldMagic = iota - fieldNameSize - fieldBoolCount - fieldNumCount - fieldStringCount - fieldTableSize -) - -// header extended fields. -const ( - fieldExtBoolCount = iota - fieldExtNumCount - fieldExtStringCount - fieldExtOffsetCount - fieldExtTableSize -) - -// hasInvalidCaps determines if the capabilities in h are invalid. -func hasInvalidCaps(h []int) bool { - return h[fieldBoolCount] > CapCountBool || - h[fieldNumCount] > CapCountNum || - h[fieldStringCount] > CapCountString -} - -// capLength returns the total length of the capabilities in bytes. -func capLength(h []int) int { - return h[fieldNameSize] + - h[fieldBoolCount] + - (h[fieldNameSize]+h[fieldBoolCount])%2 + // account for word align - h[fieldNumCount]*2 + - h[fieldStringCount]*2 + - h[fieldTableSize] -} - -// hasInvalidExtOffset determines if the extended offset field is valid. -func hasInvalidExtOffset(h []int) bool { - return h[fieldExtBoolCount]+ - h[fieldExtNumCount]+ - h[fieldExtStringCount]*2 != h[fieldExtOffsetCount] -} - -// extCapLength returns the total length of extended capabilities in bytes. -func extCapLength(h []int, numWidth int) int { - return h[fieldExtBoolCount] + - h[fieldExtBoolCount]%2 + // account for word align - h[fieldExtNumCount]*(numWidth/8) + - h[fieldExtOffsetCount]*2 + - h[fieldExtTableSize] -} - -// findNull finds the position of null in buf. -func findNull(buf []byte, i int) int { - for ; i < len(buf); i++ { - if buf[i] == 0 { - return i - } - } - return -1 -} - -// readStrings decodes n strings from string data table buf using the indexes in idx. -func readStrings(idx []int, buf []byte, n int) (map[int][]byte, int, error) { - var last int - m := make(map[int][]byte) - for i := 0; i < n; i++ { - start := idx[i] - if start < 0 { - continue - } - if end := findNull(buf, start); end != -1 { - m[i], last = buf[start:end], end+1 - } else { - return nil, 0, ErrInvalidStringTable - } - } - return m, last, nil -} - -// decoder holds state info while decoding a terminfo file. -type decoder struct { - buf []byte - pos int - n int -} - -// readBytes reads the next n bytes of buf, incrementing pos by n. -func (d *decoder) readBytes(n int) ([]byte, error) { - if d.n < d.pos+n { - return nil, ErrUnexpectedFileEnd - } - n, d.pos = d.pos, d.pos+n - return d.buf[n:d.pos], nil -} - -// readInts reads n number of ints with width w. -func (d *decoder) readInts(n, w int) ([]int, error) { - w /= 8 - l := n * w - buf, err := d.readBytes(l) - if err != nil { - return nil, err - } - // align - d.pos += d.pos % 2 - z := make([]int, n) - for i, j := 0, 0; i < l; i, j = i+w, j+1 { - switch w { - case 1: - z[i] = int(buf[i]) - case 2: - z[j] = int(int16(buf[i+1])<<8 | int16(buf[i])) - case 4: - z[j] = int(buf[i+3])<<24 | int(buf[i+2])<<16 | int(buf[i+1])<<8 | int(buf[i]) - } - } - return z, nil -} - -// readBools reads the next n bools. -func (d *decoder) readBools(n int) (map[int]bool, map[int]bool, error) { - buf, err := d.readInts(n, 8) - if err != nil { - return nil, nil, err - } - // process - bools, boolsM := make(map[int]bool), make(map[int]bool) - for i, b := range buf { - bools[i] = b == 1 - if int8(b) == -2 { - boolsM[i] = true - } - } - return bools, boolsM, nil -} - -// readNums reads the next n nums. -func (d *decoder) readNums(n, w int) (map[int]int, map[int]bool, error) { - buf, err := d.readInts(n, w) - if err != nil { - return nil, nil, err - } - // process - nums, numsM := make(map[int]int), make(map[int]bool) - for i := 0; i < n; i++ { - nums[i] = buf[i] - if buf[i] == -2 { - numsM[i] = true - } - } - return nums, numsM, nil -} - -// readStringTable reads the string data for n strings and the accompanying data -// table of length sz. -func (d *decoder) readStringTable(n, sz int) ([][]byte, []int, error) { - buf, err := d.readInts(n, 16) - if err != nil { - return nil, nil, err - } - // read string data table - data, err := d.readBytes(sz) - if err != nil { - return nil, nil, err - } - // align - d.pos += d.pos % 2 - // process - s := make([][]byte, n) - var m []int - for i := 0; i < n; i++ { - start := buf[i] - if start == -2 { - m = append(m, i) - } else if start >= 0 { - if end := findNull(data, start); end != -1 { - s[i] = data[start:end] - } else { - return nil, nil, ErrInvalidStringTable - } - } - } - return s, m, nil -} - -// readStrings reads the next n strings and processes the string data table of -// length sz. -func (d *decoder) readStrings(n, sz int) (map[int][]byte, map[int]bool, error) { - s, m, err := d.readStringTable(n, sz) - if err != nil { - return nil, nil, err - } - strs := make(map[int][]byte) - for k, v := range s { - if k == AcsChars { - v = canonicalizeAscChars(v) - } - strs[k] = v - } - strsM := make(map[int]bool, len(m)) - for _, k := range m { - strsM[k] = true - } - return strs, strsM, nil -} - -// canonicalizeAscChars reorders chars to be unique, in order. -// -// see repair_ascc in ncurses-6.3/progs/dump_entry.c -func canonicalizeAscChars(z []byte) []byte { - var c []byte - enc := make(map[byte]byte, len(z)/2) - for i := 0; i < len(z); i += 2 { - if _, ok := enc[z[i]]; !ok { - a, b := z[i], z[i+1] - // log.Printf(">>> a: %d %c, b: %d %c", a, a, b, b) - c, enc[a] = append(c, b), b - } - } - sort.Slice(c, func(i, j int) bool { - return c[i] < c[j] - }) - r := make([]byte, 2*len(c)) - for i := 0; i < len(c); i++ { - r[i*2], r[i*2+1] = c[i], enc[c[i]] - } - return r -} diff --git a/vendor/github.com/xo/terminfo/load.go b/vendor/github.com/xo/terminfo/load.go deleted file mode 100644 index d7cd266..0000000 --- a/vendor/github.com/xo/terminfo/load.go +++ /dev/null @@ -1,64 +0,0 @@ -package terminfo - -import ( - "os" - "os/user" - "path" - "strings" - "sync" -) - -// termCache is the terminfo cache. -var termCache = struct { - db map[string]*Terminfo - sync.RWMutex -}{ - db: make(map[string]*Terminfo), -} - -// Load follows the behavior described in terminfo(5) to find correct the -// terminfo file using the name, reads the file and then returns a Terminfo -// struct that describes the file. -func Load(name string) (*Terminfo, error) { - if name == "" { - return nil, ErrEmptyTermName - } - termCache.RLock() - ti, ok := termCache.db[name] - termCache.RUnlock() - if ok { - return ti, nil - } - var checkDirs []string - // check $TERMINFO - if dir := os.Getenv("TERMINFO"); dir != "" { - checkDirs = append(checkDirs, dir) - } - // check $HOME/.terminfo - u, err := user.Current() - if err != nil { - return nil, err - } - checkDirs = append(checkDirs, path.Join(u.HomeDir, ".terminfo")) - // check $TERMINFO_DIRS - if dirs := os.Getenv("TERMINFO_DIRS"); dirs != "" { - checkDirs = append(checkDirs, strings.Split(dirs, ":")...) - } - // check fallback directories - checkDirs = append(checkDirs, "/etc/terminfo", "/lib/terminfo", "/usr/share/terminfo") - for _, dir := range checkDirs { - ti, err = Open(dir, name) - if err != nil && err != ErrFileNotFound && !os.IsNotExist(err) { - return nil, err - } else if err == nil { - return ti, nil - } - } - return nil, ErrDatabaseDirectoryNotFound -} - -// LoadFromEnv loads the terminal info based on the name contained in -// environment variable TERM. -func LoadFromEnv() (*Terminfo, error) { - return Load(os.Getenv("TERM")) -} diff --git a/vendor/github.com/xo/terminfo/param.go b/vendor/github.com/xo/terminfo/param.go deleted file mode 100644 index ed4cb86..0000000 --- a/vendor/github.com/xo/terminfo/param.go +++ /dev/null @@ -1,405 +0,0 @@ -package terminfo - -import ( - "bytes" - "fmt" - "io" - "strconv" - "strings" - "sync" -) - -// parametizer represents the a scan state for a parameterized string. -type parametizer struct { - // z is the string to parameterize - z []byte - // pos is the current position in s. - pos int - // nest is the current nest level. - nest int - // s is the variable stack. - s stack - // skipElse keeps the state of skipping else. - skipElse bool - // buf is the result buffer. - buf *bytes.Buffer - // params are the parameters to interpolate. - params [9]interface{} - // vars are dynamic variables. - vars [26]interface{} -} - -// staticVars are the static, global variables. -var staticVars = struct { - vars [26]interface{} - sync.Mutex -}{} - -var parametizerPool = sync.Pool{ - New: func() interface{} { - p := new(parametizer) - p.buf = bytes.NewBuffer(make([]byte, 0, 45)) - return p - }, -} - -// newParametizer returns a new initialized parametizer from the pool. -func newParametizer(z []byte) *parametizer { - p := parametizerPool.Get().(*parametizer) - p.z = z - return p -} - -// reset resets the parametizer. -func (p *parametizer) reset() { - p.pos, p.nest = 0, 0 - p.s.reset() - p.buf.Reset() - p.params, p.vars = [9]interface{}{}, [26]interface{}{} - parametizerPool.Put(p) -} - -// stateFn represents the state of the scanner as a function that returns the -// next state. -type stateFn func() stateFn - -// exec executes the parameterizer, interpolating the supplied parameters. -func (p *parametizer) exec() string { - for state := p.scanTextFn; state != nil; { - state = state() - } - return p.buf.String() -} - -// peek returns the next byte. -func (p *parametizer) peek() (byte, error) { - if p.pos >= len(p.z) { - return 0, io.EOF - } - return p.z[p.pos], nil -} - -// writeFrom writes the characters from ppos to pos to the buffer. -func (p *parametizer) writeFrom(ppos int) { - if p.pos > ppos { - // append remaining characters. - p.buf.Write(p.z[ppos:p.pos]) - } -} - -func (p *parametizer) scanTextFn() stateFn { - ppos := p.pos - for { - ch, err := p.peek() - if err != nil { - p.writeFrom(ppos) - return nil - } - if ch == '%' { - p.writeFrom(ppos) - p.pos++ - return p.scanCodeFn - } - p.pos++ - } -} - -func (p *parametizer) scanCodeFn() stateFn { - ch, err := p.peek() - if err != nil { - return nil - } - switch ch { - case '%': - p.buf.WriteByte('%') - case ':': - // this character is used to avoid interpreting "%-" and "%+" as operators. - // the next character is where the format really begins. - p.pos++ - _, err = p.peek() - if err != nil { - return nil - } - return p.scanFormatFn - case '#', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.': - return p.scanFormatFn - case 'o': - p.buf.WriteString(strconv.FormatInt(int64(p.s.popInt()), 8)) - case 'd': - p.buf.WriteString(strconv.Itoa(p.s.popInt())) - case 'x': - p.buf.WriteString(strconv.FormatInt(int64(p.s.popInt()), 16)) - case 'X': - p.buf.WriteString(strings.ToUpper(strconv.FormatInt(int64(p.s.popInt()), 16))) - case 's': - p.buf.WriteString(p.s.popString()) - case 'c': - p.buf.WriteByte(p.s.popByte()) - case 'p': - p.pos++ - return p.pushParamFn - case 'P': - p.pos++ - return p.setDsVarFn - case 'g': - p.pos++ - return p.getDsVarFn - case '\'': - p.pos++ - ch, err = p.peek() - if err != nil { - return nil - } - p.s.push(ch) - // skip the '\'' - p.pos++ - case '{': - p.pos++ - return p.pushIntfn - case 'l': - p.s.push(len(p.s.popString())) - case '+': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai + bi) - case '-': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai - bi) - case '*': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai * bi) - case '/': - bi, ai := p.s.popInt(), p.s.popInt() - if bi != 0 { - p.s.push(ai / bi) - } else { - p.s.push(0) - } - case 'm': - bi, ai := p.s.popInt(), p.s.popInt() - if bi != 0 { - p.s.push(ai % bi) - } else { - p.s.push(0) - } - case '&': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai & bi) - case '|': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai | bi) - case '^': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai ^ bi) - case '=': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai == bi) - case '>': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai > bi) - case '<': - bi, ai := p.s.popInt(), p.s.popInt() - p.s.push(ai < bi) - case 'A': - bi, ai := p.s.popBool(), p.s.popBool() - p.s.push(ai && bi) - case 'O': - bi, ai := p.s.popBool(), p.s.popBool() - p.s.push(ai || bi) - case '!': - p.s.push(!p.s.popBool()) - case '~': - p.s.push(^p.s.popInt()) - case 'i': - for i := range p.params[:2] { - if n, ok := p.params[i].(int); ok { - p.params[i] = n + 1 - } - } - case '?', ';': - case 't': - return p.scanThenFn - case 'e': - p.skipElse = true - return p.skipTextFn - } - p.pos++ - return p.scanTextFn -} - -func (p *parametizer) scanFormatFn() stateFn { - // the character was already read, so no need to check the error. - ch, _ := p.peek() - // 6 should be the maximum length of a format string, for example "%:-9.9d". - f := []byte{'%', ch, 0, 0, 0, 0} - var err error - for { - p.pos++ - ch, err = p.peek() - if err != nil { - return nil - } - f = append(f, ch) - switch ch { - case 'o', 'd', 'x', 'X': - fmt.Fprintf(p.buf, string(f), p.s.popInt()) - break - case 's': - fmt.Fprintf(p.buf, string(f), p.s.popString()) - break - case 'c': - fmt.Fprintf(p.buf, string(f), p.s.popByte()) - break - } - } - p.pos++ - return p.scanTextFn -} - -func (p *parametizer) pushParamFn() stateFn { - ch, err := p.peek() - if err != nil { - return nil - } - if ai := int(ch - '1'); ai >= 0 && ai < len(p.params) { - p.s.push(p.params[ai]) - } else { - p.s.push(0) - } - // skip the '}' - p.pos++ - return p.scanTextFn -} - -func (p *parametizer) setDsVarFn() stateFn { - ch, err := p.peek() - if err != nil { - return nil - } - if ch >= 'A' && ch <= 'Z' { - staticVars.Lock() - staticVars.vars[int(ch-'A')] = p.s.pop() - staticVars.Unlock() - } else if ch >= 'a' && ch <= 'z' { - p.vars[int(ch-'a')] = p.s.pop() - } - p.pos++ - return p.scanTextFn -} - -func (p *parametizer) getDsVarFn() stateFn { - ch, err := p.peek() - if err != nil { - return nil - } - var a byte - if ch >= 'A' && ch <= 'Z' { - a = 'A' - } else if ch >= 'a' && ch <= 'z' { - a = 'a' - } - staticVars.Lock() - p.s.push(staticVars.vars[int(ch-a)]) - staticVars.Unlock() - p.pos++ - return p.scanTextFn -} - -func (p *parametizer) pushIntfn() stateFn { - var ai int - for { - ch, err := p.peek() - if err != nil { - return nil - } - p.pos++ - if ch < '0' || ch > '9' { - p.s.push(ai) - return p.scanTextFn - } - ai = (ai * 10) + int(ch-'0') - } -} - -func (p *parametizer) scanThenFn() stateFn { - p.pos++ - if p.s.popBool() { - return p.scanTextFn - } - p.skipElse = false - return p.skipTextFn -} - -func (p *parametizer) skipTextFn() stateFn { - for { - ch, err := p.peek() - if err != nil { - return nil - } - p.pos++ - if ch == '%' { - break - } - } - if p.skipElse { - return p.skipElseFn - } - return p.skipThenFn -} - -func (p *parametizer) skipThenFn() stateFn { - ch, err := p.peek() - if err != nil { - return nil - } - p.pos++ - switch ch { - case ';': - if p.nest == 0 { - return p.scanTextFn - } - p.nest-- - case '?': - p.nest++ - case 'e': - if p.nest == 0 { - return p.scanTextFn - } - } - return p.skipTextFn -} - -func (p *parametizer) skipElseFn() stateFn { - ch, err := p.peek() - if err != nil { - return nil - } - p.pos++ - switch ch { - case ';': - if p.nest == 0 { - return p.scanTextFn - } - p.nest-- - case '?': - p.nest++ - } - return p.skipTextFn -} - -// Printf evaluates a parameterized terminfo value z, interpolating params. -func Printf(z []byte, params ...interface{}) string { - p := newParametizer(z) - defer p.reset() - // make sure we always have 9 parameters -- makes it easier - // later to skip checks and its faster - for i := 0; i < len(p.params) && i < len(params); i++ { - p.params[i] = params[i] - } - return p.exec() -} - -// Fprintf evaluates a parameterized terminfo value z, interpolating params and -// writing to w. -func Fprintf(w io.Writer, z []byte, params ...interface{}) { - w.Write([]byte(Printf(z, params...))) -} diff --git a/vendor/github.com/xo/terminfo/stack.go b/vendor/github.com/xo/terminfo/stack.go deleted file mode 100644 index a6de395..0000000 --- a/vendor/github.com/xo/terminfo/stack.go +++ /dev/null @@ -1,48 +0,0 @@ -package terminfo - -type stack []interface{} - -func (s *stack) push(v interface{}) { - *s = append(*s, v) -} - -func (s *stack) pop() interface{} { - if len(*s) == 0 { - return nil - } - v := (*s)[len(*s)-1] - *s = (*s)[:len(*s)-1] - return v -} - -func (s *stack) popInt() int { - if i, ok := s.pop().(int); ok { - return i - } - return 0 -} - -func (s *stack) popBool() bool { - if b, ok := s.pop().(bool); ok { - return b - } - return false -} - -func (s *stack) popByte() byte { - if b, ok := s.pop().(byte); ok { - return b - } - return 0 -} - -func (s *stack) popString() string { - if a, ok := s.pop().(string); ok { - return a - } - return "" -} - -func (s *stack) reset() { - *s = (*s)[:0] -} diff --git a/vendor/github.com/xo/terminfo/terminfo.go b/vendor/github.com/xo/terminfo/terminfo.go deleted file mode 100644 index 69e3b60..0000000 --- a/vendor/github.com/xo/terminfo/terminfo.go +++ /dev/null @@ -1,479 +0,0 @@ -// Package terminfo implements reading terminfo files in pure go. -package terminfo - -//go:generate go run gen.go - -import ( - "io" - "io/ioutil" - "path" - "strconv" - "strings" -) - -// Error is a terminfo error. -type Error string - -// Error satisfies the error interface. -func (err Error) Error() string { - return string(err) -} - -const ( - // ErrInvalidFileSize is the invalid file size error. - ErrInvalidFileSize Error = "invalid file size" - // ErrUnexpectedFileEnd is the unexpected file end error. - ErrUnexpectedFileEnd Error = "unexpected file end" - // ErrInvalidStringTable is the invalid string table error. - ErrInvalidStringTable Error = "invalid string table" - // ErrInvalidMagic is the invalid magic error. - ErrInvalidMagic Error = "invalid magic" - // ErrInvalidHeader is the invalid header error. - ErrInvalidHeader Error = "invalid header" - // ErrInvalidNames is the invalid names error. - ErrInvalidNames Error = "invalid names" - // ErrInvalidExtendedHeader is the invalid extended header error. - ErrInvalidExtendedHeader Error = "invalid extended header" - // ErrEmptyTermName is the empty term name error. - ErrEmptyTermName Error = "empty term name" - // ErrDatabaseDirectoryNotFound is the database directory not found error. - ErrDatabaseDirectoryNotFound Error = "database directory not found" - // ErrFileNotFound is the file not found error. - ErrFileNotFound Error = "file not found" - // ErrInvalidTermProgramVersion is the invalid TERM_PROGRAM_VERSION error. - ErrInvalidTermProgramVersion Error = "invalid TERM_PROGRAM_VERSION" -) - -// Terminfo describes a terminal's capabilities. -type Terminfo struct { - // File is the original source file. - File string - // Names are the provided cap names. - Names []string - // Bools are the bool capabilities. - Bools map[int]bool - // BoolsM are the missing bool capabilities. - BoolsM map[int]bool - // Nums are the num capabilities. - Nums map[int]int - // NumsM are the missing num capabilities. - NumsM map[int]bool - // Strings are the string capabilities. - Strings map[int][]byte - // StringsM are the missing string capabilities. - StringsM map[int]bool - // ExtBools are the extended bool capabilities. - ExtBools map[int]bool - // ExtBoolsNames is the map of extended bool capabilities to their index. - ExtBoolNames map[int][]byte - // ExtNums are the extended num capabilities. - ExtNums map[int]int - // ExtNumsNames is the map of extended num capabilities to their index. - ExtNumNames map[int][]byte - // ExtStrings are the extended string capabilities. - ExtStrings map[int][]byte - // ExtStringsNames is the map of extended string capabilities to their index. - ExtStringNames map[int][]byte -} - -// Decode decodes the terminfo data contained in buf. -func Decode(buf []byte) (*Terminfo, error) { - var err error - // check max file length - if len(buf) >= maxFileLength { - return nil, ErrInvalidFileSize - } - d := &decoder{ - buf: buf, - n: len(buf), - } - // read header - h, err := d.readInts(6, 16) - if err != nil { - return nil, err - } - var numWidth int - // check magic - switch { - case h[fieldMagic] == magic: - numWidth = 16 - case h[fieldMagic] == magicExtended: - numWidth = 32 - default: - return nil, ErrInvalidMagic - } - // check header - if hasInvalidCaps(h) { - return nil, ErrInvalidHeader - } - // check remaining length - if d.n-d.pos < capLength(h) { - return nil, ErrUnexpectedFileEnd - } - // read names - names, err := d.readBytes(h[fieldNameSize]) - if err != nil { - return nil, err - } - // check name is terminated properly - i := findNull(names, 0) - if i == -1 { - return nil, ErrInvalidNames - } - names = names[:i] - // read bool caps - bools, boolsM, err := d.readBools(h[fieldBoolCount]) - if err != nil { - return nil, err - } - // read num caps - nums, numsM, err := d.readNums(h[fieldNumCount], numWidth) - if err != nil { - return nil, err - } - // read string caps - strs, strsM, err := d.readStrings(h[fieldStringCount], h[fieldTableSize]) - if err != nil { - return nil, err - } - ti := &Terminfo{ - Names: strings.Split(string(names), "|"), - Bools: bools, - BoolsM: boolsM, - Nums: nums, - NumsM: numsM, - Strings: strs, - StringsM: strsM, - } - // at the end of file, so no extended caps - if d.pos >= d.n { - return ti, nil - } - // decode extended header - eh, err := d.readInts(5, 16) - if err != nil { - return nil, err - } - // check extended offset field - if hasInvalidExtOffset(eh) { - return nil, ErrInvalidExtendedHeader - } - // check extended cap lengths - if d.n-d.pos != extCapLength(eh, numWidth) { - return nil, ErrInvalidExtendedHeader - } - // read extended bool caps - ti.ExtBools, _, err = d.readBools(eh[fieldExtBoolCount]) - if err != nil { - return nil, err - } - // read extended num caps - ti.ExtNums, _, err = d.readNums(eh[fieldExtNumCount], numWidth) - if err != nil { - return nil, err - } - // read extended string data table indexes - extIndexes, err := d.readInts(eh[fieldExtOffsetCount], 16) - if err != nil { - return nil, err - } - // read string data table - extData, err := d.readBytes(eh[fieldExtTableSize]) - if err != nil { - return nil, err - } - // precautionary check that exactly at end of file - if d.pos != d.n { - return nil, ErrUnexpectedFileEnd - } - var last int - // read extended string caps - ti.ExtStrings, last, err = readStrings(extIndexes, extData, eh[fieldExtStringCount]) - if err != nil { - return nil, err - } - extIndexes, extData = extIndexes[eh[fieldExtStringCount]:], extData[last:] - // read extended bool names - ti.ExtBoolNames, _, err = readStrings(extIndexes, extData, eh[fieldExtBoolCount]) - if err != nil { - return nil, err - } - extIndexes = extIndexes[eh[fieldExtBoolCount]:] - // read extended num names - ti.ExtNumNames, _, err = readStrings(extIndexes, extData, eh[fieldExtNumCount]) - if err != nil { - return nil, err - } - extIndexes = extIndexes[eh[fieldExtNumCount]:] - // read extended string names - ti.ExtStringNames, _, err = readStrings(extIndexes, extData, eh[fieldExtStringCount]) - if err != nil { - return nil, err - } - // extIndexes = extIndexes[eh[fieldExtStringCount]:] - return ti, nil -} - -// Open reads the terminfo file name from the specified directory dir. -func Open(dir, name string) (*Terminfo, error) { - var err error - var buf []byte - var filename string - for _, f := range []string{ - path.Join(dir, name[0:1], name), - path.Join(dir, strconv.FormatUint(uint64(name[0]), 16), name), - } { - buf, err = ioutil.ReadFile(f) - if err == nil { - filename = f - break - } - } - if buf == nil { - return nil, ErrFileNotFound - } - // decode - ti, err := Decode(buf) - if err != nil { - return nil, err - } - // save original file name - ti.File = filename - // add to cache - termCache.Lock() - for _, n := range ti.Names { - termCache.db[n] = ti - } - termCache.Unlock() - return ti, nil -} - -// boolCaps returns all bool and extended capabilities using f to format the -// index key. -func (ti *Terminfo) boolCaps(f func(int) string, extended bool) map[string]bool { - m := make(map[string]bool, len(ti.Bools)+len(ti.ExtBools)) - if !extended { - for k, v := range ti.Bools { - m[f(k)] = v - } - } else { - for k, v := range ti.ExtBools { - m[string(ti.ExtBoolNames[k])] = v - } - } - return m -} - -// BoolCaps returns all bool capabilities. -func (ti *Terminfo) BoolCaps() map[string]bool { - return ti.boolCaps(BoolCapName, false) -} - -// BoolCapsShort returns all bool capabilities, using the short name as the -// index. -func (ti *Terminfo) BoolCapsShort() map[string]bool { - return ti.boolCaps(BoolCapNameShort, false) -} - -// ExtBoolCaps returns all extended bool capabilities. -func (ti *Terminfo) ExtBoolCaps() map[string]bool { - return ti.boolCaps(BoolCapName, true) -} - -// ExtBoolCapsShort returns all extended bool capabilities, using the short -// name as the index. -func (ti *Terminfo) ExtBoolCapsShort() map[string]bool { - return ti.boolCaps(BoolCapNameShort, true) -} - -// numCaps returns all num and extended capabilities using f to format the -// index key. -func (ti *Terminfo) numCaps(f func(int) string, extended bool) map[string]int { - m := make(map[string]int, len(ti.Nums)+len(ti.ExtNums)) - if !extended { - for k, v := range ti.Nums { - m[f(k)] = v - } - } else { - for k, v := range ti.ExtNums { - m[string(ti.ExtNumNames[k])] = v - } - } - return m -} - -// NumCaps returns all num capabilities. -func (ti *Terminfo) NumCaps() map[string]int { - return ti.numCaps(NumCapName, false) -} - -// NumCapsShort returns all num capabilities, using the short name as the -// index. -func (ti *Terminfo) NumCapsShort() map[string]int { - return ti.numCaps(NumCapNameShort, false) -} - -// ExtNumCaps returns all extended num capabilities. -func (ti *Terminfo) ExtNumCaps() map[string]int { - return ti.numCaps(NumCapName, true) -} - -// ExtNumCapsShort returns all extended num capabilities, using the short -// name as the index. -func (ti *Terminfo) ExtNumCapsShort() map[string]int { - return ti.numCaps(NumCapNameShort, true) -} - -// stringCaps returns all string and extended capabilities using f to format the -// index key. -func (ti *Terminfo) stringCaps(f func(int) string, extended bool) map[string][]byte { - m := make(map[string][]byte, len(ti.Strings)+len(ti.ExtStrings)) - if !extended { - for k, v := range ti.Strings { - m[f(k)] = v - } - } else { - for k, v := range ti.ExtStrings { - m[string(ti.ExtStringNames[k])] = v - } - } - return m -} - -// StringCaps returns all string capabilities. -func (ti *Terminfo) StringCaps() map[string][]byte { - return ti.stringCaps(StringCapName, false) -} - -// StringCapsShort returns all string capabilities, using the short name as the -// index. -func (ti *Terminfo) StringCapsShort() map[string][]byte { - return ti.stringCaps(StringCapNameShort, false) -} - -// ExtStringCaps returns all extended string capabilities. -func (ti *Terminfo) ExtStringCaps() map[string][]byte { - return ti.stringCaps(StringCapName, true) -} - -// ExtStringCapsShort returns all extended string capabilities, using the short -// name as the index. -func (ti *Terminfo) ExtStringCapsShort() map[string][]byte { - return ti.stringCaps(StringCapNameShort, true) -} - -// Has determines if the bool cap i is present. -func (ti *Terminfo) Has(i int) bool { - return ti.Bools[i] -} - -// Num returns the num cap i, or -1 if not present. -func (ti *Terminfo) Num(i int) int { - n, ok := ti.Nums[i] - if !ok { - return -1 - } - return n -} - -// Printf formats the string cap i, interpolating parameters v. -func (ti *Terminfo) Printf(i int, v ...interface{}) string { - return Printf(ti.Strings[i], v...) -} - -// Fprintf prints the string cap i to writer w, interpolating parameters v. -func (ti *Terminfo) Fprintf(w io.Writer, i int, v ...interface{}) { - Fprintf(w, ti.Strings[i], v...) -} - -// Color takes a foreground and background color and returns string that sets -// them for this terminal. -func (ti *Terminfo) Colorf(fg, bg int, str string) string { - maxColors := int(ti.Nums[MaxColors]) - // map bright colors to lower versions if the color table only holds 8. - if maxColors == 8 { - if fg > 7 && fg < 16 { - fg -= 8 - } - if bg > 7 && bg < 16 { - bg -= 8 - } - } - var s string - if maxColors > fg && fg >= 0 { - s += ti.Printf(SetAForeground, fg) - } - if maxColors > bg && bg >= 0 { - s += ti.Printf(SetABackground, bg) - } - return s + str + ti.Printf(ExitAttributeMode) -} - -// Goto returns a string suitable for addressing the cursor at the given -// row and column. The origin 0, 0 is in the upper left corner of the screen. -func (ti *Terminfo) Goto(row, col int) string { - return Printf(ti.Strings[CursorAddress], row, col) -} - -// Puts emits the string to the writer, but expands inline padding indications -// (of the form $<[delay]> where [delay] is msec) to a suitable number of -// padding characters (usually null bytes) based upon the supplied baud. At -// high baud rates, more padding characters will be inserted. -/*func (ti *Terminfo) Puts(w io.Writer, s string, lines, baud int) (int, error) { - var err error - for { - start := strings.Index(s, "$<") - if start == -1 { - // most strings don't need padding, which is good news! - return io.WriteString(w, s) - } - end := strings.Index(s, ">") - if end == -1 { - // unterminated... just emit bytes unadulterated. - return io.WriteString(w, "$<"+s) - } - var c int - c, err = io.WriteString(w, s[:start]) - if err != nil { - return n + c, err - } - n += c - s = s[start+2:] - val := s[:end] - s = s[end+1:] - var ms int - var dot, mandatory, asterisk bool - unit := 1000 - for _, ch := range val { - switch { - case ch >= '0' && ch <= '9': - ms = (ms * 10) + int(ch-'0') - if dot { - unit *= 10 - } - case ch == '.' && !dot: - dot = true - case ch == '*' && !asterisk: - ms *= lines - asterisk = true - case ch == '/': - mandatory = true - default: - break - } - } - z, pad := ((baud/8)/unit)*ms, ti.Strings[PadChar] - b := make([]byte, len(pad)*z) - for bp := copy(b, pad); bp < len(b); bp *= 2 { - copy(b[bp:], b[:bp]) - } - if (!ti.Bools[XonXoff] && baud > int(ti.Nums[PaddingBaudRate])) || mandatory { - c, err = w.Write(b) - if err != nil { - return n + c, err - } - n += c - } - } - return n, nil -}*/ diff --git a/vendor/modules.txt b/vendor/modules.txt index 042303d..ad52845 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,25 +4,19 @@ github.com/atotto/clipboard # github.com/aymanbagabas/go-osc52/v2 v2.0.1 ## explicit; go 1.16 github.com/aymanbagabas/go-osc52/v2 -# github.com/charmbracelet/bubbletea v0.27.1 +# github.com/charmbracelet/bubbletea v1.1.0 ## explicit; go 1.18 github.com/charmbracelet/bubbletea # github.com/charmbracelet/lipgloss v0.13.0 ## explicit; go 1.18 github.com/charmbracelet/lipgloss -# github.com/charmbracelet/x/ansi v0.1.4 +# github.com/charmbracelet/x/ansi v0.2.3 ## explicit; go 1.18 github.com/charmbracelet/x/ansi github.com/charmbracelet/x/ansi/parser -# github.com/charmbracelet/x/input v0.1.3 -## explicit; go 1.18 -github.com/charmbracelet/x/input -# github.com/charmbracelet/x/term v0.1.1 +# github.com/charmbracelet/x/term v0.2.0 ## explicit; go 1.18 github.com/charmbracelet/x/term -# github.com/charmbracelet/x/windows v0.1.2 -## explicit; go 1.18 -github.com/charmbracelet/x/windows # github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f ## explicit; go 1.16 github.com/erikgeiser/coninput @@ -68,15 +62,14 @@ github.com/tobischo/argon2 github.com/tobischo/gokeepasslib/v3 github.com/tobischo/gokeepasslib/v3/crypto github.com/tobischo/gokeepasslib/v3/wrappers -# github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e -## explicit; go 1.19 -github.com/xo/terminfo # golang.org/x/crypto v0.25.0 ## explicit; go 1.20 golang.org/x/crypto/blake2b golang.org/x/crypto/chacha20 golang.org/x/crypto/internal/alias golang.org/x/crypto/twofish +# golang.org/x/exp v0.0.0-20231006140011-7918f672742d +## explicit; go 1.20 # golang.org/x/sync v0.8.0 ## explicit; go 1.18 golang.org/x/sync/errgroup