-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into PR-fix-start-panic
- Loading branch information
Showing
10 changed files
with
158 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
language: go | ||
sudo: false | ||
|
||
matrix: | ||
include: | ||
- go: 1.11.x | ||
os: linux | ||
- go: 1.12.x | ||
os: linux | ||
- go: 1.11.x | ||
os: linux | ||
env: CROSS_COMPILE=true | ||
- go: 1.12.x | ||
os: linux | ||
env: CROSS_COMPILE=true | ||
- go: 1.11.x | ||
os: osx | ||
- go: 1.12.x | ||
os: osx | ||
|
||
install: | ||
- go get ./... | ||
go: | ||
- 1.4 | ||
- tip | ||
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CROSS_COMPILE" = "true" ]; then go get github.com/mattn/go-isatty ; fi | ||
- go get -t -v ./... | ||
|
||
script: | ||
- go build | ||
- go test | ||
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CROSS_COMPILE" = "true" ]; then env GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -v; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test: | ||
@go test -race . | ||
|
||
examples: | ||
@go run -race ./example | ||
|
||
.PHONY: test examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/gosuri/uilive | ||
|
||
go 1.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// +build !windows | ||
|
||
package uilive | ||
|
||
import ( | ||
"os" | ||
"runtime" | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
type windowSize struct { | ||
rows uint16 | ||
cols uint16 | ||
} | ||
|
||
var out *os.File | ||
var err error | ||
var sz windowSize | ||
|
||
func getTermSize() (int, int) { | ||
if runtime.GOOS == "openbsd" { | ||
out, err = os.OpenFile("/dev/tty", os.O_RDWR, 0) | ||
if err != nil { | ||
return 0, 0 | ||
} | ||
|
||
} else { | ||
out, err = os.OpenFile("/dev/tty", os.O_WRONLY, 0) | ||
if err != nil { | ||
return 0, 0 | ||
} | ||
} | ||
_, _, _ = syscall.Syscall(syscall.SYS_IOCTL, | ||
out.Fd(), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&sz))) | ||
return int(sz.cols), int(sz.rows) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// +build windows | ||
|
||
package uilive | ||
|
||
import ( | ||
"os" | ||
"unsafe" | ||
) | ||
|
||
func getTermSize() (int, int) { | ||
out, err := os.Open("CONOUT$") | ||
if err != nil { | ||
return 0, 0 | ||
} | ||
defer out.Close() | ||
|
||
var csbi consoleScreenBufferInfo | ||
ret, _, _ := procGetConsoleScreenBufferInfo.Call(out.Fd(), uintptr(unsafe.Pointer(&csbi))) | ||
if ret == 0 { | ||
return 0, 0 | ||
} | ||
|
||
return int(csbi.window.right - csbi.window.left + 1), int(csbi.window.bottom - csbi.window.top + 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters