From 87b643f683bc238a31d9e6c81525a422a4614a01 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Mon, 21 May 2018 14:11:28 +0200 Subject: [PATCH] Update terminal UI libs (#789) * dep ensure * Update term UI libraries Fixes #759 * Exclude fmt.Fprint from errcheck --- .errcheck.excl | 3 + Gopkg.lock | 14 +- Makefile | 2 +- .../alecthomas/binary/binary_test.go | 410 ------------------ vendor/github.com/gdamore/tcell/README.md | 6 +- vendor/github.com/gdamore/tcell/cell.go | 8 +- vendor/github.com/gdamore/tcell/color.go | 2 +- .../github.com/gdamore/tcell/console_win.go | 13 +- vendor/github.com/gdamore/tcell/simulation.go | 3 +- .../gdamore/tcell/terminfo/README.md | 8 + .../gdamore/tcell/terminfo/mkdatabase.sh | 189 -------- .../gdamore/tcell/terminfo/mkinfo.go | 233 ++++++++-- .../gdamore/tcell/terminfo/models.txt | 2 - .../gdamore/tcell/terminfo/term_Eterm.go | 106 ----- .../tcell/terminfo/term_Eterm_256color.go | 105 ----- .../gdamore/tcell/terminfo/term_st.go | 7 +- .../tcell/terminfo/term_st_256color.go | 7 +- .../gdamore/tcell/terminfo/terminfo.go | 77 +++- vendor/github.com/jroimartin/gocui/README.md | 5 + vendor/github.com/jroimartin/gocui/view.go | 24 + .../lucasb-eyer/go-colorful/README.md | 4 +- vendor/github.com/nsf/termbox-go/README.md | 2 +- .../nsf/termbox-go/termbox_windows.go | 32 +- vendor/github.com/nsf/termbox-go/terminfo.go | 6 + vendor/github.com/sethgrid/pester/README.md | 6 +- vendor/github.com/urfave/cli/CHANGELOG.md | 8 +- vendor/github.com/urfave/cli/README.md | 2 +- vendor/vendor.json | 13 - 28 files changed, 369 insertions(+), 928 deletions(-) create mode 100644 .errcheck.excl delete mode 100644 vendor/github.com/alecthomas/binary/binary_test.go create mode 100644 vendor/github.com/gdamore/tcell/terminfo/README.md delete mode 100755 vendor/github.com/gdamore/tcell/terminfo/mkdatabase.sh delete mode 100644 vendor/github.com/gdamore/tcell/terminfo/term_Eterm.go delete mode 100644 vendor/github.com/gdamore/tcell/terminfo/term_Eterm_256color.go delete mode 100644 vendor/vendor.json diff --git a/.errcheck.excl b/.errcheck.excl new file mode 100644 index 0000000000..e471286ecb --- /dev/null +++ b/.errcheck.excl @@ -0,0 +1,3 @@ +fmt.Fprintf +fmt.Fprintln +fmt.Fprint diff --git a/Gopkg.lock b/Gopkg.lock index 0bf8cdef40..28bcf4dd65 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,6 +1,12 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. +[[projects]] + branch = "master" + name = "github.com/alecthomas/binary" + packages = ["."] + revision = "6e8df1b1fb9d591dfc8249e230e0a762524873f3" + [[projects]] branch = "master" name = "github.com/atotto/clipboard" @@ -70,7 +76,7 @@ "termbox", "terminfo" ] - revision = "aa381bce1bf2eb814ead6ce443dfad0580f4a79f" + revision = "3d5f294a6fcacb5448d76a1f4116c6827a8f0869" [[projects]] branch = "master" @@ -170,7 +176,7 @@ branch = "master" name = "github.com/jroimartin/gocui" packages = ["."] - revision = "4f518eddb04b8f73870836b6d1941e8aa3c06637" + revision = "c055c87ae801372cd74a0839b972db4f7697ae5f" [[projects]] branch = "master" @@ -242,7 +248,7 @@ branch = "master" name = "github.com/nsf/termbox-go" packages = ["."] - revision = "e2050e41c8847748ec5288741c0b19a8cb26d084" + revision = "21a4d435a86280a2927985fd6296de56cbce453e" [[projects]] name = "github.com/pelletier/go-buffruneio" @@ -494,6 +500,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "2031707fc17d49c74ff05d9a0b73924f0f5b05de1663cc552c43b0272edc7840" + inputs-digest = "6621c915e9488854dd220c56dd228ddbc62255d8da8ad32826141c95d3606ece" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Makefile b/Makefile index c7b60ffc0a..58ba10fccc 100644 --- a/Makefile +++ b/Makefile @@ -191,7 +191,7 @@ codequality: @which errcheck > /dev/null; if [ $$? -ne 0 ]; then \ $(GO) get -u github.com/kisielk/errcheck; \ fi - @errcheck $(PKGS) || exit 1 + @errcheck -exclude .errcheck.excl $(PKGS) || exit 1 @printf '%s\n' '$(OK)' @echo -n " UNCONVERT " diff --git a/vendor/github.com/alecthomas/binary/binary_test.go b/vendor/github.com/alecthomas/binary/binary_test.go deleted file mode 100644 index 2e32fc9c0c..0000000000 --- a/vendor/github.com/alecthomas/binary/binary_test.go +++ /dev/null @@ -1,410 +0,0 @@ -package binary - -import ( - "bytes" - "errors" - "fmt" - "io" - "reflect" - "testing" - "time" - - "github.com/stretchrcom/testify/assert" -) - -type s0 struct { - A string - B string - C int16 -} - -var ( - s0v = &s0{"A", "B", 1} - s0b = []byte{0x1, 0x41, 0x1, 0x42, 0x1, 0x0} -) - -func TestBinaryEncodeStruct(t *testing.T) { - b, err := Marshal(s0v) - assert.NoError(t, err) - assert.Equal(t, s0b, b) -} - -func TestBinaryDecodeStruct(t *testing.T) { - s := &s0{} - err := Unmarshal(s0b, s) - assert.NoError(t, err) - assert.Equal(t, s0v, s) -} - -func TestBinaryDecodeToValueErrors(t *testing.T) { - b := []byte{1, 0, 0, 0} - var v uint32 - err := Unmarshal(b, v) - assert.Error(t, err) - err = Unmarshal(b, &v) - assert.NoError(t, err) - assert.Equal(t, uint32(1), v) -} - -type s1 struct { - Name string - BirthDay time.Time - Phone string - Siblings int - Spouse bool - Money float64 - Tags map[string]string - Aliases []string -} - -var ( - s1v = &s1{ - Name: "Bob Smith", - BirthDay: time.Date(2013, 1, 2, 3, 4, 5, 6, time.UTC), - Phone: "5551234567", - Siblings: 2, - Spouse: false, - Money: 100.0, - Tags: map[string]string{"key": "value"}, - Aliases: []string{"Bobby", "Robert"}, - } - - svb = []byte{0x9, 0x42, 0x6f, 0x62, 0x20, 0x53, 0x6d, 0x69, 0x74, 0x68, 0xf, - 0x1, 0x0, 0x0, 0x0, 0xe, 0xc8, 0x75, 0x9a, 0xa5, 0x0, 0x0, 0x0, 0x6, 0xff, - 0xff, 0xa, 0x35, 0x35, 0x35, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x2, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x59, - 0x40, 0x1, 0x3, 0x6b, 0x65, 0x79, 0x5, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2, 0x5, - 0x42, 0x6f, 0x62, 0x62, 0x79, 0x6, 0x52, 0x6f, 0x62, 0x65, 0x72, 0x74} -) - -func TestBinaryEncodeComplex(t *testing.T) { - b, err := Marshal(s1v) - assert.NoError(t, err) - assert.Equal(t, svb, b) - s := &s1{} - err = Unmarshal(svb, s) - assert.NoError(t, err) - assert.Equal(t, s1v, s) -} - -type s2 struct { - b []byte -} - -func (s *s2) UnmarshalBinary(data []byte) error { - if len(data) != 1 { - return errors.New("expected data to be length 1") - } - s.b = data - return nil -} - -func (s *s2) MarshalBinary() (data []byte, err error) { - return s.b, nil -} - -func TestBinaryMarshalUnMarshaler(t *testing.T) { - s2v := &s2{[]byte{0x13}} - b, err := Marshal(s2v) - assert.NoError(t, err) - assert.Equal(t, []byte{0x1, 0x13}, b) -} - -func TestMarshalUnMarshalTypeAliases(t *testing.T) { - type Foo int64 - f := Foo(32) - b, err := Marshal(f) - assert.NoError(t, err) - assert.Equal(t, []byte{0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, b) -} - -func TestStructWithStruct(t *testing.T) { - type T1 struct { - ID uint64 - Name string - Slice []int - } - type T2 uint64 - type Struct struct { - V1 T1 - V2 T2 - V3 T1 - } - - s := Struct{V1: T1{1, "1", []int{1}}, V2: 2, V3: T1{3, "3", []int{3}}} - buf := new(bytes.Buffer) - enc := NewEncoder(buf) - err := enc.Encode(&s) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - v := Struct{} - dec := NewDecoder(buf) - err = dec.Decode(&v) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - if !reflect.DeepEqual(s, v) { - t.Fatalf("got= %#v\nwant=%#v\n", v, s) - } - -} - -func TestStructWithEmbeddedStruct(t *testing.T) { - type T1 struct { - ID uint64 - Name string - Slice []int - } - type T2 uint64 - type Struct struct { - T1 - V2 T2 - V3 T1 - } - - s := Struct{T1: T1{1, "1", []int{1}}, V2: 2, V3: T1{3, "3", []int{3}}} - buf := new(bytes.Buffer) - enc := NewEncoder(buf) - err := enc.Encode(&s) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - v := Struct{} - dec := NewDecoder(buf) - err = dec.Decode(&v) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - if !reflect.DeepEqual(s, v) { - t.Fatalf("got= %#v\nwant=%#v\n", v, s) - } - -} - -func TestArrayOfStructWithStruct(t *testing.T) { - type T1 struct { - ID uint64 - Name string - Slice []int - } - type T2 uint64 - type Struct struct { - V1 T1 - V2 T2 - V3 T1 - } - - s := [1]Struct{ - {V1: T1{1, "1", []int{1}}, V2: 2, V3: T1{3, "3", []int{3}}}, - } - buf := new(bytes.Buffer) - enc := NewEncoder(buf) - err := enc.Encode(&s) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - v := [1]Struct{} - dec := NewDecoder(buf) - err = dec.Decode(&v) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - if !reflect.DeepEqual(s, v) { - t.Fatalf("got= %#v\nwant=%#v\n", v, s) - } - -} - -func TestSliceOfStructWithStruct(t *testing.T) { - type T1 struct { - ID uint64 - Name string - Slice []int - } - type T2 uint64 - type Struct struct { - V1 T1 - V2 T2 - V3 T1 - } - - s := []Struct{ - {V1: T1{1, "1", []int{1}}, V2: 2, V3: T1{3, "3", []int{3}}}, - } - buf := new(bytes.Buffer) - enc := NewEncoder(buf) - err := enc.Encode(&s) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - v := []Struct{} - dec := NewDecoder(buf) - err = dec.Decode(&v) - if err != nil { - t.Fatalf("error: %v\n", err) - } - - if !reflect.DeepEqual(s, v) { - t.Fatalf("got= %#v\nwant=%#v\n", v, s) - } - -} - -func TestMarshalNonPointer(t *testing.T) { - type S struct { - A int - } - s := S{A: 1} - data, err := Marshal(s) - if err != nil { - t.Fatal(err) - } - var res S - if err := Unmarshal(data, &res); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(res, s) { - t.Fatalf("expect %v got %v", s, res) - } -} - -func BenchmarkEncodeStructI1(b *testing.B) { - type Struct struct { - S struct { - I int64 - } - } - var s Struct - s.S.I = 1024 - buf := new(bytes.Buffer) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - enc := NewEncoder(buf) - _ = enc.Encode(&s) - } - -} - -func BenchmarkEncodeStructI2(b *testing.B) { - type Struct struct { - S struct { - I int64 - } - } - var s Struct - s.S.I = 1024 - buf := new(bytes.Buffer) - enc := NewEncoder(buf) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - _ = enc.Encode(&s) - } - -} - -func BenchmarkEncodeStructI3(b *testing.B) { - type Struct struct { - S struct { - I int64 - } - } - var s Struct - s.S.I = 1024 - buf := new(bytes.Buffer) - enc := NewEncoder(buf) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := enc.Encode(&s) - if err != nil { - b.Fatalf("error: %v\n", err) - } - } - -} - -type bufferT struct { - buf []byte -} - -func (buf *bufferT) Read(data []byte) (int, error) { - n := copy(data, buf.buf) - if n != len(data) { - panic(fmt.Errorf("read too few bytes. got=%d want=%d", n, len(data))) - } - return n, nil -} - -func getTestBuffer(b *testing.B) io.Reader { - return &bufferT{ - buf: []byte{0, 4, 0, 0, 0, 0, 0, 0}, - } -} - -func BenchmarkDecodeStructI1(b *testing.B) { - - type Struct struct { - I int64 - } - - var s Struct - - buf := getTestBuffer(b) - b.ResetTimer() - for i := 0; i < b.N; i++ { - dec := NewDecoder(buf) - _ = dec.Decode(&s) - } - -} - -func BenchmarkDecodeStructI2(b *testing.B) { - - type Struct struct { - S struct { - I int64 - } - } - var s Struct - - buf := getTestBuffer(b) - dec := NewDecoder(buf) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - _ = dec.Decode(&s) - } - -} - -func BenchmarkDecodeStructI3(b *testing.B) { - - type Struct struct { - S struct { - I int64 - } - } - var s Struct - - buf := getTestBuffer(b) - dec := NewDecoder(buf) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := dec.Decode(&s) - if err != nil { - b.Fatalf("error: %v\n", err) - } - } - -} diff --git a/vendor/github.com/gdamore/tcell/README.md b/vendor/github.com/gdamore/tcell/README.md index 60a0decff2..0676c7156b 100644 --- a/vendor/github.com/gdamore/tcell/README.md +++ b/vendor/github.com/gdamore/tcell/README.md @@ -131,7 +131,7 @@ Tcell _supports true color_! (That is, if your terminal can support it, Tcell can accurately display 24-bit color.) To use 24-bit color, you need to use a terminal that supports it. Modern -xterm and similar terminal emulators can support this. As terminfo lacks any +xterm and similar teminal emulators can support this. As terminfo lacks any way to describe this capability, we fabricate the capability for terminals with names ending in *-truecolor. The stock distribution ships with a database that defines xterm-truecolor. To try it out, set your @@ -167,7 +167,7 @@ which can be located either by the $TCELLDB environment file, $HOME/.tcelldb, or is located in the Go source directory as database.json. These files (both the Go and the JSON files) can be generated using the -mkinfo.go program. If you need to regenerate the entire set for some reason, +mkinfo.go program. If you need to regnerate the entire set for some reason, run the mkdatabase.sh file. The generation uses the infocmp(1) program on the system to collect the necessary information. @@ -202,7 +202,7 @@ consoles, all support this quite nicely. On other platforms you might find that only mouse click and release events are reported, with no intervening motion events. It really depends on your terminal. -## Testability +## Testablity There is a SimulationScreen, that can be used to simulate a real screen for automated testing. The supplied tests do this. The simulation contains diff --git a/vendor/github.com/gdamore/tcell/cell.go b/vendor/github.com/gdamore/tcell/cell.go index b54abcbc98..496f10f72e 100644 --- a/vendor/github.com/gdamore/tcell/cell.go +++ b/vendor/github.com/gdamore/tcell/cell.go @@ -48,12 +48,13 @@ func (cb *CellBuffer) SetContent(x int, y int, if x >= 0 && y >= 0 && x < cb.w && y < cb.h { c := &cb.cells[(y*cb.w)+x] + c.currComb = append([]rune{}, combc...) i := 0 - for i < len(combc) { - r := combc[i] + for i < len(c.currComb) { + r := c.currComb[i] if runewidth.RuneWidth(r) != 0 { // not a combining character, yank it - combc = append(combc[:i-1], combc[i+1:]...) + c.currComb = append(c.currComb[:i-1], c.currComb[i+1:]...) continue } i++ @@ -63,7 +64,6 @@ func (cb *CellBuffer) SetContent(x int, y int, c.width = runewidth.RuneWidth(mainc) } c.currMain = mainc - c.currComb = combc c.currStyle = style } } diff --git a/vendor/github.com/gdamore/tcell/color.go b/vendor/github.com/gdamore/tcell/color.go index cc280bae95..2e096c705a 100644 --- a/vendor/github.com/gdamore/tcell/color.go +++ b/vendor/github.com/gdamore/tcell/color.go @@ -29,7 +29,7 @@ type Color int32 const ( // ColorDefault is used to leave the Color unchanged from whatever - // system or terminal default may exist. + // system or teminal default may exist. ColorDefault Color = -1 // ColorIsRGB is used to indicate that the numeric value is not diff --git a/vendor/github.com/gdamore/tcell/console_win.go b/vendor/github.com/gdamore/tcell/console_win.go index e27bf6a3e3..8fd2ab4bd6 100644 --- a/vendor/github.com/gdamore/tcell/console_win.go +++ b/vendor/github.com/gdamore/tcell/console_win.go @@ -183,7 +183,7 @@ func (s *cScreen) CharacterSet() string { } func (s *cScreen) EnableMouse() { - s.setInMode(modeResizeEn | modeMouseEn) + s.setInMode(modeResizeEn | modeMouseEn | modeExtndFlg) } func (s *cScreen) DisableMouse() { @@ -565,8 +565,14 @@ func (s *cScreen) getConsoleInput() error { if krec.ch != 0 { // synthesized key code for krec.repeat > 0 { - s.PostEvent(NewEventKey(KeyRune, rune(krec.ch), - mod2mask(krec.mod))) + // convert shift+tab to backtab + if mod2mask(krec.mod) == ModShift && krec.ch == vkTab { + s.PostEvent(NewEventKey(KeyBacktab, 0, + ModNone)) + } else { + s.PostEvent(NewEventKey(KeyRune, rune(krec.ch), + mod2mask(krec.mod))) + } krec.repeat-- } return nil @@ -920,6 +926,7 @@ func (s *cScreen) clearScreen(style Style) { } const ( + modeExtndFlg uint32 = 0x0080 modeMouseEn uint32 = 0x0010 modeResizeEn uint32 = 0x0008 modeWrapEOL uint32 = 0x0002 diff --git a/vendor/github.com/gdamore/tcell/simulation.go b/vendor/github.com/gdamore/tcell/simulation.go index 81bc089b18..850a7b3dc8 100644 --- a/vendor/github.com/gdamore/tcell/simulation.go +++ b/vendor/github.com/gdamore/tcell/simulation.go @@ -109,6 +109,7 @@ type simscreen struct { func (s *simscreen) Init() error { s.evch = make(chan Event, 10) + s.quit = make(chan struct{}) s.fillchar = 'X' s.fillstyle = StyleDefault s.mouse = false @@ -369,7 +370,7 @@ func (s *simscreen) InjectMouse(x, y int, buttons ButtonMask, mod ModMask) { } func (s *simscreen) InjectKey(key Key, r rune, mod ModMask) { - ev := NewEventKey(KeyRune, r, ModNone) + ev := NewEventKey(key, r, mod) s.PostEvent(ev) } diff --git a/vendor/github.com/gdamore/tcell/terminfo/README.md b/vendor/github.com/gdamore/tcell/terminfo/README.md new file mode 100644 index 0000000000..b33370141b --- /dev/null +++ b/vendor/github.com/gdamore/tcell/terminfo/README.md @@ -0,0 +1,8 @@ +To run the database: + +./mkinfo -all + +You can also generate a single entry: + +./mkinfo -db + diff --git a/vendor/github.com/gdamore/tcell/terminfo/mkdatabase.sh b/vendor/github.com/gdamore/tcell/terminfo/mkdatabase.sh deleted file mode 100755 index fd968bdc1e..0000000000 --- a/vendor/github.com/gdamore/tcell/terminfo/mkdatabase.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash - -# Copyright 2017 The TCell Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use file except in compliance with the License. -# You may obtain a copy of the license at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# When called with no arguments, this shell script builds the Go database, -# which is somewhat minimal for size reasons (it only contains the most -# commonly used entries), and then builds the complete JSON database. -# -# To limit the action to only building one or more terminals, specify them -# on the command line: -# -# ./mkdatabase xterm -# -# The script will also find and update or add any terminal "aliases". -# It does not remove any old entries. -# -# To add to the set of terminals that we compile into the Go database, -# add their names to the models.txt file. -# - -# This script is not very efficient, but there isn't really a better way -# without writing code to decode the terminfo binary format directly. -# Its not worth worrying about. - -# This script also requires bash, although ksh93 should work as well, because -# we use arrays, which are not specified in POSIX. - -export LANG=C -export LC_CTYPE=C - -progress() -{ - typeset -i num=$1 - typeset -i tot=$2 - typeset -i x - typeset back - typeset s - - if (( tot < 1 )) - then - s=$(printf "[ %d ]" $num) - back="\b\b\b\b\b" - x=$num - while (( x >= 10 )) - do - back="${back}\b" - x=$(( x / 10 )) - done - - else - x=$(( num * 100 / tot )) - s=$(printf "<%3d%%>" $x) - back="\b\b\b\b\b\b" - fi - printf "%s${back}" "$s" -} - -ord() -{ - printf "%02x" "'$1'" -} - -goterms=( $(cat models.txt) ) -args=( $* ) -if (( ${#args[@]} == 0 )) -then - args=( $(toe -a | cut -f1) ) -fi - -printf "Scanning terminal definitions: " -i=0 -aliases=() -models=() -for term in ${args[@]} -do - case "${term}" in - *-truecolor) - line="${term}|24-bit color" - ;; - *) - line=$(infocmp $term | head -2 | tail -1) - if [[ -z "$line" ]] - then - echo "Cannot find terminfo for $term" - exit 1 - fi - # take off the trailing comma - line=${line%,} - esac - - # grab primary name - term=${line%%|*} - all+=( ${term} ) - - # should this be in our go terminals? - for model in ${goterms[@]} - do - if [[ "${model}" == "${term}" ]] - then - models+=( ${term} ) - fi - done - - # chop off primary name - line=${line#${term}} - line=${line#|} - # chop off description - line=${line%|*} - while [[ "$line" != "" ]] - do - a=${line%%|*} - aliases+=( ${a}=${term} ) - line=${line#$a} - line=${line#|} - done - i=$(( i + 1 )) - progress $i ${#args[@]} -done -echo -# make sure we have mkinfo -printf "Building mkinfo: " -go build mkinfo.go -echo "done." - -# Build all the go database files for the "interesting" terminals". -printf "Building Go database: " -i=0 -for model in ${models[@]} -do - safe=$(echo $model | tr - _) - file=term_${safe}.go - ./mkinfo -go $file $model - go fmt ${file} >/dev/null - i=$(( i + 1 )) - progress $i ${#models[@]} -done -echo - -printf "Building JSON database: " - -# The JSON files are located for each terminal in a file with the -# terminal name, in the following fashion "database/x/xterm.json - -i=0 -for model in ${all[@]} -do - letter=$(ord ${model:0:1}) - dir=database/${letter} - file=${dir}/${model}.gz - mkdir -p ${dir} - ./mkinfo -nofatal -quiet -gzip -json ${file} ${model} - i=$(( i + 1 )) - progress $i ${#all[@]} -done -echo - -printf "Building JSON aliases: " -i=0 -for model in ${aliases[@]} -do - canon=${model#*=} - model=${model%=*} - letter=$(ord ${model:0:1}) - cletter=$(ord ${canon:0:1}) - dir=database/${letter} - file=${dir}/${model} - if [[ -f database/${cletter}/${canon}.gz ]] - then - [[ -d ${dir} ]] || mkdir -p ${dir} - # Generally speaking the aliases are better uncompressed - ./mkinfo -nofatal -quiet -json ${file} ${model} - fi - i=$(( i + 1 )) - progress $i ${#aliases[@]} -done -echo diff --git a/vendor/github.com/gdamore/tcell/terminfo/mkinfo.go b/vendor/github.com/gdamore/tcell/terminfo/mkinfo.go index 943d5a4155..50d70f74ee 100644 --- a/vendor/github.com/gdamore/tcell/terminfo/mkinfo.go +++ b/vendor/github.com/gdamore/tcell/terminfo/mkinfo.go @@ -1,6 +1,6 @@ // +build ignore -// Copyright 2017 The TCell Authors +// Copyright 2018 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use file except in compliance with the License. @@ -22,6 +22,8 @@ // // mkinfo [-init] [-go file.go] [-json file.json] [-quiet] [-nofatal] [...] // +// -all scan terminfo to determine database entries to use +// -db generate database entries (database/*), implied for -all // -gzip specifies output should be compressed (json only) // -go specifies Go output into the named file. Use - for stdout. // -json specifies JSON output in the named file. Use - for stdout @@ -31,8 +33,10 @@ package main import ( + "bufio" "bytes" "compress/gzip" + "crypto/sha1" "encoding/json" "errors" "flag" @@ -40,6 +44,7 @@ import ( "io" "os" "os/exec" + "path" "regexp" "strconv" "strings" @@ -74,6 +79,8 @@ const ( ESC ) +var notaddressable = errors.New("terminal not cursor addressable") + func unescape(s string) string { // Various escapes are in \x format. Control codes are // encoded as ^M (carat followed by ASCII equivalent). @@ -131,6 +138,25 @@ func unescape(s string) string { return (buf.String()) } +func getallterms() ([]string, error) { + out := []string{} + cmd := exec.Command("toe", "-a") + output := &bytes.Buffer{} + cmd.Stdout = output + err := cmd.Run() + if err != nil { + return nil, err + } + lines := strings.Split(output.String(), "\n") + for _, l := range lines { + fields := strings.Fields(l) + if len(fields) > 0 { + out = append(out, fields[0]) + } + } + return out, nil +} + func (tc *termcap) setupterm(name string) error { cmd := exec.Command("infocmp", "-1", name) output := &bytes.Buffer{} @@ -183,7 +209,7 @@ func (tc *termcap) setupterm(name string) error { if k := strings.SplitN(val, "=", 2); len(k) == 2 { tc.strs[k[0]] = unescape(k[1]) } else if k := strings.SplitN(val, "#", 2); len(k) == 2 { - if u, err := strconv.ParseUint(k[1], 10, 0); err != nil { + if u, err := strconv.ParseUint(k[1], 0, 0); err != nil { return (err) } else { tc.nums[k[0]] = int(u) @@ -433,7 +459,7 @@ func getinfo(name string) (*terminfo.Terminfo, string, error) { t.Colors = 0 } if t.SetCursor == "" { - return nil, "", errors.New("terminal not cursor addressable") + return nil, "", notaddressable } // For padding, we lookup the pad char. If that isn't present, @@ -677,13 +703,135 @@ func dotGoInfo(w io.Writer, t *terminfo.Terminfo, desc string) { fmt.Fprintln(w, "}") } +var packname = "terminfo" + +func dotGoFile(fname string, term *terminfo.Terminfo, desc string, makeDir bool) error { + w := os.Stdout + var e error + if fname != "-" && fname != "" { + if makeDir { + dname := path.Dir(fname) + _ = os.Mkdir(dname, 0777) + } + if w, e = os.Create(fname); e != nil { + return e + } + } + dotGoHeader(w, packname) + dotGoInfo(w, term, desc) + dotGoTrailer(w) + if w != os.Stdout { + w.Close() + } + cmd := exec.Command("go", "fmt", fname) + cmd.Run() + return nil +} + +func dotGzFile(fname string, term *terminfo.Terminfo, makeDir bool) error { + + var w io.WriteCloser = os.Stdout + var e error + if fname != "-" && fname != "" { + if makeDir { + dname := path.Dir(fname) + _ = os.Mkdir(dname, 0777) + } + if w, e = os.Create(fname); e != nil { + return e + } + } + + w = gzip.NewWriter(w) + + js, e := json.Marshal(term) + fmt.Fprintln(w, string(js)) + + if w != os.Stdout { + w.Close() + } + return nil +} + +func jsonFile(fname string, term *terminfo.Terminfo, makeDir bool) error { + w := os.Stdout + var e error + if fname != "-" && fname != "" { + if makeDir { + dname := path.Dir(fname) + _ = os.Mkdir(dname, 0777) + } + if w, e = os.Create(fname); e != nil { + return e + } + } + + js, e := json.Marshal(term) + fmt.Fprintln(w, string(js)) + + if w != os.Stdout { + w.Close() + } + return nil +} + +func dumpDatabase(terms map[string]*terminfo.Terminfo, descs map[string]string) { + + // Load models .text + mfile, e := os.Open("models.txt") + models := make(map[string]bool) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed reading models.txt: %v", e) + } + scanner := bufio.NewScanner(mfile) + for scanner.Scan() { + models[scanner.Text()] = true + } + + for name, t := range terms { + + // If this is one of our builtin models, generate the GO file + if models[name] { + desc := descs[name] + safename := strings.Replace(name, "-", "_", -1) + goname := fmt.Sprintf("term_%s.go", safename) + e = dotGoFile(goname, t, desc, true) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed creating %s: %v", goname, e) + os.Exit(1) + } + continue + } + + hash := fmt.Sprintf("%x", sha1.Sum([]byte(name))) + fname := fmt.Sprintf("%s.gz", hash[0:8]) + fname = path.Join("database", hash[0:2], fname) + e = dotGzFile(fname, t, true) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed creating %s: %v", fname, e) + os.Exit(1) + } + + for _, a := range t.Aliases { + hash = fmt.Sprintf("%x", sha1.Sum([]byte(a))) + fname = path.Join("database", hash[0:2], hash[0:8]) + e = jsonFile(fname, &terminfo.Terminfo{Name: t.Name}, true) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed creating %s: %v", fname, e) + os.Exit(1) + } + } + } +} + func main() { gofile := "" jsonfile := "" - packname := "terminfo" nofatal := false quiet := false dogzip := false + all := false + db := false flag.StringVar(&gofile, "go", "", "generate go source in named file") flag.StringVar(&jsonfile, "json", "", "generate json in named file") @@ -691,11 +839,21 @@ func main() { flag.BoolVar(&nofatal, "nofatal", false, "errors are not fatal") flag.BoolVar(&quiet, "quiet", false, "suppress error messages") flag.BoolVar(&dogzip, "gzip", false, "compress json output") + flag.BoolVar(&all, "all", false, "load all terminals from terminfo") + flag.BoolVar(&db, "db", false, "generate json db file in place") flag.Parse() var e error - js := []byte{} args := flag.Args() + if all { + db = true // implied + allterms, e := getallterms() + if e != nil { + fmt.Fprintf(os.Stderr, "Failed: %v", e) + os.Exit(1) + } + args = append(args, allterms...) + } if len(args) == 0 { args = []string{os.Getenv("TERM")} } @@ -705,6 +863,9 @@ func main() { for _, term := range args { if t, desc, e := getinfo(term); e != nil { + if all && e == notaddressable { + continue + } if !quiet { fmt.Fprintf(os.Stderr, "Failed loading %s: %v\n", term, e) @@ -722,53 +883,33 @@ func main() { // No data. os.Exit(0) } - if gofile != "" { - w := os.Stdout - if gofile != "-" { - if w, e = os.Create(gofile); e != nil { - fmt.Fprintf(os.Stderr, "Failed: %v", e) - os.Exit(1) - } - } - dotGoHeader(w, packname) + + if db { + dumpDatabase(tdata, descs) + } else if gofile != "" { for term, t := range tdata { if t.Name == term { - dotGoInfo(w, t, descs[term]) + e = dotGoFile(gofile, t, descs[term], false) + if e != nil { + fmt.Fprintf(os.Stderr, "Failed %s: %v", gofile, e) + os.Exit(1) + } } } - dotGoTrailer(w) - if w != os.Stdout { - w.Close() - } + } else { - o := os.Stdout - if jsonfile != "-" && jsonfile != "" { - if o, e = os.Create(jsonfile); e != nil { - fmt.Fprintf(os.Stderr, "Failed: %v", e) - } - } - var w io.WriteCloser - w = o - if dogzip { - w = gzip.NewWriter(o) - } - for _, term := range args { - if t := tdata[term]; t != nil { - js, e = json.Marshal(t) - fmt.Fprintln(w, string(js)) + for _, t := range tdata { + if dogzip { + if e = dotGzFile(jsonfile, t, false); e != nil { + fmt.Fprintf(os.Stderr, "Failed %s: %v", gofile, e) + os.Exit(1) + } + } else { + if e = jsonFile(jsonfile, t, false); e != nil { + fmt.Fprintf(os.Stderr, "Failed %s: %v", gofile, e) + os.Exit(1) + } } - // arguably if there is more than one term, this - // should be a javascript array, but that's not how - // we load it. We marshal objects one at a time from - // the file. - } - if e != nil { - fmt.Fprintf(os.Stderr, "Failed: %v", e) - os.Exit(1) - } - w.Close() - if w != o { - o.Close() } } } diff --git a/vendor/github.com/gdamore/tcell/terminfo/models.txt b/vendor/github.com/gdamore/tcell/terminfo/models.txt index ac0676d6f2..718eb9bcd9 100644 --- a/vendor/github.com/gdamore/tcell/terminfo/models.txt +++ b/vendor/github.com/gdamore/tcell/terminfo/models.txt @@ -8,8 +8,6 @@ cygwin d200 d210 dtterm -Eterm -Eterm-256color eterm gnome gnome-256color diff --git a/vendor/github.com/gdamore/tcell/terminfo/term_Eterm.go b/vendor/github.com/gdamore/tcell/terminfo/term_Eterm.go deleted file mode 100644 index 48f26c4f22..0000000000 --- a/vendor/github.com/gdamore/tcell/terminfo/term_Eterm.go +++ /dev/null @@ -1,106 +0,0 @@ -// Generated automatically. DO NOT HAND-EDIT. - -package terminfo - -func init() { - // Eterm with xterm-style color support (X Window System) - AddTerminfo(&Terminfo{ - Name: "Eterm", - Aliases: []string{"Eterm-color"}, - Columns: 80, - Lines: 24, - Colors: 8, - Bell: "\a", - Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b7\x1b[?47h", - ExitCA: "\x1b[2J\x1b[?47l\x1b8", - ShowCursor: "\x1b[?25h", - HideCursor: "\x1b[?25l", - AttrOff: "\x1b[m\x0f", - Underline: "\x1b[4m", - Bold: "\x1b[1m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - SetFg: "\x1b[3%p1%dm", - SetBg: "\x1b[4%p1%dm", - SetFgBg: "\x1b[3%p1%d;4%p2%dm", - PadChar: "\x00", - AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", - EnterAcs: "\x0e", - ExitAcs: "\x0f", - EnableAcs: "\x1b)0", - Mouse: "\x1b[M", - MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", - SetCursor: "\x1b[%i%p1%d;%p2%dH", - CursorBack1: "\b", - CursorUp1: "\x1b[A", - KeyUp: "\x1b[A", - KeyDown: "\x1b[B", - KeyRight: "\x1b[C", - KeyLeft: "\x1b[D", - KeyInsert: "\x1b[2~", - KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", - KeyHome: "\x1b[7~", - KeyEnd: "\x1b[8~", - KeyPgUp: "\x1b[5~", - KeyPgDn: "\x1b[6~", - KeyF1: "\x1b[11~", - KeyF2: "\x1b[12~", - KeyF3: "\x1b[13~", - KeyF4: "\x1b[14~", - KeyF5: "\x1b[15~", - KeyF6: "\x1b[17~", - KeyF7: "\x1b[18~", - KeyF8: "\x1b[19~", - KeyF9: "\x1b[20~", - KeyF10: "\x1b[21~", - KeyF11: "\x1b[23~", - KeyF12: "\x1b[24~", - KeyF13: "\x1b[25~", - KeyF14: "\x1b[26~", - KeyF15: "\x1b[28~", - KeyF16: "\x1b[29~", - KeyF17: "\x1b[31~", - KeyF18: "\x1b[32~", - KeyF19: "\x1b[33~", - KeyF20: "\x1b[34~", - KeyF21: "\x1b[23$", - KeyF22: "\x1b[24$", - KeyF23: "\x1b[11^", - KeyF24: "\x1b[12^", - KeyF25: "\x1b[13^", - KeyF26: "\x1b[14^", - KeyF27: "\x1b[15^", - KeyF28: "\x1b[17^", - KeyF29: "\x1b[18^", - KeyF30: "\x1b[19^", - KeyF31: "\x1b[20^", - KeyF32: "\x1b[21^", - KeyF33: "\x1b[23^", - KeyF34: "\x1b[24^", - KeyF35: "\x1b[25^", - KeyF36: "\x1b[26^", - KeyF37: "\x1b[28^", - KeyF38: "\x1b[29^", - KeyF39: "\x1b[31^", - KeyF40: "\x1b[32^", - KeyF41: "\x1b[33^", - KeyF42: "\x1b[34^", - KeyF43: "\x1b[23@", - KeyF44: "\x1b[24@", - KeyHelp: "\x1b[28~", - KeyShfLeft: "\x1b[d", - KeyShfRight: "\x1b[c", - KeyShfUp: "\x1b[a", - KeyShfDown: "\x1b[b", - KeyCtrlLeft: "\x1b[Od", - KeyCtrlRight: "\x1b[Oc", - KeyCtrlUp: "\x1b[Oa", - KeyCtrlDown: "\x1b[Ob", - KeyShfHome: "\x1b[7$", - KeyShfEnd: "\x1b[8$", - KeyCtrlHome: "\x1b[7^", - KeyCtrlEnd: "\x1b[8^", - }) -} diff --git a/vendor/github.com/gdamore/tcell/terminfo/term_Eterm_256color.go b/vendor/github.com/gdamore/tcell/terminfo/term_Eterm_256color.go deleted file mode 100644 index 51d4da73e4..0000000000 --- a/vendor/github.com/gdamore/tcell/terminfo/term_Eterm_256color.go +++ /dev/null @@ -1,105 +0,0 @@ -// Generated automatically. DO NOT HAND-EDIT. - -package terminfo - -func init() { - // Eterm with xterm 256-colors - AddTerminfo(&Terminfo{ - Name: "Eterm-256color", - Columns: 80, - Lines: 24, - Colors: 256, - Bell: "\a", - Clear: "\x1b[H\x1b[2J", - EnterCA: "\x1b7\x1b[?47h", - ExitCA: "\x1b[2J\x1b[?47l\x1b8", - ShowCursor: "\x1b[?25h", - HideCursor: "\x1b[?25l", - AttrOff: "\x1b[m\x0f", - Underline: "\x1b[4m", - Bold: "\x1b[1m", - Blink: "\x1b[5m", - Reverse: "\x1b[7m", - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", - PadChar: "\x00", - AltChars: "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", - EnterAcs: "\x0e", - ExitAcs: "\x0f", - EnableAcs: "\x1b)0", - Mouse: "\x1b[M", - MouseMode: "%?%p1%{1}%=%t%'h'%Pa%e%'l'%Pa%;\x1b[?1000%ga%c\x1b[?1002%ga%c\x1b[?1003%ga%c\x1b[?1006%ga%c", - SetCursor: "\x1b[%i%p1%d;%p2%dH", - CursorBack1: "\b", - CursorUp1: "\x1b[A", - KeyUp: "\x1b[A", - KeyDown: "\x1b[B", - KeyRight: "\x1b[C", - KeyLeft: "\x1b[D", - KeyInsert: "\x1b[2~", - KeyDelete: "\x1b[3~", - KeyBackspace: "\u007f", - KeyHome: "\x1b[7~", - KeyEnd: "\x1b[8~", - KeyPgUp: "\x1b[5~", - KeyPgDn: "\x1b[6~", - KeyF1: "\x1b[11~", - KeyF2: "\x1b[12~", - KeyF3: "\x1b[13~", - KeyF4: "\x1b[14~", - KeyF5: "\x1b[15~", - KeyF6: "\x1b[17~", - KeyF7: "\x1b[18~", - KeyF8: "\x1b[19~", - KeyF9: "\x1b[20~", - KeyF10: "\x1b[21~", - KeyF11: "\x1b[23~", - KeyF12: "\x1b[24~", - KeyF13: "\x1b[25~", - KeyF14: "\x1b[26~", - KeyF15: "\x1b[28~", - KeyF16: "\x1b[29~", - KeyF17: "\x1b[31~", - KeyF18: "\x1b[32~", - KeyF19: "\x1b[33~", - KeyF20: "\x1b[34~", - KeyF21: "\x1b[23$", - KeyF22: "\x1b[24$", - KeyF23: "\x1b[11^", - KeyF24: "\x1b[12^", - KeyF25: "\x1b[13^", - KeyF26: "\x1b[14^", - KeyF27: "\x1b[15^", - KeyF28: "\x1b[17^", - KeyF29: "\x1b[18^", - KeyF30: "\x1b[19^", - KeyF31: "\x1b[20^", - KeyF32: "\x1b[21^", - KeyF33: "\x1b[23^", - KeyF34: "\x1b[24^", - KeyF35: "\x1b[25^", - KeyF36: "\x1b[26^", - KeyF37: "\x1b[28^", - KeyF38: "\x1b[29^", - KeyF39: "\x1b[31^", - KeyF40: "\x1b[32^", - KeyF41: "\x1b[33^", - KeyF42: "\x1b[34^", - KeyF43: "\x1b[23@", - KeyF44: "\x1b[24@", - KeyHelp: "\x1b[28~", - KeyShfLeft: "\x1b[d", - KeyShfRight: "\x1b[c", - KeyShfUp: "\x1b[a", - KeyShfDown: "\x1b[b", - KeyCtrlLeft: "\x1b[Od", - KeyCtrlRight: "\x1b[Oc", - KeyCtrlUp: "\x1b[Oa", - KeyCtrlDown: "\x1b[Ob", - KeyShfHome: "\x1b[7$", - KeyShfEnd: "\x1b[8$", - KeyCtrlHome: "\x1b[7^", - KeyCtrlEnd: "\x1b[8^", - }) -} diff --git a/vendor/github.com/gdamore/tcell/terminfo/term_st.go b/vendor/github.com/gdamore/tcell/terminfo/term_st.go index f5547886c5..272af39c9d 100644 --- a/vendor/github.com/gdamore/tcell/terminfo/term_st.go +++ b/vendor/github.com/gdamore/tcell/terminfo/term_st.go @@ -3,9 +3,10 @@ package terminfo func init() { - // simpleterm + // simpleterm 0.4.1 AddTerminfo(&Terminfo{ Name: "st", + Aliases: []string{"stterm"}, Columns: 80, Lines: 24, Colors: 8, @@ -18,7 +19,6 @@ func init() { AttrOff: "\x1b[0m", Underline: "\x1b[4m", Bold: "\x1b[1m", - Dim: "\x1b[2m", Blink: "\x1b[5m", Reverse: "\x1b[7m", EnterKeypad: "\x1b[?1h\x1b=", @@ -26,7 +26,8 @@ func init() { SetFg: "\x1b[3%p1%dm", SetBg: "\x1b[4%p1%dm", SetFgBg: "\x1b[3%p1%d;4%p2%dm", - AltChars: "+C,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", + PadChar: "\x00", + AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", EnterAcs: "\x1b(0", ExitAcs: "\x1b(B", EnableAcs: "\x1b)0", diff --git a/vendor/github.com/gdamore/tcell/terminfo/term_st_256color.go b/vendor/github.com/gdamore/tcell/terminfo/term_st_256color.go index b74eb7b223..9b4256f3a3 100644 --- a/vendor/github.com/gdamore/tcell/terminfo/term_st_256color.go +++ b/vendor/github.com/gdamore/tcell/terminfo/term_st_256color.go @@ -3,9 +3,10 @@ package terminfo func init() { - // simpleterm with 256 colors + // simpleterm with 256 colors AddTerminfo(&Terminfo{ Name: "st-256color", + Aliases: []string{"stterm-256color"}, Columns: 80, Lines: 24, Colors: 256, @@ -18,7 +19,6 @@ func init() { AttrOff: "\x1b[0m", Underline: "\x1b[4m", Bold: "\x1b[1m", - Dim: "\x1b[2m", Blink: "\x1b[5m", Reverse: "\x1b[7m", EnterKeypad: "\x1b[?1h\x1b=", @@ -26,7 +26,8 @@ func init() { SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m", SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m", SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m", - AltChars: "+C,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", + PadChar: "\x00", + AltChars: "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~", EnterAcs: "\x1b(0", ExitAcs: "\x1b(B", EnableAcs: "\x1b)0", diff --git a/vendor/github.com/gdamore/tcell/terminfo/terminfo.go b/vendor/github.com/gdamore/tcell/terminfo/terminfo.go index b7fc0fa97e..881b9e0196 100644 --- a/vendor/github.com/gdamore/tcell/terminfo/terminfo.go +++ b/vendor/github.com/gdamore/tcell/terminfo/terminfo.go @@ -1,4 +1,4 @@ -// Copyright 2017 The TCell Authors +// Copyright 2018 The TCell Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use file except in compliance with the License. @@ -17,12 +17,14 @@ package terminfo import ( "bytes" "compress/gzip" + "crypto/sha1" "encoding/json" "errors" "fmt" "io" "os" "path" + "path/filepath" "strconv" "strings" "sync" @@ -753,8 +755,16 @@ func loadFromFile(fname string, term string) (*Terminfo, error) { // LookupTerminfo attempts to find a definition for the named $TERM. // It first looks in the builtin database, which should cover just about // everyone. If it can't find one there, then it will attempt to read -// one from the JSON file located in either $TCELLDB, $HOME/.tcelldb -// or in this package's source directory as database.json). +// one from the JSON file located in either $TCELLDB, $HOME/.tcelldb, +// or as a database file. +// +// The database files are named by taking terminal name, hashing it through +// sha1, and then a subdirectory of the form database/hash[0:2]/hash[0:8] +// (with an optional .gz extension). +// +// For other local database files, we will look for the database file using +// the terminal name, so database/term[0:2]/term[0:8], again with optional +// .gz extension. func LookupTerminfo(name string) (*Terminfo, error) { if name == "" { // else on windows: index out of bounds @@ -772,38 +782,65 @@ func LookupTerminfo(name string) (*Terminfo, error) { letter := fmt.Sprintf("%02x", name[0]) gzfile := path.Join(letter, name+".gz") jsfile := path.Join(letter, name) + hash := fmt.Sprintf("%x", sha1.Sum([]byte(name))) + gzhfile := path.Join(hash[0:2], hash[0:8]+".gz") + jshfile := path.Join(hash[0:2], hash[0:8]) // Build up the search path. Old versions of tcell used a // single database file, whereas the new ones locate them // in JSON (optionally compressed) files. // - // The search path looks like: + // The search path for "xterm" (SHA1 sig e2e28a8e...) looks + // like this: // - // $TCELLDB/x/xterm.gz - // $TCELLDB/x/xterm + // $TCELLDB/78/xterm.gz + // $TCELLDB/78/xterm // $TCELLDB - // $HOME/.tcelldb/x/xterm.gz - // $HOME/.tcelldb/x/xterm + // $HOME/.tcelldb/e2/e2e28a8e.gz + // $HOME/.tcelldb/e2/e2e28a8e + // $HOME/.tcelldb/78/xterm.gz + // $HOME/.tcelldb/78/xterm // $HOME/.tcelldb - // $GOPATH/terminfo/database/x/xterm.gz - // $GOPATH/terminfo/database/x/xterm + // $GOPATH/terminfo/database/e2/e2e28a8e.gz + // $GOPATH/terminfo/database/e2/e2e28a8e + // $GOPATH/terminfo/database/78/xterm.gz + // $GOPATH/terminfo/database/78/xterm // + // Note that the legacy name lookups (78/xterm etc.) are + // provided for compatibility. We do not actually deliver + // any files with this style of naming, to avoid collisions + // on case insensitive filesystems. (*cough* mac *cough*). + + // If $GOPATH set, honor it, else assume $HOME/go just like + // modern golang does. + gopath := os.Getenv("GOPATH") + if gopath == "" { + gopath = path.Join(os.Getenv("HOME"), "go") + } if pth := os.Getenv("TCELLDB"); pth != "" { - files = append(files, path.Join(pth, gzfile)) - files = append(files, path.Join(pth, jsfile)) - files = append(files, pth) + files = append(files, + path.Join(pth, gzfile), + path.Join(pth, jsfile), + pth) } if pth := os.Getenv("HOME"); pth != "" { pth = path.Join(pth, ".tcelldb") - files = append(files, path.Join(pth, gzfile)) - files = append(files, path.Join(pth, jsfile)) - files = append(files, pth) + files = append(files, + path.Join(pth, gzhfile), + path.Join(pth, jshfile), + path.Join(pth, gzfile), + path.Join(pth, jsfile), + pth) } - for _, pth := range strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) { - pth = path.Join(pth, "src", "github.com", "gdamore", "tcell", "terminfo", "database") - files = append(files, path.Join(pth, gzfile)) - files = append(files, path.Join(pth, jsfile)) + for _, pth := range filepath.SplitList(gopath) { + pth = path.Join(pth, "src", "github.com", + "gdamore", "tcell", "terminfo", "database") + files = append(files, + path.Join(pth, gzhfile), + path.Join(pth, jshfile), + path.Join(pth, gzfile), + path.Join(pth, jsfile)) } for _, fname := range files { diff --git a/vendor/github.com/jroimartin/gocui/README.md b/vendor/github.com/jroimartin/gocui/README.md index b1b44cd490..d7b55a3bc7 100644 --- a/vendor/github.com/jroimartin/gocui/README.md +++ b/vendor/github.com/jroimartin/gocui/README.md @@ -101,5 +101,10 @@ func quit(g *gocui.Gui, v *gocui.View) error { * [terminews](http://github.com/antavelos/terminews): Terminal based RSS reader. * [diagram](https://github.com/esimov/diagram): Tool to convert ascii arts into hand drawn diagrams. * [pody](https://github.com/JulienBreux/pody): CLI app to manage Pods in a Kubernetes cluster. +* [kubexp](https://github.com/alitari/kubexp): Kubernetes client. +* [kcli](https://github.com/cswank/kcli): Tool for inspecting kafka topics/partitions/messages. +* [fac](https://github.com/mkchoi212/fac): git merge conflict resolver +* [jsonui](https://github.com/gulyasm/jsonui): Interactive JSON explorer for your terminal. +* [cointop](https://github.com/miguelmota/cointop): Interactive terminal based UI application for tracking cryptocurrencies. Note: if your project is not listed here, let us know! :) diff --git a/vendor/github.com/jroimartin/gocui/view.go b/vendor/github.com/jroimartin/gocui/view.go index 9e4da4dd99..42082f8c38 100644 --- a/vendor/github.com/jroimartin/gocui/view.go +++ b/vendor/github.com/jroimartin/gocui/view.go @@ -408,6 +408,18 @@ func (v *View) clearRunes() { } } +// BufferLines returns the lines in the view's internal +// buffer. +func (v *View) BufferLines() []string { + lines := make([]string, len(v.lines)) + for i, l := range v.lines { + str := lineType(l).String() + str = strings.Replace(str, "\x00", " ", -1) + lines[i] = str + } + return lines +} + // Buffer returns a string with the contents of the view's internal // buffer. func (v *View) Buffer() string { @@ -418,6 +430,18 @@ func (v *View) Buffer() string { return strings.Replace(str, "\x00", " ", -1) } +// ViewBufferLines returns the lines in the view's internal +// buffer that is shown to the user. +func (v *View) ViewBufferLines() []string { + lines := make([]string, len(v.viewLines)) + for i, l := range v.viewLines { + str := lineType(l.line).String() + str = strings.Replace(str, "\x00", " ", -1) + lines[i] = str + } + return lines +} + // ViewBuffer returns a string with the contents of the view's buffer that is // shown to the user. func (v *View) ViewBuffer() string { diff --git a/vendor/github.com/lucasb-eyer/go-colorful/README.md b/vendor/github.com/lucasb-eyer/go-colorful/README.md index 42998684dd..474487389c 100644 --- a/vendor/github.com/lucasb-eyer/go-colorful/README.md +++ b/vendor/github.com/lucasb-eyer/go-colorful/README.md @@ -312,11 +312,11 @@ generating this picture in `doc/colorgens/golorgens.go`. ### Getting random palettes As soon as you need to generate more than one random color, you probably want -them to be distinguishable. Playing against an opponent which has almost the +them to be distinguishible. Playing against an opponent which has almost the same blue as I do is not fun. This is where random palettes can help. These palettes are generated using an algorithm which ensures that all colors -on the palette are as distinguishable as possible. Again, there is a `Fast` +on the palette are as distinguishible as possible. Again, there is a `Fast` method which works in HSV and is less perceptually uniform and a non-`Fast` method which works in CIE spaces. For more theory on `SoftPalette`, check out [I want hue](http://tools.medialab.sciences-po.fr/iwanthue/theory.php). Yet diff --git a/vendor/github.com/nsf/termbox-go/README.md b/vendor/github.com/nsf/termbox-go/README.md index fcc493da3f..6f65cfa9ab 100644 --- a/vendor/github.com/nsf/termbox-go/README.md +++ b/vendor/github.com/nsf/termbox-go/README.md @@ -11,7 +11,6 @@ For examples of what can be done take a look at demos in the _demos directory. Y There are also some interesting projects using termbox-go: - [godit](https://github.com/nsf/godit) is an emacsish lightweight text editor written using termbox. - - [gomatrix](https://github.com/GeertJohan/gomatrix) connects to The Matrix and displays its data streams in your terminal. - [gotetris](https://github.com/jjinux/gotetris) is an implementation of Tetris. - [sokoban-go](https://github.com/rn2dy/sokoban-go) is an implementation of sokoban game. - [hecate](https://github.com/evanmiller/hecate) is a hex editor designed by Satan. @@ -36,3 +35,4 @@ There are also some interesting projects using termbox-go: - [pinger](https://github.com/hirose31/pinger) helps you to monitor numerous hosts using ICMP ECHO_REQUEST. - [vixl44](https://github.com/sebashwa/vixl44) lets you create pixel art inside your terminal using vim movements - [zterm](https://github.com/varunrau/zterm) is a typing game inspired by http://zty.pe/ + - [cointop](https://github.com/miguelmota/cointop) is an interactive terminal based UI application for tracking cryptocurrencies. diff --git a/vendor/github.com/nsf/termbox-go/termbox_windows.go b/vendor/github.com/nsf/termbox-go/termbox_windows.go index 738847c875..7752a175b7 100644 --- a/vendor/github.com/nsf/termbox-go/termbox_windows.go +++ b/vendor/github.com/nsf/termbox-go/termbox_windows.go @@ -1,5 +1,6 @@ package termbox +import "math" import "syscall" import "unsafe" import "unicode/utf16" @@ -57,6 +58,10 @@ type ( control_key_state dword event_flags dword } + console_font_info struct { + font uint32 + font_size coord + } ) const ( @@ -94,6 +99,7 @@ var ( proc_create_event = kernel32.NewProc("CreateEventW") proc_wait_for_multiple_objects = kernel32.NewProc("WaitForMultipleObjects") proc_set_event = kernel32.NewProc("SetEvent") + proc_get_current_console_font = kernel32.NewProc("GetCurrentConsoleFont") get_system_metrics = moduser32.NewProc("GetSystemMetrics") ) @@ -339,6 +345,19 @@ func set_event(ev syscall.Handle) (err error) { return } +func get_current_console_font(h syscall.Handle, info *console_font_info) (err error) { + r0, _, e1 := syscall.Syscall(proc_get_current_console_font.Addr(), + 3, uintptr(h), 0, uintptr(unsafe.Pointer(info))) + if int(r0) == 0 { + if e1 != 0 { + err = error(e1) + } else { + err = syscall.EINVAL + } + } + return +} + type diff_msg struct { pos short lines short @@ -383,6 +402,7 @@ var ( tmp_coord0 = coord{0, 0} tmp_coord = coord{0, 0} tmp_rect = small_rect{0, 0, 0, 0} + tmp_finfo console_font_info ) func get_cursor_position(out syscall.Handle) coord { @@ -411,9 +431,14 @@ func get_win_min_size(out syscall.Handle) coord { } } + err1 := get_current_console_font(out, &tmp_finfo) + if err1 != nil { + panic(err1) + } + return coord{ - x: short(x), - y: short(y), + x: short(math.Ceil(float64(x) / float64(tmp_finfo.font_size.x))), + y: short(math.Ceil(float64(y) / float64(tmp_finfo.font_size.y))), } } @@ -442,8 +467,9 @@ func get_win_size(out syscall.Handle) coord { } func update_size_maybe() { - size := get_term_size(out) + size := get_win_size(out) if size.x != term_size.x || size.y != term_size.y { + set_console_screen_buffer_size(out, size) term_size = size back_buffer.resize(int(size.x), int(size.y)) front_buffer.resize(int(size.x), int(size.y)) diff --git a/vendor/github.com/nsf/termbox-go/terminfo.go b/vendor/github.com/nsf/termbox-go/terminfo.go index 5d38fce0c2..ab2e7a1989 100644 --- a/vendor/github.com/nsf/termbox-go/terminfo.go +++ b/vendor/github.com/nsf/termbox-go/terminfo.go @@ -69,6 +69,12 @@ func load_terminfo() ([]byte, error) { } } + // next, /lib/terminfo + data, err = ti_try_path("/lib/terminfo") + if err == nil { + return data, nil + } + // fall back to /usr/share/terminfo return ti_try_path("/usr/share/terminfo") } diff --git a/vendor/github.com/sethgrid/pester/README.md b/vendor/github.com/sethgrid/pester/README.md index da1dda0503..ac1d6d9a24 100644 --- a/vendor/github.com/sethgrid/pester/README.md +++ b/vendor/github.com/sethgrid/pester/README.md @@ -98,8 +98,8 @@ func main() { c := pester.New() c.KeepLog = true -nonExistentURL := "http://localhost:9000/foo" -_, _ = c.Get(nonExistentURL) +nonExistantURL := "http://localhost:9000/foo" +_, _ = c.Get(nonExistantURL) fmt.Println(c.LogString()) /* @@ -117,7 +117,7 @@ You can run tests in the root directory with `$ go test`. There is a benchmark-l You can see `pester` in action with `$ cd sample; go run main.go`. For watching open file descriptors, you can run `watch "lsof -i -P | grep main"` if you started the app with `go run main.go`. -I did this for watching for FD leaks. My method was to alter `sample/main.go` to only run one case (`pester.Get with set backoff strategy, concurrency and retries increased`) +I did this for watching for FD leaks. My method was to alter `sample/main.go` to only run one case (`pester.Get with set backoff stategy, concurrency and retries increased`) and adding a sleep after the result came back. This let me verify if FDs were getting left open when they should have closed. If you know a better way, let me know! I was able to see that FDs are now closing when they should :) diff --git a/vendor/github.com/urfave/cli/CHANGELOG.md b/vendor/github.com/urfave/cli/CHANGELOG.md index 9b69e24a3d..401eae5a2c 100644 --- a/vendor/github.com/urfave/cli/CHANGELOG.md +++ b/vendor/github.com/urfave/cli/CHANGELOG.md @@ -13,12 +13,12 @@ there are no `ExitCoder`s in the `MultiError`. * Fixed YAML file loading on Windows (previously would fail validate the file path) * Subcommand `Usage`, `Description`, `ArgsUsage`, `OnUsageError` correctly - propagated + propogated * `ErrWriter` is now passed downwards through command structure to avoid the need to redefine it * Pass `Command` context into `OnUsageError` rather than parent context so that - all fields are available -* Errors occurring in `Before` funcs are no longer double printed + all fields are avaiable +* Errors occuring in `Before` funcs are no longer double printed * Use `UsageText` in the help templates for commands and subcommands if defined; otherwise build the usage as before (was previously ignoring this field) @@ -42,7 +42,7 @@ `CustomAppHelpTemplate` * Support for arbitrary key/value fields on `App` to be used with `CustomAppHelpTemplate` via `ExtraInfo` -* `HelpFlag`, `VersionFlag`, and `BashCompletionFlag` changed to explicitly be +* `HelpFlag`, `VersionFlag`, and `BashCompletionFlag` changed to explictly be `cli.Flag`s allowing for the use of custom flags satisfying the `cli.Flag` interface to be used. diff --git a/vendor/github.com/urfave/cli/README.md b/vendor/github.com/urfave/cli/README.md index 6eb2996558..f2baef4f07 100644 --- a/vendor/github.com/urfave/cli/README.md +++ b/vendor/github.com/urfave/cli/README.md @@ -670,7 +670,7 @@ func main() { ``` Note that default values set from file (e.g. `FilePath`) take precedence over -default values set from the environment (e.g. `EnvVar`). +default values set from the enviornment (e.g. `EnvVar`). #### Values from alternate input sources (YAML, TOML, and others) diff --git a/vendor/vendor.json b/vendor/vendor.json deleted file mode 100644 index 92f1f8b216..0000000000 --- a/vendor/vendor.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "comment": "", - "ignore": "", - "package": [ - { - "checksumSHA1": "olEQotuonbTkMsKUHe8b25QLnzU=", - "path": "github.com/alecthomas/binary", - "revision": "6e8df1b1fb9d591dfc8249e230e0a762524873f3", - "revisionTime": "2017-11-01T08:48:25Z" - } - ], - "rootPath": "github.com/justwatchcom/gopass" -}