diff --git a/go.mod b/go.mod
index 35117cd7..e50ed978 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.22
require (
github.com/adrg/xdg v0.4.0
github.com/charmbracelet/bubbles v0.18.0
- github.com/charmbracelet/bubbletea v0.25.0
+ github.com/charmbracelet/bubbletea v1.2.4
github.com/charmbracelet/glamour v0.6.0
github.com/charmbracelet/lipgloss v1.0.0
github.com/getkin/kin-openapi v0.124.0
@@ -41,10 +41,11 @@ require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
- github.com/charmbracelet/x/ansi v0.4.2 // indirect
- github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
+ github.com/charmbracelet/x/ansi v0.4.5 // indirect
+ github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
+ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
@@ -71,7 +72,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
- github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
+ github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
diff --git a/go.sum b/go.sum
index 767c9d77..7589c92d 100644
--- a/go.sum
+++ b/go.sum
@@ -51,21 +51,21 @@ github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvF
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
-github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM=
-github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
+github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv3KnQRNCE=
+github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM=
github.com/charmbracelet/glamour v0.6.0 h1:wi8fse3Y7nfcabbbDuwolqTqMQPMnVPeZhDM273bISc=
github.com/charmbracelet/glamour v0.6.0/go.mod h1:taqWV4swIMMbWALc0m7AfE9JkPSU8om2538k9ITBxOc=
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo=
-github.com/charmbracelet/x/ansi v0.4.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk=
-github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
+github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM=
+github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
+github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
+github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
-github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
-github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -77,6 +77,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
+github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
@@ -234,8 +236,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
-github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
-github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
+github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
+github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
@@ -445,6 +447,7 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/vendor/github.com/charmbracelet/bubbletea/.gitignore b/vendor/github.com/charmbracelet/bubbletea/.gitignore
index 9cc52352..abd7c061 100644
--- a/vendor/github.com/charmbracelet/bubbletea/.gitignore
+++ b/vendor/github.com/charmbracelet/bubbletea/.gitignore
@@ -20,3 +20,4 @@ tutorials/basics/basics
tutorials/commands/commands
.idea
coverage.txt
+dist/
diff --git a/vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml b/vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml
index ef456e06..d325d4fc 100644
--- a/vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml
+++ b/vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml
@@ -1,5 +1,6 @@
run:
tests: false
+ issues-exit-code: 0
issues:
include:
@@ -14,17 +15,13 @@ issues:
linters:
enable:
- # - dupl
- exhaustive
- # - exhaustivestruct
- goconst
- godot
- godox
- - gomnd
+ - mnd
- gomoddirectives
- goprintffuncname
- - ifshort
- # - lll
- misspell
- nakedret
- nestif
@@ -35,13 +32,9 @@ linters:
# disable default linters, they are already enabled in .golangci.yml
disable:
- - deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- - structcheck
- - typecheck
- unused
- - varcheck
diff --git a/vendor/github.com/charmbracelet/bubbletea/.golangci.yml b/vendor/github.com/charmbracelet/bubbletea/.golangci.yml
index a5a91d0d..d6789e01 100644
--- a/vendor/github.com/charmbracelet/bubbletea/.golangci.yml
+++ b/vendor/github.com/charmbracelet/bubbletea/.golangci.yml
@@ -15,11 +15,10 @@ issues:
linters:
enable:
- bodyclose
- - exportloopref
+ - gofumpt
- goimports
- gosec
- nilerr
- - predeclared
- revive
- rowserrcheck
- sqlclosecheck
diff --git a/vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml b/vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml
new file mode 100644
index 00000000..3353d020
--- /dev/null
+++ b/vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml
@@ -0,0 +1,5 @@
+# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
+version: 2
+includes:
+ - from_url:
+ url: charmbracelet/meta/main/goreleaser-lib.yaml
diff --git a/vendor/github.com/charmbracelet/bubbletea/CONTRIBUTING.md b/vendor/github.com/charmbracelet/bubbletea/CONTRIBUTING.md
deleted file mode 100644
index 19ee18c7..00000000
--- a/vendor/github.com/charmbracelet/bubbletea/CONTRIBUTING.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Contributing
-
-Pull requests are welcome for any changes.
-
-Consider opening an issue for larger changes to get feedback on the idea from the team.
-
-If your change touches parts of the Bubble Tea renderer or internals, make sure
-that all the examples in the `examples/` folder continue to run correctly.
-
-For commit messages, please use conventional commits[^1] to make it easier to
-generate release notes.
-
-[^1]: https://www.conventionalcommits.org/en/v1.0.0
diff --git a/vendor/github.com/charmbracelet/bubbletea/README.md b/vendor/github.com/charmbracelet/bubbletea/README.md
index 0834246c..4dbe75eb 100644
--- a/vendor/github.com/charmbracelet/bubbletea/README.md
+++ b/vendor/github.com/charmbracelet/bubbletea/README.md
@@ -1,10 +1,11 @@
# Bubble Tea
- 
+ 
-
-
+
+
+
The fun, functional and stateful way to build terminal apps. A Go framework
@@ -34,7 +35,7 @@ Be sure to check out [Bubbles][bubbles], a library of common UI components for B
-***
+---
## Tutorial
@@ -48,7 +49,7 @@ By the way, the non-annotated source code for this program is available
[on GitHub][tut-source].
[elm]: https://guide.elm-lang.org/architecture/
-[tut-source]:https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics
+[tut-source]: https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics
### Enough! Let's get to it.
@@ -71,9 +72,9 @@ import (
Bubble Tea programs are comprised of a **model** that describes the application
state and three simple methods on that model:
-* **Init**, a function that returns an initial command for the application to run.
-* **Update**, a function that handles incoming events and updates the model accordingly.
-* **View**, a function that renders the UI based on the data in the model.
+- **Init**, a function that returns an initial command for the application to run.
+- **Update**, a function that handles incoming events and updates the model accordingly.
+- **View**, a function that renders the UI based on the data in the model.
### The Model
@@ -253,8 +254,8 @@ look at the [Command Tutorial][cmd]. It's pretty simple.
There are also several [Bubble Tea examples][examples] available and, of course,
there are [Go Docs][docs].
-[cmd]: http://github.com/charmbracelet/bubbletea/tree/master/tutorials/commands/
-[examples]: http://github.com/charmbracelet/bubbletea/tree/master/examples
+[cmd]: https://github.com/charmbracelet/bubbletea/tree/master/tutorials/commands/
+[examples]: https://github.com/charmbracelet/bubbletea/tree/master/examples
[docs]: https://pkg.go.dev/github.com/charmbracelet/bubbletea?tab=doc
## Debugging
@@ -266,15 +267,21 @@ delve in headless mode and then connect to it:
```bash
# Start the debugger
-$ dlv debug --headless .
-API server listening at: 127.0.0.1:34241
+$ dlv debug --headless --api-version=2 --listen=127.0.0.1:43000 .
+API server listening at: 127.0.0.1:43000
# Connect to it from another terminal
-$ dlv connect 127.0.0.1:34241
+$ dlv connect 127.0.0.1:43000
```
-Note that the default port used will vary on your system and per run, so
-actually watch out what address the first `dlv` run tells you to connect to.
+If you do not explicitly supply the `--listen` flag, the port used will vary
+per run, so passing this in makes the debugger easier to use from a script
+or your IDE of choice.
+
+Additionally, we pass in `--api-version=2` because delve defaults to version 1
+for backwards compatibility reasons. However, delve recommends using version 2
+for all new development and some clients may no longer work with version 1.
+For more information, see the [Delve documentation](https://github.com/go-delve/delve/tree/master/Documentation/api).
### Logging Stuff
@@ -298,95 +305,68 @@ your program in another window.
## Libraries we use with Bubble Tea
-* [Bubbles][bubbles]: Common Bubble Tea components such as text inputs, viewports, spinners and so on
-* [Lip Gloss][lipgloss]: Style, format and layout tools for terminal applications
-* [Harmonica][harmonica]: A spring animation library for smooth, natural motion
-* [BubbleZone][bubblezone]: Easy mouse event tracking for Bubble Tea components
-* [Termenv][termenv]: Advanced ANSI styling for terminal applications
-* [Reflow][reflow]: Advanced ANSI-aware methods for working with text
+- [Bubbles][bubbles]: Common Bubble Tea components such as text inputs, viewports, spinners and so on
+- [Lip Gloss][lipgloss]: Style, format and layout tools for terminal applications
+- [Harmonica][harmonica]: A spring animation library for smooth, natural motion
+- [BubbleZone][bubblezone]: Easy mouse event tracking for Bubble Tea components
+- [ntcharts][ntcharts]: A terminal charting library built for Bubble Tea and [Lip Gloss][lipgloss]
+- [Termenv][termenv]: Advanced ANSI styling for terminal applications
+- [Reflow][reflow]: Advanced ANSI-aware methods for working with text
[bubbles]: https://github.com/charmbracelet/bubbles
[lipgloss]: https://github.com/charmbracelet/lipgloss
[harmonica]: https://github.com/charmbracelet/harmonica
[bubblezone]: https://github.com/lrstanley/bubblezone
+[ntcharts]: https://github.com/NimbleMarkets/ntcharts
[termenv]: https://github.com/muesli/termenv
[reflow]: https://github.com/muesli/reflow
## Bubble Tea in the Wild
-For some Bubble Tea programs in production, see:
-
-* [AT CLI](https://github.com/daskycodes/at_cli): execute AT Commands via serial port connections
-* [Aztify](https://github.com/Azure/aztfy): bring Microsoft Azure resources under Terraform
-* [brows](https://github.com/rubysolo/brows): a GitHub release browser
-* [Canard](https://github.com/mrusme/canard): an RSS client
-* [charm](https://github.com/charmbracelet/charm): the official Charm user account manager
-* [chezmoi](https://github.com/twpayne/chezmoi): securely manage your dotfiles across multiple machines
-* [chtop](https://github.com/chhetripradeep/chtop): monitor your ClickHouse node without leaving terminal
-* [circumflex](https://github.com/bensadeh/circumflex): read Hacker News in the terminal
-* [clidle](https://github.com/ajeetdsouza/clidle): a Wordle clone
-* [cLive](https://github.com/koki-develop/clive): automate terminal operations and view them live in a browser
-* [container-canary](https://github.com/NVIDIA/container-canary): a container validator
-* [countdown](https://github.com/aldernero/countdown): a multi-event countdown timer
-* [dns53](https://github.com/purpleclay/dns53): dynamic DNS with Amazon Route53. Expose your EC2 quickly, securely and privately
-* [eks-node-viewer](https://github.com/awslabs/eks-node-viewer): a tool for visualizing dynamic node usage within an eks cluster
-* [enola](https://github.com/sherlock-project/enola): hunt down social media accounts by username across social networks
-* [flapioca](https://github.com/kbrgl/flapioca): Flappy Bird on the CLI!
-* [fm](https://github.com/knipferrc/fm): a terminal-based file manager
-* [fork-cleaner](https://github.com/caarlos0/fork-cleaner): clean up old and inactive forks in your GitHub account
-* [fztea](https://github.com/jon4hz/fztea): a Flipper Zero TUI
-* [gambit](https://github.com/maaslalani/gambit): chess in the terminal
-* [gembro](https://git.sr.ht/~rafael/gembro): a mouse-driven Gemini browser
-* [gh-b](https://github.com/joaom00/gh-b): a GitHub CLI extension for managing branches
-* [gh-dash](https://www.github.com/dlvhdr/gh-dash): a GitHub CLI extension for PRs and issues
-* [gitflow-toolkit](https://github.com/mritd/gitflow-toolkit): a GitFlow submission tool
-* [Glow](https://github.com/charmbracelet/glow): a markdown reader, browser, and online markdown stash
-* [go-sweep](https://github.com/maxpaulus43/go-sweep): Minesweeper in the terminal
-* [gocovsh](https://github.com/orlangure/gocovsh): explore Go coverage reports from the CLI
-* [got](https://github.com/fedeztk/got): a simple translator and text-to-speech app build on top of simplytranslate's APIs
-* [hiSHtory](https://github.com/ddworken/hishtory): your shell history in context, synced, and queryable
-* [httpit](https://github.com/gonetx/httpit): a rapid http(s) benchmark tool
-* [IDNT](https://github.com/r-darwish/idnt): a batch software uninstaller
-* [kboard](https://github.com/CamiloGarciaLaRotta/kboard): a typing game
-* [mandelbrot-cli](https://github.com/MicheleFiladelfia/mandelbrot-cli): a multiplatform terminal mandelbrot set explorer
-* [mc](https://github.com/minio/mc): the official [MinIO](https://min.io) client
-* [mergestat](https://github.com/mergestat/mergestat): run SQL queries on git repositories
-* [Neon Modem Overdrive](https://github.com/mrusme/neonmodem): a BBS-style TUI client for Discourse, Lemmy, Lobste.rs and Hacker News
-* [Noted](https://github.com/torbratsberg/noted): a note viewer and manager
-* [nom](https://github.com/guyfedwards/nom): RSS reader and manager
-* [pathos](https://github.com/chip/pathos): a PATH env variable editor
-* [portal](https://github.com/ZinoKader/portal): secure transfers between computers
-* [redis-viewer](https://github.com/SaltFishPr/redis-viewer): a Redis databases browser
-* [scrabbler](https://github.com/wI2L/scrabbler): Automatic draw TUI for your duplicate Scrabble games
-* [sku](https://github.com/fedeztk/sku): Sudoku on the CLI
-* [Slides](https://github.com/maaslalani/slides): a markdown-based presentation tool
-* [SlurmCommander](https://github.com/CLIP-HPC/SlurmCommander): a Slurm workload manager TUI
-* [Soft Serve](https://github.com/charmbracelet/soft-serve): a command-line-first Git server that runs a TUI over SSH
-* [solitaire-tui](https://github.com/brianstrauch/solitaire-tui): Klondike Solitaire for the terminal
-* [StormForge Optimize Controller](https://github.com/thestormforge/optimize-controller): a tool for experimenting with application configurations in Kubernetes
-* [Storydb](https://github.com/grrlopes/storydb): a bash/zsh ctrl+r improved command history finder.
-* [STTG](https://github.com/wille1101/sttg): a teletext client for SVT, Sweden’s national public television station
-* [sttr](https://github.com/abhimanyu003/sttr): a general-purpose text transformer
-* [tasktimer](https://github.com/caarlos0/tasktimer): a dead-simple task timer
-* [termdbms](https://github.com/mathaou/termdbms): a keyboard and mouse driven database browser
-* [ticker](https://github.com/achannarasappa/ticker): a terminal stock viewer and stock position tracker
-* [tran](https://github.com/abdfnx/tran): securely transfer stuff between computers (based on [portal](https://github.com/ZinoKader/portal))
-* [Typer](https://github.com/maaslalani/typer): a typing test
-* [typioca](https://github.com/bloznelis/typioca): Cozy typing speed tester in terminal
-* [tz](https://github.com/oz/tz): an aid for scheduling across multiple time zones
-* [ugm](https://github.com/ariasmn/ugm): a unix user and group browser
-* [walk](https://github.com/antonmedv/walk): a terminal navigator
-* [wander](https://github.com/robinovitch61/wander): a HashiCorp Nomad terminal client
-* [WG Commander](https://github.com/AndrianBdn/wg-cmd): a TUI for a simple WireGuard VPN setup
-* [wishlist](https://github.com/charmbracelet/wishlist): an SSH directory
+There are over 8k applications built with Bubble Tea! Here are a handful of ’em.
+
+### Staff favourites
+
+- [chezmoi](https://github.com/twpayne/chezmoi): securely manage your dotfiles across multiple machines
+- [circumflex](https://github.com/bensadeh/circumflex): read Hacker News in the terminal
+- [gh-dash](https://www.github.com/dlvhdr/gh-dash): a GitHub CLI extension for PRs and issues
+- [Tetrigo](https://github.com/Broderick-Westrope/tetrigo): Tetris in the terminal
+
+### In Industry
+
+- Microsoft Azure – [Aztify](https://github.com/Azure/aztfy): bring Microsoft Azure resources under Terraform
+- Daytona – [Daytona](https://github.com/daytonaio/daytona): open source dev environment manager
+- Truffle Security Co. – [Trufflehog](https://github.com/trufflesecurity/trufflehog): find leaked credentials
+- NVIDIA – [container-canary](https://github.com/NVIDIA/container-canary) from NVIDIA: a container validator
+- AWS – [eks-node-viewer](https://github.com/awslabs/eks-node-viewer) from AWS: a tool for visualizing dynamic node usage within an EKS cluster
+- MinIO – [mc](https://github.com/minio/mc) from Min.io: the official [MinIO](https://min.io) client
+
+### Charm stuff
+
+- [Glow](https://github.com/charmbracelet/glow): a markdown reader, browser, and online markdown stash
+- [Huh?](https://github.com/charmbracelet/huh): an interactive prompt and form toolkit
+- [Mods](https://github.com/charmbracelet/mods): AI on the CLI, built for pipelines
+- [Wishlist](https://github.com/charmbracelet/wishlist): an SSH directory (and bastion!)
+
+### There’s so much more where that came from
+
+For more applications built with Bubble Tea see [Charm & Friends][community].
+Is there something cool you made with Bubble Tea you want to share? [PRs][community] are
+welcome!
+
+## Contributing
+
+See [contributing][contribute].
+
+[contribute]: https://github.com/charmbracelet/bubbletea/contribute
## Feedback
-We'd love to hear your thoughts on this project. Feel free to drop us a note!
+We’d love to hear your thoughts on this project. Feel free to drop us a note!
-* [Twitter](https://twitter.com/charmcli)
-* [The Fediverse](https://mastodon.social/@charmcli)
-* [Discord](https://charm.sh/chat)
+- [Twitter](https://twitter.com/charmcli)
+- [The Fediverse](https://mastodon.social/@charmcli)
+- [Discord](https://charm.sh/chat)
## Acknowledgments
@@ -398,12 +378,13 @@ of days past.
[elm]: https://guide.elm-lang.org/architecture/
[gotea]: https://github.com/tj/go-tea
[zb]: https://de.wikipedia.org/wiki/Zeichenorientierte_Benutzerschnittstelle
+[community]: https://github.com/charm-and-friends/charm-in-the-wild
## License
[MIT](https://github.com/charmbracelet/bubbletea/raw/master/LICENSE)
-***
+---
Part of [Charm](https://charm.sh).
diff --git a/vendor/github.com/charmbracelet/bubbletea/commands.go b/vendor/github.com/charmbracelet/bubbletea/commands.go
index 7b139b88..bfa3b704 100644
--- a/vendor/github.com/charmbracelet/bubbletea/commands.go
+++ b/vendor/github.com/charmbracelet/bubbletea/commands.go
@@ -20,11 +20,15 @@ func Batch(cmds ...Cmd) Cmd {
}
validCmds = append(validCmds, c)
}
- if len(validCmds) == 0 {
+ switch len(validCmds) {
+ case 0:
return nil
- }
- return func() Msg {
- return BatchMsg(validCmds)
+ case 1:
+ return validCmds[0]
+ default:
+ return func() Msg {
+ return BatchMsg(validCmds)
+ }
}
}
@@ -90,11 +94,16 @@ type sequenceMsg []Cmd
//
// Every is analogous to Tick in the Elm Architecture.
func Every(duration time.Duration, fn func(time.Time) Msg) Cmd {
+ n := time.Now()
+ d := n.Truncate(duration).Add(duration).Sub(n)
+ t := time.NewTimer(d)
return func() Msg {
- n := time.Now()
- d := n.Truncate(duration).Add(duration).Sub(n)
- t := time.NewTimer(d)
- return fn(<-t.C)
+ ts := <-t.C
+ t.Stop()
+ for len(t.C) > 0 {
+ <-t.C
+ }
+ return fn(ts)
}
}
@@ -137,9 +146,14 @@ func Every(duration time.Duration, fn func(time.Time) Msg) Cmd {
// return m, nil
// }
func Tick(d time.Duration, fn func(time.Time) Msg) Cmd {
+ t := time.NewTimer(d)
return func() Msg {
- t := time.NewTimer(d)
- return fn(<-t.C)
+ ts := <-t.C
+ t.Stop()
+ for len(t.C) > 0 {
+ <-t.C
+ }
+ return fn(ts)
}
}
@@ -187,3 +201,16 @@ func SetWindowTitle(title string) Cmd {
return setWindowTitleMsg(title)
}
}
+
+type windowSizeMsg struct{}
+
+// WindowSize is a command that queries the terminal for its current size. It
+// delivers the results to Update via a [WindowSizeMsg]. Keep in mind that
+// WindowSizeMsgs will automatically be delivered to Update when the [Program]
+// starts and when the window dimensions change so in many cases you will not
+// need to explicitly invoke this command.
+func WindowSize() Cmd {
+ return func() Msg {
+ return windowSizeMsg{}
+ }
+}
diff --git a/vendor/github.com/charmbracelet/bubbletea/exec.go b/vendor/github.com/charmbracelet/bubbletea/exec.go
index fb6d91ed..7a14d2a7 100644
--- a/vendor/github.com/charmbracelet/bubbletea/exec.go
+++ b/vendor/github.com/charmbracelet/bubbletea/exec.go
@@ -109,7 +109,7 @@ func (p *Program) exec(c ExecCommand, fn ExecCallback) {
}
c.SetStdin(p.input)
- c.SetStdout(p.output.TTY())
+ c.SetStdout(p.output)
c.SetStderr(os.Stderr)
// Execute system command.
diff --git a/vendor/github.com/charmbracelet/bubbletea/focus.go b/vendor/github.com/charmbracelet/bubbletea/focus.go
new file mode 100644
index 00000000..4d34bea6
--- /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/inputreader_other.go b/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go
new file mode 100644
index 00000000..8e63a87d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/bubbletea/inputreader_other.go
@@ -0,0 +1,14 @@
+//go:build !windows
+// +build !windows
+
+package tea
+
+import (
+ "io"
+
+ "github.com/muesli/cancelreader"
+)
+
+func newInputReader(r io.Reader) (cancelreader.CancelReader, error) {
+ return cancelreader.NewReader(r)
+}
diff --git a/vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go b/vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go
new file mode 100644
index 00000000..449df479
--- /dev/null
+++ b/vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go
@@ -0,0 +1,107 @@
+//go:build windows
+// +build windows
+
+package tea
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "sync"
+
+ "github.com/charmbracelet/x/term"
+ "github.com/erikgeiser/coninput"
+ "github.com/muesli/cancelreader"
+ "golang.org/x/sys/windows"
+)
+
+type conInputReader struct {
+ cancelMixin
+
+ conin windows.Handle
+
+ originalMode uint32
+}
+
+var _ cancelreader.CancelReader = &conInputReader{}
+
+func newInputReader(r io.Reader) (cancelreader.CancelReader, error) {
+ fallback := func(io.Reader) (cancelreader.CancelReader, error) {
+ return cancelreader.NewReader(r)
+ }
+ if f, ok := r.(term.File); !ok || f.Fd() != os.Stdin.Fd() {
+ 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)
+ }
+
+ return &conInputReader{
+ conin: conin,
+ originalMode: originalMode,
+ }, nil
+}
+
+// Cancel implements cancelreader.CancelReader.
+func (r *conInputReader) Cancel() bool {
+ r.setCanceled()
+
+ return windows.CancelIo(r.conin) == nil
+}
+
+// Close implements cancelreader.CancelReader.
+func (r *conInputReader) Close() error {
+ 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 (*conInputReader) Read(_ []byte) (n int, err error) {
+ return 0, nil
+}
+
+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
+}
+
+// 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
+}
diff --git a/vendor/github.com/charmbracelet/bubbletea/key.go b/vendor/github.com/charmbracelet/bubbletea/key.go
index f851490a..ab4792ac 100644
--- a/vendor/github.com/charmbracelet/bubbletea/key.go
+++ b/vendor/github.com/charmbracelet/bubbletea/key.go
@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"regexp"
+ "strings"
"unicode/utf8"
)
@@ -54,6 +55,7 @@ type Key struct {
Type KeyType
Runes []rune
Alt bool
+ Paste bool
}
// String returns a friendly string representation for a key. It's safe (and
@@ -63,15 +65,28 @@ type Key struct {
// fmt.Println(k)
// // Output: enter
func (k Key) String() (str string) {
+ var buf strings.Builder
if k.Alt {
- str += "alt+"
+ buf.WriteString("alt+")
}
if k.Type == KeyRunes {
- str += string(k.Runes)
- return str
+ if k.Paste {
+ // Note: bubbles/keys bindings currently do string compares to
+ // recognize shortcuts. Since pasted text should never activate
+ // shortcuts, we need to ensure that the binding code doesn't
+ // match Key events that result from pastes. We achieve this
+ // here by enclosing pastes in '[...]' so that the string
+ // comparison in Matches() fails in that case.
+ buf.WriteByte('[')
+ }
+ buf.WriteString(string(k.Runes))
+ if k.Paste {
+ buf.WriteByte(']')
+ }
+ return buf.String()
} else if s, ok := keyNames[k.Type]; ok {
- str += s
- return str
+ buf.WriteString(s)
+ return buf.String()
}
return ""
}
@@ -538,9 +553,9 @@ func (u unknownCSISequenceMsg) String() string {
var spaceRunes = []rune{' '}
-// readInputs reads keypress and mouse inputs from a TTY and produces messages
+// readAnsiInputs reads keypress and mouse inputs from a TTY and produces messages
// containing information about the key or mouse events accordingly.
-func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
+func readAnsiInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
var buf [256]byte
var leftOverFromPrevIteration []byte
@@ -566,7 +581,7 @@ loop:
canHaveMoreData := numBytes == len(buf)
var i, w int
- for i, w = 0, 07; i < len(b); i += w {
+ for i, w = 0, 0; i < len(b); i += w {
var msg Msg
w, msg = detectOneMsg(b[i:], canHaveMoreData)
if w == 0 {
@@ -607,19 +622,33 @@ func detectOneMsg(b []byte, canHaveMoreData bool) (w int, msg Msg) {
case '<':
if matchIndices := mouseSGRRegex.FindSubmatchIndex(b[3:]); matchIndices != nil {
// SGR mouse events length is the length of the match plus the length of the escape sequence
- mouseEventSGRLen := matchIndices[1] + 3
+ mouseEventSGRLen := matchIndices[1] + 3 //nolint:gomnd
return mouseEventSGRLen, MouseMsg(parseSGRMouseEvent(b))
}
}
}
+ // 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)
+ if foundbp {
+ return w, msg
+ }
+
// Detect escape sequence and control characters other than NUL,
// possibly with an escape character in front to mark the Alt
// modifier.
var foundSeq bool
foundSeq, w, msg = detectSequence(b)
if foundSeq {
- return
+ return w, msg
}
// No non-NUL control character or escape sequence.
diff --git a/vendor/github.com/charmbracelet/bubbletea/key_other.go b/vendor/github.com/charmbracelet/bubbletea/key_other.go
new file mode 100644
index 00000000..b8c46082
--- /dev/null
+++ b/vendor/github.com/charmbracelet/bubbletea/key_other.go
@@ -0,0 +1,13 @@
+//go:build !windows
+// +build !windows
+
+package tea
+
+import (
+ "context"
+ "io"
+)
+
+func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
+ return readAnsiInputs(ctx, msgs, input)
+}
diff --git a/vendor/github.com/charmbracelet/bubbletea/key_sequences.go b/vendor/github.com/charmbracelet/bubbletea/key_sequences.go
index cc200f8d..15483ef5 100644
--- a/vendor/github.com/charmbracelet/bubbletea/key_sequences.go
+++ b/vendor/github.com/charmbracelet/bubbletea/key_sequences.go
@@ -1,6 +1,10 @@
package tea
-import "sort"
+import (
+ "bytes"
+ "sort"
+ "unicode/utf8"
+)
// extSequences is used by the map-based algorithm below. It contains
// the sequences plus their alternatives with an escape character
@@ -69,3 +73,59 @@ func detectSequence(input []byte) (hasSeq bool, width int, msg Msg) {
return false, 0, nil
}
+
+// detectBracketedPaste detects an input pasted while bracketed
+// paste mode was enabled.
+//
+// Note: this function is a no-op if bracketed paste was not enabled
+// on the terminal, since in that case we'd never see this
+// particular escape sequence.
+func detectBracketedPaste(input []byte) (hasBp bool, width int, msg Msg) {
+ // Detect the start sequence.
+ const bpStart = "\x1b[200~"
+ if len(input) < len(bpStart) || string(input[:len(bpStart)]) != bpStart {
+ return false, 0, nil
+ }
+
+ // Skip over the start sequence.
+ input = input[len(bpStart):]
+
+ // If we saw the start sequence, then we must have an end sequence
+ // as well. Find it.
+ const bpEnd = "\x1b[201~"
+ idx := bytes.Index(input, []byte(bpEnd))
+ inputLen := len(bpStart) + idx + len(bpEnd)
+ if idx == -1 {
+ // We have encountered the end of the input buffer without seeing
+ // the marker for the end of the bracketed paste.
+ // Tell the outer loop we have done a short read and we want more.
+ return true, 0, nil
+ }
+
+ // The paste is everything in-between.
+ paste := input[:idx]
+
+ // All there is in-between is runes, not to be interpreted further.
+ k := Key{Type: KeyRunes, Paste: true}
+ for len(paste) > 0 {
+ r, w := utf8.DecodeRune(paste)
+ if r != utf8.RuneError {
+ k.Runes = append(k.Runes, r)
+ }
+ paste = paste[w:]
+ }
+
+ 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/key_windows.go b/vendor/github.com/charmbracelet/bubbletea/key_windows.go
new file mode 100644
index 00000000..b693efd6
--- /dev/null
+++ b/vendor/github.com/charmbracelet/bubbletea/key_windows.go
@@ -0,0 +1,351 @@
+//go:build windows
+// +build windows
+
+package tea
+
+import (
+ "context"
+ "fmt"
+ "io"
+
+ "github.com/erikgeiser/coninput"
+ localereader "github.com/mattn/go-localereader"
+ "golang.org/x/sys/windows"
+)
+
+func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
+ if coninReader, ok := input.(*conInputReader); ok {
+ return readConInputs(ctx, msgs, coninReader.conin)
+ }
+
+ return readAnsiInputs(ctx, msgs, localereader.NewReader(input))
+}
+
+func readConInputs(ctx context.Context, msgsch chan<- Msg, con windows.Handle) error {
+ var ps coninput.ButtonState // keep track of previous mouse state
+ var ws coninput.WindowBufferSizeEventRecord // keep track of the last window size event
+ for {
+ events, err := coninput.ReadNConsoleInputs(con, 16)
+ if err != nil {
+ return fmt.Errorf("read coninput events: %w", err)
+ }
+
+ for _, event := range events {
+ var msgs []Msg
+ switch e := event.Unwrap().(type) {
+ case coninput.KeyEventRecord:
+ if !e.KeyDown || e.VirtualKeyCode == coninput.VK_SHIFT {
+ continue
+ }
+
+ for i := 0; i < int(e.RepeatCount); i++ {
+ eventKeyType := keyType(e)
+ var runes []rune
+
+ // Add the character only if the key type is an actual character and not a control sequence.
+ // This mimics the behavior in readAnsiInputs where the character is also removed.
+ // We don't need to handle KeySpace here. See the comment in keyType().
+ if eventKeyType == KeyRunes {
+ runes = []rune{e.Char}
+ }
+
+ msgs = append(msgs, KeyMsg{
+ Type: eventKeyType,
+ Runes: runes,
+ Alt: e.ControlKeyState.Contains(coninput.LEFT_ALT_PRESSED | coninput.RIGHT_ALT_PRESSED),
+ })
+ }
+ case coninput.WindowBufferSizeEventRecord:
+ if e != ws {
+ ws = e
+ msgs = append(msgs, WindowSizeMsg{
+ Width: int(e.Size.X),
+ Height: int(e.Size.Y),
+ })
+ }
+ case coninput.MouseEventRecord:
+ event := mouseEvent(ps, e)
+ if event.Type != MouseUnknown {
+ msgs = append(msgs, event)
+ }
+ ps = e.ButtonState
+ case coninput.FocusEventRecord, coninput.MenuEventRecord:
+ // ignore
+ default: // unknown event
+ continue
+ }
+
+ // Send all messages to the channel
+ for _, msg := range msgs {
+ select {
+ case msgsch <- msg:
+ case <-ctx.Done():
+ err := ctx.Err()
+ if err != nil {
+ return fmt.Errorf("coninput context error: %w", err)
+ }
+ return err
+ }
+ }
+ }
+ }
+}
+
+func mouseEventButton(p, s coninput.ButtonState) (button MouseButton, action MouseAction) {
+ btn := p ^ s
+ action = MouseActionPress
+ if btn&s == 0 {
+ action = MouseActionRelease
+ }
+
+ if btn == 0 {
+ switch {
+ case s&coninput.FROM_LEFT_1ST_BUTTON_PRESSED > 0:
+ button = MouseButtonLeft
+ case s&coninput.FROM_LEFT_2ND_BUTTON_PRESSED > 0:
+ button = MouseButtonMiddle
+ case s&coninput.RIGHTMOST_BUTTON_PRESSED > 0:
+ button = MouseButtonRight
+ case s&coninput.FROM_LEFT_3RD_BUTTON_PRESSED > 0:
+ button = MouseButtonBackward
+ case s&coninput.FROM_LEFT_4TH_BUTTON_PRESSED > 0:
+ button = MouseButtonForward
+ }
+ return
+ }
+
+ switch {
+ case btn == coninput.FROM_LEFT_1ST_BUTTON_PRESSED: // left button
+ button = MouseButtonLeft
+ case btn == coninput.RIGHTMOST_BUTTON_PRESSED: // right button
+ button = MouseButtonRight
+ case btn == coninput.FROM_LEFT_2ND_BUTTON_PRESSED: // middle button
+ button = MouseButtonMiddle
+ case btn == coninput.FROM_LEFT_3RD_BUTTON_PRESSED: // unknown (possibly mouse backward)
+ button = MouseButtonBackward
+ case btn == coninput.FROM_LEFT_4TH_BUTTON_PRESSED: // unknown (possibly mouse forward)
+ button = MouseButtonForward
+ }
+
+ return button, action
+}
+
+func mouseEvent(p coninput.ButtonState, e coninput.MouseEventRecord) MouseMsg {
+ ev := MouseMsg{
+ X: int(e.MousePositon.X),
+ Y: int(e.MousePositon.Y),
+ Alt: e.ControlKeyState.Contains(coninput.LEFT_ALT_PRESSED | coninput.RIGHT_ALT_PRESSED),
+ Ctrl: e.ControlKeyState.Contains(coninput.LEFT_CTRL_PRESSED | coninput.RIGHT_CTRL_PRESSED),
+ Shift: e.ControlKeyState.Contains(coninput.SHIFT_PRESSED),
+ }
+ switch e.EventFlags {
+ case coninput.CLICK, coninput.DOUBLE_CLICK:
+ ev.Button, ev.Action = mouseEventButton(p, e.ButtonState)
+ if ev.Action == MouseActionRelease {
+ ev.Type = MouseRelease
+ }
+ switch ev.Button {
+ case MouseButtonLeft:
+ ev.Type = MouseLeft
+ case MouseButtonMiddle:
+ ev.Type = MouseMiddle
+ case MouseButtonRight:
+ ev.Type = MouseRight
+ case MouseButtonBackward:
+ ev.Type = MouseBackward
+ case MouseButtonForward:
+ ev.Type = MouseForward
+ }
+ case coninput.MOUSE_WHEELED:
+ if e.WheelDirection > 0 {
+ ev.Button = MouseButtonWheelUp
+ ev.Type = MouseWheelUp
+ } else {
+ ev.Button = MouseButtonWheelDown
+ ev.Type = MouseWheelDown
+ }
+ case coninput.MOUSE_HWHEELED:
+ if e.WheelDirection > 0 {
+ ev.Button = MouseButtonWheelRight
+ ev.Type = MouseWheelRight
+ } else {
+ ev.Button = MouseButtonWheelLeft
+ ev.Type = MouseWheelLeft
+ }
+ case coninput.MOUSE_MOVED:
+ ev.Button, _ = mouseEventButton(p, e.ButtonState)
+ ev.Action = MouseActionMotion
+ ev.Type = MouseMotion
+ }
+
+ return ev
+}
+
+func keyType(e coninput.KeyEventRecord) KeyType {
+ code := e.VirtualKeyCode
+
+ shiftPressed := e.ControlKeyState.Contains(coninput.SHIFT_PRESSED)
+ ctrlPressed := e.ControlKeyState.Contains(coninput.LEFT_CTRL_PRESSED | coninput.RIGHT_CTRL_PRESSED)
+
+ switch code {
+ case coninput.VK_RETURN:
+ return KeyEnter
+ case coninput.VK_BACK:
+ return KeyBackspace
+ case coninput.VK_TAB:
+ if shiftPressed {
+ return KeyShiftTab
+ }
+ return KeyTab
+ case coninput.VK_SPACE:
+ return KeyRunes // this could be KeySpace but on unix space also produces KeyRunes
+ case coninput.VK_ESCAPE:
+ return KeyEscape
+ case coninput.VK_UP:
+ switch {
+ case shiftPressed && ctrlPressed:
+ return KeyCtrlShiftUp
+ case shiftPressed:
+ return KeyShiftUp
+ case ctrlPressed:
+ return KeyCtrlUp
+ default:
+ return KeyUp
+ }
+ case coninput.VK_DOWN:
+ switch {
+ case shiftPressed && ctrlPressed:
+ return KeyCtrlShiftDown
+ case shiftPressed:
+ return KeyShiftDown
+ case ctrlPressed:
+ return KeyCtrlDown
+ default:
+ return KeyDown
+ }
+ case coninput.VK_RIGHT:
+ switch {
+ case shiftPressed && ctrlPressed:
+ return KeyCtrlShiftRight
+ case shiftPressed:
+ return KeyShiftRight
+ case ctrlPressed:
+ return KeyCtrlRight
+ default:
+ return KeyRight
+ }
+ case coninput.VK_LEFT:
+ switch {
+ case shiftPressed && ctrlPressed:
+ return KeyCtrlShiftLeft
+ case shiftPressed:
+ return KeyShiftLeft
+ case ctrlPressed:
+ return KeyCtrlLeft
+ default:
+ return KeyLeft
+ }
+ case coninput.VK_HOME:
+ switch {
+ case shiftPressed && ctrlPressed:
+ return KeyCtrlShiftHome
+ case shiftPressed:
+ return KeyShiftHome
+ case ctrlPressed:
+ return KeyCtrlHome
+ default:
+ return KeyHome
+ }
+ case coninput.VK_END:
+ switch {
+ case shiftPressed && ctrlPressed:
+ return KeyCtrlShiftEnd
+ case shiftPressed:
+ return KeyShiftEnd
+ case ctrlPressed:
+ return KeyCtrlEnd
+ default:
+ return KeyEnd
+ }
+ case coninput.VK_PRIOR:
+ return KeyPgUp
+ case coninput.VK_NEXT:
+ return KeyPgDown
+ case coninput.VK_DELETE:
+ return KeyDelete
+ default:
+ if e.ControlKeyState&(coninput.LEFT_CTRL_PRESSED|coninput.RIGHT_CTRL_PRESSED) == 0 {
+ return KeyRunes
+ }
+
+ switch e.Char {
+ case '@':
+ return KeyCtrlAt
+ case '\x01':
+ return KeyCtrlA
+ case '\x02':
+ return KeyCtrlB
+ case '\x03':
+ return KeyCtrlC
+ case '\x04':
+ return KeyCtrlD
+ case '\x05':
+ return KeyCtrlE
+ case '\x06':
+ return KeyCtrlF
+ case '\a':
+ return KeyCtrlG
+ case '\b':
+ return KeyCtrlH
+ case '\t':
+ return KeyCtrlI
+ case '\n':
+ return KeyCtrlJ
+ case '\v':
+ return KeyCtrlK
+ case '\f':
+ return KeyCtrlL
+ case '\r':
+ return KeyCtrlM
+ case '\x0e':
+ return KeyCtrlN
+ case '\x0f':
+ return KeyCtrlO
+ case '\x10':
+ return KeyCtrlP
+ case '\x11':
+ return KeyCtrlQ
+ case '\x12':
+ return KeyCtrlR
+ case '\x13':
+ return KeyCtrlS
+ case '\x14':
+ return KeyCtrlT
+ case '\x15':
+ return KeyCtrlU
+ case '\x16':
+ return KeyCtrlV
+ case '\x17':
+ return KeyCtrlW
+ case '\x18':
+ return KeyCtrlX
+ case '\x19':
+ return KeyCtrlY
+ case '\x1a':
+ return KeyCtrlZ
+ case '\x1b':
+ return KeyCtrlCloseBracket
+ case '\x1c':
+ return KeyCtrlBackslash
+ case '\x1f':
+ return KeyCtrlUnderscore
+ }
+
+ switch code {
+ case coninput.VK_OEM_4:
+ return KeyCtrlOpenBracket
+ }
+
+ return KeyRunes
+ }
+}
diff --git a/vendor/github.com/charmbracelet/bubbletea/mouse.go b/vendor/github.com/charmbracelet/bubbletea/mouse.go
index add8d029..6ec51cc0 100644
--- a/vendor/github.com/charmbracelet/bubbletea/mouse.go
+++ b/vendor/github.com/charmbracelet/bubbletea/mouse.go
@@ -45,7 +45,7 @@ func (m MouseEvent) String() (s string) {
s += "shift+"
}
- if m.Button == MouseButtonNone {
+ if m.Button == MouseButtonNone { //nolint:nestif
if m.Action == MouseActionMotion || m.Action == MouseActionRelease {
s += mouseActions[m.Action]
} else {
@@ -172,7 +172,7 @@ const (
func parseSGRMouseEvent(buf []byte) MouseEvent {
str := string(buf[3:])
matches := mouseSGRRegex.FindStringSubmatch(str)
- if len(matches) != 5 {
+ if len(matches) != 5 { //nolint:gomnd
// Unreachable, we already checked the regex in `detectOneMsg`.
panic("invalid mouse event")
}
@@ -288,7 +288,7 @@ func parseMouseButton(b int, isSGR bool) MouseEvent {
m.Type = MouseForward
case m.Action == MouseActionMotion:
m.Type = MouseMotion
- switch m.Button {
+ switch m.Button { //nolint:exhaustive
case MouseButtonLeft:
m.Type = MouseLeft
case MouseButtonMiddle:
diff --git a/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go b/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go
index 1b1d4409..0bc4a172 100644
--- a/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go
+++ b/vendor/github.com/charmbracelet/bubbletea/nil_renderer.go
@@ -2,20 +2,27 @@ package tea
type nilRenderer struct{}
-func (n nilRenderer) start() {}
-func (n nilRenderer) stop() {}
-func (n nilRenderer) kill() {}
-func (n nilRenderer) write(_ string) {}
-func (n nilRenderer) repaint() {}
-func (n nilRenderer) clearScreen() {}
-func (n nilRenderer) altScreen() bool { return false }
-func (n nilRenderer) enterAltScreen() {}
-func (n nilRenderer) exitAltScreen() {}
-func (n nilRenderer) showCursor() {}
-func (n nilRenderer) hideCursor() {}
-func (n nilRenderer) enableMouseCellMotion() {}
-func (n nilRenderer) disableMouseCellMotion() {}
-func (n nilRenderer) enableMouseAllMotion() {}
-func (n nilRenderer) disableMouseAllMotion() {}
-func (n nilRenderer) enableMouseSGRMode() {}
-func (n nilRenderer) disableMouseSGRMode() {}
+func (n nilRenderer) start() {}
+func (n nilRenderer) stop() {}
+func (n nilRenderer) kill() {}
+func (n nilRenderer) write(_ string) {}
+func (n nilRenderer) repaint() {}
+func (n nilRenderer) clearScreen() {}
+func (n nilRenderer) altScreen() bool { return false }
+func (n nilRenderer) enterAltScreen() {}
+func (n nilRenderer) exitAltScreen() {}
+func (n nilRenderer) showCursor() {}
+func (n nilRenderer) hideCursor() {}
+func (n nilRenderer) enableMouseCellMotion() {}
+func (n nilRenderer) disableMouseCellMotion() {}
+func (n nilRenderer) enableMouseAllMotion() {}
+func (n nilRenderer) disableMouseAllMotion() {}
+func (n nilRenderer) enableBracketedPaste() {}
+func (n nilRenderer) disableBracketedPaste() {}
+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 71e94493..12e92e4e 100644
--- a/vendor/github.com/charmbracelet/bubbletea/options.go
+++ b/vendor/github.com/charmbracelet/bubbletea/options.go
@@ -4,8 +4,6 @@ import (
"context"
"io"
"sync/atomic"
-
- "github.com/muesli/termenv"
)
// ProgramOption is used to set options when initializing a Program. Program can
@@ -29,11 +27,7 @@ func WithContext(ctx context.Context) ProgramOption {
// won't need to use this.
func WithOutput(output io.Writer) ProgramOption {
return func(p *Program) {
- if o, ok := output.(*termenv.Output); ok {
- p.output = o
- } else {
- p.output = termenv.NewOutput(output, termenv.WithColorCache(true))
- }
+ p.output = output
}
}
@@ -55,6 +49,23 @@ func WithInputTTY() ProgramOption {
}
}
+// WithEnvironment sets the environment variables that the program will use.
+// This useful when the program is running in a remote session (e.g. SSH) and
+// you want to pass the environment variables from the remote session to the
+// program.
+//
+// Example:
+//
+// var sess ssh.Session // ssh.Session is a type from the github.com/charmbracelet/ssh package
+// pty, _, _ := sess.Pty()
+// environ := append(sess.Environ(), "TERM="+pty.Term)
+// p := tea.NewProgram(model, tea.WithEnvironment(environ)
+func WithEnvironment(env []string) ProgramOption {
+ return func(p *Program) {
+ p.environ = env
+ }
+}
+
// WithoutSignalHandler disables the signal handler that Bubble Tea sets up for
// Programs. This is useful if you want to handle signals yourself.
func WithoutSignalHandler() ProgramOption {
@@ -101,6 +112,13 @@ func WithAltScreen() ProgramOption {
}
}
+// WithoutBracketedPaste starts the program with bracketed paste disabled.
+func WithoutBracketedPaste() ProgramOption {
+ return func(p *Program) {
+ p.startupOptions |= withoutBracketedPaste
+ }
+}
+
// WithMouseCellMotion starts the program with the mouse enabled in "cell
// motion" mode.
//
@@ -167,6 +185,9 @@ func WithoutRenderer() ProgramOption {
//
// This feature is provisional, and may be changed or removed in a future version
// of this package.
+//
+// Deprecated: this incurs a noticable performance hit. A future release will
+// optimize ANSI automatically without the performance penalty.
func WithANSICompressor() ProgramOption {
return func(p *Program) {
p.startupOptions |= withANSICompressor
@@ -216,3 +237,16 @@ func WithFPS(fps int) ProgramOption {
p.fps = fps
}
}
+
+// WithReportFocus enables reporting when the terminal gains and loses
+// focus. When this is enabled [FocusMsg] and [BlurMsg] messages will be sent
+// to your Update method.
+//
+// Note that while most terminals and multiplexers support focus reporting,
+// some do not. Also note that tmux needs to be configured to report focus
+// events.
+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 5a3ee3c4..9eb7943b 100644
--- a/vendor/github.com/charmbracelet/bubbletea/renderer.go
+++ b/vendor/github.com/charmbracelet/bubbletea/renderer.go
@@ -56,6 +56,29 @@ type renderer interface {
// disableMouseSGRMode disables mouse extended mode (SGR).
disableMouseSGRMode()
+
+ // enableBracketedPaste enables bracketed paste, where characters
+ // inside the input are not interpreted when pasted as a whole.
+ enableBracketedPaste()
+
+ // disableBracketedPaste disables bracketed paste.
+ disableBracketedPaste()
+
+ // bracketedPasteActive reports whether bracketed paste mode is
+ // currently enabled.
+ bracketedPasteActive() bool
+
+ // 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 d064222f..dfec48f0 100644
--- a/vendor/github.com/charmbracelet/bubbletea/screen.go
+++ b/vendor/github.com/charmbracelet/bubbletea/screen.go
@@ -116,6 +116,54 @@ func ShowCursor() Msg {
// this message with ShowCursor.
type showCursorMsg struct{}
+// EnableBracketedPaste is a special command that tells the Bubble Tea program
+// to accept bracketed paste input.
+//
+// Note that bracketed paste will be automatically disabled when the
+// program quits.
+func EnableBracketedPaste() Msg {
+ return enableBracketedPasteMsg{}
+}
+
+// enableBracketedPasteMsg in an internal message signals that
+// bracketed paste should be enabled. You can send an
+// enableBracketedPasteMsg with EnableBracketedPaste.
+type enableBracketedPasteMsg struct{}
+
+// DisableBracketedPaste is a special command that tells the Bubble Tea program
+// to accept bracketed paste input.
+//
+// Note that bracketed paste will be automatically disabled when the
+// program quits.
+func DisableBracketedPaste() Msg {
+ return disableBracketedPasteMsg{}
+}
+
+// disableBracketedPasteMsg in an internal message signals that
+// bracketed paste should be disabled. You can send an
+// 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.
//
@@ -123,6 +171,8 @@ type showCursorMsg struct{}
func (p *Program) EnterAltScreen() {
if p.renderer != nil {
p.renderer.enterAltScreen()
+ } else {
+ p.startupOptions |= withAltScreen
}
}
@@ -132,6 +182,8 @@ func (p *Program) EnterAltScreen() {
func (p *Program) ExitAltScreen() {
if p.renderer != nil {
p.renderer.exitAltScreen()
+ } else {
+ p.startupOptions &^= withAltScreen
}
}
@@ -140,7 +192,11 @@ func (p *Program) ExitAltScreen() {
//
// Deprecated: Use the WithMouseCellMotion ProgramOption instead.
func (p *Program) EnableMouseCellMotion() {
- p.renderer.enableMouseCellMotion()
+ if p.renderer != nil {
+ p.renderer.enableMouseCellMotion()
+ } else {
+ p.startupOptions |= withMouseCellMotion
+ }
}
// DisableMouseCellMotion disables Mouse Cell Motion tracking. This will be
@@ -148,7 +204,11 @@ func (p *Program) EnableMouseCellMotion() {
//
// Deprecated: The mouse will automatically be disabled when the program exits.
func (p *Program) DisableMouseCellMotion() {
- p.renderer.disableMouseCellMotion()
+ if p.renderer != nil {
+ p.renderer.disableMouseCellMotion()
+ } else {
+ p.startupOptions &^= withMouseCellMotion
+ }
}
// EnableMouseAllMotion enables mouse click, release, wheel and motion events,
@@ -157,7 +217,11 @@ func (p *Program) DisableMouseCellMotion() {
//
// Deprecated: Use the WithMouseAllMotion ProgramOption instead.
func (p *Program) EnableMouseAllMotion() {
- p.renderer.enableMouseAllMotion()
+ if p.renderer != nil {
+ p.renderer.enableMouseAllMotion()
+ } else {
+ p.startupOptions |= withMouseAllMotion
+ }
}
// DisableMouseAllMotion disables All Motion mouse tracking. This will be
@@ -165,10 +229,20 @@ func (p *Program) EnableMouseAllMotion() {
//
// Deprecated: The mouse will automatically be disabled when the program exits.
func (p *Program) DisableMouseAllMotion() {
- p.renderer.disableMouseAllMotion()
+ if p.renderer != nil {
+ p.renderer.disableMouseAllMotion()
+ } else {
+ p.startupOptions &^= withMouseAllMotion
+ }
}
// SetWindowTitle sets the terminal window title.
+//
+// Deprecated: Use the SetWindowTitle command instead.
func (p *Program) SetWindowTitle(title string) {
- p.output.SetWindowTitle(title)
+ if p.renderer != nil {
+ p.renderer.setWindowTitle(title)
+ } else {
+ p.startupTitle = title
+ }
}
diff --git a/vendor/github.com/charmbracelet/bubbletea/signals_unix.go b/vendor/github.com/charmbracelet/bubbletea/signals_unix.go
index 826f58b9..40954038 100644
--- a/vendor/github.com/charmbracelet/bubbletea/signals_unix.go
+++ b/vendor/github.com/charmbracelet/bubbletea/signals_unix.go
@@ -1,5 +1,5 @@
-//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix || zos
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix zos
package tea
diff --git a/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go b/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go
index 1573a1c2..369f27f8 100644
--- a/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go
+++ b/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go
@@ -8,9 +8,8 @@ import (
"sync"
"time"
+ "github.com/charmbracelet/x/ansi"
"github.com/muesli/ansi/compressor"
- "github.com/muesli/reflow/truncate"
- "github.com/muesli/termenv"
)
const (
@@ -27,7 +26,7 @@ const (
// to exclude ranges of lines, allowing them to be written to directly.
type standardRenderer struct {
mtx *sync.Mutex
- out *termenv.Output
+ out io.Writer
buf bytes.Buffer
queuedMessageLines []string
@@ -35,7 +34,9 @@ type standardRenderer struct {
ticker *time.Ticker
done chan struct{}
lastRender string
+ lastRenderedLines []string
linesRendered int
+ altLinesRendered int
useANSICompressor bool
once sync.Once
@@ -45,6 +46,12 @@ type standardRenderer struct {
// essentially whether or not we're using the full size of the terminal
altScreenActive bool
+ // 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
@@ -55,7 +62,7 @@ type standardRenderer struct {
// newRenderer creates a new renderer. Normally you'll want to initialize it
// with os.Stdout as the first argument.
-func newRenderer(out *termenv.Output, useANSICompressor bool, fps int) renderer {
+func newRenderer(out io.Writer, useANSICompressor bool, fps int) renderer {
if fps < 1 {
fps = defaultFPS
} else if fps > maxFPS {
@@ -70,7 +77,7 @@ func newRenderer(out *termenv.Output, useANSICompressor bool, fps int) renderer
queuedMessageLines: []string{},
}
if r.useANSICompressor {
- r.out = termenv.NewOutput(&compressor.Writer{Forward: out})
+ r.out = &compressor.Writer{Forward: out}
}
return r
}
@@ -105,15 +112,22 @@ func (r *standardRenderer) stop() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.ClearLine()
+ r.execute(ansi.EraseEntireLine)
+ // Move the cursor back to the beginning of the line
+ r.execute("\r")
if r.useANSICompressor {
- if w, ok := r.out.TTY().(io.WriteCloser); ok {
+ if w, ok := r.out.(io.WriteCloser); ok {
_ = w.Close()
}
}
}
+// execute writes a sequence to the terminal.
+func (r *standardRenderer) execute(seq string) {
+ _, _ = io.WriteString(r.out, seq)
+}
+
// kill halts the renderer. The final frame will not be rendered.
func (r *standardRenderer) kill() {
// Stop the renderer before acquiring the mutex to avoid a deadlock.
@@ -124,7 +138,9 @@ func (r *standardRenderer) kill() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.ClearLine()
+ r.execute(ansi.EraseEntireLine)
+ // Move the cursor back to the beginning of the line
+ r.execute("\r")
}
// listen waits for ticks on the ticker, or a signal to stop the renderer.
@@ -147,13 +163,19 @@ func (r *standardRenderer) flush() {
defer r.mtx.Unlock()
if r.buf.Len() == 0 || r.buf.String() == r.lastRender {
- // Nothing to do
+ // Nothing to do.
return
}
- // Output buffer
+ // Output buffer.
buf := &bytes.Buffer{}
- out := termenv.NewOutput(buf)
+
+ // Moving to the beginning of the section, that we rendered.
+ if r.altScreenActive {
+ buf.WriteString(ansi.HomeCursorPosition)
+ } else if r.linesRendered > 1 {
+ buf.WriteString(ansi.CursorUp(r.linesRendered - 1))
+ }
newLines := strings.Split(r.buf.String(), "\n")
@@ -165,82 +187,92 @@ func (r *standardRenderer) flush() {
newLines = newLines[len(newLines)-r.height:]
}
- numLinesThisFlush := len(newLines)
- oldLines := strings.Split(r.lastRender, "\n")
- skipLines := make(map[int]struct{})
flushQueuedMessages := len(r.queuedMessageLines) > 0 && !r.altScreenActive
- // Add any queued messages to this render
if flushQueuedMessages {
- newLines = append(r.queuedMessageLines, newLines...)
+ // Dump the lines we've queued up for printing.
+ for _, line := range r.queuedMessageLines {
+ if ansi.StringWidth(line) < r.width {
+ // We only erase the rest of the line when the line is shorter than
+ // the width of the terminal. When the cursor reaches the end of
+ // the line, any escape sequences that follow will only affect the
+ // last cell of the line.
+
+ // Removing previously rendered content at the end of line.
+ line = line + ansi.EraseLineRight
+ }
+
+ _, _ = buf.WriteString(line)
+ _, _ = buf.WriteString("\r\n")
+ }
+ // Clear the queued message lines.
r.queuedMessageLines = []string{}
}
- // Clear any lines we painted in the last render.
- if r.linesRendered > 0 {
- for i := r.linesRendered - 1; i > 0; i-- {
- // If the number of lines we want to render hasn't increased and
- // new line is the same as the old line we can skip rendering for
- // this line as a performance optimization.
- if (len(newLines) <= len(oldLines)) && (len(newLines) > i && len(oldLines) > i) && (newLines[i] == oldLines[i]) {
- skipLines[i] = struct{}{}
- } else if _, exists := r.ignoreLines[i]; !exists {
- out.ClearLine()
+ // Paint new lines.
+ for i := 0; i < len(newLines); i++ {
+ canSkip := !flushQueuedMessages && // Queuing messages triggers repaint -> we don't have access to previous frame content.
+ len(r.lastRenderedLines) > i && r.lastRenderedLines[i] == newLines[i] // Previously rendered line is the same.
+
+ if _, ignore := r.ignoreLines[i]; ignore || canSkip {
+ // Unless this is the last line, move the cursor down.
+ if i < len(newLines)-1 {
+ buf.WriteString(ansi.CursorDown1)
}
+ continue
+ }
- out.CursorUp(1)
+ if i == 0 && r.lastRender == "" {
+ // On first render, reset the cursor to the start of the line
+ // before writing anything.
+ buf.WriteByte('\r')
}
- if _, exists := r.ignoreLines[0]; !exists {
- // We need to return to the start of the line here to properly
- // erase it. Going back the entire width of the terminal will
- // usually be farther than we need to go, but terminal emulators
- // will stop the cursor at the start of the line as a rule.
- //
- // We use this sequence in particular because it's part of the ANSI
- // standard (whereas others are proprietary to, say, VT100/VT52).
- // If cursor previous line (ESC[ + + F) were better supported
- // we could use that above to eliminate this step.
- out.CursorBack(r.width)
- out.ClearLine()
+ line := newLines[i]
+
+ // Truncate lines wider than the width of the window to avoid
+ // wrapping, which will mess up rendering. If we don't have the
+ // width of the window this will be ignored.
+ //
+ // Note that on Windows we only get the width of the window on
+ // program initialization, so after a resize this won't perform
+ // correctly (signal SIGWINCH is not supported on Windows).
+ if r.width > 0 {
+ line = ansi.Truncate(line, r.width, "")
}
- }
- // Merge the set of lines we're skipping as a rendering optimization with
- // the set of lines we've explicitly asked the renderer to ignore.
- for k, v := range r.ignoreLines {
- skipLines[k] = v
- }
+ if ansi.StringWidth(line) < r.width {
+ // We only erase the rest of the line when the line is shorter than
+ // the width of the terminal. When the cursor reaches the end of
+ // the line, any escape sequences that follow will only affect the
+ // last cell of the line.
- // Paint new lines
- for i := 0; i < len(newLines); i++ {
- if _, skip := skipLines[i]; skip {
- // Unless this is the last line, move the cursor down.
- if i < len(newLines)-1 {
- out.CursorDown(1)
- }
- } else {
- line := newLines[i]
-
- // Truncate lines wider than the width of the window to avoid
- // wrapping, which will mess up rendering. If we don't have the
- // width of the window this will be ignored.
- //
- // Note that on Windows we only get the width of the window on
- // program initialization, so after a resize this won't perform
- // correctly (signal SIGWINCH is not supported on Windows).
- if r.width > 0 {
- line = truncate.String(line, uint(r.width))
- }
+ // Removing previously rendered content at the end of line.
+ line = line + ansi.EraseLineRight
+ }
- _, _ = out.WriteString(line)
+ _, _ = buf.WriteString(line)
- if i < len(newLines)-1 {
- _, _ = out.WriteString("\r\n")
- }
+ if i < len(newLines)-1 {
+ _, _ = buf.WriteString("\r\n")
}
}
- r.linesRendered = numLinesThisFlush
+
+ lastLinesRendered := r.linesRendered
+ if r.altScreenActive {
+ lastLinesRendered = r.altLinesRendered
+ }
+
+ // Clearing left over content from last render.
+ if lastLinesRendered > len(newLines) {
+ buf.WriteString(ansi.EraseScreenBelow)
+ }
+
+ if r.altScreenActive {
+ r.altLinesRendered = len(newLines)
+ } else {
+ r.linesRendered = len(newLines)
+ }
// Make sure the cursor is at the start of the last line to keep rendering
// behavior consistent.
@@ -248,13 +280,18 @@ func (r *standardRenderer) flush() {
// This case fixes a bug in macOS terminal. In other terminals the
// other case seems to do the job regardless of whether or not we're
// using the full terminal window.
- out.MoveCursor(r.linesRendered, 0)
+ buf.WriteString(ansi.SetCursorPosition(0, len(newLines)))
} else {
- out.CursorBack(r.width)
+ buf.WriteString(ansi.CursorLeft(r.width))
}
_, _ = r.out.Write(buf.Bytes())
r.lastRender = r.buf.String()
+
+ // Save previously rendered lines for comparison in the next render. If we
+ // don't do this, we can't skip rendering lines that haven't changed.
+ // See https://github.com/charmbracelet/bubbletea/pull/1233
+ r.lastRenderedLines = newLines
r.buf.Reset()
}
@@ -278,14 +315,15 @@ func (r *standardRenderer) write(s string) {
func (r *standardRenderer) repaint() {
r.lastRender = ""
+ r.lastRenderedLines = nil
}
func (r *standardRenderer) clearScreen() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.ClearScreen()
- r.out.MoveCursor(1, 1)
+ r.execute(ansi.EraseEntireScreen)
+ r.execute(ansi.HomeCursorPosition)
r.repaint()
}
@@ -306,7 +344,7 @@ func (r *standardRenderer) enterAltScreen() {
}
r.altScreenActive = true
- r.out.AltScreen()
+ r.execute(ansi.EnableAltScreenBuffer)
// Ensure that the terminal is cleared, even when it doesn't support
// alt screen (or alt screen support is disabled, like GNU screen by
@@ -314,18 +352,21 @@ func (r *standardRenderer) enterAltScreen() {
//
// Note: we can't use r.clearScreen() here because the mutex is already
// locked.
- r.out.ClearScreen()
- r.out.MoveCursor(1, 1)
+ r.execute(ansi.EraseEntireScreen)
+ r.execute(ansi.HomeCursorPosition)
// cmd.exe and other terminals keep separate cursor states for the AltScreen
// and the main buffer. We have to explicitly reset the cursor visibility
// whenever we enter AltScreen.
if r.cursorHidden {
- r.out.HideCursor()
+ r.execute(ansi.HideCursor)
} else {
- r.out.ShowCursor()
+ r.execute(ansi.ShowCursor)
}
+ // Entering the alt screen resets the lines rendered count.
+ r.altLinesRendered = 0
+
r.repaint()
}
@@ -338,15 +379,15 @@ func (r *standardRenderer) exitAltScreen() {
}
r.altScreenActive = false
- r.out.ExitAltScreen()
+ r.execute(ansi.DisableAltScreenBuffer)
// cmd.exe and other terminals keep separate cursor states for the AltScreen
// and the main buffer. We have to explicitly reset the cursor visibility
// whenever we exit AltScreen.
if r.cursorHidden {
- r.out.HideCursor()
+ r.execute(ansi.HideCursor)
} else {
- r.out.ShowCursor()
+ r.execute(ansi.ShowCursor)
}
r.repaint()
@@ -357,7 +398,7 @@ func (r *standardRenderer) showCursor() {
defer r.mtx.Unlock()
r.cursorHidden = false
- r.out.ShowCursor()
+ r.execute(ansi.ShowCursor)
}
func (r *standardRenderer) hideCursor() {
@@ -365,49 +406,100 @@ func (r *standardRenderer) hideCursor() {
defer r.mtx.Unlock()
r.cursorHidden = true
- r.out.HideCursor()
+ r.execute(ansi.HideCursor)
}
func (r *standardRenderer) enableMouseCellMotion() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.EnableMouseCellMotion()
+ r.execute(ansi.EnableMouseCellMotion)
}
func (r *standardRenderer) disableMouseCellMotion() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.DisableMouseCellMotion()
+ r.execute(ansi.DisableMouseCellMotion)
}
func (r *standardRenderer) enableMouseAllMotion() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.EnableMouseAllMotion()
+ r.execute(ansi.EnableMouseAllMotion)
}
func (r *standardRenderer) disableMouseAllMotion() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.DisableMouseAllMotion()
+ r.execute(ansi.DisableMouseAllMotion)
}
func (r *standardRenderer) enableMouseSGRMode() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.EnableMouseExtendedMode()
+ r.execute(ansi.EnableMouseSgrExt)
}
func (r *standardRenderer) disableMouseSGRMode() {
r.mtx.Lock()
defer r.mtx.Unlock()
- r.out.DisableMouseExtendedMode()
+ r.execute(ansi.DisableMouseSgrExt)
+}
+
+func (r *standardRenderer) enableBracketedPaste() {
+ r.mtx.Lock()
+ defer r.mtx.Unlock()
+
+ r.execute(ansi.EnableBracketedPaste)
+ r.bpActive = true
+}
+
+func (r *standardRenderer) disableBracketedPaste() {
+ r.mtx.Lock()
+ defer r.mtx.Unlock()
+
+ r.execute(ansi.DisableBracketedPaste)
+ r.bpActive = false
+}
+
+func (r *standardRenderer) bracketedPasteActive() bool {
+ r.mtx.Lock()
+ defer r.mtx.Unlock()
+
+ 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))
}
// setIgnoredLines specifies lines not to be touched by the standard Bubble Tea
@@ -430,15 +522,14 @@ func (r *standardRenderer) setIgnoredLines(from int, to int) {
// Erase ignored lines
if r.linesRendered > 0 {
buf := &bytes.Buffer{}
- out := termenv.NewOutput(buf)
for i := r.linesRendered - 1; i >= 0; i-- {
if _, exists := r.ignoreLines[i]; exists {
- out.ClearLine()
+ buf.WriteString(ansi.EraseEntireLine)
}
- out.CursorUp(1)
+ buf.WriteString(ansi.CursorUp1)
}
- out.MoveCursor(r.linesRendered, 0) // put cursor back
+ buf.WriteString(ansi.SetCursorPosition(0, r.linesRendered)) // put cursor back
_, _ = r.out.Write(buf.Bytes())
}
}
@@ -468,21 +559,23 @@ func (r *standardRenderer) clearIgnoredLines() {
// use in high-performance rendering, such as a pager that could potentially
// be rendering very complicated ansi. In cases where the content is simpler
// standard Bubble Tea rendering should suffice.
+//
+// Deprecated: This option is deprecated and will be removed in a future
+// version of this package.
func (r *standardRenderer) insertTop(lines []string, topBoundary, bottomBoundary int) {
r.mtx.Lock()
defer r.mtx.Unlock()
buf := &bytes.Buffer{}
- out := termenv.NewOutput(buf)
- out.ChangeScrollingRegion(topBoundary, bottomBoundary)
- out.MoveCursor(topBoundary, 0)
- out.InsertLines(len(lines))
- _, _ = out.WriteString(strings.Join(lines, "\r\n"))
- out.ChangeScrollingRegion(0, r.height)
+ buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary))
+ buf.WriteString(ansi.SetCursorPosition(0, topBoundary))
+ buf.WriteString(ansi.InsertLine(len(lines)))
+ _, _ = buf.WriteString(strings.Join(lines, "\r\n"))
+ buf.WriteString(ansi.SetScrollingRegion(0, r.height))
// Move cursor back to where the main rendering routine expects it to be
- out.MoveCursor(r.linesRendered, 0)
+ buf.WriteString(ansi.SetCursorPosition(0, r.linesRendered))
_, _ = r.out.Write(buf.Bytes())
}
@@ -496,20 +589,22 @@ func (r *standardRenderer) insertTop(lines []string, topBoundary, bottomBoundary
// See note in insertTop() for caveats, how this function only makes sense for
// full-window applications, and how it differs from the normal way we do
// rendering in Bubble Tea.
+//
+// Deprecated: This option is deprecated and will be removed in a future
+// version of this package.
func (r *standardRenderer) insertBottom(lines []string, topBoundary, bottomBoundary int) {
r.mtx.Lock()
defer r.mtx.Unlock()
buf := &bytes.Buffer{}
- out := termenv.NewOutput(buf)
- out.ChangeScrollingRegion(topBoundary, bottomBoundary)
- out.MoveCursor(bottomBoundary, 0)
- _, _ = out.WriteString("\r\n" + strings.Join(lines, "\r\n"))
- out.ChangeScrollingRegion(0, r.height)
+ buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary))
+ buf.WriteString(ansi.SetCursorPosition(0, bottomBoundary))
+ _, _ = buf.WriteString("\r\n" + strings.Join(lines, "\r\n"))
+ buf.WriteString(ansi.SetScrollingRegion(0, r.height))
// Move cursor back to where the main rendering routine expects it to be
- out.MoveCursor(r.linesRendered, 0)
+ buf.WriteString(ansi.SetCursorPosition(0, r.linesRendered))
_, _ = r.out.Write(buf.Bytes())
}
@@ -581,6 +676,8 @@ type syncScrollAreaMsg struct {
// should also be called on resize (WindowSizeMsg).
//
// For high-performance, scroll-based rendering only.
+//
+// Deprecated: This option will be removed in a future version of this package.
func SyncScrollArea(lines []string, topBoundary int, bottomBoundary int) Cmd {
return func() Msg {
return syncScrollAreaMsg{
@@ -597,6 +694,8 @@ type clearScrollAreaMsg struct{}
// those lines to the main rendering routine.
//
// For high-performance, scroll-based rendering only.
+//
+// Deprecated: This option will be removed in a future version of this package.
func ClearScrollArea() Msg {
return clearScrollAreaMsg{}
}
@@ -612,6 +711,8 @@ type scrollUpMsg struct {
// from view.
//
// For high-performance, scroll-based rendering only.
+//
+// Deprecated: This option will be removed in a future version of this package.
func ScrollUp(newLines []string, topBoundary, bottomBoundary int) Cmd {
return func() Msg {
return scrollUpMsg{
@@ -633,6 +734,8 @@ type scrollDownMsg struct {
// disappear from view.
//
// For high-performance, scroll-based rendering only.
+//
+// Deprecated: This option will be removed in a future version of this package.
func ScrollDown(newLines []string, topBoundary, bottomBoundary int) Cmd {
return func() Msg {
return scrollDownMsg{
diff --git a/vendor/github.com/charmbracelet/bubbletea/tea.go b/vendor/github.com/charmbracelet/bubbletea/tea.go
index f18cb87c..87211ba2 100644
--- a/vendor/github.com/charmbracelet/bubbletea/tea.go
+++ b/vendor/github.com/charmbracelet/bubbletea/tea.go
@@ -21,10 +21,8 @@ import (
"sync/atomic"
"syscall"
- "github.com/containerd/console"
- isatty "github.com/mattn/go-isatty"
+ "github.com/charmbracelet/x/term"
"github.com/muesli/cancelreader"
- "github.com/muesli/termenv"
"golang.org/x/sync/errgroup"
)
@@ -81,7 +79,7 @@ func (i inputType) String() string {
// generally set with ProgramOptions.
//
// The options here are treated as bits.
-type startupOptions byte
+type startupOptions int16
func (s startupOptions) has(option startupOptions) bool {
return s&option != 0
@@ -93,26 +91,28 @@ const (
withMouseAllMotion
withANSICompressor
withoutSignalHandler
-
// Catching panics is incredibly useful for restoring the terminal to a
// usable state after a panic occurs. When this is set, Bubble Tea will
// recover from panics, print the stack trace, and disable raw mode. This
// feature is on by default.
withoutCatchPanics
+ withoutBracketedPaste
+ withReportFocus
)
-// handlers manages series of channels returned by various processes. It allows
-// us to wait for those processes to terminate before exiting the program.
-type handlers []chan struct{}
+// channelHandlers manages the series of channels returned by various processes.
+// It allows us to wait for those processes to terminate before exiting the
+// program.
+type channelHandlers []chan struct{}
// Adds a channel to the list of handlers. We wait for all handlers to terminate
// gracefully on shutdown.
-func (h *handlers) add(ch chan struct{}) {
+func (h *channelHandlers) add(ch chan struct{}) {
*h = append(*h, ch)
}
// shutdown waits for all handlers to terminate.
-func (h handlers) shutdown() {
+func (h channelHandlers) shutdown() {
var wg sync.WaitGroup
for _, ch := range h {
wg.Add(1)
@@ -128,10 +128,18 @@ func (h handlers) shutdown() {
type Program struct {
initialModel Model
+ // handlers is a list of channels that need to be waited on before the
+ // program can exit.
+ handlers channelHandlers
+
// Configuration options that will set as the program is initializing,
// treated as bits. These options can be set via various ProgramOptions.
startupOptions startupOptions
+ // startupTitle is the title that will be set on the terminal when the
+ // program starts.
+ startupTitle string
+
inputType inputType
ctx context.Context
@@ -142,28 +150,29 @@ type Program struct {
finished chan struct{}
// where to send output, this will usually be os.Stdout.
- output *termenv.Output
- restoreOutput func() error
- renderer renderer
+ output io.Writer
+ // ttyOutput is null if output is not a TTY.
+ ttyOutput term.File
+ previousOutputState *term.State
+ renderer renderer
+
+ // the environment variables for the program, defaults to os.Environ().
+ environ []string
// where to read inputs from, this will usually be os.Stdin.
- input io.Reader
- cancelReader cancelreader.CancelReader
- readLoopDone chan struct{}
- console console.Console
+ input io.Reader
+ // ttyInput is null if input is not a TTY.
+ ttyInput term.File
+ previousTtyInputState *term.State
+ cancelReader cancelreader.CancelReader
+ readLoopDone chan struct{}
// was the altscreen active before releasing the terminal?
altScreenWasActive bool
ignoreSignals uint32
- // Stores the original reference to stdin for cases where input is not a
- // TTY on windows and we've automatically opened CONIN$ to receive input.
- // When the program exits this will be restored.
- //
- // Lint ignore note: the linter will find false positive on unix systems
- // as this value only comes into play on Windows, hence the ignore comment
- // below.
- windowsStdin *os.File //nolint:golint,structcheck,unused
+ 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
@@ -181,6 +190,22 @@ func Quit() Msg {
// Quit.
type QuitMsg struct{}
+// Suspend is a special command that tells the Bubble Tea program to suspend.
+func Suspend() Msg {
+ return SuspendMsg{}
+}
+
+// SuspendMsg signals the program should suspend.
+// This usually happens when ctrl+z is pressed on common programs, but since
+// bubbletea puts the terminal in raw mode, we need to handle it in a
+// per-program basis.
+// You can send this message with Suspend.
+type SuspendMsg struct{}
+
+// ResumeMsg can be listen to to do something once a program is resumed back
+// from a suspend state.
+type ResumeMsg struct{}
+
// NewProgram creates a new Program.
func NewProgram(model Model, opts ...ProgramOption) *Program {
p := &Program{
@@ -203,13 +228,13 @@ func NewProgram(model Model, opts ...ProgramOption) *Program {
// if no output was set, set it to stdout
if p.output == nil {
- p.output = termenv.DefaultOutput()
-
- // cache detected color values
- termenv.WithColorCache(true)(p.output)
+ p.output = os.Stdout
}
- p.restoreOutput, _ = termenv.EnableVirtualTerminalProcessing(p.output)
+ // if no environment was set, set it to os.Environ()
+ if p.environ == nil {
+ p.environ = os.Environ()
+ }
return p
}
@@ -254,7 +279,7 @@ func (p *Program) handleSignals() chan struct{} {
func (p *Program) handleResize() chan struct{} {
ch := make(chan struct{})
- if f, ok := p.output.TTY().(*os.File); ok && isatty.IsTerminal(f.Fd()) {
+ if p.ttyOutput != nil {
// Get the initial terminal size and send it to the program.
go p.checkResize()
@@ -291,6 +316,11 @@ func (p *Program) handleCommands(cmds chan Cmd) chan struct{} {
// possible to cancel them so we'll have to leak the goroutine
// until Cmd returns.
go func() {
+ // Recover from panics.
+ if !p.startupOptions.has(withoutCatchPanics) {
+ defer p.recoverFromPanic()
+ }
+
msg := cmd() // this can be long.
p.Send(msg)
}()
@@ -332,6 +362,11 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
case QuitMsg:
return model, nil
+ case SuspendMsg:
+ if suspendSupported {
+ p.suspend()
+ }
+
case clearScreenMsg:
p.renderer.clearScreen()
@@ -360,6 +395,18 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
case hideCursorMsg:
p.renderer.hideCursor()
+ case enableBracketedPasteMsg:
+ p.renderer.enableBracketedPaste()
+
+ 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)
@@ -400,6 +447,9 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
case setWindowTitleMsg:
p.SetWindowTitle(string(msg))
+
+ case windowSizeMsg:
+ go p.checkResize()
}
// Process internal messages for the renderer.
@@ -419,7 +469,7 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
// terminated by either [Program.Quit], [Program.Kill], or its signal handler.
// Returns the final model.
func (p *Program) Run() (Model, error) {
- handlers := handlers{}
+ p.handlers = channelHandlers{}
cmds := make(chan Cmd)
p.errs = make(chan error)
p.finished = make(chan struct{}, 1)
@@ -436,11 +486,11 @@ func (p *Program) Run() (Model, error) {
// piped in or redirected to the application.
//
// To disable input entirely pass nil to the [WithInput] program option.
- f, isFile := p.input.(*os.File)
+ f, isFile := p.input.(term.File)
if !isFile {
break
}
- if isatty.IsTerminal(f.Fd()) {
+ if term.IsTerminal(f.Fd()) {
break
}
@@ -466,19 +516,12 @@ func (p *Program) Run() (Model, error) {
// Handle signals.
if !p.startupOptions.has(withoutSignalHandler) {
- handlers.add(p.handleSignals())
+ p.handlers.add(p.handleSignals())
}
// Recover from panics.
if !p.startupOptions.has(withoutCatchPanics) {
- defer func() {
- if r := recover(); r != nil {
- p.shutdown(true)
- fmt.Printf("Caught panic:\n\n%s\n\nRestoring terminal...\n\n", r)
- debug.PrintStack()
- return
- }
- }()
+ defer p.recoverFromPanic()
}
// If no renderer is set use the standard one.
@@ -493,9 +536,15 @@ func (p *Program) Run() (Model, error) {
}
// Honor program startup options.
+ if p.startupTitle != "" {
+ p.renderer.setWindowTitle(p.startupTitle)
+ }
if p.startupOptions&withAltScreen != 0 {
p.renderer.enterAltScreen()
}
+ if p.startupOptions&withoutBracketedPaste == 0 {
+ p.renderer.enableBracketedPaste()
+ }
if p.startupOptions&withMouseCellMotion != 0 {
p.renderer.enableMouseCellMotion()
p.renderer.enableMouseSGRMode()
@@ -503,12 +552,18 @@ 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()
// Initialize the program.
model := p.initialModel
if initCmd := model.Init(); initCmd != nil {
ch := make(chan struct{})
- handlers.add(ch)
+ p.handlers.add(ch)
go func() {
defer close(ch)
@@ -520,9 +575,6 @@ func (p *Program) Run() (Model, error) {
}()
}
- // Start the renderer.
- p.renderer.start()
-
// Render the initial view.
p.renderer.write(model.View())
@@ -534,36 +586,21 @@ func (p *Program) Run() (Model, error) {
}
// Handle resize events.
- handlers.add(p.handleResize())
+ p.handlers.add(p.handleResize())
// Process commands.
- handlers.add(p.handleCommands(cmds))
+ p.handlers.add(p.handleCommands(cmds))
// Run event loop, handle updates and draw.
model, err := p.eventLoop(model, cmds)
killed := p.ctx.Err() != nil
if killed {
- err = ErrProgramKilled
+ err = fmt.Errorf("%w: %s", ErrProgramKilled, p.ctx.Err())
} else {
// Ensure we rendered the final state of the model.
p.renderer.write(model.View())
}
- // Tear down.
- p.cancel()
-
- // Check if the cancel reader has been setup before waiting and closing.
- if p.cancelReader != nil {
- // Wait for input loop to finish.
- if p.cancelReader.Cancel() {
- p.waitForReadLoop()
- }
- _ = p.cancelReader.Close()
- }
-
- // Wait for all handlers to finish.
- handlers.shutdown()
-
// Restore terminal state.
p.shutdown(killed)
@@ -618,7 +655,7 @@ func (p *Program) Quit() {
// The final render that you would normally see when quitting will be skipped.
// [program.Run] returns a [ErrProgramKilled] error.
func (p *Program) Kill() {
- p.cancel()
+ p.shutdown(true)
}
// Wait waits/blocks until the underlying Program finished shutting down.
@@ -629,6 +666,22 @@ func (p *Program) Wait() {
// shutdown performs operations to free up resources and restore the terminal
// to its original state.
func (p *Program) shutdown(kill bool) {
+ p.cancel()
+
+ // Wait for all handlers to finish.
+ p.handlers.shutdown()
+
+ // Check if the cancel reader has been setup before waiting and closing.
+ if p.cancelReader != nil {
+ // Wait for input loop to finish.
+ if p.cancelReader.Cancel() {
+ if !kill {
+ p.waitForReadLoop()
+ }
+ }
+ _ = p.cancelReader.Close()
+ }
+
if p.renderer != nil {
if kill {
p.renderer.kill()
@@ -638,24 +691,38 @@ func (p *Program) shutdown(kill bool) {
}
_ = p.restoreTerminalState()
- if p.restoreOutput != nil {
- _ = p.restoreOutput()
+ if !kill {
+ p.finished <- struct{}{}
+ }
+}
+
+// recoverFromPanic recovers from a panic, prints the stack trace, and restores
+// the terminal to a usable state.
+func (p *Program) recoverFromPanic() {
+ if r := recover(); r != nil {
+ p.shutdown(true)
+ fmt.Printf("Caught panic:\n\n%s\n\nRestoring terminal...\n\n", r)
+ debug.PrintStack()
}
- p.finished <- struct{}{}
}
// ReleaseTerminal restores the original terminal state and cancels the input
// reader. You can return control to the Program with RestoreTerminal.
func (p *Program) ReleaseTerminal() error {
atomic.StoreUint32(&p.ignoreSignals, 1)
- p.cancelReader.Cancel()
+ if p.cancelReader != nil {
+ p.cancelReader.Cancel()
+ }
+
p.waitForReadLoop()
if p.renderer != nil {
p.renderer.stop()
+ p.altScreenWasActive = p.renderer.altScreen()
+ p.bpWasActive = p.renderer.bracketedPasteActive()
+ p.reportFocus = p.renderer.reportFocus()
}
- p.altScreenWasActive = p.renderer.altScreen()
return p.restoreTerminalState()
}
@@ -671,7 +738,6 @@ func (p *Program) RestoreTerminal() error {
if err := p.initCancelReader(); err != nil {
return err
}
-
if p.altScreenWasActive {
p.renderer.enterAltScreen()
} else {
@@ -681,6 +747,12 @@ func (p *Program) RestoreTerminal() error {
if p.renderer != nil {
p.renderer.start()
}
+ 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/tea_init.go b/vendor/github.com/charmbracelet/bubbletea/tea_init.go
new file mode 100644
index 00000000..19b6cc39
--- /dev/null
+++ b/vendor/github.com/charmbracelet/bubbletea/tea_init.go
@@ -0,0 +1,22 @@
+package tea
+
+import (
+ "github.com/charmbracelet/lipgloss"
+)
+
+func init() {
+ // XXX: This is a workaround to make assure that Lip Gloss and Termenv
+ // query the terminal before any Bubble Tea Program runs and acquires the
+ // terminal. Without this, Programs that use Lip Gloss/Termenv might hang
+ // while waiting for a a [termenv.OSCTimeout] while querying the terminal
+ // for its background/foreground colors.
+ //
+ // This happens because Bubble Tea acquires the terminal before termenv
+ // reads any responses.
+ //
+ // Note that this will only affect programs running on the default IO i.e.
+ // [os.Stdout] and [os.Stdin].
+ //
+ // This workaround will be removed in v2.
+ _ = lipgloss.HasDarkBackground()
+}
diff --git a/vendor/github.com/charmbracelet/bubbletea/tty.go b/vendor/github.com/charmbracelet/bubbletea/tty.go
index 01f084d4..02507782 100644
--- a/vendor/github.com/charmbracelet/bubbletea/tty.go
+++ b/vendor/github.com/charmbracelet/bubbletea/tty.go
@@ -4,26 +4,32 @@ import (
"errors"
"fmt"
"io"
- "os"
"time"
- isatty "github.com/mattn/go-isatty"
- localereader "github.com/mattn/go-localereader"
+ "github.com/charmbracelet/x/term"
"github.com/muesli/cancelreader"
- "golang.org/x/term"
)
+func (p *Program) suspend() {
+ if err := p.ReleaseTerminal(); err != nil {
+ // If we can't release input, abort.
+ return
+ }
+
+ suspendProcess()
+
+ _ = p.RestoreTerminal()
+ go p.Send(ResumeMsg{})
+}
+
func (p *Program) initTerminal() error {
- err := p.initInput()
- if err != nil {
- return err
+ if _, ok := p.renderer.(*nilRenderer); ok {
+ // No need to initialize the terminal if we're not rendering
+ return nil
}
- if p.console != nil {
- err = p.console.SetRaw()
- if err != nil {
- return fmt.Errorf("error entering raw mode: %w", err)
- }
+ if err := p.initInput(); err != nil {
+ return err
}
p.renderer.hideCursor()
@@ -34,9 +40,14 @@ func (p *Program) initTerminal() error {
// Bubble Tea program.
func (p *Program) restoreTerminalState() error {
if p.renderer != nil {
+ p.renderer.disableBracketedPaste()
p.renderer.showCursor()
p.disableMouse()
+ if p.renderer.reportFocus() {
+ p.renderer.disableReportFocus()
+ }
+
if p.renderer.altScreen() {
p.renderer.exitAltScreen()
@@ -45,20 +56,28 @@ func (p *Program) restoreTerminalState() error {
}
}
- if p.console != nil {
- err := p.console.Reset()
- if err != nil {
- return fmt.Errorf("error restoring terminal state: %w", err)
+ return p.restoreInput()
+}
+
+// restoreInput restores the tty input to its original state.
+func (p *Program) restoreInput() error {
+ if p.ttyInput != nil && p.previousTtyInputState != nil {
+ if err := term.Restore(p.ttyInput.Fd(), p.previousTtyInputState); err != nil {
+ return fmt.Errorf("error restoring console: %w", err)
}
}
-
- return p.restoreInput()
+ if p.ttyOutput != nil && p.previousOutputState != nil {
+ if err := term.Restore(p.ttyOutput.Fd(), p.previousOutputState); err != nil {
+ return fmt.Errorf("error restoring console: %w", err)
+ }
+ }
+ return nil
}
// initCancelReader (re)commences reading inputs.
func (p *Program) initCancelReader() error {
var err error
- p.cancelReader, err = cancelreader.NewReader(p.input)
+ p.cancelReader, err = newInputReader(p.input)
if err != nil {
return fmt.Errorf("error creating cancelreader: %w", err)
}
@@ -72,8 +91,7 @@ func (p *Program) initCancelReader() error {
func (p *Program) readLoop() {
defer close(p.readLoopDone)
- input := localereader.NewReader(p.cancelReader)
- err := readInputs(p.ctx, p.msgs, input)
+ err := readInputs(p.ctx, p.msgs, p.cancelReader)
if !errors.Is(err, io.EOF) && !errors.Is(err, cancelreader.ErrCanceled) {
select {
case <-p.ctx.Done():
@@ -96,13 +114,12 @@ func (p *Program) waitForReadLoop() {
// checkResize detects the current size of the output and informs the program
// via a WindowSizeMsg.
func (p *Program) checkResize() {
- f, ok := p.output.TTY().(*os.File)
- if !ok || !isatty.IsTerminal(f.Fd()) {
+ if p.ttyOutput == nil {
// can't query window size
return
}
- w, h, err := term.GetSize(int(f.Fd()))
+ w, h, err := term.GetSize(p.ttyOutput.Fd())
if err != nil {
select {
case <-p.ctx.Done():
diff --git a/vendor/github.com/charmbracelet/bubbletea/tty_unix.go b/vendor/github.com/charmbracelet/bubbletea/tty_unix.go
index a3a25b8f..5cbb4fe1 100644
--- a/vendor/github.com/charmbracelet/bubbletea/tty_unix.go
+++ b/vendor/github.com/charmbracelet/bubbletea/tty_unix.go
@@ -1,38 +1,31 @@
-//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || aix || zos
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris aix zos
package tea
import (
"fmt"
"os"
+ "os/signal"
+ "syscall"
- "github.com/containerd/console"
+ "github.com/charmbracelet/x/term"
)
-func (p *Program) initInput() error {
- // If input's a file, use console to manage it
- if f, ok := p.input.(*os.File); ok {
- c, err := console.ConsoleFromFile(f)
+func (p *Program) initInput() (err error) {
+ // Check if input is a terminal
+ if f, ok := p.input.(term.File); ok && term.IsTerminal(f.Fd()) {
+ p.ttyInput = f
+ p.previousTtyInputState, err = term.MakeRaw(p.ttyInput.Fd())
if err != nil {
- return nil //nolint:nilerr // ignore error, this was just a test
+ return fmt.Errorf("error entering raw mode: %w", err)
}
- p.console = c
}
- return nil
-}
-
-// On unix systems, RestoreInput closes any TTYs we opened for input. Note that
-// we don't do this on Windows as it causes the prompt to not be drawn until
-// the terminal receives a keypress rather than appearing promptly after the
-// program exits.
-func (p *Program) restoreInput() error {
- if p.console != nil {
- if err := p.console.Reset(); err != nil {
- return fmt.Errorf("error restoring console: %w", err)
- }
+ if f, ok := p.output.(term.File); ok && term.IsTerminal(f.Fd()) {
+ p.ttyOutput = f
}
+
return nil
}
@@ -43,3 +36,14 @@ func openInputTTY() (*os.File, error) {
}
return f, nil
}
+
+const suspendSupported = true
+
+// Send SIGTSTP to the entire process group.
+func suspendProcess() {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, syscall.SIGCONT)
+ _ = syscall.Kill(0, syscall.SIGTSTP)
+ // blocks until a CONT happens...
+ <-c
+}
diff --git a/vendor/github.com/charmbracelet/bubbletea/tty_windows.go b/vendor/github.com/charmbracelet/bubbletea/tty_windows.go
index be415aef..a3a2525b 100644
--- a/vendor/github.com/charmbracelet/bubbletea/tty_windows.go
+++ b/vendor/github.com/charmbracelet/bubbletea/tty_windows.go
@@ -4,44 +4,65 @@
package tea
import (
+ "fmt"
"os"
- "github.com/containerd/console"
+ "github.com/charmbracelet/x/term"
+ "golang.org/x/sys/windows"
)
-func (p *Program) initInput() error {
- // If input's a file, use console to manage it
- if f, ok := p.input.(*os.File); ok {
- // Save a reference to the current stdin then replace stdin with our
- // input. We do this so we can hand input off to containerd/console to
- // set raw mode, and do it in this fashion because the method
- // console.ConsoleFromFile isn't supported on Windows.
- p.windowsStdin = os.Stdin
- os.Stdin = f
-
- // Note: this will panic if it fails.
- c := console.Current()
- p.console = c
+func (p *Program) initInput() (err error) {
+ // Save stdin state and enable VT input
+ // We also need to enable VT
+ // input here.
+ if f, ok := p.input.(term.File); ok && term.IsTerminal(f.Fd()) {
+ p.ttyInput = f
+ p.previousTtyInputState, err = term.MakeRaw(p.ttyInput.Fd())
+ if err != nil {
+ return err
+ }
+
+ // Enable VT input
+ var mode uint32
+ if err := windows.GetConsoleMode(windows.Handle(p.ttyInput.Fd()), &mode); err != nil {
+ return fmt.Errorf("error getting console mode: %w", err)
+ }
+
+ if err := windows.SetConsoleMode(windows.Handle(p.ttyInput.Fd()), mode|windows.ENABLE_VIRTUAL_TERMINAL_INPUT); err != nil {
+ return fmt.Errorf("error setting console mode: %w", err)
+ }
}
- return nil
-}
+ // Save output screen buffer state and enable VT processing.
+ if f, ok := p.output.(term.File); ok && term.IsTerminal(f.Fd()) {
+ p.ttyOutput = f
+ p.previousOutputState, err = term.GetState(f.Fd())
+ if err != nil {
+ return err
+ }
-// restoreInput restores stdout in the event that we placed it aside to handle
-// input with CONIN$, above.
-func (p *Program) restoreInput() error {
- if p.windowsStdin != nil {
- os.Stdin = p.windowsStdin
+ var mode uint32
+ if err := windows.GetConsoleMode(windows.Handle(p.ttyOutput.Fd()), &mode); err != nil {
+ return fmt.Errorf("error getting console mode: %w", err)
+ }
+
+ if err := windows.SetConsoleMode(windows.Handle(p.ttyOutput.Fd()), mode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING); err != nil {
+ return fmt.Errorf("error setting console mode: %w", err)
+ }
}
- return nil
+ return
}
// Open the Windows equivalent of a TTY.
func openInputTTY() (*os.File, error) {
- f, err := os.OpenFile("CONIN$", os.O_RDWR, 0644)
+ f, err := os.OpenFile("CONIN$", os.O_RDWR, 0o644)
if err != nil {
return nil, err
}
return f, nil
}
+
+const suspendSupported = false
+
+func suspendProcess() {}
diff --git a/vendor/github.com/charmbracelet/x/ansi/cursor.go b/vendor/github.com/charmbracelet/x/ansi/cursor.go
index 8a917b2d..da144b92 100644
--- a/vendor/github.com/charmbracelet/x/ansi/cursor.go
+++ b/vendor/github.com/charmbracelet/x/ansi/cursor.go
@@ -163,6 +163,10 @@ func SetCursorPosition(col, row int) string {
return "\x1b[" + strconv.Itoa(row) + ";" + strconv.Itoa(col) + "H"
}
+// HomeCursorPosition is a sequence for moving the cursor to the upper left
+// corner of the scrolling region. This is equivalent to `SetCursorPosition(1, 1)`.
+const HomeCursorPosition = "\x1b[H"
+
// MoveCursor (CUP) returns a sequence for setting the cursor to the
// given row and column.
//
@@ -177,6 +181,8 @@ func MoveCursor(col, row int) string {
// CursorOrigin is a sequence for moving the cursor to the upper left corner of
// the display. This is equivalent to `SetCursorPosition(1, 1)`.
+//
+// Deprecated: use [HomeCursorPosition] instead.
const CursorOrigin = "\x1b[1;1H"
// MoveCursorOrigin is a sequence for moving the cursor to the upper left
diff --git a/vendor/github.com/charmbracelet/x/ansi/notification.go b/vendor/github.com/charmbracelet/x/ansi/notification.go
new file mode 100644
index 00000000..4943366f
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/ansi/notification.go
@@ -0,0 +1,13 @@
+package ansi
+
+// Notify sends a desktop notification using iTerm's OSC 9.
+//
+// OSC 9 ; Mc ST
+// OSC 9 ; Mc BEL
+//
+// Where Mc is the notification body.
+//
+// See: https://iterm2.com/documentation-escape-codes.html
+func Notify(s string) string {
+ return "\x1b]9;" + s + "\x07"
+}
diff --git a/vendor/github.com/charmbracelet/x/ansi/parser_decode.go b/vendor/github.com/charmbracelet/x/ansi/parser_decode.go
index ba6ebd2a..0ed802cb 100644
--- a/vendor/github.com/charmbracelet/x/ansi/parser_decode.go
+++ b/vendor/github.com/charmbracelet/x/ansi/parser_decode.go
@@ -437,7 +437,11 @@ 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
+ p := int(s) & parser.ParamMask
+ if p == parser.MissingParam {
+ return -1
+ }
+ return p
}
// HasMore returns true if the parameter has more sub-parameters.
diff --git a/vendor/github.com/charmbracelet/x/ansi/wrap.go b/vendor/github.com/charmbracelet/x/ansi/wrap.go
index d080a77a..77d239a5 100644
--- a/vendor/github.com/charmbracelet/x/ansi/wrap.go
+++ b/vendor/github.com/charmbracelet/x/ansi/wrap.go
@@ -83,7 +83,9 @@ func Hardwrap(s string, limit int, preserveSpace bool) string {
}
buf.WriteByte(b[i])
- curWidth++
+ if action == parser.PrintAction {
+ curWidth++
+ }
default:
buf.WriteByte(b[i])
}
diff --git a/vendor/github.com/charmbracelet/x/term/LICENSE b/vendor/github.com/charmbracelet/x/term/LICENSE
new file mode 100644
index 00000000..65a5654e
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/LICENSE
@@ -0,0 +1,21 @@
+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/term/term.go b/vendor/github.com/charmbracelet/x/term/term.go
new file mode 100644
index 00000000..58d6522c
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term.go
@@ -0,0 +1,49 @@
+package term
+
+// State contains platform-specific state of a terminal.
+type State struct {
+ state
+}
+
+// IsTerminal returns whether the given file descriptor is a terminal.
+func IsTerminal(fd uintptr) bool {
+ return isTerminal(fd)
+}
+
+// MakeRaw puts the terminal connected to the given file descriptor into raw
+// mode and returns the previous state of the terminal so that it can be
+// restored.
+func MakeRaw(fd uintptr) (*State, error) {
+ return makeRaw(fd)
+}
+
+// GetState returns the current state of a terminal which may be useful to
+// restore the terminal after a signal.
+func GetState(fd uintptr) (*State, error) {
+ return getState(fd)
+}
+
+// SetState sets the given state of the terminal.
+func SetState(fd uintptr, state *State) error {
+ return setState(fd, state)
+}
+
+// Restore restores the terminal connected to the given file descriptor to a
+// previous state.
+func Restore(fd uintptr, oldState *State) error {
+ return restore(fd, oldState)
+}
+
+// GetSize returns the visible dimensions of the given terminal.
+//
+// These dimensions don't include any scrollback buffer height.
+func GetSize(fd uintptr) (width, height int, err error) {
+ return getSize(fd)
+}
+
+// ReadPassword reads a line of input from a terminal without local echo. This
+// is commonly used for inputting passwords and other sensitive data. The slice
+// returned does not include the \n.
+func ReadPassword(fd uintptr) ([]byte, error) {
+ return readPassword(fd)
+}
diff --git a/vendor/github.com/charmbracelet/x/term/term_other.go b/vendor/github.com/charmbracelet/x/term/term_other.go
new file mode 100644
index 00000000..092c7e9d
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_other.go
@@ -0,0 +1,39 @@
+//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !zos && !windows && !solaris && !plan9
+// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!zos,!windows,!solaris,!plan9
+
+package term
+
+import (
+ "fmt"
+ "runtime"
+)
+
+type state struct{}
+
+func isTerminal(fd uintptr) bool {
+ return false
+}
+
+func makeRaw(fd uintptr) (*State, error) {
+ return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func getState(fd uintptr) (*State, error) {
+ return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func restore(fd uintptr, state *State) error {
+ return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func getSize(fd uintptr) (width, height int, err error) {
+ return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func setState(fd uintptr, state *State) error {
+ return fmt.Errorf("terminal: SetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
+
+func readPassword(fd uintptr) ([]byte, error) {
+ return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+}
diff --git a/vendor/github.com/charmbracelet/x/term/term_unix.go b/vendor/github.com/charmbracelet/x/term/term_unix.go
new file mode 100644
index 00000000..1459cb1b
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_unix.go
@@ -0,0 +1,96 @@
+//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
+
+package term
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+type state struct {
+ unix.Termios
+}
+
+func isTerminal(fd uintptr) bool {
+ _, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ return err == nil
+}
+
+func makeRaw(fd uintptr) (*State, error) {
+ termios, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ if err != nil {
+ return nil, err
+ }
+
+ oldState := State{state{Termios: *termios}}
+
+ // This attempts to replicate the behaviour documented for cfmakeraw in
+ // the termios(3) manpage.
+ termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
+ termios.Oflag &^= unix.OPOST
+ termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
+ termios.Cflag &^= unix.CSIZE | unix.PARENB
+ termios.Cflag |= unix.CS8
+ termios.Cc[unix.VMIN] = 1
+ termios.Cc[unix.VTIME] = 0
+ if err := unix.IoctlSetTermios(int(fd), ioctlWriteTermios, termios); err != nil {
+ return nil, err
+ }
+
+ return &oldState, nil
+}
+
+func setState(fd uintptr, state *State) error {
+ var termios *unix.Termios
+ if state != nil {
+ termios = &state.Termios
+ }
+ return unix.IoctlSetTermios(int(fd), ioctlWriteTermios, termios)
+}
+
+func getState(fd uintptr) (*State, error) {
+ termios, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ if err != nil {
+ return nil, err
+ }
+
+ return &State{state{Termios: *termios}}, nil
+}
+
+func restore(fd uintptr, state *State) error {
+ return unix.IoctlSetTermios(int(fd), ioctlWriteTermios, &state.Termios)
+}
+
+func getSize(fd uintptr) (width, height int, err error) {
+ ws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
+ if err != nil {
+ return 0, 0, err
+ }
+ return int(ws.Col), int(ws.Row), nil
+}
+
+// passwordReader is an io.Reader that reads from a specific file descriptor.
+type passwordReader int
+
+func (r passwordReader) Read(buf []byte) (int, error) {
+ return unix.Read(int(r), buf)
+}
+
+func readPassword(fd uintptr) ([]byte, error) {
+ termios, err := unix.IoctlGetTermios(int(fd), ioctlReadTermios)
+ if err != nil {
+ return nil, err
+ }
+
+ newState := *termios
+ newState.Lflag &^= unix.ECHO
+ newState.Lflag |= unix.ICANON | unix.ISIG
+ newState.Iflag |= unix.ICRNL
+ if err := unix.IoctlSetTermios(int(fd), ioctlWriteTermios, &newState); err != nil {
+ return nil, err
+ }
+
+ defer unix.IoctlSetTermios(int(fd), ioctlWriteTermios, termios)
+
+ return readPasswordLine(passwordReader(fd))
+}
diff --git a/vendor/github.com/charmbracelet/x/term/term_unix_bsd.go b/vendor/github.com/charmbracelet/x/term/term_unix_bsd.go
new file mode 100644
index 00000000..b435031a
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_unix_bsd.go
@@ -0,0 +1,11 @@
+//go:build darwin || dragonfly || freebsd || netbsd || openbsd
+// +build darwin dragonfly freebsd netbsd openbsd
+
+package term
+
+import "golang.org/x/sys/unix"
+
+const (
+ ioctlReadTermios = unix.TIOCGETA
+ ioctlWriteTermios = unix.TIOCSETA
+)
diff --git a/vendor/github.com/charmbracelet/x/term/term_unix_other.go b/vendor/github.com/charmbracelet/x/term/term_unix_other.go
new file mode 100644
index 00000000..ee2a29eb
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_unix_other.go
@@ -0,0 +1,11 @@
+//go:build aix || linux || solaris || zos
+// +build aix linux solaris zos
+
+package term
+
+import "golang.org/x/sys/unix"
+
+const (
+ ioctlReadTermios = unix.TCGETS
+ ioctlWriteTermios = unix.TCSETS
+)
diff --git a/vendor/github.com/charmbracelet/x/term/term_windows.go b/vendor/github.com/charmbracelet/x/term/term_windows.go
new file mode 100644
index 00000000..fe7afdec
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/term_windows.go
@@ -0,0 +1,87 @@
+//go:build windows
+// +build windows
+
+package term
+
+import (
+ "os"
+
+ "golang.org/x/sys/windows"
+)
+
+type state struct {
+ Mode uint32
+}
+
+func isTerminal(fd uintptr) bool {
+ var st uint32
+ err := windows.GetConsoleMode(windows.Handle(fd), &st)
+ return err == nil
+}
+
+func makeRaw(fd uintptr) (*State, error) {
+ var st uint32
+ if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
+ return nil, err
+ }
+ raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
+ raw |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT
+ if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
+ return nil, err
+ }
+ return &State{state{st}}, nil
+}
+
+func setState(fd uintptr, state *State) error {
+ var mode uint32
+ if state != nil {
+ mode = state.Mode
+ }
+ return windows.SetConsoleMode(windows.Handle(fd), mode)
+}
+
+func getState(fd uintptr) (*State, error) {
+ var st uint32
+ if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
+ return nil, err
+ }
+ return &State{state{st}}, nil
+}
+
+func restore(fd uintptr, state *State) error {
+ return windows.SetConsoleMode(windows.Handle(fd), state.Mode)
+}
+
+func getSize(fd uintptr) (width, height int, err error) {
+ var info windows.ConsoleScreenBufferInfo
+ if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
+ return 0, 0, err
+ }
+ return int(info.Window.Right - info.Window.Left + 1), int(info.Window.Bottom - info.Window.Top + 1), nil
+}
+
+func readPassword(fd uintptr) ([]byte, error) {
+ var st uint32
+ if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
+ return nil, err
+ }
+ old := st
+
+ st &^= (windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT)
+ st |= (windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_PROCESSED_INPUT)
+ if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil {
+ return nil, err
+ }
+
+ defer windows.SetConsoleMode(windows.Handle(fd), old)
+
+ var h windows.Handle
+ p, _ := windows.GetCurrentProcess()
+ if err := windows.DuplicateHandle(p, windows.Handle(fd), p, &h, 0, false, windows.DUPLICATE_SAME_ACCESS); err != nil {
+ return nil, err
+ }
+
+ f := os.NewFile(uintptr(h), "stdin")
+ defer f.Close()
+ return readPasswordLine(f)
+}
diff --git a/vendor/github.com/charmbracelet/x/term/terminal.go b/vendor/github.com/charmbracelet/x/term/terminal.go
new file mode 100644
index 00000000..8963163f
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/terminal.go
@@ -0,0 +1,12 @@
+package term
+
+import (
+ "io"
+)
+
+// File represents a file that has a file descriptor and can be read from,
+// written to, and closed.
+type File interface {
+ io.ReadWriteCloser
+ Fd() uintptr
+}
diff --git a/vendor/github.com/charmbracelet/x/term/util.go b/vendor/github.com/charmbracelet/x/term/util.go
new file mode 100644
index 00000000..b7313418
--- /dev/null
+++ b/vendor/github.com/charmbracelet/x/term/util.go
@@ -0,0 +1,47 @@
+package term
+
+import (
+ "io"
+ "runtime"
+)
+
+// readPasswordLine reads from reader until it finds \n or io.EOF.
+// The slice returned does not include the \n.
+// readPasswordLine also ignores any \r it finds.
+// Windows uses \r as end of line. So, on Windows, readPasswordLine
+// reads until it finds \r and ignores any \n it finds during processing.
+func readPasswordLine(reader io.Reader) ([]byte, error) {
+ var buf [1]byte
+ var ret []byte
+
+ for {
+ n, err := reader.Read(buf[:])
+ if n > 0 {
+ switch buf[0] {
+ case '\b':
+ if len(ret) > 0 {
+ ret = ret[:len(ret)-1]
+ }
+ case '\n':
+ if runtime.GOOS != "windows" {
+ return ret, nil
+ }
+ // otherwise ignore \n
+ case '\r':
+ if runtime.GOOS == "windows" {
+ return ret, nil
+ }
+ // otherwise ignore \r
+ default:
+ ret = append(ret, buf[0])
+ }
+ continue
+ }
+ if err != nil {
+ if err == io.EOF && len(ret) > 0 {
+ return ret, nil
+ }
+ return ret, err
+ }
+ }
+}
diff --git a/vendor/github.com/containerd/console/.golangci.yml b/vendor/github.com/containerd/console/.golangci.yml
deleted file mode 100644
index abe3d84b..00000000
--- a/vendor/github.com/containerd/console/.golangci.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-linters:
- enable:
- - gofmt
- - goimports
- - ineffassign
- - misspell
- - revive
- - staticcheck
- - structcheck
- - unconvert
- - unused
- - varcheck
- - vet
- disable:
- - errcheck
-
-run:
- timeout: 3m
- skip-dirs:
- - vendor
diff --git a/vendor/github.com/containerd/console/LICENSE b/vendor/github.com/containerd/console/LICENSE
deleted file mode 100644
index 584149b6..00000000
--- a/vendor/github.com/containerd/console/LICENSE
+++ /dev/null
@@ -1,191 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- Copyright The containerd Authors
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/containerd/console/README.md b/vendor/github.com/containerd/console/README.md
deleted file mode 100644
index 580b461a..00000000
--- a/vendor/github.com/containerd/console/README.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# console
-
-[](https://pkg.go.dev/github.com/containerd/console)
-[](https://github.com/containerd/console/actions?query=workflow%3ACI)
-[](https://goreportcard.com/report/github.com/containerd/console)
-
-Golang package for dealing with consoles. Light on deps and a simple API.
-
-## Modifying the current process
-
-```go
-current := console.Current()
-defer current.Reset()
-
-if err := current.SetRaw(); err != nil {
-}
-ws, err := current.Size()
-current.Resize(ws)
-```
-
-## Project details
-
-console is a containerd sub-project, licensed under the [Apache 2.0 license](./LICENSE).
-As a containerd sub-project, you will find the:
- * [Project governance](https://github.com/containerd/project/blob/master/GOVERNANCE.md),
- * [Maintainers](https://github.com/containerd/project/blob/master/MAINTAINERS),
- * and [Contributing guidelines](https://github.com/containerd/project/blob/master/CONTRIBUTING.md)
-
-information in our [`containerd/project`](https://github.com/containerd/project) repository.
diff --git a/vendor/github.com/containerd/console/console.go b/vendor/github.com/containerd/console/console.go
deleted file mode 100644
index 810a71f4..00000000
--- a/vendor/github.com/containerd/console/console.go
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "errors"
- "io"
- "os"
-)
-
-var ErrNotAConsole = errors.New("provided file is not a console")
-
-type File interface {
- io.ReadWriteCloser
-
- // Fd returns its file descriptor
- Fd() uintptr
- // Name returns its file name
- Name() string
-}
-
-type Console interface {
- File
-
- // Resize resizes the console to the provided window size
- Resize(WinSize) error
- // ResizeFrom resizes the calling console to the size of the
- // provided console
- ResizeFrom(Console) error
- // SetRaw sets the console in raw mode
- SetRaw() error
- // DisableEcho disables echo on the console
- DisableEcho() error
- // Reset restores the console to its orignal state
- Reset() error
- // Size returns the window size of the console
- Size() (WinSize, error)
-}
-
-// WinSize specifies the window size of the console
-type WinSize struct {
- // Height of the console
- Height uint16
- // Width of the console
- Width uint16
- x uint16
- y uint16
-}
-
-// Current returns the current process' console
-func Current() (c Console) {
- var err error
- // Usually all three streams (stdin, stdout, and stderr)
- // are open to the same console, but some might be redirected,
- // so try all three.
- for _, s := range []*os.File{os.Stderr, os.Stdout, os.Stdin} {
- if c, err = ConsoleFromFile(s); err == nil {
- return c
- }
- }
- // One of the std streams should always be a console
- // for the design of this function.
- panic(err)
-}
-
-// ConsoleFromFile returns a console using the provided file
-// nolint:revive
-func ConsoleFromFile(f File) (Console, error) {
- if err := checkConsole(f); err != nil {
- return nil, err
- }
- return newMaster(f)
-}
diff --git a/vendor/github.com/containerd/console/console_linux.go b/vendor/github.com/containerd/console/console_linux.go
deleted file mode 100644
index 28b77b7a..00000000
--- a/vendor/github.com/containerd/console/console_linux.go
+++ /dev/null
@@ -1,281 +0,0 @@
-//go:build linux
-// +build linux
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "io"
- "os"
- "sync"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- maxEvents = 128
-)
-
-// Epoller manages multiple epoll consoles using edge-triggered epoll api so we
-// dont have to deal with repeated wake-up of EPOLLER or EPOLLHUP.
-// For more details, see:
-// - https://github.com/systemd/systemd/pull/4262
-// - https://github.com/moby/moby/issues/27202
-//
-// Example usage of Epoller and EpollConsole can be as follow:
-//
-// epoller, _ := NewEpoller()
-// epollConsole, _ := epoller.Add(console)
-// go epoller.Wait()
-// var (
-// b bytes.Buffer
-// wg sync.WaitGroup
-// )
-// wg.Add(1)
-// go func() {
-// io.Copy(&b, epollConsole)
-// wg.Done()
-// }()
-// // perform I/O on the console
-// epollConsole.Shutdown(epoller.CloseConsole)
-// wg.Wait()
-// epollConsole.Close()
-type Epoller struct {
- efd int
- mu sync.Mutex
- fdMapping map[int]*EpollConsole
- closeOnce sync.Once
-}
-
-// NewEpoller returns an instance of epoller with a valid epoll fd.
-func NewEpoller() (*Epoller, error) {
- efd, err := unix.EpollCreate1(unix.EPOLL_CLOEXEC)
- if err != nil {
- return nil, err
- }
- return &Epoller{
- efd: efd,
- fdMapping: make(map[int]*EpollConsole),
- }, nil
-}
-
-// Add creates an epoll console based on the provided console. The console will
-// be registered with EPOLLET (i.e. using edge-triggered notification) and its
-// file descriptor will be set to non-blocking mode. After this, user should use
-// the return console to perform I/O.
-func (e *Epoller) Add(console Console) (*EpollConsole, error) {
- sysfd := int(console.Fd())
- // Set sysfd to non-blocking mode
- if err := unix.SetNonblock(sysfd, true); err != nil {
- return nil, err
- }
-
- ev := unix.EpollEvent{
- Events: unix.EPOLLIN | unix.EPOLLOUT | unix.EPOLLRDHUP | unix.EPOLLET,
- Fd: int32(sysfd),
- }
- if err := unix.EpollCtl(e.efd, unix.EPOLL_CTL_ADD, sysfd, &ev); err != nil {
- return nil, err
- }
- ef := &EpollConsole{
- Console: console,
- sysfd: sysfd,
- readc: sync.NewCond(&sync.Mutex{}),
- writec: sync.NewCond(&sync.Mutex{}),
- }
- e.mu.Lock()
- e.fdMapping[sysfd] = ef
- e.mu.Unlock()
- return ef, nil
-}
-
-// Wait starts the loop to wait for its consoles' notifications and signal
-// appropriate console that it can perform I/O.
-func (e *Epoller) Wait() error {
- events := make([]unix.EpollEvent, maxEvents)
- for {
- n, err := unix.EpollWait(e.efd, events, -1)
- if err != nil {
- // EINTR: The call was interrupted by a signal handler before either
- // any of the requested events occurred or the timeout expired
- if err == unix.EINTR {
- continue
- }
- return err
- }
- for i := 0; i < n; i++ {
- ev := &events[i]
- // the console is ready to be read from
- if ev.Events&(unix.EPOLLIN|unix.EPOLLHUP|unix.EPOLLERR) != 0 {
- if epfile := e.getConsole(int(ev.Fd)); epfile != nil {
- epfile.signalRead()
- }
- }
- // the console is ready to be written to
- if ev.Events&(unix.EPOLLOUT|unix.EPOLLHUP|unix.EPOLLERR) != 0 {
- if epfile := e.getConsole(int(ev.Fd)); epfile != nil {
- epfile.signalWrite()
- }
- }
- }
- }
-}
-
-// CloseConsole unregisters the console's file descriptor from epoll interface
-func (e *Epoller) CloseConsole(fd int) error {
- e.mu.Lock()
- defer e.mu.Unlock()
- delete(e.fdMapping, fd)
- return unix.EpollCtl(e.efd, unix.EPOLL_CTL_DEL, fd, &unix.EpollEvent{})
-}
-
-func (e *Epoller) getConsole(sysfd int) *EpollConsole {
- e.mu.Lock()
- f := e.fdMapping[sysfd]
- e.mu.Unlock()
- return f
-}
-
-// Close closes the epoll fd
-func (e *Epoller) Close() error {
- closeErr := os.ErrClosed // default to "file already closed"
- e.closeOnce.Do(func() {
- closeErr = unix.Close(e.efd)
- })
- return closeErr
-}
-
-// EpollConsole acts like a console but registers its file descriptor with an
-// epoll fd and uses epoll API to perform I/O.
-type EpollConsole struct {
- Console
- readc *sync.Cond
- writec *sync.Cond
- sysfd int
- closed bool
-}
-
-// Read reads up to len(p) bytes into p. It returns the number of bytes read
-// (0 <= n <= len(p)) and any error encountered.
-//
-// If the console's read returns EAGAIN or EIO, we assume that it's a
-// temporary error because the other side went away and wait for the signal
-// generated by epoll event to continue.
-func (ec *EpollConsole) Read(p []byte) (n int, err error) {
- var read int
- ec.readc.L.Lock()
- defer ec.readc.L.Unlock()
- for {
- read, err = ec.Console.Read(p[n:])
- n += read
- if err != nil {
- var hangup bool
- if perr, ok := err.(*os.PathError); ok {
- hangup = (perr.Err == unix.EAGAIN || perr.Err == unix.EIO)
- } else {
- hangup = (err == unix.EAGAIN || err == unix.EIO)
- }
- // if the other end disappear, assume this is temporary and wait for the
- // signal to continue again. Unless we didnt read anything and the
- // console is already marked as closed then we should exit
- if hangup && !(n == 0 && len(p) > 0 && ec.closed) {
- ec.readc.Wait()
- continue
- }
- }
- break
- }
- // if we didnt read anything then return io.EOF to end gracefully
- if n == 0 && len(p) > 0 && err == nil {
- err = io.EOF
- }
- // signal for others that we finished the read
- ec.readc.Signal()
- return n, err
-}
-
-// Writes len(p) bytes from p to the console. It returns the number of bytes
-// written from p (0 <= n <= len(p)) and any error encountered that caused
-// the write to stop early.
-//
-// If writes to the console returns EAGAIN or EIO, we assume that it's a
-// temporary error because the other side went away and wait for the signal
-// generated by epoll event to continue.
-func (ec *EpollConsole) Write(p []byte) (n int, err error) {
- var written int
- ec.writec.L.Lock()
- defer ec.writec.L.Unlock()
- for {
- written, err = ec.Console.Write(p[n:])
- n += written
- if err != nil {
- var hangup bool
- if perr, ok := err.(*os.PathError); ok {
- hangup = (perr.Err == unix.EAGAIN || perr.Err == unix.EIO)
- } else {
- hangup = (err == unix.EAGAIN || err == unix.EIO)
- }
- // if the other end disappears, assume this is temporary and wait for the
- // signal to continue again.
- if hangup {
- ec.writec.Wait()
- continue
- }
- }
- // unrecoverable error, break the loop and return the error
- break
- }
- if n < len(p) && err == nil {
- err = io.ErrShortWrite
- }
- // signal for others that we finished the write
- ec.writec.Signal()
- return n, err
-}
-
-// Shutdown closes the file descriptor and signals call waiters for this fd.
-// It accepts a callback which will be called with the console's fd. The
-// callback typically will be used to do further cleanup such as unregister the
-// console's fd from the epoll interface.
-// User should call Shutdown and wait for all I/O operation to be finished
-// before closing the console.
-func (ec *EpollConsole) Shutdown(close func(int) error) error {
- ec.readc.L.Lock()
- defer ec.readc.L.Unlock()
- ec.writec.L.Lock()
- defer ec.writec.L.Unlock()
-
- ec.readc.Broadcast()
- ec.writec.Broadcast()
- ec.closed = true
- return close(ec.sysfd)
-}
-
-// signalRead signals that the console is readable.
-func (ec *EpollConsole) signalRead() {
- ec.readc.L.Lock()
- ec.readc.Signal()
- ec.readc.L.Unlock()
-}
-
-// signalWrite signals that the console is writable.
-func (ec *EpollConsole) signalWrite() {
- ec.writec.L.Lock()
- ec.writec.Signal()
- ec.writec.L.Unlock()
-}
diff --git a/vendor/github.com/containerd/console/console_unix.go b/vendor/github.com/containerd/console/console_unix.go
deleted file mode 100644
index 161f5d12..00000000
--- a/vendor/github.com/containerd/console/console_unix.go
+++ /dev/null
@@ -1,157 +0,0 @@
-//go:build darwin || freebsd || linux || netbsd || openbsd || zos
-// +build darwin freebsd linux netbsd openbsd zos
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "golang.org/x/sys/unix"
-)
-
-// NewPty creates a new pty pair
-// The master is returned as the first console and a string
-// with the path to the pty slave is returned as the second
-func NewPty() (Console, string, error) {
- f, err := openpt()
- if err != nil {
- return nil, "", err
- }
- slave, err := ptsname(f)
- if err != nil {
- return nil, "", err
- }
- if err := unlockpt(f); err != nil {
- return nil, "", err
- }
- m, err := newMaster(f)
- if err != nil {
- return nil, "", err
- }
- return m, slave, nil
-}
-
-type master struct {
- f File
- original *unix.Termios
-}
-
-func (m *master) Read(b []byte) (int, error) {
- return m.f.Read(b)
-}
-
-func (m *master) Write(b []byte) (int, error) {
- return m.f.Write(b)
-}
-
-func (m *master) Close() error {
- return m.f.Close()
-}
-
-func (m *master) Resize(ws WinSize) error {
- return tcswinsz(m.f.Fd(), ws)
-}
-
-func (m *master) ResizeFrom(c Console) error {
- ws, err := c.Size()
- if err != nil {
- return err
- }
- return m.Resize(ws)
-}
-
-func (m *master) Reset() error {
- if m.original == nil {
- return nil
- }
- return tcset(m.f.Fd(), m.original)
-}
-
-func (m *master) getCurrent() (unix.Termios, error) {
- var termios unix.Termios
- if err := tcget(m.f.Fd(), &termios); err != nil {
- return unix.Termios{}, err
- }
- return termios, nil
-}
-
-func (m *master) SetRaw() error {
- rawState, err := m.getCurrent()
- if err != nil {
- return err
- }
- rawState = cfmakeraw(rawState)
- rawState.Oflag = rawState.Oflag | unix.OPOST
- return tcset(m.f.Fd(), &rawState)
-}
-
-func (m *master) DisableEcho() error {
- rawState, err := m.getCurrent()
- if err != nil {
- return err
- }
- rawState.Lflag = rawState.Lflag &^ unix.ECHO
- return tcset(m.f.Fd(), &rawState)
-}
-
-func (m *master) Size() (WinSize, error) {
- return tcgwinsz(m.f.Fd())
-}
-
-func (m *master) Fd() uintptr {
- return m.f.Fd()
-}
-
-func (m *master) Name() string {
- return m.f.Name()
-}
-
-// checkConsole checks if the provided file is a console
-func checkConsole(f File) error {
- var termios unix.Termios
- if tcget(f.Fd(), &termios) != nil {
- return ErrNotAConsole
- }
- return nil
-}
-
-func newMaster(f File) (Console, error) {
- m := &master{
- f: f,
- }
- t, err := m.getCurrent()
- if err != nil {
- return nil, err
- }
- m.original = &t
- return m, nil
-}
-
-// ClearONLCR sets the necessary tty_ioctl(4)s to ensure that a pty pair
-// created by us acts normally. In particular, a not-very-well-known default of
-// Linux unix98 ptys is that they have +onlcr by default. While this isn't a
-// problem for terminal emulators, because we relay data from the terminal we
-// also relay that funky line discipline.
-func ClearONLCR(fd uintptr) error {
- return setONLCR(fd, false)
-}
-
-// SetONLCR sets the necessary tty_ioctl(4)s to ensure that a pty pair
-// created by us acts as intended for a terminal emulator.
-func SetONLCR(fd uintptr) error {
- return setONLCR(fd, true)
-}
diff --git a/vendor/github.com/containerd/console/console_windows.go b/vendor/github.com/containerd/console/console_windows.go
deleted file mode 100644
index f48e4861..00000000
--- a/vendor/github.com/containerd/console/console_windows.go
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "errors"
- "fmt"
- "os"
-
- "golang.org/x/sys/windows"
-)
-
-var (
- vtInputSupported bool
- ErrNotImplemented = errors.New("not implemented")
-)
-
-func (m *master) initStdios() {
- // Note: We discard console mode warnings, because in/out can be redirected.
- //
- // TODO: Investigate opening CONOUT$/CONIN$ to handle this correctly
-
- m.in = windows.Handle(os.Stdin.Fd())
- if err := windows.GetConsoleMode(m.in, &m.inMode); err == nil {
- // Validate that windows.ENABLE_VIRTUAL_TERMINAL_INPUT is supported, but do not set it.
- if err = windows.SetConsoleMode(m.in, m.inMode|windows.ENABLE_VIRTUAL_TERMINAL_INPUT); err == nil {
- vtInputSupported = true
- }
- // Unconditionally set the console mode back even on failure because SetConsoleMode
- // remembers invalid bits on input handles.
- windows.SetConsoleMode(m.in, m.inMode)
- }
-
- m.out = windows.Handle(os.Stdout.Fd())
- if err := windows.GetConsoleMode(m.out, &m.outMode); err == nil {
- if err := windows.SetConsoleMode(m.out, m.outMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING); err == nil {
- m.outMode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
- } else {
- windows.SetConsoleMode(m.out, m.outMode)
- }
- }
-
- m.err = windows.Handle(os.Stderr.Fd())
- if err := windows.GetConsoleMode(m.err, &m.errMode); err == nil {
- if err := windows.SetConsoleMode(m.err, m.errMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING); err == nil {
- m.errMode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
- } else {
- windows.SetConsoleMode(m.err, m.errMode)
- }
- }
-}
-
-type master struct {
- in windows.Handle
- inMode uint32
-
- out windows.Handle
- outMode uint32
-
- err windows.Handle
- errMode uint32
-}
-
-func (m *master) SetRaw() error {
- if err := makeInputRaw(m.in, m.inMode); err != nil {
- return err
- }
-
- // Set StdOut and StdErr to raw mode, we ignore failures since
- // windows.DISABLE_NEWLINE_AUTO_RETURN might not be supported on this version of
- // Windows.
-
- windows.SetConsoleMode(m.out, m.outMode|windows.DISABLE_NEWLINE_AUTO_RETURN)
-
- windows.SetConsoleMode(m.err, m.errMode|windows.DISABLE_NEWLINE_AUTO_RETURN)
-
- return nil
-}
-
-func (m *master) Reset() error {
- var errs []error
-
- for _, s := range []struct {
- fd windows.Handle
- mode uint32
- }{
- {m.in, m.inMode},
- {m.out, m.outMode},
- {m.err, m.errMode},
- } {
- if err := windows.SetConsoleMode(s.fd, s.mode); err != nil {
- // we can't just abort on the first error, otherwise we might leave
- // the console in an unexpected state.
- errs = append(errs, fmt.Errorf("unable to restore console mode: %w", err))
- }
- }
-
- if len(errs) > 0 {
- return errs[0]
- }
-
- return nil
-}
-
-func (m *master) Size() (WinSize, error) {
- var info windows.ConsoleScreenBufferInfo
- err := windows.GetConsoleScreenBufferInfo(m.out, &info)
- if err != nil {
- return WinSize{}, fmt.Errorf("unable to get console info: %w", err)
- }
-
- winsize := WinSize{
- Width: uint16(info.Window.Right - info.Window.Left + 1),
- Height: uint16(info.Window.Bottom - info.Window.Top + 1),
- }
-
- return winsize, nil
-}
-
-func (m *master) Resize(ws WinSize) error {
- return ErrNotImplemented
-}
-
-func (m *master) ResizeFrom(c Console) error {
- return ErrNotImplemented
-}
-
-func (m *master) DisableEcho() error {
- mode := m.inMode &^ windows.ENABLE_ECHO_INPUT
- mode |= windows.ENABLE_PROCESSED_INPUT
- mode |= windows.ENABLE_LINE_INPUT
-
- if err := windows.SetConsoleMode(m.in, mode); err != nil {
- return fmt.Errorf("unable to set console to disable echo: %w", err)
- }
-
- return nil
-}
-
-func (m *master) Close() error {
- return nil
-}
-
-func (m *master) Read(b []byte) (int, error) {
- return os.Stdin.Read(b)
-}
-
-func (m *master) Write(b []byte) (int, error) {
- return os.Stdout.Write(b)
-}
-
-func (m *master) Fd() uintptr {
- return uintptr(m.in)
-}
-
-// on windows, console can only be made from os.Std{in,out,err}, hence there
-// isnt a single name here we can use. Return a dummy "console" value in this
-// case should be sufficient.
-func (m *master) Name() string {
- return "console"
-}
-
-// makeInputRaw puts the terminal (Windows Console) connected to the given
-// file descriptor into raw mode
-func makeInputRaw(fd windows.Handle, mode uint32) error {
- // See
- // -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx
- // -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms683462(v=vs.85).aspx
-
- // Disable these modes
- mode &^= windows.ENABLE_ECHO_INPUT
- mode &^= windows.ENABLE_LINE_INPUT
- mode &^= windows.ENABLE_MOUSE_INPUT
- mode &^= windows.ENABLE_WINDOW_INPUT
- mode &^= windows.ENABLE_PROCESSED_INPUT
-
- // Enable these modes
- mode |= windows.ENABLE_EXTENDED_FLAGS
- mode |= windows.ENABLE_INSERT_MODE
- mode |= windows.ENABLE_QUICK_EDIT_MODE
-
- if vtInputSupported {
- mode |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT
- }
-
- if err := windows.SetConsoleMode(fd, mode); err != nil {
- return fmt.Errorf("unable to set console to raw mode: %w", err)
- }
-
- return nil
-}
-
-func checkConsole(f File) error {
- var mode uint32
- if err := windows.GetConsoleMode(windows.Handle(f.Fd()), &mode); err != nil {
- return err
- }
- return nil
-}
-
-func newMaster(f File) (Console, error) {
- if f != os.Stdin && f != os.Stdout && f != os.Stderr {
- return nil, errors.New("creating a console from a file is not supported on windows")
- }
- m := &master{}
- m.initStdios()
- return m, nil
-}
diff --git a/vendor/github.com/containerd/console/pty_freebsd_cgo.go b/vendor/github.com/containerd/console/pty_freebsd_cgo.go
deleted file mode 100644
index 22368623..00000000
--- a/vendor/github.com/containerd/console/pty_freebsd_cgo.go
+++ /dev/null
@@ -1,46 +0,0 @@
-//go:build freebsd && cgo
-// +build freebsd,cgo
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "fmt"
- "os"
-)
-
-/*
-#include
-#include
-#include
-*/
-import "C"
-
-// openpt allocates a new pseudo-terminal and establishes a connection with its
-// control device.
-func openpt() (*os.File, error) {
- fd, err := C.posix_openpt(C.O_RDWR)
- if err != nil {
- return nil, fmt.Errorf("posix_openpt: %w", err)
- }
- if _, err := C.grantpt(fd); err != nil {
- C.close(fd)
- return nil, fmt.Errorf("grantpt: %w", err)
- }
- return os.NewFile(uintptr(fd), ""), nil
-}
diff --git a/vendor/github.com/containerd/console/pty_freebsd_nocgo.go b/vendor/github.com/containerd/console/pty_freebsd_nocgo.go
deleted file mode 100644
index ceb90a47..00000000
--- a/vendor/github.com/containerd/console/pty_freebsd_nocgo.go
+++ /dev/null
@@ -1,37 +0,0 @@
-//go:build freebsd && !cgo
-// +build freebsd,!cgo
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "os"
-)
-
-//
-// Implementing the functions below requires cgo support. Non-cgo stubs
-// versions are defined below to enable cross-compilation of source code
-// that depends on these functions, but the resultant cross-compiled
-// binaries cannot actually be used. If the stub function(s) below are
-// actually invoked they will display an error message and cause the
-// calling process to exit.
-//
-
-func openpt() (*os.File, error) {
- panic("openpt() support requires cgo.")
-}
diff --git a/vendor/github.com/containerd/console/pty_unix.go b/vendor/github.com/containerd/console/pty_unix.go
deleted file mode 100644
index f5a5b805..00000000
--- a/vendor/github.com/containerd/console/pty_unix.go
+++ /dev/null
@@ -1,31 +0,0 @@
-//go:build darwin || linux || netbsd || openbsd
-// +build darwin linux netbsd openbsd
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-// openpt allocates a new pseudo-terminal by opening the /dev/ptmx device
-func openpt() (*os.File, error) {
- return os.OpenFile("/dev/ptmx", unix.O_RDWR|unix.O_NOCTTY|unix.O_CLOEXEC, 0)
-}
diff --git a/vendor/github.com/containerd/console/pty_zos.go b/vendor/github.com/containerd/console/pty_zos.go
deleted file mode 100644
index 58f59aba..00000000
--- a/vendor/github.com/containerd/console/pty_zos.go
+++ /dev/null
@@ -1,43 +0,0 @@
-//go:build zos
-// +build zos
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "fmt"
- "os"
-)
-
-// openpt allocates a new pseudo-terminal by opening the first available /dev/ptypXX device
-func openpt() (*os.File, error) {
- var f *os.File
- var err error
- for i := 0; ; i++ {
- ptyp := fmt.Sprintf("/dev/ptyp%04d", i)
- f, err = os.OpenFile(ptyp, os.O_RDWR, 0600)
- if err == nil {
- break
- }
- if os.IsNotExist(err) {
- return nil, err
- }
- // else probably Resource Busy
- }
- return f, nil
-}
diff --git a/vendor/github.com/containerd/console/tc_darwin.go b/vendor/github.com/containerd/console/tc_darwin.go
deleted file mode 100644
index 78715458..00000000
--- a/vendor/github.com/containerd/console/tc_darwin.go
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "fmt"
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- cmdTcGet = unix.TIOCGETA
- cmdTcSet = unix.TIOCSETA
-)
-
-// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
-// unlockpt should be called before opening the slave side of a pty.
-func unlockpt(f *os.File) error {
- return unix.IoctlSetPointerInt(int(f.Fd()), unix.TIOCPTYUNLK, 0)
-}
-
-// ptsname retrieves the name of the first available pts for the given master.
-func ptsname(f *os.File) (string, error) {
- n, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCPTYGNAME)
- if err != nil {
- return "", err
- }
- return fmt.Sprintf("/dev/pts/%d", n), nil
-}
diff --git a/vendor/github.com/containerd/console/tc_freebsd_cgo.go b/vendor/github.com/containerd/console/tc_freebsd_cgo.go
deleted file mode 100644
index 33282579..00000000
--- a/vendor/github.com/containerd/console/tc_freebsd_cgo.go
+++ /dev/null
@@ -1,58 +0,0 @@
-//go:build freebsd && cgo
-// +build freebsd,cgo
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "fmt"
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-/*
-#include
-#include
-*/
-import "C"
-
-const (
- cmdTcGet = unix.TIOCGETA
- cmdTcSet = unix.TIOCSETA
-)
-
-// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
-// unlockpt should be called before opening the slave side of a pty.
-func unlockpt(f *os.File) error {
- fd := C.int(f.Fd())
- if _, err := C.unlockpt(fd); err != nil {
- C.close(fd)
- return fmt.Errorf("unlockpt: %w", err)
- }
- return nil
-}
-
-// ptsname retrieves the name of the first available pts for the given master.
-func ptsname(f *os.File) (string, error) {
- n, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN)
- if err != nil {
- return "", err
- }
- return fmt.Sprintf("/dev/pts/%d", n), nil
-}
diff --git a/vendor/github.com/containerd/console/tc_freebsd_nocgo.go b/vendor/github.com/containerd/console/tc_freebsd_nocgo.go
deleted file mode 100644
index 18a9b9cb..00000000
--- a/vendor/github.com/containerd/console/tc_freebsd_nocgo.go
+++ /dev/null
@@ -1,56 +0,0 @@
-//go:build freebsd && !cgo
-// +build freebsd,!cgo
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "fmt"
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- cmdTcGet = unix.TIOCGETA
- cmdTcSet = unix.TIOCSETA
-)
-
-//
-// Implementing the functions below requires cgo support. Non-cgo stubs
-// versions are defined below to enable cross-compilation of source code
-// that depends on these functions, but the resultant cross-compiled
-// binaries cannot actually be used. If the stub function(s) below are
-// actually invoked they will display an error message and cause the
-// calling process to exit.
-//
-
-// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
-// unlockpt should be called before opening the slave side of a pty.
-func unlockpt(f *os.File) error {
- panic("unlockpt() support requires cgo.")
-}
-
-// ptsname retrieves the name of the first available pts for the given master.
-func ptsname(f *os.File) (string, error) {
- n, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN)
- if err != nil {
- return "", err
- }
- return fmt.Sprintf("/dev/pts/%d", n), nil
-}
diff --git a/vendor/github.com/containerd/console/tc_linux.go b/vendor/github.com/containerd/console/tc_linux.go
deleted file mode 100644
index 7d552ea4..00000000
--- a/vendor/github.com/containerd/console/tc_linux.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "fmt"
- "os"
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- cmdTcGet = unix.TCGETS
- cmdTcSet = unix.TCSETS
-)
-
-// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
-// unlockpt should be called before opening the slave side of a pty.
-func unlockpt(f *os.File) error {
- var u int32
- // XXX do not use unix.IoctlSetPointerInt here, see commit dbd69c59b81.
- if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))); err != 0 {
- return err
- }
- return nil
-}
-
-// ptsname retrieves the name of the first available pts for the given master.
-func ptsname(f *os.File) (string, error) {
- var u uint32
- // XXX do not use unix.IoctlGetInt here, see commit dbd69c59b81.
- if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&u))); err != 0 {
- return "", err
- }
- return fmt.Sprintf("/dev/pts/%d", u), nil
-}
diff --git a/vendor/github.com/containerd/console/tc_netbsd.go b/vendor/github.com/containerd/console/tc_netbsd.go
deleted file mode 100644
index 71227aef..00000000
--- a/vendor/github.com/containerd/console/tc_netbsd.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "bytes"
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- cmdTcGet = unix.TIOCGETA
- cmdTcSet = unix.TIOCSETA
-)
-
-// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
-// unlockpt should be called before opening the slave side of a pty.
-// This does not exist on NetBSD, it does not allocate controlling terminals on open
-func unlockpt(f *os.File) error {
- return nil
-}
-
-// ptsname retrieves the name of the first available pts for the given master.
-func ptsname(f *os.File) (string, error) {
- ptm, err := unix.IoctlGetPtmget(int(f.Fd()), unix.TIOCPTSNAME)
- if err != nil {
- return "", err
- }
- return string(ptm.Sn[:bytes.IndexByte(ptm.Sn[:], 0)]), nil
-}
diff --git a/vendor/github.com/containerd/console/tc_openbsd_cgo.go b/vendor/github.com/containerd/console/tc_openbsd_cgo.go
deleted file mode 100644
index 0e76f6cc..00000000
--- a/vendor/github.com/containerd/console/tc_openbsd_cgo.go
+++ /dev/null
@@ -1,52 +0,0 @@
-//go:build openbsd && cgo
-// +build openbsd,cgo
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-//#include
-import "C"
-
-const (
- cmdTcGet = unix.TIOCGETA
- cmdTcSet = unix.TIOCSETA
-)
-
-// ptsname retrieves the name of the first available pts for the given master.
-func ptsname(f *os.File) (string, error) {
- ptspath, err := C.ptsname(C.int(f.Fd()))
- if err != nil {
- return "", err
- }
- return C.GoString(ptspath), nil
-}
-
-// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
-// unlockpt should be called before opening the slave side of a pty.
-func unlockpt(f *os.File) error {
- if _, err := C.grantpt(C.int(f.Fd())); err != nil {
- return err
- }
- return nil
-}
diff --git a/vendor/github.com/containerd/console/tc_openbsd_nocgo.go b/vendor/github.com/containerd/console/tc_openbsd_nocgo.go
deleted file mode 100644
index dca92418..00000000
--- a/vendor/github.com/containerd/console/tc_openbsd_nocgo.go
+++ /dev/null
@@ -1,48 +0,0 @@
-//go:build openbsd && !cgo
-// +build openbsd,!cgo
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-//
-// Implementing the functions below requires cgo support. Non-cgo stubs
-// versions are defined below to enable cross-compilation of source code
-// that depends on these functions, but the resultant cross-compiled
-// binaries cannot actually be used. If the stub function(s) below are
-// actually invoked they will display an error message and cause the
-// calling process to exit.
-//
-
-package console
-
-import (
- "os"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- cmdTcGet = unix.TIOCGETA
- cmdTcSet = unix.TIOCSETA
-)
-
-func ptsname(f *os.File) (string, error) {
- panic("ptsname() support requires cgo.")
-}
-
-func unlockpt(f *os.File) error {
- panic("unlockpt() support requires cgo.")
-}
diff --git a/vendor/github.com/containerd/console/tc_unix.go b/vendor/github.com/containerd/console/tc_unix.go
deleted file mode 100644
index f5053b2f..00000000
--- a/vendor/github.com/containerd/console/tc_unix.go
+++ /dev/null
@@ -1,92 +0,0 @@
-//go:build darwin || freebsd || linux || netbsd || openbsd || zos
-// +build darwin freebsd linux netbsd openbsd zos
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "golang.org/x/sys/unix"
-)
-
-func tcget(fd uintptr, p *unix.Termios) error {
- termios, err := unix.IoctlGetTermios(int(fd), cmdTcGet)
- if err != nil {
- return err
- }
- *p = *termios
- return nil
-}
-
-func tcset(fd uintptr, p *unix.Termios) error {
- return unix.IoctlSetTermios(int(fd), cmdTcSet, p)
-}
-
-func tcgwinsz(fd uintptr) (WinSize, error) {
- var ws WinSize
-
- uws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
- if err != nil {
- return ws, err
- }
-
- // Translate from unix.Winsize to console.WinSize
- ws.Height = uws.Row
- ws.Width = uws.Col
- ws.x = uws.Xpixel
- ws.y = uws.Ypixel
- return ws, nil
-}
-
-func tcswinsz(fd uintptr, ws WinSize) error {
- // Translate from console.WinSize to unix.Winsize
-
- var uws unix.Winsize
- uws.Row = ws.Height
- uws.Col = ws.Width
- uws.Xpixel = ws.x
- uws.Ypixel = ws.y
-
- return unix.IoctlSetWinsize(int(fd), unix.TIOCSWINSZ, &uws)
-}
-
-func setONLCR(fd uintptr, enable bool) error {
- var termios unix.Termios
- if err := tcget(fd, &termios); err != nil {
- return err
- }
- if enable {
- // Set +onlcr so we can act like a real terminal
- termios.Oflag |= unix.ONLCR
- } else {
- // Set -onlcr so we don't have to deal with \r.
- termios.Oflag &^= unix.ONLCR
- }
- return tcset(fd, &termios)
-}
-
-func cfmakeraw(t unix.Termios) unix.Termios {
- t.Iflag &^= (unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON)
- t.Oflag &^= unix.OPOST
- t.Lflag &^= (unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN)
- t.Cflag &^= (unix.CSIZE | unix.PARENB)
- t.Cflag &^= unix.CS8
- t.Cc[unix.VMIN] = 1
- t.Cc[unix.VTIME] = 0
-
- return t
-}
diff --git a/vendor/github.com/containerd/console/tc_zos.go b/vendor/github.com/containerd/console/tc_zos.go
deleted file mode 100644
index fc90ba5f..00000000
--- a/vendor/github.com/containerd/console/tc_zos.go
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package console
-
-import (
- "os"
- "strings"
-
- "golang.org/x/sys/unix"
-)
-
-const (
- cmdTcGet = unix.TCGETS
- cmdTcSet = unix.TCSETS
-)
-
-// unlockpt is a no-op on zos.
-func unlockpt(_ *os.File) error {
- return nil
-}
-
-// ptsname retrieves the name of the first available pts for the given master.
-func ptsname(f *os.File) (string, error) {
- return "/dev/ttyp" + strings.TrimPrefix(f.Name(), "/dev/ptyp"), nil
-}
diff --git a/vendor/github.com/erikgeiser/coninput/.gitignore b/vendor/github.com/erikgeiser/coninput/.gitignore
new file mode 100644
index 00000000..66fd13c9
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/.gitignore
@@ -0,0 +1,15 @@
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
diff --git a/vendor/github.com/erikgeiser/coninput/.golangci.yml b/vendor/github.com/erikgeiser/coninput/.golangci.yml
new file mode 100644
index 00000000..d3ed7103
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/.golangci.yml
@@ -0,0 +1,24 @@
+linters:
+ enable-all: true
+ disable:
+ - golint
+ - interfacer
+ - scopelint
+ - maligned
+ - rowserrcheck
+ - funlen
+ - depguard
+ - goerr113
+ - exhaustivestruct
+ - testpackage
+ - gochecknoglobals
+ - wrapcheck
+ - forbidigo
+ - ifshort
+ - cyclop
+ - gomoddirectives
+linters-settings:
+ exhaustive:
+ default-signifies-exhaustive: true
+issues:
+ exclude-use-default: false
diff --git a/vendor/github.com/erikgeiser/coninput/LICENSE b/vendor/github.com/erikgeiser/coninput/LICENSE
new file mode 100644
index 00000000..83c24408
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Erik G.
+
+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/erikgeiser/coninput/README.md b/vendor/github.com/erikgeiser/coninput/README.md
new file mode 100644
index 00000000..22619d13
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/README.md
@@ -0,0 +1,2 @@
+# coninput
+Go library for input handling using Windows Console API
diff --git a/vendor/github.com/erikgeiser/coninput/keycodes.go b/vendor/github.com/erikgeiser/coninput/keycodes.go
new file mode 100644
index 00000000..902ee1b7
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/keycodes.go
@@ -0,0 +1,205 @@
+package coninput
+
+// VirtualKeyCode holds a virtual key code (see
+// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes).
+type VirtualKeyCode uint16
+
+const (
+ VK_LBUTTON VirtualKeyCode = 0x01
+ VK_RBUTTON VirtualKeyCode = 0x02
+ VK_CANCEL VirtualKeyCode = 0x03
+ VK_MBUTTON VirtualKeyCode = 0x04
+ VK_XBUTTON1 VirtualKeyCode = 0x05
+ VK_XBUTTON2 VirtualKeyCode = 0x06
+ VK_BACK VirtualKeyCode = 0x08
+ VK_TAB VirtualKeyCode = 0x09
+ VK_CLEAR VirtualKeyCode = 0x0C
+ VK_RETURN VirtualKeyCode = 0x0D
+ VK_SHIFT VirtualKeyCode = 0x10
+ VK_CONTROL VirtualKeyCode = 0x11
+ VK_MENU VirtualKeyCode = 0x12
+ VK_PAUSE VirtualKeyCode = 0x13
+ VK_CAPITAL VirtualKeyCode = 0x14
+ VK_KANA VirtualKeyCode = 0x15
+ VK_HANGEUL VirtualKeyCode = 0x15
+ VK_HANGUL VirtualKeyCode = 0x15
+ VK_IME_ON VirtualKeyCode = 0x16
+ VK_JUNJA VirtualKeyCode = 0x17
+ VK_FINAL VirtualKeyCode = 0x18
+ VK_HANJA VirtualKeyCode = 0x19
+ VK_KANJI VirtualKeyCode = 0x19
+ VK_IME_OFF VirtualKeyCode = 0x1A
+ VK_ESCAPE VirtualKeyCode = 0x1B
+ VK_CONVERT VirtualKeyCode = 0x1C
+ VK_NONCONVERT VirtualKeyCode = 0x1D
+ VK_ACCEPT VirtualKeyCode = 0x1E
+ VK_MODECHANGE VirtualKeyCode = 0x1F
+ VK_SPACE VirtualKeyCode = 0x20
+ VK_PRIOR VirtualKeyCode = 0x21
+ VK_NEXT VirtualKeyCode = 0x22
+ VK_END VirtualKeyCode = 0x23
+ VK_HOME VirtualKeyCode = 0x24
+ VK_LEFT VirtualKeyCode = 0x25
+ VK_UP VirtualKeyCode = 0x26
+ VK_RIGHT VirtualKeyCode = 0x27
+ VK_DOWN VirtualKeyCode = 0x28
+ VK_SELECT VirtualKeyCode = 0x29
+ VK_PRINT VirtualKeyCode = 0x2A
+ VK_EXECUTE VirtualKeyCode = 0x2B
+ VK_SNAPSHOT VirtualKeyCode = 0x2C
+ VK_INSERT VirtualKeyCode = 0x2D
+ VK_DELETE VirtualKeyCode = 0x2E
+ VK_HELP VirtualKeyCode = 0x2F
+ VK_0 VirtualKeyCode = 0x30
+ VK_1 VirtualKeyCode = 0x31
+ VK_2 VirtualKeyCode = 0x32
+ VK_3 VirtualKeyCode = 0x33
+ VK_4 VirtualKeyCode = 0x34
+ VK_5 VirtualKeyCode = 0x35
+ VK_6 VirtualKeyCode = 0x36
+ VK_7 VirtualKeyCode = 0x37
+ VK_8 VirtualKeyCode = 0x38
+ VK_9 VirtualKeyCode = 0x39
+ VK_A VirtualKeyCode = 0x41
+ VK_B VirtualKeyCode = 0x42
+ VK_C VirtualKeyCode = 0x43
+ VK_D VirtualKeyCode = 0x44
+ VK_E VirtualKeyCode = 0x45
+ VK_F VirtualKeyCode = 0x46
+ VK_G VirtualKeyCode = 0x47
+ VK_H VirtualKeyCode = 0x48
+ VK_I VirtualKeyCode = 0x49
+ VK_J VirtualKeyCode = 0x4A
+ VK_K VirtualKeyCode = 0x4B
+ VK_L VirtualKeyCode = 0x4C
+ VK_M VirtualKeyCode = 0x4D
+ VK_N VirtualKeyCode = 0x4E
+ VK_O VirtualKeyCode = 0x4F
+ VK_P VirtualKeyCode = 0x50
+ VK_Q VirtualKeyCode = 0x51
+ VK_R VirtualKeyCode = 0x52
+ VK_S VirtualKeyCode = 0x53
+ VK_T VirtualKeyCode = 0x54
+ VK_U VirtualKeyCode = 0x55
+ VK_V VirtualKeyCode = 0x56
+ VK_W VirtualKeyCode = 0x57
+ VK_X VirtualKeyCode = 0x58
+ VK_Y VirtualKeyCode = 0x59
+ VK_Z VirtualKeyCode = 0x5A
+ VK_LWIN VirtualKeyCode = 0x5B
+ VK_RWIN VirtualKeyCode = 0x5C
+ VK_APPS VirtualKeyCode = 0x5D
+ VK_SLEEP VirtualKeyCode = 0x5F
+ VK_NUMPAD0 VirtualKeyCode = 0x60
+ VK_NUMPAD1 VirtualKeyCode = 0x61
+ VK_NUMPAD2 VirtualKeyCode = 0x62
+ VK_NUMPAD3 VirtualKeyCode = 0x63
+ VK_NUMPAD4 VirtualKeyCode = 0x64
+ VK_NUMPAD5 VirtualKeyCode = 0x65
+ VK_NUMPAD6 VirtualKeyCode = 0x66
+ VK_NUMPAD7 VirtualKeyCode = 0x67
+ VK_NUMPAD8 VirtualKeyCode = 0x68
+ VK_NUMPAD9 VirtualKeyCode = 0x69
+ VK_MULTIPLY VirtualKeyCode = 0x6A
+ VK_ADD VirtualKeyCode = 0x6B
+ VK_SEPARATOR VirtualKeyCode = 0x6C
+ VK_SUBTRACT VirtualKeyCode = 0x6D
+ VK_DECIMAL VirtualKeyCode = 0x6E
+ VK_DIVIDE VirtualKeyCode = 0x6F
+ VK_F1 VirtualKeyCode = 0x70
+ VK_F2 VirtualKeyCode = 0x71
+ VK_F3 VirtualKeyCode = 0x72
+ VK_F4 VirtualKeyCode = 0x73
+ VK_F5 VirtualKeyCode = 0x74
+ VK_F6 VirtualKeyCode = 0x75
+ VK_F7 VirtualKeyCode = 0x76
+ VK_F8 VirtualKeyCode = 0x77
+ VK_F9 VirtualKeyCode = 0x78
+ VK_F10 VirtualKeyCode = 0x79
+ VK_F11 VirtualKeyCode = 0x7A
+ VK_F12 VirtualKeyCode = 0x7B
+ VK_F13 VirtualKeyCode = 0x7C
+ VK_F14 VirtualKeyCode = 0x7D
+ VK_F15 VirtualKeyCode = 0x7E
+ VK_F16 VirtualKeyCode = 0x7F
+ VK_F17 VirtualKeyCode = 0x80
+ VK_F18 VirtualKeyCode = 0x81
+ VK_F19 VirtualKeyCode = 0x82
+ VK_F20 VirtualKeyCode = 0x83
+ VK_F21 VirtualKeyCode = 0x84
+ VK_F22 VirtualKeyCode = 0x85
+ VK_F23 VirtualKeyCode = 0x86
+ VK_F24 VirtualKeyCode = 0x87
+ VK_NUMLOCK VirtualKeyCode = 0x90
+ VK_SCROLL VirtualKeyCode = 0x91
+ VK_OEM_NEC_EQUAL VirtualKeyCode = 0x92
+ VK_OEM_FJ_JISHO VirtualKeyCode = 0x92
+ VK_OEM_FJ_MASSHOU VirtualKeyCode = 0x93
+ VK_OEM_FJ_TOUROKU VirtualKeyCode = 0x94
+ VK_OEM_FJ_LOYA VirtualKeyCode = 0x95
+ VK_OEM_FJ_ROYA VirtualKeyCode = 0x96
+ VK_LSHIFT VirtualKeyCode = 0xA0
+ VK_RSHIFT VirtualKeyCode = 0xA1
+ VK_LCONTROL VirtualKeyCode = 0xA2
+ VK_RCONTROL VirtualKeyCode = 0xA3
+ VK_LMENU VirtualKeyCode = 0xA4
+ VK_RMENU VirtualKeyCode = 0xA5
+ VK_BROWSER_BACK VirtualKeyCode = 0xA6
+ VK_BROWSER_FORWARD VirtualKeyCode = 0xA7
+ VK_BROWSER_REFRESH VirtualKeyCode = 0xA8
+ VK_BROWSER_STOP VirtualKeyCode = 0xA9
+ VK_BROWSER_SEARCH VirtualKeyCode = 0xAA
+ VK_BROWSER_FAVORITES VirtualKeyCode = 0xAB
+ VK_BROWSER_HOME VirtualKeyCode = 0xAC
+ VK_VOLUME_MUTE VirtualKeyCode = 0xAD
+ VK_VOLUME_DOWN VirtualKeyCode = 0xAE
+ VK_VOLUME_UP VirtualKeyCode = 0xAF
+ VK_MEDIA_NEXT_TRACK VirtualKeyCode = 0xB0
+ VK_MEDIA_PREV_TRACK VirtualKeyCode = 0xB1
+ VK_MEDIA_STOP VirtualKeyCode = 0xB2
+ VK_MEDIA_PLAY_PAUSE VirtualKeyCode = 0xB3
+ VK_LAUNCH_MAIL VirtualKeyCode = 0xB4
+ VK_LAUNCH_MEDIA_SELECT VirtualKeyCode = 0xB5
+ VK_LAUNCH_APP1 VirtualKeyCode = 0xB6
+ VK_LAUNCH_APP2 VirtualKeyCode = 0xB7
+ VK_OEM_1 VirtualKeyCode = 0xBA
+ VK_OEM_PLUS VirtualKeyCode = 0xBB
+ VK_OEM_COMMA VirtualKeyCode = 0xBC
+ VK_OEM_MINUS VirtualKeyCode = 0xBD
+ VK_OEM_PERIOD VirtualKeyCode = 0xBE
+ VK_OEM_2 VirtualKeyCode = 0xBF
+ VK_OEM_3 VirtualKeyCode = 0xC0
+ VK_OEM_4 VirtualKeyCode = 0xDB
+ VK_OEM_5 VirtualKeyCode = 0xDC
+ VK_OEM_6 VirtualKeyCode = 0xDD
+ VK_OEM_7 VirtualKeyCode = 0xDE
+ VK_OEM_8 VirtualKeyCode = 0xDF
+ VK_OEM_AX VirtualKeyCode = 0xE1
+ VK_OEM_102 VirtualKeyCode = 0xE2
+ VK_ICO_HELP VirtualKeyCode = 0xE3
+ VK_ICO_00 VirtualKeyCode = 0xE4
+ VK_PROCESSKEY VirtualKeyCode = 0xE5
+ VK_ICO_CLEAR VirtualKeyCode = 0xE6
+ VK_OEM_RESET VirtualKeyCode = 0xE9
+ VK_OEM_JUMP VirtualKeyCode = 0xEA
+ VK_OEM_PA1 VirtualKeyCode = 0xEB
+ VK_OEM_PA2 VirtualKeyCode = 0xEC
+ VK_OEM_PA3 VirtualKeyCode = 0xED
+ VK_OEM_WSCTRL VirtualKeyCode = 0xEE
+ VK_OEM_CUSEL VirtualKeyCode = 0xEF
+ VK_OEM_ATTN VirtualKeyCode = 0xF0
+ VK_OEM_FINISH VirtualKeyCode = 0xF1
+ VK_OEM_COPY VirtualKeyCode = 0xF2
+ VK_OEM_AUTO VirtualKeyCode = 0xF3
+ VK_OEM_ENLW VirtualKeyCode = 0xF4
+ VK_OEM_BACKTAB VirtualKeyCode = 0xF5
+ VK_ATTN VirtualKeyCode = 0xF6
+ VK_CRSEL VirtualKeyCode = 0xF7
+ VK_EXSEL VirtualKeyCode = 0xF8
+ VK_EREOF VirtualKeyCode = 0xF9
+ VK_PLAY VirtualKeyCode = 0xFA
+ VK_ZOOM VirtualKeyCode = 0xFB
+ VK_NONAME VirtualKeyCode = 0xFC
+ VK_PA1 VirtualKeyCode = 0xFD
+ VK_OEM_CLEAR VirtualKeyCode = 0xFE
+)
diff --git a/vendor/github.com/erikgeiser/coninput/mode.go b/vendor/github.com/erikgeiser/coninput/mode.go
new file mode 100644
index 00000000..e6d8bf44
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/mode.go
@@ -0,0 +1,82 @@
+//go:build windows
+// +build windows
+
+package coninput
+
+import (
+ "strings"
+
+ "golang.org/x/sys/windows"
+)
+
+// AddInputModes returns the given mode with one or more additional modes enabled.
+func AddInputModes(mode uint32, enableModes ...uint32) uint32 {
+ for _, enableMode := range enableModes {
+ mode |= enableMode
+ }
+
+ return mode
+}
+
+// RemoveInputModes returns the given mode with one or more additional modes disabled.
+func RemoveInputModes(mode uint32, disableModes ...uint32) uint32 {
+ for _, disableMode := range disableModes {
+ mode &^= disableMode
+ }
+
+ return mode
+}
+
+// ToggleInputModes returns the given mode with one or more additional modes toggeled.
+func ToggleInputModes(mode uint32, toggleModes ...uint32) uint32 {
+ for _, toggeMode := range toggleModes {
+ mode ^= toggeMode
+ }
+
+ return mode
+}
+
+var inputModes = []struct {
+ mode uint32
+ name string
+}{
+ {mode: windows.ENABLE_ECHO_INPUT, name: "ENABLE_ECHO_INPUT"},
+ {mode: windows.ENABLE_INSERT_MODE, name: "ENABLE_INSERT_MODE"},
+ {mode: windows.ENABLE_LINE_INPUT, name: "ENABLE_LINE_INPUT"},
+ {mode: windows.ENABLE_MOUSE_INPUT, name: "ENABLE_MOUSE_INPUT"},
+ {mode: windows.ENABLE_PROCESSED_INPUT, name: "ENABLE_PROCESSED_INPUT"},
+ {mode: windows.ENABLE_QUICK_EDIT_MODE, name: "ENABLE_QUICK_EDIT_MODE"},
+ {mode: windows.ENABLE_WINDOW_INPUT, name: "ENABLE_WINDOW_INPUT"},
+ {mode: windows.ENABLE_VIRTUAL_TERMINAL_INPUT, name: "ENABLE_VIRTUAL_TERMINAL_INPUT"},
+}
+
+// ListInputMode returnes the isolated enabled input modes as a list.
+func ListInputModes(mode uint32) []uint32 {
+ modes := []uint32{}
+
+ for _, inputMode := range inputModes {
+ if mode&inputMode.mode > 0 {
+ modes = append(modes, inputMode.mode)
+ }
+ }
+
+ return modes
+}
+
+// ListInputMode returnes the isolated enabled input mode names as a list.
+func ListInputModeNames(mode uint32) []string {
+ modes := []string{}
+
+ for _, inputMode := range inputModes {
+ if mode&inputMode.mode > 0 {
+ modes = append(modes, inputMode.name)
+ }
+ }
+
+ return modes
+}
+
+// DescribeInputMode returns a string containing the names of each enabled input mode.
+func DescribeInputMode(mode uint32) string {
+ return strings.Join(ListInputModeNames(mode), "|")
+}
diff --git a/vendor/github.com/erikgeiser/coninput/read.go b/vendor/github.com/erikgeiser/coninput/read.go
new file mode 100644
index 00000000..b2dd82f1
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/read.go
@@ -0,0 +1,154 @@
+//go:build windows
+// +build windows
+
+package coninput
+
+import (
+ "fmt"
+ "syscall"
+ "unsafe"
+
+ "golang.org/x/sys/windows"
+)
+
+var (
+ modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
+ procReadConsoleInputW = modkernel32.NewProc("ReadConsoleInputW")
+ procPeekConsoleInputW = modkernel32.NewProc("PeekConsoleInputW")
+ procGetNumberOfConsoleInputEvents = modkernel32.NewProc("GetNumberOfConsoleInputEvents")
+ procFlushConsoleInputBuffer = modkernel32.NewProc("FlushConsoleInputBuffer")
+)
+
+// NewStdinHandle is a shortcut for windows.GetStdHandle(windows.STD_INPUT_HANDLE).
+func NewStdinHandle() (windows.Handle, error) {
+ return windows.GetStdHandle(windows.STD_INPUT_HANDLE)
+}
+
+// WinReadConsoleInput is a thin wrapper around the Windows console API function
+// ReadConsoleInput (see
+// https://docs.microsoft.com/en-us/windows/console/readconsoleinput). In most
+// cases it is more practical to either use ReadConsoleInput or
+// ReadNConsoleInputs.
+func WinReadConsoleInput(consoleInput windows.Handle, buffer *InputRecord,
+ length uint32, numberOfEventsRead *uint32) error {
+ r, _, e := syscall.Syscall6(procReadConsoleInputW.Addr(), 4,
+ uintptr(consoleInput), uintptr(unsafe.Pointer(buffer)), uintptr(length),
+ uintptr(unsafe.Pointer(numberOfEventsRead)), 0, 0)
+ if r == 0 {
+ return error(e)
+ }
+
+ return nil
+}
+
+// ReadNConsoleInputs is a wrapper around ReadConsoleInput (see
+// https://docs.microsoft.com/en-us/windows/console/readconsoleinput) that
+// automates the event buffer allocation in oder to provide io.Reader-like
+// sematics. maxEvents must be greater than zero.
+func ReadNConsoleInputs(console windows.Handle, maxEvents uint32) ([]InputRecord, error) {
+ if maxEvents == 0 {
+ return nil, fmt.Errorf("maxEvents cannot be zero")
+ }
+
+ var inputRecords = make([]InputRecord, maxEvents)
+ n, err := ReadConsoleInput(console, inputRecords)
+
+ return inputRecords[:n], err
+}
+
+// ReadConsoleInput provides an ideomatic interface to the Windows console API
+// function ReadConsoleInput (see
+// https://docs.microsoft.com/en-us/windows/console/readconsoleinput). The size
+// of inputRecords must be greater than zero.
+func ReadConsoleInput(console windows.Handle, inputRecords []InputRecord) (uint32, error) {
+ if len(inputRecords) == 0 {
+ return 0, fmt.Errorf("size of input record buffer cannot be zero")
+ }
+
+ var read uint32
+ err := WinReadConsoleInput(console, &inputRecords[0], uint32(len(inputRecords)), &read)
+
+ return read, err
+}
+
+// WinPeekConsoleInput is a thin wrapper around the Windows console API function
+// PeekConsoleInput (see
+// https://docs.microsoft.com/en-us/windows/console/peekconsoleinput). In most
+// cases it is more practical to either use PeekConsoleInput or
+// PeekNConsoleInputs.
+func WinPeekConsoleInput(consoleInput windows.Handle, buffer *InputRecord,
+ length uint32, numberOfEventsRead *uint32) error {
+ r, _, e := syscall.Syscall6(procPeekConsoleInputW.Addr(), 4,
+ uintptr(consoleInput), uintptr(unsafe.Pointer(buffer)), uintptr(length),
+ uintptr(unsafe.Pointer(numberOfEventsRead)), 0, 0)
+ if r == 0 {
+ return error(e)
+ }
+
+ return nil
+
+}
+
+// PeekNConsoleInputs is a wrapper around PeekConsoleInput (see
+// https://docs.microsoft.com/en-us/windows/console/peekconsoleinput) that
+// automates the event buffer allocation in oder to provide io.Reader-like
+// sematics. maxEvents must be greater than zero.
+func PeekNConsoleInputs(console windows.Handle, maxEvents uint32) ([]InputRecord, error) {
+ if maxEvents == 0 {
+ return nil, fmt.Errorf("maxEvents cannot be zero")
+ }
+
+ var inputRecords = make([]InputRecord, maxEvents)
+ n, err := PeekConsoleInput(console, inputRecords)
+
+ return inputRecords[:n], err
+}
+
+// PeekConsoleInput provides an ideomatic interface to the Windows console API
+// function PeekConsoleInput (see
+// https://docs.microsoft.com/en-us/windows/console/peekconsoleinput). The size
+// of inputRecords must be greater than zero.
+func PeekConsoleInput(console windows.Handle, inputRecords []InputRecord) (uint32, error) {
+ if len(inputRecords) == 0 {
+ return 0, fmt.Errorf("size of input record buffer cannot be zero")
+ }
+
+ var read uint32
+
+ err := WinPeekConsoleInput(console, &inputRecords[0], uint32(len(inputRecords)), &read)
+
+ return read, err
+}
+
+// WinGetNumberOfConsoleInputEvents provides an ideomatic interface to the
+// Windows console API function GetNumberOfConsoleInputEvents (see
+// https://docs.microsoft.com/en-us/windows/console/getnumberofconsoleinputevents).
+func WinGetNumberOfConsoleInputEvents(consoleInput windows.Handle, numberOfEvents *uint32) error {
+ r, _, e := syscall.Syscall6(procGetNumberOfConsoleInputEvents.Addr(), 2,
+ uintptr(consoleInput), uintptr(unsafe.Pointer(numberOfEvents)), 0,
+ 0, 0, 0)
+ if r == 0 {
+ return error(e)
+ }
+
+ return nil
+}
+
+// GetNumberOfConsoleInputEvents provides an ideomatic interface to the Windows
+// console API function GetNumberOfConsoleInputEvents (see
+// https://docs.microsoft.com/en-us/windows/console/getnumberofconsoleinputevents).
+func GetNumberOfConsoleInputEvents(console windows.Handle) (uint32, error) {
+ var nEvents uint32
+ err := WinGetNumberOfConsoleInputEvents(console, &nEvents)
+
+ return nEvents, err
+}
+
+func FlushConsoleInputBuffer(consoleInput windows.Handle) error {
+ r, _, e := syscall.Syscall(procFlushConsoleInputBuffer.Addr(), 1, uintptr(consoleInput), 0, 0)
+ if r == 0 {
+ return error(e)
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/erikgeiser/coninput/records.go b/vendor/github.com/erikgeiser/coninput/records.go
new file mode 100644
index 00000000..cccf7fbf
--- /dev/null
+++ b/vendor/github.com/erikgeiser/coninput/records.go
@@ -0,0 +1,486 @@
+package coninput
+
+import (
+ "encoding/binary"
+ "fmt"
+ "strconv"
+ "strings"
+)
+
+const (
+ maxEventSize = 16
+ wordPaddingBytes = 2
+)
+
+// EventType denots the type of an event
+type EventType uint16
+
+// EventUnion is the union data type that contains the data for any event.
+type EventUnion [maxEventSize]byte
+
+// InputRecord corresponds to the INPUT_RECORD structure from the Windows
+// console API (see
+// https://docs.microsoft.com/en-us/windows/console/input-record-str).
+type InputRecord struct {
+ // EventType specifies the type of event that helt in Event.
+ EventType EventType
+
+ // Padding of the 16-bit EventType to a whole 32-bit dword.
+ _ [wordPaddingBytes]byte
+
+ // Event holds the actual event data. Use Unrap to access it as its
+ // respective event type.
+ Event EventUnion
+}
+
+// String implements fmt.Stringer for InputRecord.
+func (ir InputRecord) String() string {
+ return ir.Unwrap().String()
+}
+
+// Unwrap parses the event data into an EventRecord of the respective event
+// type. The data in the returned EventRecord does not contain any references to
+// the passed InputRecord.
+func (ir InputRecord) Unwrap() EventRecord {
+ switch ir.EventType {
+ case FocusEventType:
+ return FocusEventRecord{SetFocus: ir.Event[0] > 0}
+ case KeyEventType:
+ return KeyEventRecord{
+ KeyDown: binary.LittleEndian.Uint32(ir.Event[0:4]) > 0,
+ RepeatCount: binary.LittleEndian.Uint16(ir.Event[4:6]),
+ VirtualKeyCode: VirtualKeyCode(binary.LittleEndian.Uint16(ir.Event[6:8])),
+ VirtualScanCode: VirtualKeyCode(binary.LittleEndian.Uint16(ir.Event[8:10])),
+ Char: rune(binary.LittleEndian.Uint16(ir.Event[10:12])),
+ ControlKeyState: ControlKeyState(binary.LittleEndian.Uint32(ir.Event[12:16])),
+ }
+ case MouseEventType:
+ m := MouseEventRecord{
+ MousePositon: Coord{
+ X: binary.LittleEndian.Uint16(ir.Event[0:2]),
+ Y: binary.LittleEndian.Uint16(ir.Event[2:4]),
+ },
+ ButtonState: ButtonState(binary.LittleEndian.Uint32(ir.Event[4:8])),
+ ControlKeyState: ControlKeyState(binary.LittleEndian.Uint32(ir.Event[8:12])),
+ EventFlags: EventFlags(binary.LittleEndian.Uint32(ir.Event[12:16])),
+ }
+
+ if (m.EventFlags&MOUSE_WHEELED > 0) || (m.EventFlags&MOUSE_HWHEELED > 0) {
+ if int16(highWord(uint32(m.ButtonState))) > 0 {
+ m.WheelDirection = 1
+ } else {
+ m.WheelDirection = -1
+ }
+ }
+
+ return m
+ case WindowBufferSizeEventType:
+ return WindowBufferSizeEventRecord{
+ Size: Coord{
+ X: binary.LittleEndian.Uint16(ir.Event[0:2]),
+ Y: binary.LittleEndian.Uint16(ir.Event[2:4]),
+ },
+ }
+ case MenuEventType:
+ return MenuEventRecord{
+ CommandID: binary.LittleEndian.Uint32(ir.Event[0:4]),
+ }
+ default:
+ return &UnknownEvent{InputRecord: ir}
+ }
+}
+
+// EventRecord represents one of the following event types:
+// TypeFocusEventRecord, TypeKeyEventRecord, TypeMouseEventRecord,
+// TypeWindowBufferSizeEvent, TypeMenuEventRecord and UnknownEvent.
+type EventRecord interface {
+ Type() string
+ fmt.Stringer
+}
+
+// FocusEventType is the event type for a FocusEventRecord (see
+// https://docs.microsoft.com/en-us/windows/console/input-record-str).
+const FocusEventType EventType = 0x0010
+
+// FocusEventRecord represent the FOCUS_EVENT_RECORD structure from the Windows
+// console API (see
+// https://docs.microsoft.com/en-us/windows/console/focus-event-record-str).
+// These events are used internally by the Windows console API and should be
+// ignored.
+type FocusEventRecord struct {
+ // SetFocus is reserved and should not be used.
+ SetFocus bool
+}
+
+// Ensure that FocusEventRecord satisfies EventRecord interface.
+var _ EventRecord = FocusEventRecord{}
+
+// Type ensures that FocusEventRecord satisfies EventRecord interface.
+func (e FocusEventRecord) Type() string { return "FocusEvent" }
+
+// String ensures that FocusEventRecord satisfies EventRecord and fmt.Stringer
+// interfaces.
+func (e FocusEventRecord) String() string { return fmt.Sprintf("%s[%v]", e.Type(), e.SetFocus) }
+
+// KeyEventType is the event type for a KeyEventRecord (see
+// https://docs.microsoft.com/en-us/windows/console/input-record-str).
+const KeyEventType EventType = 0x0001
+
+// KeyEventRecord represent the KEY_EVENT_RECORD structure from the Windows
+// console API (see
+// https://docs.microsoft.com/en-us/windows/console/key-event-record-str).
+type KeyEventRecord struct {
+ // KeyDown specified whether the key is pressed or released.
+ KeyDown bool
+
+ // RepeatCount indicates that a key is being held down. For example, when a
+ // key is held down, five events with RepeatCount equal to 1 may be
+ // generated, one event with RepeatCount equal to 5, or multiple events
+ // with RepeatCount greater than or equal to 1.
+ RepeatCount uint16
+
+ // VirtualKeyCode identifies the given key in a device-independent manner
+ // (see
+ // https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes).
+ VirtualKeyCode VirtualKeyCode
+
+ // VirtualScanCode represents the device-dependent value generated by the
+ // keyboard hardware.
+ VirtualScanCode VirtualKeyCode
+
+ // Char is the character that corresponds to the pressed key. Char can be
+ // zero for some keys.
+ Char rune
+
+ //ControlKeyState holds the state of the control keys.
+ ControlKeyState ControlKeyState
+}
+
+// Ensure that KeyEventRecord satisfies EventRecord interface.
+var _ EventRecord = KeyEventRecord{}
+
+// Type ensures that KeyEventRecord satisfies EventRecord interface.
+func (e KeyEventRecord) Type() string { return "KeyEvent" }
+
+// String ensures that KeyEventRecord satisfies EventRecord and fmt.Stringer
+// interfaces.
+func (e KeyEventRecord) String() string {
+ infos := []string{}
+
+ repeat := ""
+ if e.RepeatCount > 1 {
+ repeat = "x" + strconv.Itoa(int(e.RepeatCount))
+ }
+
+ infos = append(infos, fmt.Sprintf("%q%s", e.Char, repeat))
+
+ direction := "up"
+ if e.KeyDown {
+ direction = "down"
+ }
+
+ infos = append(infos, direction)
+
+ if e.ControlKeyState != NO_CONTROL_KEY {
+ infos = append(infos, e.ControlKeyState.String())
+ }
+
+ infos = append(infos, fmt.Sprintf("KeyCode: %d", e.VirtualKeyCode))
+ infos = append(infos, fmt.Sprintf("ScanCode: %d", e.VirtualScanCode))
+
+ return fmt.Sprintf("%s[%s]", e.Type(), strings.Join(infos, ", "))
+}
+
+// MenuEventType is the event type for a MenuEventRecord (see
+// https://docs.microsoft.com/en-us/windows/console/input-record-str).
+const MenuEventType EventType = 0x0008
+
+// MenuEventRecord represent the MENU_EVENT_RECORD structure from the Windows
+// console API (see
+// https://docs.microsoft.com/en-us/windows/console/menu-event-record-str).
+// These events are deprecated by the Windows console API and should be ignored.
+type MenuEventRecord struct {
+ CommandID uint32
+}
+
+// Ensure that MenuEventRecord satisfies EventRecord interface.
+var _ EventRecord = MenuEventRecord{}
+
+// Type ensures that MenuEventRecord satisfies EventRecord interface.
+func (e MenuEventRecord) Type() string { return "MenuEvent" }
+
+// String ensures that MenuEventRecord satisfies EventRecord and fmt.Stringer
+// interfaces.
+func (e MenuEventRecord) String() string { return fmt.Sprintf("MenuEvent[%d]", e.CommandID) }
+
+// MouseEventType is the event type for a MouseEventRecord (see
+// https://docs.microsoft.com/en-us/windows/console/input-record-str).
+const MouseEventType EventType = 0x0002
+
+// MouseEventRecord represent the MOUSE_EVENT_RECORD structure from the Windows
+// console API (see
+// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str).
+type MouseEventRecord struct {
+ // MousePosition contains the location of the cursor, in terms of the
+ // console screen buffer's character-cell coordinates.
+ MousePositon Coord
+
+ // ButtonState holds the status of the mouse buttons.
+ ButtonState ButtonState
+
+ // ControlKeyState holds the state of the control keys.
+ ControlKeyState ControlKeyState
+
+ // EventFlags specify tge type of mouse event.
+ EventFlags EventFlags
+
+ // WheelDirection specified the direction in which the mouse wheel is
+ // spinning when EventFlags contains MOUSE_HWHEELED or MOUSE_WHEELED. When
+ // the event flags specify MOUSE_WHEELED it is 1 if the wheel rotated
+ // forward (away from the user) or -1 when it rotates backwards. When
+ // MOUSE_HWHEELED is specified it is 1 when the wheel rotates right and -1
+ // when it rotates left. When the EventFlags do not indicate a mouse wheel
+ // event it is 0.
+ WheelDirection int
+}
+
+// Ensure that MouseEventRecord satisfies EventRecord interface.
+var _ EventRecord = MouseEventRecord{}
+
+func (e MouseEventRecord) WheelDirectionName() string {
+ if e.EventFlags&MOUSE_WHEELED > 0 {
+ if e.WheelDirection > 0 {
+ return "Forward"
+ }
+
+ return "Backward"
+ } else if e.EventFlags&MOUSE_HWHEELED > 0 {
+ if e.WheelDirection > 0 {
+ return "Right"
+ }
+
+ return "Left"
+ }
+
+ return ""
+}
+
+// Type ensures that MouseEventRecord satisfies EventRecord interface.
+func (e MouseEventRecord) Type() string { return "MouseEvent" }
+
+// String ensures that MouseEventRecord satisfies EventRecord and fmt.Stringer
+// interfaces.
+func (e MouseEventRecord) String() string {
+ infos := []string{e.MousePositon.String()}
+
+ if e.ButtonState&0xFF != 0 {
+ infos = append(infos, e.ButtonState.String())
+ }
+
+ eventDescription := e.EventFlags.String()
+
+ wheelDirection := e.WheelDirectionName()
+ if wheelDirection != "" {
+ eventDescription += "(" + wheelDirection + ")"
+ }
+
+ infos = append(infos, eventDescription)
+
+ if e.ControlKeyState != NO_CONTROL_KEY {
+ infos = append(infos, e.ControlKeyState.String())
+ }
+
+ return fmt.Sprintf("%s[%s]", e.Type(), strings.Join(infos, ", "))
+}
+
+// WindowBufferSizeEventType is the event type for a WindowBufferSizeEventRecord
+// (see https://docs.microsoft.com/en-us/windows/console/input-record-str).
+const WindowBufferSizeEventType EventType = 0x0004
+
+// WindowBufferSizeEventRecord represent the WINDOW_BUFFER_SIZE_RECORD structure
+// from the Windows console API (see
+// https://docs.microsoft.com/en-us/windows/console/window-buffer-size-record-str).
+type WindowBufferSizeEventRecord struct {
+ // Size contains the size of the console screen buffer, in character cell columns and rows.
+ Size Coord
+}
+
+// Ensure that WindowBufferSizeEventRecord satisfies EventRecord interface.
+var _ EventRecord = WindowBufferSizeEventRecord{}
+
+// Type ensures that WindowBufferSizeEventRecord satisfies EventRecord interface.
+func (e WindowBufferSizeEventRecord) Type() string { return "WindowBufferSizeEvent" }
+
+// String ensures that WindowBufferSizeEventRecord satisfies EventRecord and fmt.Stringer
+// interfaces.
+func (e WindowBufferSizeEventRecord) String() string {
+ return fmt.Sprintf("WindowBufferSizeEvent[%s]", e.Size)
+}
+
+// UnknownEvent is generated when the event type does not match one of the
+// following types: TypeFocusEventRecord, TypeKeyEventRecord,
+// TypeMouseEventRecord, TypeWindowBufferSizeEvent, TypeMenuEventRecord and
+// UnknownEvent.
+type UnknownEvent struct {
+ InputRecord
+}
+
+// Ensure that UnknownEvent satisfies EventRecord interface.
+var _ EventRecord = UnknownEvent{}
+
+// Type ensures that UnknownEvent satisfies EventRecord interface.
+func (e UnknownEvent) Type() string { return "UnknownEvent" }
+
+// String ensures that UnknownEvent satisfies EventRecord and fmt.Stringer
+// interfaces.
+func (e UnknownEvent) String() string {
+ return fmt.Sprintf("%s[Type: %d, Data: %v]", e.Type(), e.InputRecord.EventType, e.InputRecord.Event[:])
+}
+
+// Coord represent the COORD structure from the Windows
+// console API (see https://docs.microsoft.com/en-us/windows/console/coord-str).
+type Coord struct {
+ // X is the horizontal coordinate or column value. The units depend on the function call.
+ X uint16
+ // Y is the vertical coordinate or row value. The units depend on the function call.
+ Y uint16
+}
+
+// String ensures that Coord satisfies the fmt.Stringer interface.
+func (c Coord) String() string {
+ return fmt.Sprintf("(%d, %d)", c.X, c.Y)
+}
+
+// ButtonState holds the state of the mouse buttons (see
+// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str).
+type ButtonState uint32
+
+func (bs ButtonState) Contains(state ButtonState) bool {
+ return bs&state > 0
+}
+
+// String ensures that ButtonState satisfies the fmt.Stringer interface.
+func (bs ButtonState) String() string {
+ switch {
+ case bs&FROM_LEFT_1ST_BUTTON_PRESSED > 0:
+ return "Left"
+ case bs&FROM_LEFT_2ND_BUTTON_PRESSED > 0:
+ return "2"
+ case bs&FROM_LEFT_3RD_BUTTON_PRESSED > 0:
+ return "3"
+ case bs&FROM_LEFT_4TH_BUTTON_PRESSED > 0:
+ return "4"
+ case bs&RIGHTMOST_BUTTON_PRESSED > 0:
+ return "Right"
+ case bs&0xFF == 0:
+ return "No Button"
+ default:
+ return fmt.Sprintf("Unknown(%d)", bs)
+ }
+}
+
+func (bs ButtonState) IsReleased() bool {
+ return bs&0xff > 0
+}
+
+// Valid values for ButtonState.
+const (
+ FROM_LEFT_1ST_BUTTON_PRESSED ButtonState = 0x0001
+ RIGHTMOST_BUTTON_PRESSED ButtonState = 0x0002
+ FROM_LEFT_2ND_BUTTON_PRESSED ButtonState = 0x0004
+ FROM_LEFT_3RD_BUTTON_PRESSED ButtonState = 0x0008
+ FROM_LEFT_4TH_BUTTON_PRESSED ButtonState = 0x0010
+)
+
+// ControlKeyState holds the state of the control keys for key and mouse events
+// (see https://docs.microsoft.com/en-us/windows/console/key-event-record-str
+// and https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str).
+type ControlKeyState uint32
+
+func (cks ControlKeyState) Contains(state ControlKeyState) bool {
+ return cks&state > 0
+}
+
+// Valid values for ControlKeyState.
+const (
+ CAPSLOCK_ON ControlKeyState = 0x0080
+ ENHANCED_KEY ControlKeyState = 0x0100
+ LEFT_ALT_PRESSED ControlKeyState = 0x0002
+ LEFT_CTRL_PRESSED ControlKeyState = 0x0008
+ NUMLOCK_ON ControlKeyState = 0x0020
+ RIGHT_ALT_PRESSED ControlKeyState = 0x0001
+ RIGHT_CTRL_PRESSED ControlKeyState = 0x0004
+ SCROLLLOCK_ON ControlKeyState = 0x0040
+ SHIFT_PRESSED ControlKeyState = 0x0010
+ NO_CONTROL_KEY ControlKeyState = 0x0000
+)
+
+// String ensures that ControlKeyState satisfies the fmt.Stringer interface.
+func (cks ControlKeyState) String() string {
+ controlKeys := []string{}
+
+ switch {
+ case cks&CAPSLOCK_ON > 0:
+ controlKeys = append(controlKeys, "CapsLock")
+ case cks&ENHANCED_KEY > 0:
+ controlKeys = append(controlKeys, "Enhanced")
+ case cks&LEFT_ALT_PRESSED > 0:
+ controlKeys = append(controlKeys, "Alt")
+ case cks&LEFT_CTRL_PRESSED > 0:
+ controlKeys = append(controlKeys, "CTRL")
+ case cks&NUMLOCK_ON > 0:
+ controlKeys = append(controlKeys, "NumLock")
+ case cks&RIGHT_ALT_PRESSED > 0:
+ controlKeys = append(controlKeys, "RightAlt")
+ case cks&RIGHT_CTRL_PRESSED > 0:
+ controlKeys = append(controlKeys, "RightCTRL")
+ case cks&SCROLLLOCK_ON > 0:
+ controlKeys = append(controlKeys, "ScrollLock")
+ case cks&SHIFT_PRESSED > 0:
+ controlKeys = append(controlKeys, "Shift")
+ case cks == NO_CONTROL_KEY:
+ default:
+ return fmt.Sprintf("Unknown(%d)", cks)
+ }
+
+ return strings.Join(controlKeys, ",")
+}
+
+// EventFlags specifies the type of a mouse event (see
+// https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str).
+type EventFlags uint32
+
+// String ensures that EventFlags satisfies the fmt.Stringer interface.
+func (ef EventFlags) String() string {
+ switch {
+ case ef&DOUBLE_CLICK > 0:
+ return "DoubleClick"
+ case ef&MOUSE_WHEELED > 0:
+ return "Wheeled"
+ case ef&MOUSE_MOVED > 0:
+ return "Moved"
+ case ef&MOUSE_HWHEELED > 0:
+ return "HWheeld"
+ case ef == CLICK:
+ return "Click"
+ default:
+ return fmt.Sprintf("Unknown(%d)", ef)
+ }
+}
+
+func (ef EventFlags) Contains(flag EventFlags) bool {
+ return ef&flag > 0
+}
+
+// Valid values for EventFlags.
+const (
+ CLICK EventFlags = 0x0000
+ MOUSE_MOVED EventFlags = 0x0001
+ DOUBLE_CLICK EventFlags = 0x0002
+ MOUSE_WHEELED EventFlags = 0x0004
+ MOUSE_HWHEELED EventFlags = 0x0008
+)
+
+func highWord(data uint32) uint16 {
+ return uint16((data & 0xFFFF0000) >> 16)
+}
diff --git a/vendor/github.com/muesli/ansi/README.md b/vendor/github.com/muesli/ansi/README.md
index cb28c656..f9d0fe9a 100644
--- a/vendor/github.com/muesli/ansi/README.md
+++ b/vendor/github.com/muesli/ansi/README.md
@@ -1,2 +1,31 @@
# ansi
+
+[](https://github.com/muesli/ansi/releases)
+[](https://github.com/muesli/ansi/actions)
+[](https://coveralls.io/github/muesli/ansi?branch=master)
+[](https://goreportcard.com/report/muesli/ansi)
+[](https://pkg.go.dev/github.com/muesli/ansi)
+
Raw ANSI sequence helpers
+
+## ANSI Writer
+
+```go
+import "github.com/muesli/ansi"
+
+w := ansi.Writer{Forward: os.Stdout}
+w.Write([]byte("\x1b[31mHello, world!\x1b[0m"))
+w.Close()
+```
+
+## Compressor
+
+The ANSI compressor eliminates unnecessary/redundant ANSI sequences.
+
+```go
+import "github.com/muesli/ansi/compressor"
+
+w := compressor.Writer{Forward: os.Stdout}
+w.Write([]byte("\x1b[31mHello, world!\x1b[0m"))
+w.Close()
+```
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 39ee8302..587d75fa 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -62,8 +62,8 @@ github.com/charmbracelet/bubbles/runeutil
github.com/charmbracelet/bubbles/spinner
github.com/charmbracelet/bubbles/textinput
github.com/charmbracelet/bubbles/viewport
-# github.com/charmbracelet/bubbletea v0.25.0
-## explicit; go 1.17
+# github.com/charmbracelet/bubbletea v1.2.4
+## explicit; go 1.18
github.com/charmbracelet/bubbletea
# github.com/charmbracelet/glamour v0.6.0
## explicit; go 1.13
@@ -72,13 +72,13 @@ github.com/charmbracelet/glamour/ansi
# github.com/charmbracelet/lipgloss v1.0.0
## explicit; go 1.18
github.com/charmbracelet/lipgloss
-# github.com/charmbracelet/x/ansi v0.4.2
+# github.com/charmbracelet/x/ansi v0.4.5
## explicit; go 1.18
github.com/charmbracelet/x/ansi
github.com/charmbracelet/x/ansi/parser
-# github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81
-## explicit; go 1.13
-github.com/containerd/console
+# github.com/charmbracelet/x/term v0.2.1
+## explicit; go 1.18
+github.com/charmbracelet/x/term
# github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
## explicit
github.com/davecgh/go-spew/spew
@@ -86,6 +86,9 @@ github.com/davecgh/go-spew/spew
## explicit
github.com/dlclark/regexp2
github.com/dlclark/regexp2/syntax
+# github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f
+## explicit; go 1.16
+github.com/erikgeiser/coninput
# github.com/felixge/httpsnoop v1.0.3
## explicit; go 1.13
github.com/felixge/httpsnoop
@@ -235,7 +238,7 @@ github.com/mitchellh/mapstructure
# github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
## explicit
github.com/mohae/deepcopy
-# github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b
+# github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6
## explicit; go 1.17
github.com/muesli/ansi
github.com/muesli/ansi/compressor