Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita8360d1

Browse files
committed
Support starting PTY with a size
You get unexpected padding in screen if you try to resize afterward.
1 parent0c73164 commita8360d1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

‎pty/pty.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,19 @@ type WithFlags interface {
8080
EchoEnabled() (bool,error)
8181
}
8282

83-
// Options representsaan option for a PTY.
83+
// Options represents an option for a PTY.
8484
typeOptionfunc(*ptyOptions)
8585

86+
typeWinsizestruct {
87+
Heightuint16
88+
Widthuint16
89+
}
90+
8691
typeptyOptionsstruct {
8792
logger*log.Logger
8893
sshReq*ssh.Pty
8994
setGPGTTYbool
95+
size*Winsize
9096
}
9197

9298
// WithSSHRequest applies the ssh.Pty request to the PTY.
@@ -113,6 +119,13 @@ func WithGPGTTY() Option {
113119
}
114120
}
115121

122+
// WithSize sets the initial size at which to spawn the PTY.
123+
funcWithSize(size*Winsize)Option {
124+
returnfunc(opts*ptyOptions) {
125+
opts.size=size
126+
}
127+
}
128+
116129
// New constructs a new Pty.
117130
funcNew(opts...Option) (PTY,error) {
118131
returnnewPty(opts...)

‎pty/pty_other.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ func newPty(opt ...Option) (retPTY *otherPty, err error) {
2626
iferr!=nil {
2727
returnnil,err
2828
}
29+
ifopts.size!=nil {
30+
_=pty.Setsize(ptyFile,&pty.Winsize{
31+
Rows:opts.size.Height,
32+
Cols:opts.size.Width,
33+
})
34+
}
2935
opty:=&otherPty{
3036
pty:ptyFile,
3137
tty:ttyFile,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp