diff --git a/README.md b/README.md index 860d5614..0d82c1bf 100644 --- a/README.md +++ b/README.md @@ -252,8 +252,11 @@ Key Binding | Description Ctrl + C or Q | Exit Tab | Switch between the layer and filetree views Ctrl + F | Filter files -PageUp | Scroll up a page -PageDown | Scroll down a page +ESC | Close filter files +PageUp or U | Scroll up a page +PageDown or D | Scroll down a page +Up or K | Move up one line within a page +Down or J | Move down one line within a page Ctrl + A | Layer view: see aggregated image modifications Ctrl + L | Layer view: see current layer modifications Space | Filetree view: collapse/uncollapse a directory @@ -263,8 +266,8 @@ Key Binding | Description Ctrl + M | Filetree view: show/hide modified files Ctrl + U | Filetree view: show/hide unmodified files Ctrl + B | Filetree view: show/hide file attributes -PageUp | Filetree view: scroll up a page -PageDown | Filetree view: scroll down a page +PageUp or U | Filetree view: scroll up a page +PageDown or D | Filetree view: scroll down a page ## UI Configuration @@ -286,6 +289,11 @@ keybinding: quit: ctrl+c toggle-view: tab filter-files: ctrl+f, ctrl+slash + close-filter-files: esc + up: up,k + down: down,j + left: left,h + right: right,l # Layer view specific bindings compare-all: ctrl+a @@ -299,8 +307,8 @@ keybinding: toggle-modified-files: ctrl+m toggle-unmodified-files: ctrl+u toggle-filetree-attributes: ctrl+b - page-up: pgup - page-down: pgdn + page-up: pgup,u + page-down: pgdn,d diff: # You can change the default files shown in the filetree (right pane). All diff types are shown by default. diff --git a/cmd/root.go b/cmd/root.go index a230ff38..ad9f10be 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -80,6 +80,7 @@ func initConfig() { viper.SetDefault("keybinding.quit", "ctrl+c,q") viper.SetDefault("keybinding.toggle-view", "tab") viper.SetDefault("keybinding.filter-files", "ctrl+f, ctrl+slash") + viper.SetDefault("keybinding.close-filter-files", "esc") // keybindings: layer view viper.SetDefault("keybinding.compare-all", "ctrl+a") viper.SetDefault("keybinding.compare-layer", "ctrl+l") @@ -94,8 +95,12 @@ func initConfig() { viper.SetDefault("keybinding.toggle-unmodified-files", "ctrl+u") viper.SetDefault("keybinding.toggle-wrap-tree", "ctrl+p") viper.SetDefault("keybinding.extract-file", "ctrl+e") - viper.SetDefault("keybinding.page-up", "pgup") - viper.SetDefault("keybinding.page-down", "pgdn") + viper.SetDefault("keybinding.page-up", "pgup,u") + viper.SetDefault("keybinding.page-down", "pgdn,d") + viper.SetDefault("keybinding.up", "up,k") + viper.SetDefault("keybinding.down", "down,j") + viper.SetDefault("keybinding.left", "left,h") + viper.SetDefault("keybinding.right", "right,l") viper.SetDefault("diff.hide", "") diff --git a/runtime/ui/app.go b/runtime/ui/app.go index 85ce5845..ac922496 100644 --- a/runtime/ui/app.go +++ b/runtime/ui/app.go @@ -77,12 +77,12 @@ func newApp(gui *gocui.Gui, imageName string, resolver image.Resolver, analysis Display: "Switch view", }, { - Key: gocui.KeyArrowRight, - OnAction: controller.NextPane, + ConfigKeys: []string{"keybinding.right"}, + OnAction: controller.NextPane, }, { - Key: gocui.KeyArrowLeft, - OnAction: controller.PrevPane, + ConfigKeys: []string{"keybinding.left"}, + OnAction: controller.PrevPane, }, { ConfigKeys: []string{"keybinding.filter-files"}, @@ -90,6 +90,10 @@ func newApp(gui *gocui.Gui, imageName string, resolver image.Resolver, analysis IsSelected: controller.views.Filter.IsVisible, Display: "Filter", }, + { + ConfigKeys: []string{"keybinding.close-filter-files"}, + OnAction: controller.CloseFilterView, + }, } globalHelpKeys, err = key.GenerateBindings(gui, "", infos) diff --git a/runtime/ui/controller.go b/runtime/ui/controller.go index 9f3fbe6a..fd403980 100644 --- a/runtime/ui/controller.go +++ b/runtime/ui/controller.go @@ -223,6 +223,15 @@ func (c *Controller) ToggleView() (err error) { return c.UpdateAndRender() } +func (c *Controller) CloseFilterView() error { + // filter view needs to be visible + if c.views.Filter.IsVisible() { + // toggle filter view + return c.ToggleFilterView() + } + return nil +} + func (c *Controller) ToggleFilterView() error { // delete all user input from the tree view err := c.views.Filter.ToggleVisible() diff --git a/runtime/ui/view/filetree.go b/runtime/ui/view/filetree.go index 55717458..923f7a9e 100644 --- a/runtime/ui/view/filetree.go +++ b/runtime/ui/view/filetree.go @@ -160,24 +160,24 @@ func (v *FileTree) Setup(view, header *gocui.View) error { OnAction: v.PageDown, }, { - Key: gocui.KeyArrowDown, - Modifier: gocui.ModNone, - OnAction: v.CursorDown, + ConfigKeys: []string{"keybinding.down"}, + Modifier: gocui.ModNone, + OnAction: v.CursorDown, }, { - Key: gocui.KeyArrowUp, - Modifier: gocui.ModNone, - OnAction: v.CursorUp, + ConfigKeys: []string{"keybinding.up"}, + Modifier: gocui.ModNone, + OnAction: v.CursorUp, }, { - Key: gocui.KeyArrowLeft, - Modifier: gocui.ModNone, - OnAction: v.CursorLeft, + ConfigKeys: []string{"keybinding.left"}, + Modifier: gocui.ModNone, + OnAction: v.CursorLeft, }, { - Key: gocui.KeyArrowRight, - Modifier: gocui.ModNone, - OnAction: v.CursorRight, + ConfigKeys: []string{"keybinding.right"}, + Modifier: gocui.ModNone, + OnAction: v.CursorRight, }, } diff --git a/runtime/ui/view/image_details.go b/runtime/ui/view/image_details.go index 08098ab6..977a72c0 100644 --- a/runtime/ui/view/image_details.go +++ b/runtime/ui/view/image_details.go @@ -44,14 +44,14 @@ func (v *ImageDetails) Setup(body, header *gocui.View) error { var infos = []key.BindingInfo{ { - Key: gocui.KeyArrowDown, - Modifier: gocui.ModNone, - OnAction: v.CursorDown, + ConfigKeys: []string{"keybinding.down"}, + Modifier: gocui.ModNone, + OnAction: v.CursorDown, }, { - Key: gocui.KeyArrowUp, - Modifier: gocui.ModNone, - OnAction: v.CursorUp, + ConfigKeys: []string{"keybinding.up"}, + Modifier: gocui.ModNone, + OnAction: v.CursorUp, }, { ConfigKeys: []string{"keybinding.page-up"}, diff --git a/runtime/ui/view/layer.go b/runtime/ui/view/layer.go index 8c26929d..9aba2793 100644 --- a/runtime/ui/view/layer.go +++ b/runtime/ui/view/layer.go @@ -116,14 +116,14 @@ func (v *Layer) Setup(body *gocui.View, header *gocui.View) error { Display: "Show aggregated changes", }, { - Key: gocui.KeyArrowDown, - Modifier: gocui.ModNone, - OnAction: v.CursorDown, + ConfigKeys: []string{"keybinding.down"}, + Modifier: gocui.ModNone, + OnAction: v.CursorDown, }, { - Key: gocui.KeyArrowUp, - Modifier: gocui.ModNone, - OnAction: v.CursorUp, + ConfigKeys: []string{"keybinding.up"}, + Modifier: gocui.ModNone, + OnAction: v.CursorUp, }, { ConfigKeys: []string{"keybinding.page-up"}, diff --git a/runtime/ui/view/layer_details.go b/runtime/ui/view/layer_details.go index 4981fd12..0334fb24 100644 --- a/runtime/ui/view/layer_details.go +++ b/runtime/ui/view/layer_details.go @@ -40,14 +40,14 @@ func (v *LayerDetails) Setup(body, header *gocui.View) error { var infos = []key.BindingInfo{ { - Key: gocui.KeyArrowDown, - Modifier: gocui.ModNone, - OnAction: v.CursorDown, + ConfigKeys: []string{"keybinding.down"}, + Modifier: gocui.ModNone, + OnAction: v.CursorDown, }, { - Key: gocui.KeyArrowUp, - Modifier: gocui.ModNone, - OnAction: v.CursorUp, + ConfigKeys: []string{"keybinding.up"}, + Modifier: gocui.ModNone, + OnAction: v.CursorUp, }, }