@@ -12,18 +12,24 @@ import (
1212 "github.com/jesseduffield/gocui"
1313)
1414
15+ func (gui * Gui ) desiredPtySize () * pty.Winsize {
16+ width , height := gui .Views .Main .Size ()
17+
18+ return & pty.Winsize {Cols : uint16 (width ), Rows : uint16 (height )}
19+ }
20+
1521func (gui * Gui ) onResize () error {
1622 if gui .State .Ptmx == nil {
1723 return nil
1824 }
19- width , height := gui .Views .Main .Size ()
2025
21- if err := pty .Setsize (gui .State .Ptmx , & pty.Winsize {Cols : uint16 (width ), Rows : uint16 (height )}); err != nil {
26+ // TODO: handle resizing properly: we need to actually clear the main view
27+ // and re-read the output from our pty. Or we could just re-run the original
28+ // command from scratch
29+ if err := pty .Setsize (gui .State .Ptmx , gui .desiredPtySize ()); err != nil {
2230 return err
2331 }
2432
25- // TODO: handle resizing properly
26-
2733 return nil
2834}
2935
@@ -52,7 +58,7 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
5258 manager := gui .getManager (view )
5359
5460 start := func () (* exec.Cmd , io.Reader ) {
55- ptmx , err := pty .Start (cmd )
61+ ptmx , err := pty .StartWithSize (cmd , gui . desiredPtySize () )
5662 if err != nil {
5763 gui .Log .Error (err )
5864 }
@@ -67,10 +73,6 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
6773 gui .State .Ptmx = nil
6874 }
6975
70- if err := gui .onResize (); err != nil {
71- return err
72- }
73-
7476 if err := manager .NewTask (manager .NewCmdTask (start , prefix , height + oy + 10 , onClose ), cmdStr ); err != nil {
7577 return err
7678 }
0 commit comments