Skip to content

Commit

Permalink
Updates key bindings
Browse files Browse the repository at this point in the history
It was annoying to have to press ctrl+s to ssh and ctrl+d to delete
contexts, so this commit switches to just "s" and "d".
  • Loading branch information
robgonnella committed Mar 21, 2024
1 parent bd7094b commit 8f71e6f
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 8f71e6f

Please sign in to comment.