File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -80,13 +80,19 @@ type WithFlags interface {
80
80
EchoEnabled () (bool , error )
81
81
}
82
82
83
- // Options represents a an option for a PTY.
83
+ // Options represents an option for a PTY.
84
84
type Option func (* ptyOptions )
85
85
86
+ type Winsize struct {
87
+ Height uint16
88
+ Width uint16
89
+ }
90
+
86
91
type ptyOptions struct {
87
92
logger * log.Logger
88
93
sshReq * ssh.Pty
89
94
setGPGTTY bool
95
+ size * Winsize
90
96
}
91
97
92
98
// WithSSHRequest applies the ssh.Pty request to the PTY.
@@ -113,6 +119,13 @@ func WithGPGTTY() Option {
113
119
}
114
120
}
115
121
122
+ // WithSize sets the initial size at which to spawn the PTY.
123
+ func WithSize (size * Winsize ) Option {
124
+ return func (opts * ptyOptions ) {
125
+ opts .size = size
126
+ }
127
+ }
128
+
116
129
// New constructs a new Pty.
117
130
func New (opts ... Option ) (PTY , error ) {
118
131
return newPty (opts ... )
Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ func newPty(opt ...Option) (retPTY *otherPty, err error) {
26
26
if err != nil {
27
27
return nil , err
28
28
}
29
+ if opts .size != nil {
30
+ _ = pty .Setsize (ptyFile , & pty.Winsize {
31
+ Rows : opts .size .Height ,
32
+ Cols : opts .size .Width ,
33
+ })
34
+ }
29
35
opty := & otherPty {
30
36
pty : ptyFile ,
31
37
tty : ttyFile ,
You can’t perform that action at this time.
0 commit comments