Add terminal command context
This commit is contained in:
parent
8126d82956
commit
10dd23f05d
3 changed files with 26 additions and 5 deletions
commands/terminal
23
commands/terminal/close.go
Normal file
23
commands/terminal/close.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package terminal
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.sr.ht/~sircmpwn/aerc2/widgets"
|
||||
)
|
||||
|
||||
func init() {
|
||||
register("close", CommandClose)
|
||||
}
|
||||
|
||||
func CommandClose(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) != 1 {
|
||||
return errors.New("Usage: close")
|
||||
}
|
||||
thost, ok := aerc.SelectedTab().(*widgets.TermHost)
|
||||
if !ok {
|
||||
return errors.New("Error: not a terminal")
|
||||
}
|
||||
thost.Terminal().Close(nil)
|
||||
return nil
|
||||
}
|
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…
Add table
Add a link
Reference in a new issue