Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vim like arrow, scroll, and close filtering motions #501

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ Key Binding | Description
<kbd>Ctrl + C</kbd> or <kbd>Q</kbd> | Exit
<kbd>Tab</kbd> | Switch between the layer and filetree views
<kbd>Ctrl + F</kbd> | Filter files
<kbd>PageUp</kbd> | Scroll up a page
<kbd>PageDown</kbd> | Scroll down a page
<kbd>PageUp</kbd> or <kbd>U</kbd> | Scroll up a page
<kbd>PageDown</kbd> or <kbd>D</kbd> | Scroll down a page
<kbd>Up</kbd> or <kbd>K</kbd> | Move up one line within a page
<kbd>Down</kbd> or <kbd>J</kbd> | Move down one line within a page
<kbd>Ctrl + A</kbd> | Layer view: see aggregated image modifications
<kbd>Ctrl + L</kbd> | Layer view: see current layer modifications
<kbd>Space</kbd> | Filetree view: collapse/uncollapse a directory
Expand All @@ -229,8 +231,8 @@ Key Binding | Description
<kbd>Ctrl + M</kbd> | Filetree view: show/hide modified files
<kbd>Ctrl + U</kbd> | Filetree view: show/hide unmodified files
<kbd>Ctrl + B</kbd> | Filetree view: show/hide file attributes
<kbd>PageUp</kbd> | Filetree view: scroll up a page
<kbd>PageDown</kbd> | Filetree view: scroll down a page
<kbd>PageUp</kbd> or <kbd>U</kbd> | Filetree view: scroll up a page
<kbd>PageDown</kbd> or <kbd>D</kbd> | Filetree view: scroll down a page

## UI Configuration

Expand All @@ -252,6 +254,10 @@ keybinding:
quit: ctrl+c
toggle-view: tab
filter-files: ctrl+f, ctrl+slash
up: up,k
down: down,j
left: left,h
right: right,l

# Layer view specific bindings
compare-all: ctrl+a
Expand All @@ -265,8 +271,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.
Expand Down
8 changes: 6 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ func initConfig() {
viper.SetDefault("keybinding.toggle-modified-files", "ctrl+m")
viper.SetDefault("keybinding.toggle-unmodified-files", "ctrl+u")
viper.SetDefault("keybinding.toggle-wrap-tree", "ctrl+p")
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", "")

Expand Down
4 changes: 2 additions & 2 deletions runtime/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func newApp(gui *gocui.Gui, imageName string, analysis *image.AnalysisResult, ca
Display: "Switch view",
},
{
Key: gocui.KeyArrowRight,
ConfigKeys: []string{"keybinding.right"},
OnAction: controller.NextPane,
},
{
Key: gocui.KeyArrowLeft,
ConfigKeys: []string{"keybinding.left"},
OnAction: controller.PrevPane,
},
{
Expand Down
16 changes: 8 additions & 8 deletions runtime/ui/view/filetree.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ 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,
ConfigKeys: []string{"keybinding.left"},
Modifier: gocui.ModNone,
OnAction: v.CursorLeft,
},
{
Key: gocui.KeyArrowRight,
ConfigKeys: []string{"keybinding.right"},
Modifier: gocui.ModNone,
OnAction: v.CursorRight,
},
Expand Down
12 changes: 6 additions & 6 deletions runtime/ui/view/image_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
12 changes: 6 additions & 6 deletions runtime/ui/view/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
12 changes: 6 additions & 6 deletions runtime/ui/view/layer_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,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,
},
}

Expand Down