diff --git a/go.mod b/go.mod index 2104c84..f174a32 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/charmbracelet/bubbles v0.9.0 - github.com/charmbracelet/bubbletea v0.17.0 // indirect + github.com/charmbracelet/bubbletea v0.19.1 // indirect github.com/charmbracelet/lipgloss v0.4.0 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect ) diff --git a/go.sum b/go.sum index 685946a..f2ca6c6 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/charmbracelet/bubbles v0.9.0/go.mod h1:NWT/c+0rYEnYChz5qCyX4Lj6fDw9gG github.com/charmbracelet/bubbletea v0.14.1/go.mod h1:b5lOf5mLjMg1tRn1HVla54guZB+jvsyV0yYAQja95zE= github.com/charmbracelet/bubbletea v0.17.0 h1:ABmd01l6K7Q8lSQxF7yG8yWayz5gXWSt3JfB/X1eYP4= github.com/charmbracelet/bubbletea v0.17.0/go.mod h1:YTZSs2p3odhwYZdhqJheYHVUjU37c9OLgS85kw6NGQY= +github.com/charmbracelet/bubbletea v0.19.1 h1:VHuzkJbnTAkxhOfi9+Lb5PYfNM9+Oh+qhP8uDX5ReOU= +github.com/charmbracelet/bubbletea v0.19.1/go.mod h1:VuXF2pToRxDUHcBUcPmCRUHRvFATM4Ckb/ql1rBl3KA= github.com/charmbracelet/harmonica v0.1.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao= github.com/charmbracelet/lipgloss v0.3.0/go.mod h1:VkhdBS2eNAmRkTwRKLJCFhCOVkjntMusBDxv7TXahuk= github.com/charmbracelet/lipgloss v0.4.0 h1:768h64EFkGUr8V5yAKV7/Ta0NiVceiPaV+PphaW1K9g= @@ -24,6 +26,8 @@ github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34= +github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho= github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 h1:y1p/ycavWjGT9FnmSjdbWUlLGvcxrY0Rw3ATltrxOhk= github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= diff --git a/ui/login/login.go b/ui/login/login.go index 0277994..1a8826d 100644 --- a/ui/login/login.go +++ b/ui/login/login.go @@ -73,23 +73,21 @@ func NewLogin() State { func (s State) Update(msg tea.Msg) (State, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: - switch msg.String() { - case "tab", "shift+tab", "enter", "up", "down", "space": - str := msg.String() - + key := msg.String() + switch key { + case " ", "enter": // run the newClient cmd when pressing "enter" while focused on the connect button - if str == "enter" && s.FocusIndex == len(s.Inputs)+1 { + if key == "enter" && s.FocusIndex == len(s.Inputs)+1 { return s, connect } - // toggle tls state when pressing "enter" while focused on the checkbox - // TODO: figure out why space isn't working here. all other keys works just fine - if (str == "enter" || str == "space") && s.FocusIndex == len(s.Inputs) { + // toggle tls state when pressing "enter" or "space" while focused on the checkbox + if (key == "enter" || key == " ") && s.FocusIndex == len(s.Inputs) { s.TLS = !s.TLS return s, nil } - - if str == "up" || str == "shift+tab" { + case "tab", "shift+tab", "up", "down": + if key == "up" || key == "shift+tab" { s.FocusIndex-- } else { s.FocusIndex++