mirror of
https://github.com/yudai/gotty.git
synced 2026-03-06 13:50:17 +01:00
Refine API of webtty package
This commit is contained in:
parent
d1ec7125cf
commit
807bcc25a4
10 changed files with 82 additions and 97 deletions
|
|
@ -148,29 +148,17 @@ func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn) e
|
|||
if server.options.EnableReconnect {
|
||||
opts = append(opts, webtty.WithReconnect(server.options.ReconnectTime))
|
||||
}
|
||||
if server.options.Width > 0 || server.options.Height > 0 {
|
||||
width, height, err := slave.GetTerminalSize()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get default terminal size")
|
||||
}
|
||||
if server.options.Width > 0 {
|
||||
width = server.options.Width
|
||||
}
|
||||
if server.options.Height > 0 {
|
||||
height = server.options.Height
|
||||
}
|
||||
err = slave.ResizeTerminal(width, height)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to resize terminal")
|
||||
}
|
||||
|
||||
opts = append(opts, webtty.WithFixedSize(server.options.Width, server.options.Height))
|
||||
if server.options.Width > 0 {
|
||||
opts = append(opts, webtty.WithFixedColumns(server.options.Width))
|
||||
}
|
||||
if server.options.Height > 0 {
|
||||
opts = append(opts, webtty.WithFixedRows(server.options.Height))
|
||||
}
|
||||
if server.options.Preferences != nil {
|
||||
opts = append(opts, webtty.WithMasterPreferences(server.options.Preferences))
|
||||
}
|
||||
|
||||
tty, err := webtty.New(conn, slave, opts...)
|
||||
tty, err := webtty.New(&wsWrapper{conn}, slave, opts...)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create webtty")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue