Path: blob/main/vendor/github.com/chzyer/readline/term_nosyscall6.go
2875 views
// Copyright 2013 The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34// +build aix os400 solaris56package readline78import "golang.org/x/sys/unix"910// GetSize returns the dimensions of the given terminal.11func GetSize(fd int) (int, int, error) {12ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)13if err != nil {14return 0, 0, err15}16return int(ws.Col), int(ws.Row), nil17}1819type Termios unix.Termios2021func getTermios(fd int) (*Termios, error) {22termios, err := unix.IoctlGetTermios(fd, unix.TCGETS)23if err != nil {24return nil, err25}26return (*Termios)(termios), nil27}2829func setTermios(fd int, termios *Termios) error {30return unix.IoctlSetTermios(fd, unix.TCSETSF, (*unix.Termios)(termios))31}323334