|
@@ -23,6 +23,15 @@ func newMainFlex() *MainFlex {
|
|
|
messageInput: newMessageInput(),
|
|
messageInput: newMessageInput(),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ mf.init()
|
|
|
|
|
+ mf.SetInputCapture(mf.onInputCapture)
|
|
|
|
|
+
|
|
|
|
|
+ return mf
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (mf *MainFlex) init() {
|
|
|
|
|
+ mf.Clear()
|
|
|
|
|
+
|
|
|
right := tview.NewFlex()
|
|
right := tview.NewFlex()
|
|
|
right.SetDirection(tview.FlexRow)
|
|
right.SetDirection(tview.FlexRow)
|
|
|
right.AddItem(mf.messagesText, 0, 1, false)
|
|
right.AddItem(mf.messagesText, 0, 1, false)
|
|
@@ -30,13 +39,24 @@ func newMainFlex() *MainFlex {
|
|
|
// The guilds tree is always focused first at start-up.
|
|
// The guilds tree is always focused first at start-up.
|
|
|
mf.AddItem(mf.guildsTree, 0, 1, true)
|
|
mf.AddItem(mf.guildsTree, 0, 1, true)
|
|
|
mf.AddItem(right, 0, 4, false)
|
|
mf.AddItem(right, 0, 4, false)
|
|
|
- mf.SetInputCapture(mf.onInputCapture)
|
|
|
|
|
-
|
|
|
|
|
- return mf
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mf *MainFlex) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
|
func (mf *MainFlex) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
|
|
switch event.Name() {
|
|
switch event.Name() {
|
|
|
|
|
+ case config.Current.Keys.GuildsTree.Toggle:
|
|
|
|
|
+ // The guilds tree is visible if the numbers of items is two.
|
|
|
|
|
+ if mf.GetItemCount() == 2 {
|
|
|
|
|
+ mf.RemoveItem(mf.guildsTree)
|
|
|
|
|
+
|
|
|
|
|
+ if mf.guildsTree.HasFocus() {
|
|
|
|
|
+ app.SetFocus(mf)
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mf.init()
|
|
|
|
|
+ app.SetFocus(mf.guildsTree)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return nil
|
|
|
case config.Current.Keys.GuildsTree.Focus:
|
|
case config.Current.Keys.GuildsTree.Focus:
|
|
|
app.SetFocus(mf.guildsTree)
|
|
app.SetFocus(mf.guildsTree)
|
|
|
return nil
|
|
return nil
|