diff --git a/Makefile b/Makefile index 798608a..5f9f08b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 1.1.4 +VERSION = 1.1.5 APP := jp PACKAGES := $(shell go list -f {{.Dir}} ./...) diff --git a/README.md b/README.md index bf01e58..25faf25 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,16 @@ Or [download the binary](https://github.com/sgreben/jp/releases/latest) from the ```bash # Linux -curl -LO https://github.com/sgreben/jp/releases/download/1.1.4/jp_1.1.4_linux_x86_64.zip -unzip jp_1.1.4_linux_x86_64.zip +curl -LO https://github.com/sgreben/jp/releases/download/1.1.5/jp_1.1.5_linux_x86_64.zip +unzip jp_1.1.5_linux_x86_64.zip # OS X -curl -LO https://github.com/sgreben/jp/releases/download/1.1.4/jp_1.1.4_osx_x86_64.zip -unzip jp_1.1.4_osx_x86_64.zip +curl -LO https://github.com/sgreben/jp/releases/download/1.1.5/jp_1.1.5_osx_x86_64.zip +unzip jp_1.1.5_osx_x86_64.zip # Windows -curl -LO https://github.com/sgreben/jp/releases/download/1.1.4/jp_1.1.4_windows_x86_64.zip -unzip jp_1.1.4_windows_x86_64.zip +curl -LO https://github.com/sgreben/jp/releases/download/1.1.5/jp_1.1.5_windows_x86_64.zip +unzip jp_1.1.5_windows_x86_64.zip ``` ## Use it @@ -69,6 +69,8 @@ Usage of jp: Plot width (default 0 (auto)) -canvas value Canvas type. One of [full quarter braille auto] (default auto) + -bins uint + Number of histogram bins (default 0 (auto)) -input value Input type. One of [json csv] (default json) ``` diff --git a/pkg/terminal/terminal.go b/pkg/terminal/terminal.go index 207275d..d15acee 100644 --- a/pkg/terminal/terminal.go +++ b/pkg/terminal/terminal.go @@ -31,7 +31,7 @@ func Width() int { col, _, err := getWinsize() if err != nil { - return -1 + return 79 } return col @@ -40,7 +40,7 @@ func Width() int { func Height() int { _, row, err := getWinsize() if err != nil { - return -1 + return 24 } return row } diff --git a/pkg/terminal/terminal_sysioctl.go b/pkg/terminal/terminal_sysioctl.go index 121b566..36bc1e2 100644 --- a/pkg/terminal/terminal_sysioctl.go +++ b/pkg/terminal/terminal_sysioctl.go @@ -11,9 +11,19 @@ import ( func getWinsize() (int, int, error) { ws, err := unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ) - if err != nil { - return 0, 0, os.NewSyscallError("GetWinsize", err) + if err == nil { + return int(ws.Col), int(ws.Row), nil } - return int(ws.Col), int(ws.Row), nil + ws, err = unix.IoctlGetWinsize(int(os.Stdin.Fd()), unix.TIOCGWINSZ) + if err == nil { + return int(ws.Col), int(ws.Row), nil + } + + ws, err = unix.IoctlGetWinsize(int(os.Stderr.Fd()), unix.TIOCGWINSZ) + if err == nil { + return int(ws.Col), int(ws.Row), nil + } + + return 0, 0, os.NewSyscallError("GetWinsize", err) }