From 8f71e6fcec1e8b0687fbb80accbace3452223fa4 Mon Sep 17 00:00:00 2001 From: Rob Gonnella Date: Wed, 20 Mar 2024 21:45:40 -0400 Subject: [PATCH] Updates key bindings 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". --- internal/ui/component/context.go | 2 +- internal/ui/component/server.go | 2 +- internal/ui/key/key.go | 8 ++++---- internal/ui/view.go | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/ui/component/context.go b/internal/ui/component/context.go index c1116ed..9fe064f 100644 --- a/internal/ui/component/context.go +++ b/internal/ui/component/context.go @@ -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 diff --git a/internal/ui/component/server.go b/internal/ui/component/server.go index 439b5f5..023e740 100644 --- a/internal/ui/component/server.go +++ b/internal/ui/component/server.go @@ -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) diff --git a/internal/ui/key/key.go b/internal/ui/key/key.go index 7c4426e..16e572d 100644 --- a/internal/ui/key/key.go +++ b/internal/ui/key/key.go @@ -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 diff --git a/internal/ui/view.go b/internal/ui/view.go index d3e6734..c2f64f8 100644 --- a/internal/ui/view.go +++ b/internal/ui/view.go @@ -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() @@ -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: