From da64fee41cebd8ae356e67e7d76c01cd82bd0899 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Tue, 5 Nov 2024 12:53:10 -0500 Subject: [PATCH] refactor: use arrow keys and remove hotkeys --- ui/pages/accounts/model.go | 2 +- ui/pages/keys/model.go | 4 ++-- ui/pages/transaction/model.go | 4 ++-- ui/viewport.go | 36 ++--------------------------------- 4 files changed, 7 insertions(+), 39 deletions(-) diff --git a/ui/pages/accounts/model.go b/ui/pages/accounts/model.go index 425adf4..2784f9a 100644 --- a/ui/pages/accounts/model.go +++ b/ui/pages/accounts/model.go @@ -26,7 +26,7 @@ func New(state *internal.StateModel) ViewModel { Height: 0, Data: state.Accounts, controls: "( (g)enerate )", - navigation: "| " + style.Green.Render("(a)ccounts") + " | (k)eys | (t)xn |", + navigation: "| " + style.Green.Render("accounts") + " | keys | txn |", } m.table = table.New( diff --git a/ui/pages/keys/model.go b/ui/pages/keys/model.go index e3879de..d974c99 100644 --- a/ui/pages/keys/model.go +++ b/ui/pages/keys/model.go @@ -31,8 +31,8 @@ func New(address string, keys *[]api.ParticipationKey) ViewModel { Width: 80, Height: 24, - controls: "( (g)enerate | (d)elete )", - navigation: "| (a)ccounts | " + style.Green.Render("(k)eys") + " | (t)xn |", + controls: "( (g)enerate )", + navigation: "| accounts | " + style.Green.Render("keys") + " | txn |", table: table.New(), } diff --git a/ui/pages/transaction/model.go b/ui/pages/transaction/model.go index be00c1f..ac4b2b5 100644 --- a/ui/pages/transaction/model.go +++ b/ui/pages/transaction/model.go @@ -39,7 +39,7 @@ func New(state *internal.StateModel) ViewModel { return ViewModel{ State: state, IsOnline: false, - navigation: "| (a)ccounts | (k)eys | " + style.Green.Render("(t)xn") + " |", - controls: "( shift+tab: back )", + navigation: "| accounts | keys | " + style.Green.Render("txn") + " |", + controls: "( <- back )", } } diff --git a/ui/viewport.go b/ui/viewport.go index 660c73c..f602d67 100644 --- a/ui/viewport.go +++ b/ui/viewport.go @@ -100,7 +100,7 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch msg.String() { // Tab Backwards - case "shift+tab": + case "left": if m.page == AccountsPage { return m, nil } @@ -112,7 +112,7 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } // Tab Forwards - case "tab": + case "right": if m.page == AccountsPage { selAcc := m.accountsPage.SelectedAccount() if selAcc != (internal.Account{}) { @@ -129,38 +129,6 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } return m, nil - case "a": - m.page = AccountsPage - case "g": - m.generatePage.Inputs[0].SetValue(m.accountsPage.SelectedAccount().Address) - m.page = GeneratePage - return m, nil - case "k": - selAcc := m.accountsPage.SelectedAccount() - if selAcc != (internal.Account{}) { - m.page = KeysPage - return m, accounts.EmitAccountSelected(selAcc) - } - return m, nil - case "t": - if m.page == AccountsPage { - acct := m.accountsPage.SelectedAccount() - data := *m.Data.ParticipationKeys - for i, key := range data { - if key.Address == acct.Address { - m.page = TransactionPage - return m, keys.EmitKeySelected(&data[i]) - } - } - } - if m.page == KeysPage { - selKey := m.keysPage.SelectedKey() - if selKey != nil { - m.page = TransactionPage - return m, keys.EmitKeySelected(selKey) - } - } - return m, nil case "ctrl+c": if m.page != GeneratePage { return m, tea.Quit