Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit d19255b

Browse files
committed
support arrow keys
to work for selecting an entry in a panel, as in j and k Request: support arrow keys ↑↓ #25
1 parent 72ef3b6 commit d19255b

File tree

5 files changed

+12
-24
lines changed

5 files changed

+12
-24
lines changed

panel/containerPanel.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ func (c *ContainerList) SetView(g *gocui.Gui) error {
117117
func (c *ContainerList) SetKeyBinding() {
118118
c.SetKeyBindingToPanel(c.name)
119119

120-
if err := c.SetKeybinding(c.name, 'j', gocui.ModNone, CursorDown); err != nil {
121-
panic(err)
122-
}
123-
if err := c.SetKeybinding(c.name, 'k', gocui.ModNone, CursorUp); err != nil {
124-
panic(err)
125-
}
126120
if err := c.SetKeybinding(c.name, gocui.KeyEnter, gocui.ModNone, c.DetailContainer); err != nil {
127121
panic(err)
128122
}

panel/gui.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ func (gui *Gui) SetKeyBindingToPanel(panel string) {
108108
if err := gui.SetKeybinding(panel, gocui.KeyCtrlO, gocui.ModNone, gui.DockerInfo); err != nil {
109109
panic(err)
110110
}
111+
if err := gui.SetKeybinding(panel, 'j', gocui.ModNone, CursorDown); err != nil {
112+
panic(err)
113+
}
114+
if err := gui.SetKeybinding(panel, gocui.KeyArrowDown, gocui.ModNone, CursorDown); err != nil {
115+
panic(err)
116+
}
117+
if err := gui.SetKeybinding(panel, 'k', gocui.ModNone, CursorUp); err != nil {
118+
panic(err)
119+
}
120+
if err := gui.SetKeybinding(panel, gocui.KeyArrowUp, gocui.ModNone, CursorUp); err != nil {
121+
panic(err)
122+
}
111123
}
112124

113125
func (gui *Gui) SetGlobalKeyBinding() {

panel/imagePanel.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,6 @@ func (i *ImageList) Refresh(g *gocui.Gui, v *gocui.View) error {
130130
func (i *ImageList) SetKeyBinding() {
131131
i.SetKeyBindingToPanel(i.name)
132132

133-
if err := i.SetKeybinding(i.name, 'j', gocui.ModNone, CursorDown); err != nil {
134-
panic(err)
135-
}
136-
if err := i.SetKeybinding(i.name, 'k', gocui.ModNone, CursorUp); err != nil {
137-
panic(err)
138-
}
139133
if err := i.SetKeybinding(i.name, gocui.KeyEnter, gocui.ModNone, i.DetailImage); err != nil {
140134
panic(err)
141135
}

panel/networkPanel.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ func (n *NetworkList) Refresh(g *gocui.Gui, v *gocui.View) error {
125125
func (n *NetworkList) SetKeyBinding() {
126126
n.SetKeyBindingToPanel(n.name)
127127

128-
if err := n.SetKeybinding(n.name, 'j', gocui.ModNone, CursorDown); err != nil {
129-
panic(err)
130-
}
131-
if err := n.SetKeybinding(n.name, 'k', gocui.ModNone, CursorUp); err != nil {
132-
panic(err)
133-
}
134128
if err := n.SetKeybinding(n.name, gocui.KeyCtrlR, gocui.ModNone, n.Refresh); err != nil {
135129
panic(err)
136130
}

panel/volumePanel.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ func (vl *VolumeList) SetView(g *gocui.Gui) error {
112112
func (vl *VolumeList) SetKeyBinding() {
113113
vl.SetKeyBindingToPanel(vl.name)
114114

115-
if err := vl.SetKeybinding(vl.name, 'j', gocui.ModNone, CursorDown); err != nil {
116-
panic(err)
117-
}
118-
if err := vl.SetKeybinding(vl.name, 'k', gocui.ModNone, CursorUp); err != nil {
119-
panic(err)
120-
}
121115
if err := vl.SetKeybinding(vl.name, 'c', gocui.ModNone, vl.CreateVolumePanel); err != nil {
122116
panic(err)
123117
}

0 commit comments

Comments
 (0)