summaryrefslogtreecommitdiff
path: root/vendor/github.com/buger
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/buger')
-rw-r--r--vendor/github.com/buger/goterm/LICENSE21
-rw-r--r--vendor/github.com/buger/goterm/README.md10
-rw-r--r--vendor/github.com/buger/goterm/plot.go8
-rw-r--r--vendor/github.com/buger/goterm/terminal.go14
-rw-r--r--vendor/github.com/buger/goterm/terminal_sysioctl.go28
5 files changed, 42 insertions, 39 deletions
diff --git a/vendor/github.com/buger/goterm/LICENSE b/vendor/github.com/buger/goterm/LICENSE
new file mode 100644
index 000000000..ac25aeb7d
--- /dev/null
+++ b/vendor/github.com/buger/goterm/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 Leonid Bugaev
+
+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.
diff --git a/vendor/github.com/buger/goterm/README.md b/vendor/github.com/buger/goterm/README.md
index 536b7b885..fc74e2105 100644
--- a/vendor/github.com/buger/goterm/README.md
+++ b/vendor/github.com/buger/goterm/README.md
@@ -93,13 +93,13 @@ Chart example:
chart := tm.NewLineChart(100, 20)
data := new(tm.DataTable)
- data.addColumn("Time")
- data.addColumn("Sin(x)")
- data.addColumn("Cos(x+1)")
+ data.AddColumn("Time")
+ data.AddColumn("Sin(x)")
+ data.AddColumn("Cos(x+1)")
for i := 0.1; i < 10; i += 0.1 {
- data.addRow(i, math.Sin(i), math.Cos(i+1))
- }
+ data.AddRow(i, math.Sin(i), math.Cos(i+1))
+ }
tm.Println(chart.Draw(data))
```
diff --git a/vendor/github.com/buger/goterm/plot.go b/vendor/github.com/buger/goterm/plot.go
index 77b9fb097..120147623 100644
--- a/vendor/github.com/buger/goterm/plot.go
+++ b/vendor/github.com/buger/goterm/plot.go
@@ -242,10 +242,10 @@ func (c *LineChart) DrawLine(x0, y0, x1, y1 int, symbol string) {
}
func getBoundaryValues(data *DataTable, index int) (maxX, minX, maxY, minY float64) {
- maxX = data.rows[0][0]
- minX = data.rows[0][0]
- maxY = data.rows[0][1]
- minY = data.rows[0][1]
+ maxX = math.Inf(-1)
+ minX = math.Inf(1)
+ maxY = math.Inf(-1)
+ minY = math.Inf(1)
for _, r := range data.rows {
maxX = math.Max(maxX, r[0])
diff --git a/vendor/github.com/buger/goterm/terminal.go b/vendor/github.com/buger/goterm/terminal.go
index 6b45c78bc..7c4dfa70f 100644
--- a/vendor/github.com/buger/goterm/terminal.go
+++ b/vendor/github.com/buger/goterm/terminal.go
@@ -27,7 +27,7 @@ const RESET = "\033[0m"
// Reset to default color
const RESET_COLOR = "\033[32m"
-// Return curor to start of line and clean it
+// Return cursor to start of line and clean it
const RESET_LINE = "\r\033[K"
// List of possible colors
@@ -68,10 +68,10 @@ type winsize struct {
}
// Global screen buffer
-// Its not recommented write to buffer dirrectly, use package Print,Printf,Println fucntions instead.
+// Its not recommended write to buffer dirrectly, use package Print,Printf,Println fucntions instead.
var Screen *bytes.Buffer = new(bytes.Buffer)
-// Get relative or absolute coorditantes
+// Get relative or absolute coordinates
// To get relative, set PCT flag to number:
//
// // Get 10% of total width to `x` and 20 to y
@@ -113,7 +113,7 @@ func Clear() {
// Move cursor to given position
func MoveCursor(x int, y int) {
- fmt.Fprintf(Screen, "\033[%d;%dH", x, y)
+ fmt.Fprintf(Screen, "\033[%d;%dH", y, x)
}
// Move cursor up relative the current position
@@ -148,7 +148,7 @@ func MoveTo(str string, x int, y int) (out string) {
// Return carrier to start of line
func ResetLine(str string) (out string) {
return applyTransform(str, func(idx int, line string) string {
- return fmt.Sprintf(RESET_LINE, line)
+ return fmt.Sprintf("%s%s", RESET_LINE, line)
})
}
@@ -215,12 +215,12 @@ func CurrentHeight() int {
// Flush buffer and ensure that it will not overflow screen
func Flush() {
- for idx, str := range strings.Split(Screen.String(), "\n") {
+ for idx, str := range strings.SplitAfter(Screen.String(), "\n") {
if idx > Height() {
return
}
- Output.WriteString(str + "\n")
+ Output.WriteString(str)
}
Output.Flush()
diff --git a/vendor/github.com/buger/goterm/terminal_sysioctl.go b/vendor/github.com/buger/goterm/terminal_sysioctl.go
index e98430fb9..5a61cd52b 100644
--- a/vendor/github.com/buger/goterm/terminal_sysioctl.go
+++ b/vendor/github.com/buger/goterm/terminal_sysioctl.go
@@ -3,34 +3,16 @@
package goterm
import (
- "fmt"
"os"
- "runtime"
- "syscall"
- "unsafe"
+ "golang.org/x/sys/unix"
)
-func getWinsize() (*winsize, error) {
- ws := new(winsize)
+func getWinsize() (*unix.Winsize, error) {
- var _TIOCGWINSZ int64
-
- switch runtime.GOOS {
- case "linux":
- _TIOCGWINSZ = 0x5413
- case "darwin":
- _TIOCGWINSZ = 1074295912
+ ws, err := unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ)
+ if err != nil {
+ return nil, os.NewSyscallError("GetWinsize", err)
}
- r1, _, errno := syscall.Syscall(syscall.SYS_IOCTL,
- uintptr(syscall.Stdin),
- uintptr(_TIOCGWINSZ),
- uintptr(unsafe.Pointer(ws)),
- )
-
- if int(r1) == -1 {
- fmt.Println("Error:", os.NewSyscallError("GetWinsize", errno))
- return nil, os.NewSyscallError("GetWinsize", errno)
- }
return ws, nil
}