Added h key binding

This commit is contained in:
mjarkk 2019-07-06 21:20:21 +02:00
parent 4dc13ebda5
commit b89b02eee5
No known key found for this signature in database
GPG key ID: 147D0BE9258C6C95
4 changed files with 25 additions and 1 deletions

View file

@ -29,6 +29,7 @@ type DockerCommand struct {
Config *config.AppConfig
Client *client.Client
InDockerComposeProject bool
ShowExited bool
ErrorChan chan error
ContainerMutex sync.Mutex
ServiceMutex sync.Mutex

View file

@ -277,7 +277,17 @@ func (gui *Gui) refreshContainersAndServices() error {
gui.g.Update(func(g *gocui.Gui) error {
containersView.Clear()
isFocused := gui.g.CurrentView().Name() == "containers"
list, err := utils.RenderList(gui.DockerCommand.DisplayContainers, utils.IsFocused(isFocused))
toRender := gui.DockerCommand.DisplayContainers
if !gui.DockerCommand.ShowExited {
toRender = []*commands.Container{}
for _, container := range gui.DockerCommand.DisplayContainers {
if container.Container.State != "exited" {
toRender = append(toRender, container)
}
}
}
list, err := utils.RenderList(toRender, utils.IsFocused(isFocused))
if err != nil {
return err
}
@ -371,6 +381,11 @@ func (r *removeContainerOption) GetDisplayStrings(isFocused bool) []string {
return []string{r.description, color.New(color.FgRed).Sprint(r.command)}
}
func (gui *Gui) handleHideStoppedContainers(g *gocui.Gui, v *gocui.View) error {
gui.DockerCommand.ShowExited = !gui.DockerCommand.ShowExited
return nil
}
func (gui *Gui) handleContainersRemoveMenu(g *gocui.Gui, v *gocui.View) error {
container, err := gui.getSelectedContainer()
if err != nil {

View file

@ -211,6 +211,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleContainersRemoveMenu,
Description: gui.Tr.Remove,
},
{
ViewName: "containers",
Key: 'h',
Modifier: gocui.ModNone,
Handler: gui.handleHideStoppedContainers,
Description: gui.Tr.HideStopped,
},
{
ViewName: "containers",
Key: 's',

View file

@ -31,6 +31,7 @@ type TranslationSet struct {
Cancel string
CustomCommandTitle string
Remove string
HideStopped string
ForceRemove string
RemoveWithVolumes string
MustForceToRemoveContainer string