Add terminal command context
This commit is contained in:
parent
8126d82956
commit
10dd23f05d
3 changed files with 26 additions and 5 deletions
8
aerc.go
8
aerc.go
|
@ -12,6 +12,7 @@ import (
|
||||||
"git.sr.ht/~sircmpwn/aerc2/config"
|
"git.sr.ht/~sircmpwn/aerc2/config"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/commands"
|
"git.sr.ht/~sircmpwn/aerc2/commands"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/commands/account"
|
"git.sr.ht/~sircmpwn/aerc2/commands/account"
|
||||||
|
"git.sr.ht/~sircmpwn/aerc2/commands/terminal"
|
||||||
libui "git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
libui "git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/widgets"
|
"git.sr.ht/~sircmpwn/aerc2/widgets"
|
||||||
)
|
)
|
||||||
|
@ -20,8 +21,13 @@ func getCommands(selected libui.Drawable) []*commands.Commands {
|
||||||
switch selected.(type) {
|
switch selected.(type) {
|
||||||
case *widgets.AccountView:
|
case *widgets.AccountView:
|
||||||
return []*commands.Commands{
|
return []*commands.Commands{
|
||||||
commands.GlobalCommands,
|
|
||||||
account.AccountCommands,
|
account.AccountCommands,
|
||||||
|
commands.GlobalCommands,
|
||||||
|
}
|
||||||
|
case *widgets.TermHost:
|
||||||
|
return []*commands.Commands{
|
||||||
|
terminal.TerminalCommands,
|
||||||
|
commands.GlobalCommands,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return []*commands.Commands{commands.GlobalCommands}
|
return []*commands.Commands{commands.GlobalCommands}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package commands
|
package terminal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -7,11 +7,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// TODO: Move this command into a terminal-specific command set
|
register("close", CommandClose)
|
||||||
register("close", TermClose)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TermClose(aerc *widgets.Aerc, args []string) error {
|
func CommandClose(aerc *widgets.Aerc, args []string) error {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return errors.New("Usage: close")
|
return errors.New("Usage: close")
|
||||||
}
|
}
|
16
commands/terminal/terminal.go
Normal file
16
commands/terminal/terminal.go
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package terminal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.sr.ht/~sircmpwn/aerc2/commands"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
TerminalCommands *commands.Commands
|
||||||
|
)
|
||||||
|
|
||||||
|
func register(name string, cmd commands.AercCommand) {
|
||||||
|
if TerminalCommands == nil {
|
||||||
|
TerminalCommands = commands.NewCommands()
|
||||||
|
}
|
||||||
|
TerminalCommands.Register(name, cmd)
|
||||||
|
}
|
Loading…
Reference in a new issue