工具基本实现write功能
This commit is contained in:
25
cmd/saastool/term.go
Normal file
25
cmd/saastool/term.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://man7.org/linux/man-pages/man2/TIOCSWINSZ.2const.html
|
||||
|
||||
// winSize console窗口大小
|
||||
type winSize struct {
|
||||
wsRow uint16
|
||||
wsCols uint16
|
||||
wsXPixels uint16
|
||||
wxYPixels uint16
|
||||
}
|
||||
|
||||
// getConsoleSize 获取控制台窗口大小
|
||||
func getConsoleSize() (cols, rows int) {
|
||||
var sz winSize
|
||||
_, _, _ = syscall.Syscall(syscall.SYS_IOCTL,
|
||||
os.Stdout.Fd(), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&sz)))
|
||||
return int(sz.wsCols), int(sz.wsRow)
|
||||
}
|
||||
Reference in New Issue
Block a user