Skip to content

Commit

Permalink
Update pty term size when setting up
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Mar 4, 2020
1 parent ec9f1a1 commit a449646
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion term.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ func (t *Terminal) Resize(s fyne.Size) {
t.config.Rows = uint16(math.Floor(float64(s.Height) / float64(cellSize.Height)))
t.onConfigure()

t.updatePTYSize()
}

func (t *Terminal) updatePTYSize() {
scale := float32(1.0)
c := fyne.CurrentApp().Driver().CanvasForObject(t)
if c != nil {
scale = c.Scale()
}
_ = pty.Setsize(t.pty, &pty.Winsize{
Rows: t.config.Rows, Cols: t.config.Columns,
X: uint16(float32(s.Width) * scale), Y: uint16(float32(s.Height) * scale)})
X: uint16(float32(t.Size().Width) * scale), Y: uint16(float32(t.Size().Height) * scale)})
}

func (t *Terminal) onConfigure() {
Expand Down Expand Up @@ -95,6 +99,8 @@ func (t *Terminal) open() error {
return err
}
t.pty = handle

t.updatePTYSize()
return nil
}

Expand Down

0 comments on commit a449646

Please sign in to comment.