@@ -73,10 +73,14 @@ func (c *InteractiveCmd) Run(ctx *Globals) error {
7373
7474 m := initialModel (c , c .Query , stdInBytes )
7575
76- p := tea .NewProgram (m )
76+ p := tea .NewProgram (m , tea . WithOutput ( ctx . Stdout ) )
7777
7878 _ , err = p .Run ()
79- return err
79+ if err != nil {
80+ return err
81+ }
82+
83+ return nil
8084}
8185
8286func initialModel (it * InteractiveCmd , defaultCommand string , stdInBytes []byte ) interactiveTeaModel {
@@ -124,6 +128,9 @@ func (m interactiveTeaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
124128 m .previousCommand = m .currentCommand
125129
126130 m .currentCommand = m .commandInput .Value ()
131+ if m .firstUpdate {
132+ cmds = append (cmds , tea .EnterAltScreen )
133+ }
127134 if m .firstUpdate || m .currentCommand != m .previousCommand {
128135 m .firstUpdate = false
129136 // If the command has changed, we need to execute it
@@ -160,12 +167,7 @@ func (m interactiveTeaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
160167 switch msg := msg .(type ) {
161168 case tea.KeyMsg :
162169 switch msg .Type {
163- case tea .KeyEsc :
164- return m , tea .Quit
165- //if m.commandInput.Focused() {
166- // m.commandInput.Blur()
167- //}
168- case tea .KeyCtrlC :
170+ case tea .KeyEsc , tea .KeyCtrlC :
169171 return m , tea .Quit
170172 default :
171173 if ! m .commandInput .Focused () {
@@ -180,7 +182,7 @@ func (m interactiveTeaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
180182 resultHeaderHeight := lipgloss .Height (m .resultHeaderView ())
181183 verticalMarginHeight := headerHeight + 2 + commandInputHeight + resultHeaderHeight
182184
183- viewportHeight := msg .Height - verticalMarginHeight
185+ viewportHeight := msg .Height - verticalMarginHeight - 2
184186 viewportWidth := (msg .Width / 2 ) - 4
185187
186188 if ! m .outputReady {
0 commit comments