From 31bbb86a2d8ecabed98f329c519426e933d33067 Mon Sep 17 00:00:00 2001 From: ayntgl Date: Mon, 24 Oct 2022 01:18:10 +0530 Subject: [PATCH] Prefix enum with focusedId --- ui/view.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ui/view.go b/ui/view.go index 99834a5..d0a9519 100644 --- a/ui/view.go +++ b/ui/view.go @@ -5,13 +5,13 @@ import ( "github.com/rivo/tview" ) -type FocusedID int +type focusedId int const ( - guildsView FocusedID = iota - channelsView - messagesView - inputView + focusedIdGuildsView focusedId = iota + focusedIdChannelsView + focusedIdMessagesView + focusedIdInputView ) type View struct { @@ -23,7 +23,7 @@ type View struct { InputView *InputView app *Application - focused FocusedID + focused focusedId } func newView(app *Application) *View { @@ -61,7 +61,7 @@ func (v *View) onInputCapture(event *tcell.EventKey) *tcell.EventKey { case tcell.KeyBacktab: // If the currently focused view is the guilds view (first), then focus the input view (last) if v.focused == 0 { - v.focused = inputView + v.focused = focusedIdInputView } else { v.focused-- } @@ -69,8 +69,8 @@ func (v *View) onInputCapture(event *tcell.EventKey) *tcell.EventKey { v.setFocus() case tcell.KeyTab: // If the currently focused view is the input view (last), then focus the guilds view (first) - if v.focused == inputView { - v.focused = guildsView + if v.focused == focusedIdInputView { + v.focused = focusedIdGuildsView } else { v.focused++ } @@ -84,13 +84,13 @@ func (v *View) onInputCapture(event *tcell.EventKey) *tcell.EventKey { func (v *View) setFocus() { var p tview.Primitive switch v.focused { - case guildsView: + case focusedIdGuildsView: p = v.GuildsView - case channelsView: + case focusedIdChannelsView: p = v.ChannelsView - case messagesView: + case focusedIdMessagesView: p = v.MessagesView - case inputView: + case focusedIdInputView: p = v.InputView }