Skip to content

Commit

Permalink
Merge pull request #31 from robgonnella/update-key-bindings
Browse files Browse the repository at this point in the history
Updates key bindings
  • Loading branch information
robgonnella authored Mar 21, 2024
2 parents bd7094b + 8f71e6f commit 81f0463
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/ui/component/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewConfigContext(
table := createTable("Context", colHeaders)

table.SetInputCapture(func(evt *tcell.EventKey) *tcell.EventKey {
if evt.Key() == key.KeyCtrlD {
if evt.Rune() == key.Rune_d {
row, _ := table.GetSelection()

id := table.GetCell(row, 0).Text
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/component/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewServerTable(hostHostname, hostIP string, OnSSH func(ip string)) *ServerT
table := createTable("servers", columnHeaders)

table.SetInputCapture(func(evt *tcell.EventKey) *tcell.EventKey {
if evt.Key() == key.KeyCtrlS {
if evt.Rune() == key.Rune_s {
row, _ := table.GetSelection()
ip := table.GetCell(row, 1).Text
OnSSH(ip)
Expand Down
8 changes: 4 additions & 4 deletions internal/ui/key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import "github.com/gdamore/tcell/v2"
const (
// RuneColon Colon Key as Rune
RuneColon = ':'
// Rune_s s key as Rune
Rune_s = 's'
// Rune_d d key as Rune
Rune_d = 'd'
)

const (
// KeyCtrlC key
KeyCtrlC = tcell.KeyCtrlC
// KeyCtrlD key
KeyCtrlD = tcell.KeyCtrlD
// KeyCtrlS key
KeyCtrlS = tcell.KeyCtrlS
// KeyEnter key
KeyEnter = tcell.KeyEnter
// KeyEsc key
Expand Down
7 changes: 4 additions & 3 deletions internal/ui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (v *view) focus(name string) {
switch name {
case "servers":
v.header.RemoveAllExtraLegendKeys()
v.header.AddLegendKey("ctrl+s", "ssh to selected machine")
v.header.AddLegendKey("s", "ssh to selected machine")
case "context":
confs, err := v.appCore.GetConfigs()

Expand All @@ -391,9 +391,10 @@ func (v *view) focus(name string) {
return
}

v.header.RemoveAllExtraLegendKeys()

if len(confs) > 1 {
v.header.RemoveAllExtraLegendKeys()
v.header.AddLegendKey("ctrl+d", "delete context")
v.header.AddLegendKey("d", "delete context")
v.header.AddLegendKey("enter", "select new context")
}
default:
Expand Down

0 comments on commit 81f0463

Please sign in to comment.