mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 05:40:42 +00:00 
			
		
		
		
	godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
		
			
				
	
	
		
			36 lines
		
	
	
		
			625 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			625 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package pty
 | |
| 
 | |
| import (
 | |
| 	"os"
 | |
| 	"syscall"
 | |
| 	"unsafe"
 | |
| )
 | |
| 
 | |
| // Getsize returns the number of rows (lines) and cols (positions
 | |
| // in each line) in terminal t.
 | |
| func Getsize(t *os.File) (rows, cols int, err error) {
 | |
| 	var ws winsize
 | |
| 	err = windowrect(&ws, t.Fd())
 | |
| 	return int(ws.ws_row), int(ws.ws_col), err
 | |
| }
 | |
| 
 | |
| type winsize struct {
 | |
| 	ws_row    uint16
 | |
| 	ws_col    uint16
 | |
| 	ws_xpixel uint16
 | |
| 	ws_ypixel uint16
 | |
| }
 | |
| 
 | |
| func windowrect(ws *winsize, fd uintptr) error {
 | |
| 	_, _, errno := syscall.Syscall(
 | |
| 		syscall.SYS_IOCTL,
 | |
| 		fd,
 | |
| 		syscall.TIOCGWINSZ,
 | |
| 		uintptr(unsafe.Pointer(ws)),
 | |
| 	)
 | |
| 	if errno != 0 {
 | |
| 		return syscall.Errno(errno)
 | |
| 	}
 | |
| 	return nil
 | |
| }
 |