forked from cerc-io/plugeth
Merge pull request #15248 from karalabe/update-liner
vendor: update liner to fix docker and mips bugs
This commit is contained in:
commit
eb9abbd3f2
7
vendor/github.com/peterh/liner/common.go
generated
vendored
7
vendor/github.com/peterh/liner/common.go
generated
vendored
@ -64,6 +64,11 @@ var ErrNotTerminalOutput = errors.New("standard output is not a terminal")
|
|||||||
// be colour codes on some platforms).
|
// be colour codes on some platforms).
|
||||||
var ErrInvalidPrompt = errors.New("invalid prompt")
|
var ErrInvalidPrompt = errors.New("invalid prompt")
|
||||||
|
|
||||||
|
// ErrInternal is returned when liner experiences an error that it cannot
|
||||||
|
// handle. For example, if the number of colums becomes zero during an
|
||||||
|
// active call to Prompt
|
||||||
|
var ErrInternal = errors.New("liner: internal error")
|
||||||
|
|
||||||
// KillRingMax is the max number of elements to save on the killring.
|
// KillRingMax is the max number of elements to save on the killring.
|
||||||
const KillRingMax = 60
|
const KillRingMax = 60
|
||||||
|
|
||||||
@ -156,7 +161,7 @@ func (s *State) getHistoryByPrefix(prefix string) (ph []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the history lines matching the inteligent search
|
// Returns the history lines matching the intelligent search
|
||||||
func (s *State) getHistoryByPattern(pattern string) (ph []string, pos []int) {
|
func (s *State) getHistoryByPattern(pattern string) (ph []string, pos []int) {
|
||||||
if pattern == "" {
|
if pattern == "" {
|
||||||
return
|
return
|
||||||
|
4
vendor/github.com/peterh/liner/input.go
generated
vendored
4
vendor/github.com/peterh/liner/input.go
generated
vendored
@ -113,7 +113,7 @@ func (s *State) nextPending(timeout <-chan time.Time) (rune, error) {
|
|||||||
select {
|
select {
|
||||||
case thing, ok := <-s.next:
|
case thing, ok := <-s.next:
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, errors.New("liner: internal error")
|
return 0, ErrInternal
|
||||||
}
|
}
|
||||||
if thing.err != nil {
|
if thing.err != nil {
|
||||||
return 0, thing.err
|
return 0, thing.err
|
||||||
@ -137,7 +137,7 @@ func (s *State) readNext() (interface{}, error) {
|
|||||||
select {
|
select {
|
||||||
case thing, ok := <-s.next:
|
case thing, ok := <-s.next:
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, errors.New("liner: internal error")
|
return 0, ErrInternal
|
||||||
}
|
}
|
||||||
if thing.err != nil {
|
if thing.err != nil {
|
||||||
return nil, thing.err
|
return nil, thing.err
|
||||||
|
87
vendor/github.com/peterh/liner/line.go
generated
vendored
87
vendor/github.com/peterh/liner/line.go
generated
vendored
@ -3,10 +3,12 @@
|
|||||||
package liner
|
package liner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"container/ring"
|
"container/ring"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@ -90,6 +92,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *State) refresh(prompt []rune, buf []rune, pos int) error {
|
func (s *State) refresh(prompt []rune, buf []rune, pos int) error {
|
||||||
|
if s.columns == 0 {
|
||||||
|
return ErrInternal
|
||||||
|
}
|
||||||
|
|
||||||
s.needRefresh = false
|
s.needRefresh = false
|
||||||
if s.multiLineMode {
|
if s.multiLineMode {
|
||||||
return s.refreshMultiLine(prompt, buf, pos)
|
return s.refreshMultiLine(prompt, buf, pos)
|
||||||
@ -351,8 +357,8 @@ func (s *State) tabComplete(p []rune, line []rune, pos int) ([]rune, int, interf
|
|||||||
}
|
}
|
||||||
hl := utf8.RuneCountInString(head)
|
hl := utf8.RuneCountInString(head)
|
||||||
if len(list) == 1 {
|
if len(list) == 1 {
|
||||||
s.refresh(p, []rune(head+list[0]+tail), hl+utf8.RuneCountInString(list[0]))
|
err := s.refresh(p, []rune(head+list[0]+tail), hl+utf8.RuneCountInString(list[0]))
|
||||||
return []rune(head + list[0] + tail), hl + utf8.RuneCountInString(list[0]), rune(esc), nil
|
return []rune(head + list[0] + tail), hl + utf8.RuneCountInString(list[0]), rune(esc), err
|
||||||
}
|
}
|
||||||
|
|
||||||
direction := tabForward
|
direction := tabForward
|
||||||
@ -366,7 +372,10 @@ func (s *State) tabComplete(p []rune, line []rune, pos int) ([]rune, int, interf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return line, pos, rune(esc), err
|
return line, pos, rune(esc), err
|
||||||
}
|
}
|
||||||
s.refresh(p, []rune(head+pick+tail), hl+utf8.RuneCountInString(pick))
|
err = s.refresh(p, []rune(head+pick+tail), hl+utf8.RuneCountInString(pick))
|
||||||
|
if err != nil {
|
||||||
|
return line, pos, rune(esc), err
|
||||||
|
}
|
||||||
|
|
||||||
next, err := s.readNext()
|
next, err := s.readNext()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -392,7 +401,10 @@ func (s *State) tabComplete(p []rune, line []rune, pos int) ([]rune, int, interf
|
|||||||
// reverse intelligent search, implements a bash-like history search.
|
// reverse intelligent search, implements a bash-like history search.
|
||||||
func (s *State) reverseISearch(origLine []rune, origPos int) ([]rune, int, interface{}, error) {
|
func (s *State) reverseISearch(origLine []rune, origPos int) ([]rune, int, interface{}, error) {
|
||||||
p := "(reverse-i-search)`': "
|
p := "(reverse-i-search)`': "
|
||||||
s.refresh([]rune(p), origLine, origPos)
|
err := s.refresh([]rune(p), origLine, origPos)
|
||||||
|
if err != nil {
|
||||||
|
return origLine, origPos, rune(esc), err
|
||||||
|
}
|
||||||
|
|
||||||
line := []rune{}
|
line := []rune{}
|
||||||
pos := 0
|
pos := 0
|
||||||
@ -478,7 +490,10 @@ func (s *State) reverseISearch(origLine []rune, origPos int) ([]rune, int, inter
|
|||||||
case action:
|
case action:
|
||||||
return []rune(foundLine), foundPos, next, err
|
return []rune(foundLine), foundPos, next, err
|
||||||
}
|
}
|
||||||
s.refresh(getLine())
|
err = s.refresh(getLine())
|
||||||
|
if err != nil {
|
||||||
|
return []rune(foundLine), foundPos, rune(esc), err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,7 +550,10 @@ func (s *State) yank(p []rune, text []rune, pos int) ([]rune, int, interface{},
|
|||||||
line = append(line, lineEnd...)
|
line = append(line, lineEnd...)
|
||||||
|
|
||||||
pos = len(lineStart) + len(value)
|
pos = len(lineStart) + len(value)
|
||||||
s.refresh(p, line, pos)
|
err := s.refresh(p, line, pos)
|
||||||
|
if err != nil {
|
||||||
|
return line, pos, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
next, err := s.readNext()
|
next, err := s.readNext()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -577,6 +595,11 @@ func (s *State) PromptWithSuggestion(prompt string, text string, pos int) (strin
|
|||||||
if s.inputRedirected || !s.terminalSupported {
|
if s.inputRedirected || !s.terminalSupported {
|
||||||
return s.promptUnsupported(prompt)
|
return s.promptUnsupported(prompt)
|
||||||
}
|
}
|
||||||
|
p := []rune(prompt)
|
||||||
|
const minWorkingSpace = 10
|
||||||
|
if s.columns < countGlyphs(p)+minWorkingSpace {
|
||||||
|
return s.tooNarrow(prompt)
|
||||||
|
}
|
||||||
if s.outputRedirected {
|
if s.outputRedirected {
|
||||||
return "", ErrNotTerminalOutput
|
return "", ErrNotTerminalOutput
|
||||||
}
|
}
|
||||||
@ -585,7 +608,6 @@ func (s *State) PromptWithSuggestion(prompt string, text string, pos int) (strin
|
|||||||
defer s.historyMutex.RUnlock()
|
defer s.historyMutex.RUnlock()
|
||||||
|
|
||||||
fmt.Print(prompt)
|
fmt.Print(prompt)
|
||||||
p := []rune(prompt)
|
|
||||||
var line = []rune(text)
|
var line = []rune(text)
|
||||||
historyEnd := ""
|
historyEnd := ""
|
||||||
var historyPrefix []string
|
var historyPrefix []string
|
||||||
@ -600,7 +622,10 @@ func (s *State) PromptWithSuggestion(prompt string, text string, pos int) (strin
|
|||||||
pos = len(text)
|
pos = len(text)
|
||||||
}
|
}
|
||||||
if len(line) > 0 {
|
if len(line) > 0 {
|
||||||
s.refresh(p, line, pos)
|
err := s.refresh(p, line, pos)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
@ -624,7 +649,10 @@ mainLoop:
|
|||||||
switch v {
|
switch v {
|
||||||
case cr, lf:
|
case cr, lf:
|
||||||
if s.needRefresh {
|
if s.needRefresh {
|
||||||
s.refresh(p, line, pos)
|
err := s.refresh(p, line, pos)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if s.multiLineMode {
|
if s.multiLineMode {
|
||||||
s.resetMultiLine(p, line, pos)
|
s.resetMultiLine(p, line, pos)
|
||||||
@ -958,7 +986,10 @@ mainLoop:
|
|||||||
s.needRefresh = true
|
s.needRefresh = true
|
||||||
}
|
}
|
||||||
if s.needRefresh && !s.inputWaiting() {
|
if s.needRefresh && !s.inputWaiting() {
|
||||||
s.refresh(p, line, pos)
|
err := s.refresh(p, line, pos)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !historyAction {
|
if !historyAction {
|
||||||
historyStale = true
|
historyStale = true
|
||||||
@ -978,7 +1009,7 @@ func (s *State) PasswordPrompt(prompt string) (string, error) {
|
|||||||
return "", ErrInvalidPrompt
|
return "", ErrInvalidPrompt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !s.terminalSupported {
|
if !s.terminalSupported || s.columns == 0 {
|
||||||
return "", errors.New("liner: function not supported in this terminal")
|
return "", errors.New("liner: function not supported in this terminal")
|
||||||
}
|
}
|
||||||
if s.inputRedirected {
|
if s.inputRedirected {
|
||||||
@ -988,6 +1019,12 @@ func (s *State) PasswordPrompt(prompt string) (string, error) {
|
|||||||
return "", ErrNotTerminalOutput
|
return "", ErrNotTerminalOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p := []rune(prompt)
|
||||||
|
const minWorkingSpace = 1
|
||||||
|
if s.columns < countGlyphs(p)+minWorkingSpace {
|
||||||
|
return s.tooNarrow(prompt)
|
||||||
|
}
|
||||||
|
|
||||||
defer s.stopPrompt()
|
defer s.stopPrompt()
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
@ -995,7 +1032,6 @@ restart:
|
|||||||
s.getColumns()
|
s.getColumns()
|
||||||
|
|
||||||
fmt.Print(prompt)
|
fmt.Print(prompt)
|
||||||
p := []rune(prompt)
|
|
||||||
var line []rune
|
var line []rune
|
||||||
pos := 0
|
pos := 0
|
||||||
|
|
||||||
@ -1014,7 +1050,10 @@ mainLoop:
|
|||||||
switch v {
|
switch v {
|
||||||
case cr, lf:
|
case cr, lf:
|
||||||
if s.needRefresh {
|
if s.needRefresh {
|
||||||
s.refresh(p, line, pos)
|
err := s.refresh(p, line, pos)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if s.multiLineMode {
|
if s.multiLineMode {
|
||||||
s.resetMultiLine(p, line, pos)
|
s.resetMultiLine(p, line, pos)
|
||||||
@ -1032,7 +1071,10 @@ mainLoop:
|
|||||||
s.restartPrompt()
|
s.restartPrompt()
|
||||||
case ctrlL: // clear screen
|
case ctrlL: // clear screen
|
||||||
s.eraseScreen()
|
s.eraseScreen()
|
||||||
s.refresh(p, []rune{}, 0)
|
err := s.refresh(p, []rune{}, 0)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
case ctrlH, bs: // Backspace
|
case ctrlH, bs: // Backspace
|
||||||
if pos <= 0 {
|
if pos <= 0 {
|
||||||
fmt.Print(beep)
|
fmt.Print(beep)
|
||||||
@ -1068,3 +1110,20 @@ mainLoop:
|
|||||||
}
|
}
|
||||||
return string(line), nil
|
return string(line), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *State) tooNarrow(prompt string) (string, error) {
|
||||||
|
// Docker and OpenWRT and etc sometimes return 0 column width
|
||||||
|
// Reset mode temporarily. Restore baked mode in case the terminal
|
||||||
|
// is wide enough for the next Prompt attempt.
|
||||||
|
m, merr := TerminalMode()
|
||||||
|
s.origMode.ApplyMode()
|
||||||
|
if merr == nil {
|
||||||
|
defer m.ApplyMode()
|
||||||
|
}
|
||||||
|
if s.r == nil {
|
||||||
|
// Windows does not always set s.r
|
||||||
|
s.r = bufio.NewReader(os.Stdin)
|
||||||
|
defer func() { s.r = nil }()
|
||||||
|
}
|
||||||
|
return s.promptUnsupported(prompt)
|
||||||
|
}
|
||||||
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
@ -256,10 +256,10 @@
|
|||||||
"revisionTime": "2017-01-12T15:04:04Z"
|
"revisionTime": "2017-01-12T15:04:04Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "4SfJoLxQlfSSQjBIMqK+IgNxLMk=",
|
"checksumSHA1": "lSRg5clrIZUxq4aaExbpnpAgtWA=",
|
||||||
"path": "github.com/peterh/liner",
|
"path": "github.com/peterh/liner",
|
||||||
"revision": "bf27d3ba8e1d9899d45a457ffac16c953eb2d647",
|
"revision": "a37ad39843113264dae84a5d89fcee28f50b35c6",
|
||||||
"revisionTime": "2017-02-11T19:53:22Z"
|
"revisionTime": "2017-09-02T20:46:57Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "WbbxCn2jUYIL5viqLo0BKXEdPrQ=",
|
"checksumSHA1": "WbbxCn2jUYIL5viqLo0BKXEdPrQ=",
|
||||||
|
Loading…
Reference in New Issue
Block a user