-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the shell to be used inline, rather than full screen
- Loading branch information
Showing
11 changed files
with
197 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package shell | ||
|
||
import ( | ||
"github.com/charmbracelet/bubbles/key" | ||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
type CommandRunningMode struct{ KeepInputContent bool } | ||
|
||
var _ Mode = (*CommandRunningMode)(nil) | ||
|
||
func (c *CommandRunningMode) Enter(m Model) (Model, tea.Cmd) { | ||
return m, nil | ||
} | ||
|
||
func (c *CommandRunningMode) Leave(m Model) (Model, tea.Cmd) { | ||
return m, nil | ||
} | ||
|
||
func (c *CommandRunningMode) Update(m Model, msg tea.Msg) (Model, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch { | ||
case key.Matches(msg, m.cfg.KeyMap.Cancel): | ||
if m.currentCmdCancel != nil { | ||
m.currentCmdCancel() | ||
m.currentCmdCancel = nil | ||
return m, nil | ||
} else { | ||
return m, tea.Quit | ||
} | ||
} | ||
} | ||
|
||
return m, nil | ||
} | ||
|
||
func (c *CommandRunningMode) AdditionalView(m Model) string { | ||
return "" | ||
} | ||
|
||
func (c *CommandRunningMode) ShortHelp(m Model, keyMap KeyMap) []key.Binding { | ||
cancel := keyMap.Cancel | ||
|
||
if m.currentCmdCancel != nil { | ||
cancel.SetHelp(cancel.Help().Key, "stop executing command") | ||
} else { | ||
cancel.SetHelp(cancel.Help().Key, "quit") | ||
} | ||
|
||
return []key.Binding{ | ||
cancel, | ||
} | ||
} | ||
|
||
func (c *CommandRunningMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding { | ||
return [][]key.Binding{ | ||
c.ShortHelp(m, keyMap), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.