diff options
Diffstat (limited to 'pkg/gui/pty.go')
-rw-r--r-- | pkg/gui/pty.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/pkg/gui/pty.go b/pkg/gui/pty.go index 56956c399..26b9156ad 100644 --- a/pkg/gui/pty.go +++ b/pkg/gui/pty.go @@ -12,18 +12,24 @@ import ( "github.com/jesseduffield/gocui" ) +func (gui *Gui) desiredPtySize() *pty.Winsize { + width, height := gui.Views.Main.Size() + + return &pty.Winsize{Cols: uint16(width), Rows: uint16(height)} +} + func (gui *Gui) onResize() error { if gui.State.Ptmx == nil { return nil } - width, height := gui.Views.Main.Size() - if err := pty.Setsize(gui.State.Ptmx, &pty.Winsize{Cols: uint16(width), Rows: uint16(height)}); err != nil { + // TODO: handle resizing properly: we need to actually clear the main view + // and re-read the output from our pty. Or we could just re-run the original + // command from scratch + if err := pty.Setsize(gui.State.Ptmx, gui.desiredPtySize()); err != nil { return err } - // TODO: handle resizing properly - return nil } @@ -52,7 +58,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error manager := gui.getManager(view) start := func() (*exec.Cmd, io.Reader) { - ptmx, err := pty.Start(cmd) + ptmx, err := pty.StartWithSize(cmd, gui.desiredPtySize()) if err != nil { gui.Log.Error(err) } @@ -67,10 +73,6 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error gui.State.Ptmx = nil } - if err := gui.onResize(); err != nil { - return err - } - if err := manager.NewTask(manager.NewCmdTask(start, prefix, height+oy+10, onClose), cmdStr); err != nil { return err } |