diff options
author | Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> | 2020-09-18 02:16:25 +0900 |
---|---|---|
committer | Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> | 2020-09-18 02:22:25 +0900 |
commit | 661786808c8a5249e05672af1f4d9cfaef39b38e (patch) | |
tree | 448e550f29119957d11060226dc8198837770973 /vendor/github.com/moby/term/ascii.go | |
parent | 031ddf9c8476202c6b0c810c6c0f6a7a0040c035 (diff) | |
download | podman-661786808c8a5249e05672af1f4d9cfaef39b38e.tar.gz podman-661786808c8a5249e05672af1f4d9cfaef39b38e.tar.bz2 podman-661786808c8a5249e05672af1f4d9cfaef39b38e.zip |
update github.com/docker/docker and relevant deps
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Diffstat (limited to 'vendor/github.com/moby/term/ascii.go')
-rw-r--r-- | vendor/github.com/moby/term/ascii.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/vendor/github.com/moby/term/ascii.go b/vendor/github.com/moby/term/ascii.go new file mode 100644 index 000000000..55873c055 --- /dev/null +++ b/vendor/github.com/moby/term/ascii.go @@ -0,0 +1,66 @@ +package term + +import ( + "fmt" + "strings" +) + +// ASCII list the possible supported ASCII key sequence +var ASCII = []string{ + "ctrl-@", + "ctrl-a", + "ctrl-b", + "ctrl-c", + "ctrl-d", + "ctrl-e", + "ctrl-f", + "ctrl-g", + "ctrl-h", + "ctrl-i", + "ctrl-j", + "ctrl-k", + "ctrl-l", + "ctrl-m", + "ctrl-n", + "ctrl-o", + "ctrl-p", + "ctrl-q", + "ctrl-r", + "ctrl-s", + "ctrl-t", + "ctrl-u", + "ctrl-v", + "ctrl-w", + "ctrl-x", + "ctrl-y", + "ctrl-z", + "ctrl-[", + "ctrl-\\", + "ctrl-]", + "ctrl-^", + "ctrl-_", +} + +// ToBytes converts a string representing a suite of key-sequence to the corresponding ASCII code. +func ToBytes(keys string) ([]byte, error) { + codes := []byte{} +next: + for _, key := range strings.Split(keys, ",") { + if len(key) != 1 { + for code, ctrl := range ASCII { + if ctrl == key { + codes = append(codes, byte(code)) + continue next + } + } + if key == "DEL" { + codes = append(codes, 127) + } else { + return nil, fmt.Errorf("Unknown character: '%s'", key) + } + } else { + codes = append(codes, key[0]) + } + } + return codes, nil +} |