refactor(cmd): add/remove mentions list page instead
This commit is contained in:
parent
4a77d7cbd5
commit
ba458ca972
2 changed files with 14 additions and 7 deletions
|
|
@ -103,9 +103,7 @@ func (a *application) init() {
|
|||
a.flex.
|
||||
AddItem(a.guildsTree, 0, 1, true).
|
||||
AddItem(right, 0, 4, false)
|
||||
a.pages.
|
||||
AddAndSwitchToPage(flexPageName, a.flex, true).
|
||||
AddPage(mentionsListPageName, a.messageInput.autocomplete, false, false)
|
||||
a.pages.AddAndSwitchToPage(flexPageName, a.flex, true)
|
||||
}
|
||||
|
||||
func (a *application) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
|
|
@ -124,11 +122,11 @@ func (a *application) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
|||
func (a *application) onFlexInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
||||
switch event.Name() {
|
||||
case a.cfg.Keys.FocusGuildsTree:
|
||||
a.pages.HidePage(mentionsListPageName)
|
||||
a.messageInput.removeMentionsList()
|
||||
a.SetFocus(app.guildsTree)
|
||||
return nil
|
||||
case a.cfg.Keys.FocusMessagesText:
|
||||
a.pages.HidePage(mentionsListPageName)
|
||||
a.messageInput.removeMentionsList()
|
||||
a.SetFocus(app.messagesText)
|
||||
return nil
|
||||
case a.cfg.Keys.FocusMessageInput:
|
||||
|
|
|
|||
|
|
@ -371,7 +371,10 @@ func (mi *messageInput) showMentionList(col int) {
|
|||
x += min(col, maxW-w)
|
||||
}
|
||||
l.SetRect(x, y, w, h)
|
||||
app.pages.ShowPage(mentionsListPageName)
|
||||
|
||||
app.pages.
|
||||
AddAndSwitchToPage(mentionsListPageName, l, false).
|
||||
ShowPage(flexPageName)
|
||||
app.SetFocus(mi)
|
||||
}
|
||||
|
||||
|
|
@ -414,10 +417,16 @@ func (mi *messageInput) addAutocompleteItem(gID discord.GuildID, m *discord.Memb
|
|||
return mi.autocomplete.GetItemCount() > int(mi.cfg.AutocompleteLimit)
|
||||
}
|
||||
|
||||
func (mi *messageInput) removeMentionsList() {
|
||||
app.pages.
|
||||
RemovePage(mentionsListPageName).
|
||||
SwitchToPage(flexPageName)
|
||||
}
|
||||
|
||||
func (mi *messageInput) stopTabCompletion() {
|
||||
if mi.cfg.AutocompleteLimit > 0 {
|
||||
app.pages.HidePage(mentionsListPageName)
|
||||
mi.autocomplete.Clear()
|
||||
mi.removeMentionsList()
|
||||
app.SetFocus(mi)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue