build: go mod vendor
This commit is contained in:
parent
cdfb8a08bb
commit
b7c1e87c0b
21
vendor/github.com/muesli/reflow/LICENSE
generated
vendored
21
vendor/github.com/muesli/reflow/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Christian Muehlhaeuser
|
||||
|
||||
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.
|
7
vendor/github.com/muesli/reflow/ansi/ansi.go
generated
vendored
7
vendor/github.com/muesli/reflow/ansi/ansi.go
generated
vendored
@ -1,7 +0,0 @@
|
||||
package ansi
|
||||
|
||||
const Marker = '\x1B'
|
||||
|
||||
func IsTerminator(c rune) bool {
|
||||
return (c >= 0x40 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a)
|
||||
}
|
40
vendor/github.com/muesli/reflow/ansi/buffer.go
generated
vendored
40
vendor/github.com/muesli/reflow/ansi/buffer.go
generated
vendored
@ -1,40 +0,0 @@
|
||||
package ansi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
)
|
||||
|
||||
// Buffer is a buffer aware of ANSI escape sequences.
|
||||
type Buffer struct {
|
||||
bytes.Buffer
|
||||
}
|
||||
|
||||
// PrintableRuneWidth returns the cell width of all printable runes in the
|
||||
// buffer.
|
||||
func (w Buffer) PrintableRuneWidth() int {
|
||||
return PrintableRuneWidth(w.String())
|
||||
}
|
||||
|
||||
// PrintableRuneWidth returns the cell width of the given string.
|
||||
func PrintableRuneWidth(s string) int {
|
||||
var n int
|
||||
var ansi bool
|
||||
|
||||
for _, c := range s {
|
||||
if c == Marker {
|
||||
// ANSI escape sequence
|
||||
ansi = true
|
||||
} else if ansi {
|
||||
if IsTerminator(c) {
|
||||
// ANSI sequence terminated
|
||||
ansi = false
|
||||
}
|
||||
} else {
|
||||
n += runewidth.RuneWidth(c)
|
||||
}
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
76
vendor/github.com/muesli/reflow/ansi/writer.go
generated
vendored
76
vendor/github.com/muesli/reflow/ansi/writer.go
generated
vendored
@ -1,76 +0,0 @@
|
||||
package ansi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
type Writer struct {
|
||||
Forward io.Writer
|
||||
|
||||
ansi bool
|
||||
ansiseq bytes.Buffer
|
||||
lastseq bytes.Buffer
|
||||
seqchanged bool
|
||||
runeBuf []byte
|
||||
}
|
||||
|
||||
// Write is used to write content to the ANSI buffer.
|
||||
func (w *Writer) Write(b []byte) (int, error) {
|
||||
for _, c := range string(b) {
|
||||
if c == Marker {
|
||||
// ANSI escape sequence
|
||||
w.ansi = true
|
||||
w.seqchanged = true
|
||||
_, _ = w.ansiseq.WriteRune(c)
|
||||
} else if w.ansi {
|
||||
_, _ = w.ansiseq.WriteRune(c)
|
||||
if IsTerminator(c) {
|
||||
// ANSI sequence terminated
|
||||
w.ansi = false
|
||||
|
||||
if bytes.HasSuffix(w.ansiseq.Bytes(), []byte("[0m")) {
|
||||
// reset sequence
|
||||
w.lastseq.Reset()
|
||||
w.seqchanged = false
|
||||
} else if c == 'm' {
|
||||
// color code
|
||||
_, _ = w.lastseq.Write(w.ansiseq.Bytes())
|
||||
}
|
||||
|
||||
_, _ = w.ansiseq.WriteTo(w.Forward)
|
||||
}
|
||||
} else {
|
||||
_, err := w.writeRune(c)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func (w *Writer) writeRune(r rune) (int, error) {
|
||||
if w.runeBuf == nil {
|
||||
w.runeBuf = make([]byte, utf8.UTFMax)
|
||||
}
|
||||
n := utf8.EncodeRune(w.runeBuf, r)
|
||||
return w.Forward.Write(w.runeBuf[:n])
|
||||
}
|
||||
|
||||
func (w *Writer) LastSequence() string {
|
||||
return w.lastseq.String()
|
||||
}
|
||||
|
||||
func (w *Writer) ResetAnsi() {
|
||||
if !w.seqchanged {
|
||||
return
|
||||
}
|
||||
_, _ = w.Forward.Write([]byte("\x1b[0m"))
|
||||
}
|
||||
|
||||
func (w *Writer) RestoreAnsi() {
|
||||
_, _ = w.Forward.Write(w.lastseq.Bytes())
|
||||
}
|
167
vendor/github.com/muesli/reflow/wordwrap/wordwrap.go
generated
vendored
167
vendor/github.com/muesli/reflow/wordwrap/wordwrap.go
generated
vendored
@ -1,167 +0,0 @@
|
||||
package wordwrap
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/muesli/reflow/ansi"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultBreakpoints = []rune{'-'}
|
||||
defaultNewline = []rune{'\n'}
|
||||
)
|
||||
|
||||
// WordWrap contains settings and state for customisable text reflowing with
|
||||
// support for ANSI escape sequences. This means you can style your terminal
|
||||
// output without affecting the word wrapping algorithm.
|
||||
type WordWrap struct {
|
||||
Limit int
|
||||
Breakpoints []rune
|
||||
Newline []rune
|
||||
KeepNewlines bool
|
||||
|
||||
buf bytes.Buffer
|
||||
space bytes.Buffer
|
||||
word ansi.Buffer
|
||||
|
||||
lineLen int
|
||||
ansi bool
|
||||
}
|
||||
|
||||
// NewWriter returns a new instance of a word-wrapping writer, initialized with
|
||||
// default settings.
|
||||
func NewWriter(limit int) *WordWrap {
|
||||
return &WordWrap{
|
||||
Limit: limit,
|
||||
Breakpoints: defaultBreakpoints,
|
||||
Newline: defaultNewline,
|
||||
KeepNewlines: true,
|
||||
}
|
||||
}
|
||||
|
||||
// Bytes is shorthand for declaring a new default WordWrap instance,
|
||||
// used to immediately word-wrap a byte slice.
|
||||
func Bytes(b []byte, limit int) []byte {
|
||||
f := NewWriter(limit)
|
||||
_, _ = f.Write(b)
|
||||
_ = f.Close()
|
||||
|
||||
return f.Bytes()
|
||||
}
|
||||
|
||||
// String is shorthand for declaring a new default WordWrap instance,
|
||||
// used to immediately word-wrap a string.
|
||||
func String(s string, limit int) string {
|
||||
return string(Bytes([]byte(s), limit))
|
||||
}
|
||||
|
||||
func (w *WordWrap) addSpace() {
|
||||
w.lineLen += w.space.Len()
|
||||
_, _ = w.buf.Write(w.space.Bytes())
|
||||
w.space.Reset()
|
||||
}
|
||||
|
||||
func (w *WordWrap) addWord() {
|
||||
if w.word.Len() > 0 {
|
||||
w.addSpace()
|
||||
w.lineLen += w.word.PrintableRuneWidth()
|
||||
_, _ = w.buf.Write(w.word.Bytes())
|
||||
w.word.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WordWrap) addNewLine() {
|
||||
_, _ = w.buf.WriteRune('\n')
|
||||
w.lineLen = 0
|
||||
w.space.Reset()
|
||||
}
|
||||
|
||||
func inGroup(a []rune, c rune) bool {
|
||||
for _, v := range a {
|
||||
if v == c {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Write is used to write more content to the word-wrap buffer.
|
||||
func (w *WordWrap) Write(b []byte) (int, error) {
|
||||
if w.Limit == 0 {
|
||||
return w.buf.Write(b)
|
||||
}
|
||||
|
||||
s := string(b)
|
||||
if !w.KeepNewlines {
|
||||
s = strings.Replace(strings.TrimSpace(s), "\n", " ", -1)
|
||||
}
|
||||
|
||||
for _, c := range s {
|
||||
if c == '\x1B' {
|
||||
// ANSI escape sequence
|
||||
_, _ = w.word.WriteRune(c)
|
||||
w.ansi = true
|
||||
} else if w.ansi {
|
||||
_, _ = w.word.WriteRune(c)
|
||||
if (c >= 0x40 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a) {
|
||||
// ANSI sequence terminated
|
||||
w.ansi = false
|
||||
}
|
||||
} else if inGroup(w.Newline, c) {
|
||||
// end of current line
|
||||
// see if we can add the content of the space buffer to the current line
|
||||
if w.word.Len() == 0 {
|
||||
if w.lineLen+w.space.Len() > w.Limit {
|
||||
w.lineLen = 0
|
||||
} else {
|
||||
// preserve whitespace
|
||||
_, _ = w.buf.Write(w.space.Bytes())
|
||||
}
|
||||
w.space.Reset()
|
||||
}
|
||||
|
||||
w.addWord()
|
||||
w.addNewLine()
|
||||
} else if unicode.IsSpace(c) {
|
||||
// end of current word
|
||||
w.addWord()
|
||||
_, _ = w.space.WriteRune(c)
|
||||
} else if inGroup(w.Breakpoints, c) {
|
||||
// valid breakpoint
|
||||
w.addSpace()
|
||||
w.addWord()
|
||||
_, _ = w.buf.WriteRune(c)
|
||||
} else {
|
||||
// any other character
|
||||
_, _ = w.word.WriteRune(c)
|
||||
|
||||
// add a line break if the current word would exceed the line's
|
||||
// character limit
|
||||
if w.lineLen+w.space.Len()+w.word.PrintableRuneWidth() > w.Limit &&
|
||||
w.word.PrintableRuneWidth() < w.Limit {
|
||||
w.addNewLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
// Close will finish the word-wrap operation. Always call it before trying to
|
||||
// retrieve the final result.
|
||||
func (w *WordWrap) Close() error {
|
||||
w.addWord()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Bytes returns the word-wrapped result as a byte slice.
|
||||
func (w *WordWrap) Bytes() []byte {
|
||||
return w.buf.Bytes()
|
||||
}
|
||||
|
||||
// String returns the word-wrapped result as a string.
|
||||
func (w *WordWrap) String() string {
|
||||
return w.buf.String()
|
||||
}
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -466,8 +466,6 @@ github.com/muesli/ansi/compressor
|
||||
github.com/muesli/cancelreader
|
||||
# github.com/muesli/reflow v0.3.0
|
||||
## explicit; go 1.13
|
||||
github.com/muesli/reflow/ansi
|
||||
github.com/muesli/reflow/wordwrap
|
||||
# github.com/muesli/termenv v0.16.0
|
||||
## explicit; go 1.17
|
||||
github.com/muesli/termenv
|
||||
|
Loading…
x
Reference in New Issue
Block a user