diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-17 14:02:33 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-17 14:02:33 -0400 |
commit | 1170893e395ff5e3e7bee7ff51224b4a572f01cf (patch) | |
tree | f15e996bb529293c772159dbcf7a8b3fcd1a312f /widgets/account.go | |
parent | 13ba53c9d03c375877395a6580d6f694bd19020f (diff) | |
download | aerc-1170893e395ff5e3e7bee7ff51224b4a572f01cf.tar.gz |
Add basic terminal widget
Diffstat (limited to 'widgets/account.go')
-rw-r--r-- | widgets/account.go | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/widgets/account.go b/widgets/account.go index 6919c0e..b6ba595 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -20,7 +20,7 @@ type AccountView struct { dirlist *DirectoryList grid *ui.Grid logger *log.Logger - interactive ui.Interactive + interactive []ui.Interactive onInvalidate func(d ui.Drawable) runCmd func(cmd string) error msglist *MessageList @@ -116,6 +116,21 @@ func (acct *AccountView) Draw(ctx *ui.Context) { acct.grid.Draw(ctx) } +func (acct *AccountView) popInteractive() { + acct.interactive = acct.interactive[:len(acct.interactive)-1] + if len(acct.interactive) != 0 { + acct.interactive[len(acct.interactive)-1].Focus(true) + } +} + +func (acct *AccountView) pushInteractive(item ui.Interactive) { + if len(acct.interactive) != 0 { + acct.interactive[len(acct.interactive)-1].Focus(false) + } + acct.interactive = append(acct.interactive, item) + item.Focus(true) +} + func (acct *AccountView) beginExCommand() { exline := NewExLine(func(command string) { err := acct.runCmd(command) @@ -124,18 +139,18 @@ func (acct *AccountView) beginExCommand() { Color(tcell.ColorRed, tcell.ColorWhite) } acct.statusbar.Pop() - acct.interactive = nil + acct.popInteractive() }, func() { acct.statusbar.Pop() - acct.interactive = nil + acct.popInteractive() }) - acct.interactive = exline + acct.pushInteractive(exline) acct.statusbar.Push(exline) } func (acct *AccountView) Event(event tcell.Event) bool { - if acct.interactive != nil { - return acct.interactive.Event(event) + if len(acct.interactive) != 0 { + return acct.interactive[len(acct.interactive)-1].Event(event) } switch event := event.(type) { |