vendor: github.com/nsf/termbox-go and dependencies for rclone ncdu
This commit is contained in:
parent
e069fc439e
commit
e31fc877e2
37 changed files with 6388 additions and 1 deletions
8
vendor/github.com/mattn/go-runewidth/.travis.yml
generated
vendored
Normal file
8
vendor/github.com/mattn/go-runewidth/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
language: go
|
||||
go:
|
||||
- tip
|
||||
before_install:
|
||||
- go get github.com/mattn/goveralls
|
||||
- go get golang.org/x/tools/cmd/cover
|
||||
script:
|
||||
- $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL
|
21
vendor/github.com/mattn/go-runewidth/LICENSE
generated
vendored
Normal file
21
vendor/github.com/mattn/go-runewidth/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Yasuhiro Matsumoto
|
||||
|
||||
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.
|
27
vendor/github.com/mattn/go-runewidth/README.mkd
generated
vendored
Normal file
27
vendor/github.com/mattn/go-runewidth/README.mkd
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
go-runewidth
|
||||
============
|
||||
|
||||
[](https://travis-ci.org/mattn/go-runewidth)
|
||||
[](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD)
|
||||
[](http://godoc.org/github.com/mattn/go-runewidth)
|
||||
[](https://goreportcard.com/report/github.com/mattn/go-runewidth)
|
||||
|
||||
Provides functions to get fixed width of the character or string.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
```go
|
||||
runewidth.StringWidth("つのだ☆HIRO") == 12
|
||||
```
|
||||
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Yasuhiro Matsumoto
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
under the MIT License: http://mattn.mit-license.org/2013
|
1223
vendor/github.com/mattn/go-runewidth/runewidth.go
generated
vendored
Normal file
1223
vendor/github.com/mattn/go-runewidth/runewidth.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
8
vendor/github.com/mattn/go-runewidth/runewidth_js.go
generated
vendored
Normal file
8
vendor/github.com/mattn/go-runewidth/runewidth_js.go
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
// +build js
|
||||
|
||||
package runewidth
|
||||
|
||||
func IsEastAsian() bool {
|
||||
// TODO: Implement this for the web. Detect east asian in a compatible way, and return true.
|
||||
return false
|
||||
}
|
77
vendor/github.com/mattn/go-runewidth/runewidth_posix.go
generated
vendored
Normal file
77
vendor/github.com/mattn/go-runewidth/runewidth_posix.go
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
// +build !windows,!js
|
||||
|
||||
package runewidth
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\.(.+)`)
|
||||
|
||||
var mblenTable = map[string]int{
|
||||
"utf-8": 6,
|
||||
"utf8": 6,
|
||||
"jis": 8,
|
||||
"eucjp": 3,
|
||||
"euckr": 2,
|
||||
"euccn": 2,
|
||||
"sjis": 2,
|
||||
"cp932": 2,
|
||||
"cp51932": 2,
|
||||
"cp936": 2,
|
||||
"cp949": 2,
|
||||
"cp950": 2,
|
||||
"big5": 2,
|
||||
"gbk": 2,
|
||||
"gb2312": 2,
|
||||
}
|
||||
|
||||
func isEastAsian(locale string) bool {
|
||||
charset := strings.ToLower(locale)
|
||||
r := reLoc.FindStringSubmatch(locale)
|
||||
if len(r) == 2 {
|
||||
charset = strings.ToLower(r[1])
|
||||
}
|
||||
|
||||
if strings.HasSuffix(charset, "@cjk_narrow") {
|
||||
return false
|
||||
}
|
||||
|
||||
for pos, b := range []byte(charset) {
|
||||
if b == '@' {
|
||||
charset = charset[:pos]
|
||||
break
|
||||
}
|
||||
}
|
||||
max := 1
|
||||
if m, ok := mblenTable[charset]; ok {
|
||||
max = m
|
||||
}
|
||||
if max > 1 && (charset[0] != 'u' ||
|
||||
strings.HasPrefix(locale, "ja") ||
|
||||
strings.HasPrefix(locale, "ko") ||
|
||||
strings.HasPrefix(locale, "zh")) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsEastAsian return true if the current locale is CJK
|
||||
func IsEastAsian() bool {
|
||||
locale := os.Getenv("LC_CTYPE")
|
||||
if locale == "" {
|
||||
locale = os.Getenv("LANG")
|
||||
}
|
||||
|
||||
// ignore C locale
|
||||
if locale == "POSIX" || locale == "C" {
|
||||
return false
|
||||
}
|
||||
if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') {
|
||||
return false
|
||||
}
|
||||
|
||||
return isEastAsian(locale)
|
||||
}
|
275
vendor/github.com/mattn/go-runewidth/runewidth_test.go
generated
vendored
Normal file
275
vendor/github.com/mattn/go-runewidth/runewidth_test.go
generated
vendored
Normal file
|
@ -0,0 +1,275 @@
|
|||
package runewidth
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var _ sort.Interface = (*table)(nil)
|
||||
|
||||
func (t table) Len() int {
|
||||
return len(t)
|
||||
}
|
||||
|
||||
func (t table) Less(i, j int) bool {
|
||||
return t[i].first < t[j].first
|
||||
}
|
||||
|
||||
func (t *table) Swap(i, j int) {
|
||||
(*t)[i], (*t)[j] = (*t)[j], (*t)[i]
|
||||
}
|
||||
|
||||
var tables = []table{
|
||||
private,
|
||||
nonprint,
|
||||
combining,
|
||||
doublewidth,
|
||||
ambiguous,
|
||||
emoji,
|
||||
notassigned,
|
||||
neutral,
|
||||
}
|
||||
|
||||
func TestSorted(t *testing.T) {
|
||||
for _, tbl := range tables {
|
||||
if !sort.IsSorted(&tbl) {
|
||||
t.Errorf("not sorted")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var runewidthtests = []struct {
|
||||
in rune
|
||||
out int
|
||||
eaout int
|
||||
}{
|
||||
{'世', 2, 2},
|
||||
{'界', 2, 2},
|
||||
{'セ', 1, 1},
|
||||
{'カ', 1, 1},
|
||||
{'イ', 1, 1},
|
||||
{'☆', 1, 2}, // double width in ambiguous
|
||||
{'\x00', 0, 0},
|
||||
{'\x01', 0, 0},
|
||||
{'\u0300', 0, 0},
|
||||
}
|
||||
|
||||
func TestRuneWidth(t *testing.T) {
|
||||
c := NewCondition()
|
||||
for _, tt := range runewidthtests {
|
||||
if out := c.RuneWidth(tt.in); out != tt.out {
|
||||
t.Errorf("RuneWidth(%q) = %d, want %d", tt.in, out, tt.out)
|
||||
}
|
||||
}
|
||||
c.EastAsianWidth = true
|
||||
for _, tt := range runewidthtests {
|
||||
if out := c.RuneWidth(tt.in); out != tt.eaout {
|
||||
t.Errorf("RuneWidth(%q) = %d, want %d", tt.in, out, tt.eaout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isambiguouswidthtests = []struct {
|
||||
in rune
|
||||
out bool
|
||||
}{
|
||||
{'世', false},
|
||||
{'■', true},
|
||||
{'界', false},
|
||||
{'○', true},
|
||||
{'㈱', false},
|
||||
{'①', true},
|
||||
{'②', true},
|
||||
{'③', true},
|
||||
{'④', true},
|
||||
{'⑤', true},
|
||||
{'⑥', true},
|
||||
{'⑦', true},
|
||||
{'⑧', true},
|
||||
{'⑨', true},
|
||||
{'⑩', true},
|
||||
{'⑪', true},
|
||||
{'⑫', true},
|
||||
{'⑬', true},
|
||||
{'⑭', true},
|
||||
{'⑮', true},
|
||||
{'⑯', true},
|
||||
{'⑰', true},
|
||||
{'⑱', true},
|
||||
{'⑲', true},
|
||||
{'⑳', true},
|
||||
{'☆', true},
|
||||
}
|
||||
|
||||
func TestIsAmbiguousWidth(t *testing.T) {
|
||||
for _, tt := range isambiguouswidthtests {
|
||||
if out := IsAmbiguousWidth(tt.in); out != tt.out {
|
||||
t.Errorf("IsAmbiguousWidth(%q) = %v, want %v", tt.in, out, tt.out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var stringwidthtests = []struct {
|
||||
in string
|
||||
out int
|
||||
eaout int
|
||||
}{
|
||||
{"■㈱の世界①", 10, 12},
|
||||
{"スター☆", 7, 8},
|
||||
{"つのだ☆HIRO", 11, 12},
|
||||
}
|
||||
|
||||
func TestStringWidth(t *testing.T) {
|
||||
c := NewCondition()
|
||||
for _, tt := range stringwidthtests {
|
||||
if out := c.StringWidth(tt.in); out != tt.out {
|
||||
t.Errorf("StringWidth(%q) = %q, want %q", tt.in, out, tt.out)
|
||||
}
|
||||
}
|
||||
c.EastAsianWidth = true
|
||||
for _, tt := range stringwidthtests {
|
||||
if out := c.StringWidth(tt.in); out != tt.eaout {
|
||||
t.Errorf("StringWidth(%q) = %q, want %q", tt.in, out, tt.eaout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringWidthInvalid(t *testing.T) {
|
||||
s := "こんにちわ\x00世界"
|
||||
if out := StringWidth(s); out != 14 {
|
||||
t.Errorf("StringWidth(%q) = %q, want %q", s, out, 14)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateSmaller(t *testing.T) {
|
||||
s := "あいうえお"
|
||||
expected := "あいうえお"
|
||||
|
||||
if out := Truncate(s, 10, "..."); out != expected {
|
||||
t.Errorf("Truncate(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncate(t *testing.T) {
|
||||
s := "あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおおお"
|
||||
expected := "あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおお..."
|
||||
out := Truncate(s, 80, "...")
|
||||
if out != expected {
|
||||
t.Errorf("Truncate(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
width := StringWidth(out)
|
||||
if width != 79 {
|
||||
t.Errorf("width of Truncate(%q) should be %d, but %d", s, 79, width)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateFit(t *testing.T) {
|
||||
s := "aあいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおおお"
|
||||
expected := "aあいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおお..."
|
||||
|
||||
out := Truncate(s, 80, "...")
|
||||
if out != expected {
|
||||
t.Errorf("Truncate(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
width := StringWidth(out)
|
||||
if width != 80 {
|
||||
t.Errorf("width of Truncate(%q) should be %d, but %d", s, 80, width)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateJustFit(t *testing.T) {
|
||||
s := "あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおお"
|
||||
expected := "あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおお"
|
||||
|
||||
out := Truncate(s, 80, "...")
|
||||
if out != expected {
|
||||
t.Errorf("Truncate(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
width := StringWidth(out)
|
||||
if width != 80 {
|
||||
t.Errorf("width of Truncate(%q) should be %d, but %d", s, 80, width)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrap(t *testing.T) {
|
||||
s := `東京特許許可局局長はよく柿喰う客だ/東京特許許可局局長はよく柿喰う客だ
|
||||
123456789012345678901234567890
|
||||
|
||||
END`
|
||||
expected := `東京特許許可局局長はよく柿喰う
|
||||
客だ/東京特許許可局局長はよく
|
||||
柿喰う客だ
|
||||
123456789012345678901234567890
|
||||
|
||||
END`
|
||||
|
||||
if out := Wrap(s, 30); out != expected {
|
||||
t.Errorf("Wrap(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateNoNeeded(t *testing.T) {
|
||||
s := "あいうえおあい"
|
||||
expected := "あいうえおあい"
|
||||
|
||||
if out := Truncate(s, 80, "..."); out != expected {
|
||||
t.Errorf("Truncate(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
}
|
||||
|
||||
var isneutralwidthtests = []struct {
|
||||
in rune
|
||||
out bool
|
||||
}{
|
||||
{'→', false},
|
||||
{'┊', false},
|
||||
{'┈', false},
|
||||
{'~', false},
|
||||
{'└', false},
|
||||
{'⣀', true},
|
||||
{'⣀', true},
|
||||
}
|
||||
|
||||
func TestIsNeutralWidth(t *testing.T) {
|
||||
for _, tt := range isneutralwidthtests {
|
||||
if out := IsNeutralWidth(tt.in); out != tt.out {
|
||||
t.Errorf("IsNeutralWidth(%q) = %v, want %v", tt.in, out, tt.out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFillLeft(t *testing.T) {
|
||||
s := "あxいうえお"
|
||||
expected := " あxいうえお"
|
||||
|
||||
if out := FillLeft(s, 15); out != expected {
|
||||
t.Errorf("FillLeft(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFillLeftFit(t *testing.T) {
|
||||
s := "あいうえお"
|
||||
expected := "あいうえお"
|
||||
|
||||
if out := FillLeft(s, 10); out != expected {
|
||||
t.Errorf("FillLeft(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFillRight(t *testing.T) {
|
||||
s := "あxいうえお"
|
||||
expected := "あxいうえお "
|
||||
|
||||
if out := FillRight(s, 15); out != expected {
|
||||
t.Errorf("FillRight(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFillRightFit(t *testing.T) {
|
||||
s := "あいうえお"
|
||||
expected := "あいうえお"
|
||||
|
||||
if out := FillRight(s, 10); out != expected {
|
||||
t.Errorf("FillRight(%q) = %q, want %q", s, out, expected)
|
||||
}
|
||||
}
|
25
vendor/github.com/mattn/go-runewidth/runewidth_windows.go
generated
vendored
Normal file
25
vendor/github.com/mattn/go-runewidth/runewidth_windows.go
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
package runewidth
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var (
|
||||
kernel32 = syscall.NewLazyDLL("kernel32")
|
||||
procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP")
|
||||
)
|
||||
|
||||
// IsEastAsian return true if the current locale is CJK
|
||||
func IsEastAsian() bool {
|
||||
r1, _, _ := procGetConsoleOutputCP.Call()
|
||||
if r1 == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
switch int(r1) {
|
||||
case 932, 51932, 936, 949, 950:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue