diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-10 21:15:24 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-10 21:15:24 -0400 |
commit | b60999c39e11bf4d1e236f2b10a2f895b44d23fb (patch) | |
tree | 8ce8023277815a7d1f25dc7c48fa910c698d5b1b /widgets/aerc.go | |
parent | 62862d8a9e7f684bc3ff4e9ea115678ff44d8644 (diff) | |
download | aerc-b60999c39e11bf4d1e236f2b10a2f895b44d23fb.tar.gz |
Start building out command subsystem
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r-- | widgets/aerc.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go index 26dc5f2..bf545f9 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -1,7 +1,6 @@ package widgets import ( - "fmt" "log" "github.com/gdamore/tcell" @@ -13,11 +12,14 @@ import ( type Aerc struct { accounts map[string]*AccountView + cmd func(cmd string) error grid *libui.Grid tabs *libui.Tabs } -func NewAerc(conf *config.AercConfig, logger *log.Logger) *Aerc { +func NewAerc(conf *config.AercConfig, logger *log.Logger, + cmd func(cmd string) error) *Aerc { + tabs := libui.NewTabs() mainGrid := libui.NewGrid().Rows([]libui.GridSpec{ @@ -37,12 +39,13 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger) *Aerc { aerc := &Aerc{ accounts: make(map[string]*AccountView), + cmd: cmd, grid: mainGrid, tabs: tabs, } for _, acct := range conf.Accounts { - view := NewAccountView(&acct, logger, aerc.RunCommand) + view := NewAccountView(&acct, logger, cmd) aerc.accounts[acct.Name] = view tabs.Add(view, acct.Name) } @@ -73,7 +76,6 @@ func (aerc *Aerc) Event(event tcell.Event) bool { return acct.Event(event) } -func (aerc *Aerc) RunCommand(cmd string) error { - // TODO - return fmt.Errorf("TODO: execute '%s'", cmd) +func (aerc *Aerc) SelectedAccount() *AccountView { + return aerc.accounts[aerc.tabs.Tabs[aerc.tabs.Selected].Name] } |