From d81319ff169f53289ed8bdf55d24e640c9623611 Mon Sep 17 00:00:00 2001 From: "beeb@neb.one" Date: Tue, 10 Sep 2024 17:44:39 +0700 Subject: [PATCH] feat: add new text input styling --- models/weaveinit/run_l1_node.go | 8 ++++---- utils/text_input.go | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/models/weaveinit/run_l1_node.go b/models/weaveinit/run_l1_node.go index fb58d16b..c39ab3c1 100644 --- a/models/weaveinit/run_l1_node.go +++ b/models/weaveinit/run_l1_node.go @@ -88,7 +88,7 @@ func (m *RunL1NodeVersionInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) { input, cmd, done := m.TextInput.Update(msg) if done { m.state.initiadVersion = input.Text - return NewRunL1NodeChainIdInput(m.state), nil + return NewRunL1NodeChainIdInput(m.state), cmd } m.TextInput = input return m, cmd @@ -118,7 +118,7 @@ func (m *RunL1NodeChainIdInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) { input, cmd, done := m.TextInput.Update(msg) if done { m.state.chainId = input.Text - return NewRunL1NodeMonikerInput(m.state), nil + return NewRunL1NodeMonikerInput(m.state), cmd } m.TextInput = input return m, cmd @@ -277,7 +277,7 @@ func (m *MinGasPriceInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) { input, cmd, done := m.TextInput.Update(msg) if done { m.state.minGasPrice = input.Text - return NewEnableFeaturesCheckbox(m.state), nil + return NewEnableFeaturesCheckbox(m.state), cmd } m.TextInput = input return m, cmd @@ -359,7 +359,7 @@ func (m *SeedsInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) { input, cmd, done := m.TextInput.Update(msg) if done { m.state.seeds = input.Text - return NewPersistentPeersInput(m.state), nil + return NewPersistentPeersInput(m.state), cmd } m.TextInput = input return m, cmd diff --git a/utils/text_input.go b/utils/text_input.go index 40607efd..5e5b70cb 100644 --- a/utils/text_input.go +++ b/utils/text_input.go @@ -23,7 +23,8 @@ func (ti TextInput) Update(msg tea.Msg) (TextInput, tea.Cmd, bool) { case tea.KeyMsg: switch msg.Type { case tea.KeyEnter: - return ti, nil, true + ti.Entered = true + return ti, nil, false case tea.KeyBackspace, tea.KeyCtrlH: if ti.Cursor > 0 && len(ti.Text) > 0 { ti.Text = ti.Text[:ti.Cursor-1] + ti.Text[ti.Cursor:] @@ -43,6 +44,7 @@ func (ti TextInput) Update(msg tea.Msg) (TextInput, tea.Cmd, bool) { case tea.KeyCtrlC: return ti, tea.Quit, false } + } return ti, nil, false }