diff --git a/discordo.go b/discordo.go index d578fd7..38b8826 100644 --- a/discordo.go +++ b/discordo.go @@ -32,7 +32,7 @@ func main() { channelsList = ui.NewChannelsList(onChannelsListSelected) messagesTextView = ui.NewMessagesTextView(onMessagesTextViewChanged) mainFlex = ui.NewMainFlex(guildsDropDown, channelsList, messagesTextView) - app = ui.NewApp() + app = ui.NewApp(onAppInputCapture) token := util.GetPassword("token") if token != "" { @@ -50,6 +50,10 @@ func main() { } } +func onAppInputCapture(event *tcell.EventKey) *tcell.EventKey { + return event +} + func onLoginFormQuitButtonSelected() { app.Stop() } diff --git a/ui/app.go b/ui/app.go index 8218a13..1b078d0 100644 --- a/ui/app.go +++ b/ui/app.go @@ -1,12 +1,14 @@ package ui import ( + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) -func NewApp() (app *tview.Application) { +func NewApp(onAppInputCapture func(event *tcell.EventKey) *tcell.EventKey) (app *tview.Application) { app = tview.NewApplication(). - EnableMouse(true) + EnableMouse(true). + SetInputCapture(onAppInputCapture) return } diff --git a/ui/flex.go b/ui/flex.go index bcabfad..e35ea17 100644 --- a/ui/flex.go +++ b/ui/flex.go @@ -5,17 +5,19 @@ import ( ) func NewMainFlex(guildsDropDown *tview.DropDown, channelsList *tview.List, messagesTextView *tview.TextView) (mainFlex *tview.Flex) { + midFlex := NewMidFlex(channelsList, messagesTextView) mainFlex = tview.NewFlex(). SetDirection(tview.FlexRow). AddItem(guildsDropDown, 3, 1, false). - AddItem( - tview.NewFlex(). - AddItem(channelsList, 20, 1, false). - AddItem(messagesTextView, 0, 3, false), - 0, - 1, - false, - ) + AddItem(midFlex, 0, 1, false) + + return +} + +func NewMidFlex(channelsList *tview.List, messagesTextView *tview.TextView) (midFlex *tview.Flex) { + midFlex = tview.NewFlex(). + AddItem(channelsList, 20, 1, false). + AddItem(messagesTextView, 0, 3, false) return }