-
Notifications
You must be signed in to change notification settings - Fork 927
/
terminal_helper.go
43 lines (32 loc) · 1.03 KB
/
terminal_helper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package clissh
import (
"io"
"github.com/moby/moby/pkg/term"
)
//go:generate counterfeiter . TerminalHelper
type TerminalHelper interface {
GetFdInfo(in interface{}) (fd uintptr, isTerminal bool)
SetRawTerminal(fd uintptr) (*term.State, error)
RestoreTerminal(fd uintptr, state *term.State) error
GetWinsize(fd uintptr) (*term.Winsize, error)
StdStreams() (stdin io.ReadCloser, stdout io.Writer, stderr io.Writer)
}
type terminalHelper struct{}
func DefaultTerminalHelper() terminalHelper {
return terminalHelper{}
}
func (terminalHelper) GetFdInfo(in interface{}) (uintptr, bool) {
return term.GetFdInfo(in)
}
func (terminalHelper) GetWinsize(fd uintptr) (*term.Winsize, error) {
return term.GetWinsize(fd)
}
func (terminalHelper) RestoreTerminal(fd uintptr, state *term.State) error {
return term.RestoreTerminal(fd, state)
}
func (terminalHelper) SetRawTerminal(fd uintptr) (*term.State, error) {
return term.SetRawTerminal(fd)
}
func (terminalHelper) StdStreams() (io.ReadCloser, io.Writer, io.Writer) {
return term.StdStreams()
}