forked from coyim/coyim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
33 lines (28 loc) · 942 Bytes
/
interfaces.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
package terminal
import "io"
// Terminal represents terminal control
type Terminal interface {
ReadLine() (string, error)
ReadPassword(string) (string, error)
SetBracketedPasteMode(bool)
SetPrompt(string)
SetSize(int, int) error
Write([]byte) (int, error)
}
// EscapeCodes represents the escape codes used for a specific terminal
type EscapeCodes struct {
Black, Red, Green, Yellow, Blue, Magenta, Cyan, White []byte
Reset []byte
}
// Control represents terminal control
type Control interface {
ErrPasteIndicator() error
Escape(Terminal) EscapeCodes
GetSize(int) (int, int, error)
MakeRaw(int) (interface{}, error)
NewTerminal(io.ReadWriter, string) Terminal
Restore(int, interface{}) error
SetAutoCompleteCallback(Terminal, func(string, int, rune) (string, int, bool))
}
// ControlFactory represents a function that can create a Control
type ControlFactory func() Control