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

Updates key bindings #31

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading