mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg/term: deprecate package in favor of moby/term
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ba8129b28a
commit
701b39f5f0
11 changed files with 43 additions and 3 deletions
|
@ -42,6 +42,7 @@ var ASCII = []string{
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToBytes converts a string representing a suite of key-sequence to the corresponding ASCII code.
|
// ToBytes converts a string representing a suite of key-sequence to the corresponding ASCII code.
|
||||||
|
// Deprecated: use github.com/moby/term.ToBytes
|
||||||
func ToBytes(keys string) ([]byte, error) {
|
func ToBytes(keys string) ([]byte, error) {
|
||||||
codes := []byte{}
|
codes := []byte{}
|
||||||
next:
|
next:
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
// EscapeError is special error which returned by a TTY proxy reader's Read()
|
// EscapeError is special error which returned by a TTY proxy reader's Read()
|
||||||
// method in case its detach escape sequence is read.
|
// method in case its detach escape sequence is read.
|
||||||
|
// Deprecated: use github.com/moby/term.EscapeError
|
||||||
type EscapeError struct{}
|
type EscapeError struct{}
|
||||||
|
|
||||||
func (EscapeError) Error() string {
|
func (EscapeError) Error() string {
|
||||||
|
@ -25,6 +26,7 @@ type escapeProxy struct {
|
||||||
// NewEscapeProxy returns a new TTY proxy reader which wraps the given reader
|
// NewEscapeProxy returns a new TTY proxy reader which wraps the given reader
|
||||||
// and detects when the specified escape keys are read, in which case the Read
|
// and detects when the specified escape keys are read, in which case the Read
|
||||||
// method will return an error of type EscapeError.
|
// method will return an error of type EscapeError.
|
||||||
|
// Deprecated: use github.com/moby/term.NewEscapeProxy
|
||||||
func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader {
|
func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader {
|
||||||
return &escapeProxy{
|
return &escapeProxy{
|
||||||
escapeKeys: escapeKeys,
|
escapeKeys: escapeKeys,
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
// Package term provides structures and helper functions to work with
|
// Package term provides structures and helper functions to work with
|
||||||
// terminal (state, sizes).
|
// terminal (state, sizes).
|
||||||
|
//
|
||||||
|
// Deprecated: use github.com/moby/term instead
|
||||||
package term // import "github.com/docker/docker/pkg/term"
|
package term // import "github.com/docker/docker/pkg/term"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -20,11 +22,13 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// State represents the state of the terminal.
|
// State represents the state of the terminal.
|
||||||
|
// Deprecated: use github.com/moby/term.State
|
||||||
type State struct {
|
type State struct {
|
||||||
termios Termios
|
termios Termios
|
||||||
}
|
}
|
||||||
|
|
||||||
// Winsize represents the size of the terminal window.
|
// Winsize represents the size of the terminal window.
|
||||||
|
// Deprecated: use github.com/moby/term.Winsize
|
||||||
type Winsize struct {
|
type Winsize struct {
|
||||||
Height uint16
|
Height uint16
|
||||||
Width uint16
|
Width uint16
|
||||||
|
@ -33,11 +37,13 @@ type Winsize struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// StdStreams returns the standard streams (stdin, stdout, stderr).
|
// StdStreams returns the standard streams (stdin, stdout, stderr).
|
||||||
|
// Deprecated: use github.com/moby/term.StdStreams
|
||||||
func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||||
return os.Stdin, os.Stdout, os.Stderr
|
return os.Stdin, os.Stdout, os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.
|
// GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.
|
||||||
|
// Deprecated: use github.com/moby/term.GetFdInfo
|
||||||
func GetFdInfo(in interface{}) (uintptr, bool) {
|
func GetFdInfo(in interface{}) (uintptr, bool) {
|
||||||
var inFd uintptr
|
var inFd uintptr
|
||||||
var isTerminalIn bool
|
var isTerminalIn bool
|
||||||
|
@ -49,6 +55,7 @@ func GetFdInfo(in interface{}) (uintptr, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||||
|
// Deprecated: use github.com/moby/term.IsTerminal
|
||||||
func IsTerminal(fd uintptr) bool {
|
func IsTerminal(fd uintptr) bool {
|
||||||
var termios Termios
|
var termios Termios
|
||||||
return tcget(fd, &termios) == 0
|
return tcget(fd, &termios) == 0
|
||||||
|
@ -56,6 +63,7 @@ func IsTerminal(fd uintptr) bool {
|
||||||
|
|
||||||
// RestoreTerminal restores the terminal connected to the given file descriptor
|
// RestoreTerminal restores the terminal connected to the given file descriptor
|
||||||
// to a previous state.
|
// to a previous state.
|
||||||
|
// Deprecated: use github.com/moby/term.RestoreTerminal
|
||||||
func RestoreTerminal(fd uintptr, state *State) error {
|
func RestoreTerminal(fd uintptr, state *State) error {
|
||||||
if state == nil {
|
if state == nil {
|
||||||
return ErrInvalidState
|
return ErrInvalidState
|
||||||
|
@ -67,6 +75,7 @@ func RestoreTerminal(fd uintptr, state *State) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveState saves the state of the terminal connected to the given file descriptor.
|
// SaveState saves the state of the terminal connected to the given file descriptor.
|
||||||
|
// Deprecated: use github.com/moby/term.SaveState
|
||||||
func SaveState(fd uintptr) (*State, error) {
|
func SaveState(fd uintptr) (*State, error) {
|
||||||
var oldState State
|
var oldState State
|
||||||
if err := tcget(fd, &oldState.termios); err != 0 {
|
if err := tcget(fd, &oldState.termios); err != 0 {
|
||||||
|
@ -78,6 +87,7 @@ func SaveState(fd uintptr) (*State, error) {
|
||||||
|
|
||||||
// DisableEcho applies the specified state to the terminal connected to the file
|
// DisableEcho applies the specified state to the terminal connected to the file
|
||||||
// descriptor, with echo disabled.
|
// descriptor, with echo disabled.
|
||||||
|
// Deprecated: use github.com/moby/term.DisableEcho
|
||||||
func DisableEcho(fd uintptr, state *State) error {
|
func DisableEcho(fd uintptr, state *State) error {
|
||||||
newState := state.termios
|
newState := state.termios
|
||||||
newState.Lflag &^= unix.ECHO
|
newState.Lflag &^= unix.ECHO
|
||||||
|
@ -92,6 +102,7 @@ func DisableEcho(fd uintptr, state *State) error {
|
||||||
// SetRawTerminal puts the terminal connected to the given file descriptor into
|
// SetRawTerminal puts the terminal connected to the given file descriptor into
|
||||||
// raw mode and returns the previous state. On UNIX, this puts both the input
|
// raw mode and returns the previous state. On UNIX, this puts both the input
|
||||||
// and output into raw mode. On Windows, it only puts the input into raw mode.
|
// and output into raw mode. On Windows, it only puts the input into raw mode.
|
||||||
|
// Deprecated: use github.com/moby/term.SetRawTerminal
|
||||||
func SetRawTerminal(fd uintptr) (*State, error) {
|
func SetRawTerminal(fd uintptr) (*State, error) {
|
||||||
oldState, err := MakeRaw(fd)
|
oldState, err := MakeRaw(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -104,6 +115,7 @@ func SetRawTerminal(fd uintptr) (*State, error) {
|
||||||
// SetRawTerminalOutput puts the output of terminal connected to the given file
|
// SetRawTerminalOutput puts the output of terminal connected to the given file
|
||||||
// descriptor into raw mode. On UNIX, this does nothing and returns nil for the
|
// descriptor into raw mode. On UNIX, this does nothing and returns nil for the
|
||||||
// state. On Windows, it disables LF -> CRLF translation.
|
// state. On Windows, it disables LF -> CRLF translation.
|
||||||
|
// Deprecated: use github.com/moby/term.SetRawTerminalOutput
|
||||||
func SetRawTerminalOutput(fd uintptr) (*State, error) {
|
func SetRawTerminalOutput(fd uintptr) (*State, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// State holds the console mode for the terminal.
|
// State holds the console mode for the terminal.
|
||||||
|
// Deprecated: use github.com/moby/term.State
|
||||||
type State struct {
|
type State struct {
|
||||||
mode uint32
|
mode uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Winsize is used for window size.
|
// Winsize is used for window size.
|
||||||
|
// Deprecated: use github.com/moby/term.Winsize
|
||||||
type Winsize struct {
|
type Winsize struct {
|
||||||
Height uint16
|
Height uint16
|
||||||
Width uint16
|
Width uint16
|
||||||
|
@ -25,6 +27,7 @@ type Winsize struct {
|
||||||
var vtInputSupported bool
|
var vtInputSupported bool
|
||||||
|
|
||||||
// StdStreams returns the standard streams (stdin, stdout, stderr).
|
// StdStreams returns the standard streams (stdin, stdout, stderr).
|
||||||
|
// Deprecated: use github.com/moby/term.StdStreams
|
||||||
func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||||
// Turn on VT handling on all std handles, if possible. This might
|
// Turn on VT handling on all std handles, if possible. This might
|
||||||
// fail, in which case we will fall back to terminal emulation.
|
// fail, in which case we will fall back to terminal emulation.
|
||||||
|
@ -88,11 +91,13 @@ func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.
|
// GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.
|
||||||
|
// Deprecated: use github.com/moby/term.GetFdInfo
|
||||||
func GetFdInfo(in interface{}) (uintptr, bool) {
|
func GetFdInfo(in interface{}) (uintptr, bool) {
|
||||||
return windowsconsole.GetHandleInfo(in)
|
return windowsconsole.GetHandleInfo(in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWinsize returns the window size based on the specified file descriptor.
|
// GetWinsize returns the window size based on the specified file descriptor.
|
||||||
|
// Deprecated: use github.com/moby/term.GetWinsize
|
||||||
func GetWinsize(fd uintptr) (*Winsize, error) {
|
func GetWinsize(fd uintptr) (*Winsize, error) {
|
||||||
info, err := winterm.GetConsoleScreenBufferInfo(fd)
|
info, err := winterm.GetConsoleScreenBufferInfo(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -108,17 +113,20 @@ func GetWinsize(fd uintptr) (*Winsize, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||||
|
// Deprecated: use github.com/moby/term.IsTerminal
|
||||||
func IsTerminal(fd uintptr) bool {
|
func IsTerminal(fd uintptr) bool {
|
||||||
return windowsconsole.IsConsole(fd)
|
return windowsconsole.IsConsole(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreTerminal restores the terminal connected to the given file descriptor
|
// RestoreTerminal restores the terminal connected to the given file descriptor
|
||||||
// to a previous state.
|
// to a previous state.
|
||||||
|
// Deprecated: use github.com/moby/term.RestoreTerminal
|
||||||
func RestoreTerminal(fd uintptr, state *State) error {
|
func RestoreTerminal(fd uintptr, state *State) error {
|
||||||
return winterm.SetConsoleMode(fd, state.mode)
|
return winterm.SetConsoleMode(fd, state.mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveState saves the state of the terminal connected to the given file descriptor.
|
// SaveState saves the state of the terminal connected to the given file descriptor.
|
||||||
|
// Deprecated: use github.com/moby/term.SaveState
|
||||||
func SaveState(fd uintptr) (*State, error) {
|
func SaveState(fd uintptr) (*State, error) {
|
||||||
mode, e := winterm.GetConsoleMode(fd)
|
mode, e := winterm.GetConsoleMode(fd)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
@ -130,6 +138,7 @@ func SaveState(fd uintptr) (*State, error) {
|
||||||
|
|
||||||
// DisableEcho disables echo for the terminal connected to the given file descriptor.
|
// DisableEcho disables echo for the terminal connected to the given file descriptor.
|
||||||
// -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683462(v=vs.85).aspx
|
// -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683462(v=vs.85).aspx
|
||||||
|
// Deprecated: use github.com/moby/term.DisableEcho
|
||||||
func DisableEcho(fd uintptr, state *State) error {
|
func DisableEcho(fd uintptr, state *State) error {
|
||||||
mode := state.mode
|
mode := state.mode
|
||||||
mode &^= winterm.ENABLE_ECHO_INPUT
|
mode &^= winterm.ENABLE_ECHO_INPUT
|
||||||
|
@ -147,6 +156,7 @@ func DisableEcho(fd uintptr, state *State) error {
|
||||||
// SetRawTerminal puts the terminal connected to the given file descriptor into
|
// SetRawTerminal puts the terminal connected to the given file descriptor into
|
||||||
// raw mode and returns the previous state. On UNIX, this puts both the input
|
// raw mode and returns the previous state. On UNIX, this puts both the input
|
||||||
// and output into raw mode. On Windows, it only puts the input into raw mode.
|
// and output into raw mode. On Windows, it only puts the input into raw mode.
|
||||||
|
// Deprecated: use github.com/moby/term.SetRawTerminal
|
||||||
func SetRawTerminal(fd uintptr) (*State, error) {
|
func SetRawTerminal(fd uintptr) (*State, error) {
|
||||||
state, err := MakeRaw(fd)
|
state, err := MakeRaw(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -161,6 +171,7 @@ func SetRawTerminal(fd uintptr) (*State, error) {
|
||||||
// SetRawTerminalOutput puts the output of terminal connected to the given file
|
// SetRawTerminalOutput puts the output of terminal connected to the given file
|
||||||
// descriptor into raw mode. On UNIX, this does nothing and returns nil for the
|
// descriptor into raw mode. On UNIX, this does nothing and returns nil for the
|
||||||
// state. On Windows, it disables LF -> CRLF translation.
|
// state. On Windows, it disables LF -> CRLF translation.
|
||||||
|
// Deprecated: use github.com/moby/term.SetRawTerminalOutput
|
||||||
func SetRawTerminalOutput(fd uintptr) (*State, error) {
|
func SetRawTerminalOutput(fd uintptr) (*State, error) {
|
||||||
state, err := SaveState(fd)
|
state, err := SaveState(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -175,6 +186,7 @@ func SetRawTerminalOutput(fd uintptr) (*State, error) {
|
||||||
|
|
||||||
// MakeRaw puts the terminal (Windows Console) connected to the given file descriptor into raw
|
// MakeRaw puts the terminal (Windows Console) connected to the given file descriptor into raw
|
||||||
// mode and returns the previous state of the terminal so that it can be restored.
|
// mode and returns the previous state of the terminal so that it can be restored.
|
||||||
|
// Deprecated: use github.com/moby/term.MakeRaw
|
||||||
func MakeRaw(fd uintptr) (*State, error) {
|
func MakeRaw(fd uintptr) (*State, error) {
|
||||||
state, err := SaveState(fd)
|
state, err := SaveState(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -14,11 +14,13 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Termios is the Unix API for terminal I/O.
|
// Termios is the Unix API for terminal I/O.
|
||||||
|
// Deprecated: use github.com/moby/term.Termios
|
||||||
type Termios unix.Termios
|
type Termios unix.Termios
|
||||||
|
|
||||||
// MakeRaw put the terminal connected to the given file descriptor into raw
|
// MakeRaw put the terminal connected to the given file descriptor into raw
|
||||||
// mode and returns the previous state of the terminal so that it can be
|
// mode and returns the previous state of the terminal so that it can be
|
||||||
// restored.
|
// restored.
|
||||||
|
// Deprecated: use github.com/moby/term.MakeRaw
|
||||||
func MakeRaw(fd uintptr) (*State, error) {
|
func MakeRaw(fd uintptr) (*State, error) {
|
||||||
var oldState State
|
var oldState State
|
||||||
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
|
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
|
||||||
|
|
|
@ -10,11 +10,13 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Termios is the Unix API for terminal I/O.
|
// Termios is the Unix API for terminal I/O.
|
||||||
|
// Deprecated: use github.com/moby/term.Termios
|
||||||
type Termios unix.Termios
|
type Termios unix.Termios
|
||||||
|
|
||||||
// MakeRaw put the terminal connected to the given file descriptor into raw
|
// MakeRaw put the terminal connected to the given file descriptor into raw
|
||||||
// mode and returns the previous state of the terminal so that it can be
|
// mode and returns the previous state of the terminal so that it can be
|
||||||
// restored.
|
// restored.
|
||||||
|
// Deprecated: use github.com/moby/term.MakeRaw
|
||||||
func MakeRaw(fd uintptr) (*State, error) {
|
func MakeRaw(fd uintptr) (*State, error) {
|
||||||
termios, err := unix.IoctlGetTermios(int(fd), getTermios)
|
termios, err := unix.IoctlGetTermios(int(fd), getTermios)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -30,6 +30,7 @@ type ansiReader struct {
|
||||||
|
|
||||||
// NewAnsiReader returns an io.ReadCloser that provides VT100 terminal emulation on top of a
|
// NewAnsiReader returns an io.ReadCloser that provides VT100 terminal emulation on top of a
|
||||||
// Windows console input handle.
|
// Windows console input handle.
|
||||||
|
// Deprecated: use github.com/moby/term/windows.NewAnsiReader
|
||||||
func NewAnsiReader(nFile int) io.ReadCloser {
|
func NewAnsiReader(nFile int) io.ReadCloser {
|
||||||
initLogger()
|
initLogger()
|
||||||
file, fd := winterm.GetStdFile(nFile)
|
file, fd := winterm.GetStdFile(nFile)
|
||||||
|
|
|
@ -23,6 +23,7 @@ type ansiWriter struct {
|
||||||
|
|
||||||
// NewAnsiWriter returns an io.Writer that provides VT100 terminal emulation on top of a
|
// NewAnsiWriter returns an io.Writer that provides VT100 terminal emulation on top of a
|
||||||
// Windows console output handle.
|
// Windows console output handle.
|
||||||
|
// Deprecated: use github.com/moby/term/windows.NewAnsiWriter
|
||||||
func NewAnsiWriter(nFile int) io.Writer {
|
func NewAnsiWriter(nFile int) io.Writer {
|
||||||
initLogger()
|
initLogger()
|
||||||
file, fd := winterm.GetStdFile(nFile)
|
file, fd := winterm.GetStdFile(nFile)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetHandleInfo returns file descriptor and bool indicating whether the file is a console.
|
// GetHandleInfo returns file descriptor and bool indicating whether the file is a console.
|
||||||
|
// Deprecated: use github.com/moby/term/windows.GetHandleInfo
|
||||||
func GetHandleInfo(in interface{}) (uintptr, bool) {
|
func GetHandleInfo(in interface{}) (uintptr, bool) {
|
||||||
switch t := in.(type) {
|
switch t := in.(type) {
|
||||||
case *ansiReader:
|
case *ansiReader:
|
||||||
|
@ -29,6 +30,7 @@ func GetHandleInfo(in interface{}) (uintptr, bool) {
|
||||||
|
|
||||||
// IsConsole returns true if the given file descriptor is a Windows Console.
|
// IsConsole returns true if the given file descriptor is a Windows Console.
|
||||||
// The code assumes that GetConsoleMode will return an error for file descriptors that are not a console.
|
// The code assumes that GetConsoleMode will return an error for file descriptors that are not a console.
|
||||||
|
// Deprecated: use github.com/moby/term/windows.IsConsole
|
||||||
func IsConsole(fd uintptr) bool {
|
func IsConsole(fd uintptr) bool {
|
||||||
_, e := winterm.GetConsoleMode(fd)
|
_, e := winterm.GetConsoleMode(fd)
|
||||||
return e == nil
|
return e == nil
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
// +build windows
|
// +build windows
|
||||||
// These files implement ANSI-aware input and output streams for use by the Docker Windows client.
|
|
||||||
// When asked for the set of standard streams (e.g., stdin, stdout, stderr), the code will create
|
|
||||||
// and return pseudo-streams that convert ANSI sequences to / from Windows Console API calls.
|
|
||||||
|
|
||||||
|
// Package windowsconsole implements ANSI-aware input and output streams for use
|
||||||
|
// by the Docker Windows client. When asked for the set of standard streams (e.g.,
|
||||||
|
// stdin, stdout, stderr), the code will create and return pseudo-streams that
|
||||||
|
// convert ANSI sequences to / from Windows Console API calls.
|
||||||
|
//
|
||||||
|
// Deprecated: use github.com/moby/term/windows instead
|
||||||
package windowsconsole // import "github.com/docker/docker/pkg/term/windows"
|
package windowsconsole // import "github.com/docker/docker/pkg/term/windows"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetWinsize returns the window size based on the specified file descriptor.
|
// GetWinsize returns the window size based on the specified file descriptor.
|
||||||
|
// Deprecated: use github.com/moby/term.GetWinsize
|
||||||
func GetWinsize(fd uintptr) (*Winsize, error) {
|
func GetWinsize(fd uintptr) (*Winsize, error) {
|
||||||
uws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
|
uws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
|
||||||
ws := &Winsize{Height: uws.Row, Width: uws.Col, x: uws.Xpixel, y: uws.Ypixel}
|
ws := &Winsize{Height: uws.Row, Width: uws.Col, x: uws.Xpixel, y: uws.Ypixel}
|
||||||
|
@ -14,6 +15,7 @@ func GetWinsize(fd uintptr) (*Winsize, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWinsize tries to set the specified window size for the specified file descriptor.
|
// SetWinsize tries to set the specified window size for the specified file descriptor.
|
||||||
|
// Deprecated: use github.com/moby/term.GetWinsize
|
||||||
func SetWinsize(fd uintptr, ws *Winsize) error {
|
func SetWinsize(fd uintptr, ws *Winsize) error {
|
||||||
uws := &unix.Winsize{Row: ws.Height, Col: ws.Width, Xpixel: ws.x, Ypixel: ws.y}
|
uws := &unix.Winsize{Row: ws.Height, Col: ws.Width, Xpixel: ws.x, Ypixel: ws.y}
|
||||||
return unix.IoctlSetWinsize(int(fd), unix.TIOCSWINSZ, uws)
|
return unix.IoctlSetWinsize(int(fd), unix.TIOCSWINSZ, uws)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue