Watch 6 Star 6 Fork 2

ShirDon-廖显东 / uiprogressGoMIT

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
uiprogress是用于实时更新终端输出的go库 spread retract

https://gitee.com/shirdonl/uiprogress.git

Clone or download
terminal_size.go 604 Bytes
Copy Edit Web IDE Raw Blame History
ShirDon-廖显东 authored 2019-12-01 20:12 . git commit
// +build !windows
package uiprogress
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)
}
Go
1
https://gitee.com/shirdonl/uiprogress.git
git@gitee.com:shirdonl/uiprogress.git
shirdonl
uiprogress
uiprogress
master

Help Search