diff options
-rw-r--r-- | commands/term.go | 21 | ||||
-rw-r--r-- | config/aerc.conf | 2 | ||||
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | go.sum | 11 | ||||
-rw-r--r-- | widgets/aerc.go | 1 | ||||
-rw-r--r-- | widgets/terminal.go | 13 |
6 files changed, 43 insertions, 8 deletions
diff --git a/commands/term.go b/commands/term.go index 0a2aa3b..7ce1947 100644 --- a/commands/term.go +++ b/commands/term.go @@ -1,11 +1,12 @@ package commands import ( - "errors" "os/exec" "git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/aerc2/widgets" + + "github.com/riywo/loginshell" ) func init() { @@ -13,8 +14,12 @@ func init() { } func Term(aerc *widgets.Aerc, args []string) error { - if len(args) > 2 { - return errors.New("Usage: term [<command>]") + if len(args) == 1 { + shell, err := loginshell.Shell() + if err != nil { + return err + } + args = append(args, shell) } term, err := widgets.NewTerminal(exec.Command(args[1], args[2:]...)) if err != nil { @@ -27,7 +32,13 @@ func Term(aerc *widgets.Aerc, args []string) error { {ui.SIZE_WEIGHT, 1}, }) grid.AddChild(term).At(0, 1) - aerc.NewTab(grid, "Terminal") - // TODO: update tab name when child process changes it + tab := aerc.NewTab(grid, "Terminal") + term.OnTitle = func(title string) { + if title == "" { + title = "Terminal" + } + tab.Name = title + tab.Content.Invalidate() + } return nil } diff --git a/config/aerc.conf b/config/aerc.conf index e465d5e..5a4317f 100644 --- a/config/aerc.conf +++ b/config/aerc.conf @@ -126,7 +126,7 @@ h = :prev-tab<Enter> d = :confirm 'Really delete this message?' ':delete-message<Enter>'<Enter> c = :cf<space> -$ = :term-exec +$ = :term<space> [mbinds] # @@ -1,7 +1,7 @@ module git.sr.ht/~sircmpwn/aerc2 require ( - git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190316225658-2a4963dd9ec0 + git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317210455-72d6c2838fbe github.com/emersion/go-imap v1.0.0-beta.1 github.com/emersion/go-imap-idle v0.0.0-20180114101550-2af93776db6b github.com/emersion/go-sasl v0.0.0-20161116183048-7e096a0a6197 // indirect @@ -16,6 +16,7 @@ require ( github.com/mattn/go-runewidth v0.0.2 github.com/mitchellh/go-homedir v1.1.0 github.com/nsf/termbox-go v0.0.0-20180129072728-88b7b944be8b + github.com/riywo/loginshell v0.0.0-20181227004642-c2f4167b2303 github.com/stretchr/testify v1.3.0 golang.org/x/text v0.3.0 ) @@ -1,5 +1,13 @@ git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190316225658-2a4963dd9ec0 h1:aIQh7m6L3uS8/lg021Cia2QtttUgZO0LuuxJ8wc57dQ= git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190316225658-2a4963dd9ec0/go.mod h1:cp37LbiS1y4CrTOmKSF87ZMLwawWUF612RYKTi8vbDc= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317204448-1089ad765386 h1:3Zw5LLe4S7iyeZZsuDPyMPKalUvD8//FBdO7uSlB+s0= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317204448-1089ad765386/go.mod h1:cp37LbiS1y4CrTOmKSF87ZMLwawWUF612RYKTi8vbDc= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317205821-0763add02731 h1:/TF+apPakaqSpg2co0zXsndxeYQODhCbyGxlGpVeEhw= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317205821-0763add02731/go.mod h1:hT88+cTemwwESbMptwC7O33qrJfQX0SgRWbXlndUS2c= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317205953-0674b071e8bf h1:6Ynr+M6lUnkIxi8ONNmDn6dbyBTt1PawA6sT39S7i/8= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317205953-0674b071e8bf/go.mod h1:hT88+cTemwwESbMptwC7O33qrJfQX0SgRWbXlndUS2c= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317210455-72d6c2838fbe h1:pg73OOcg6PZp+XUOsFaqGG4Heu3kYAJZHSaS6eRRmJk= +git.sr.ht/~sircmpwn/go-libvterm v0.0.0-20190317210455-72d6c2838fbe/go.mod h1:hT88+cTemwwESbMptwC7O33qrJfQX0SgRWbXlndUS2c= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emersion/go-imap v1.0.0-beta.1 h1:bTCaVlUnb5mKoW9lEukusxguSYYZPer+q0g5t+vw5X0= @@ -39,8 +47,11 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/nsf/termbox-go v0.0.0-20180129072728-88b7b944be8b/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/riywo/loginshell v0.0.0-20181227004642-c2f4167b2303 h1:iVSzuQeMQqR6xo15tY215nUTBmrgpTq0Qwaw+YEil24= +github.com/riywo/loginshell v0.0.0-20181227004642-c2f4167b2303/go.mod h1:/PfPXh0EntGc3QAAyUaviy4S9tzy4Zp0e2ilq4voC6E= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/widgets/aerc.go b/widgets/aerc.go index b94d03d..a968ab1 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -96,7 +96,6 @@ func (aerc *Aerc) Draw(ctx *libui.Context) { func (aerc *Aerc) Event(event tcell.Event) bool { if aerc.focused != nil { - aerc.logger.Println("sending event to focused child") return aerc.focused.Event(event) } diff --git a/widgets/terminal.go b/widgets/terminal.go index 502d974..bd84ab4 100644 --- a/widgets/terminal.go +++ b/widgets/terminal.go @@ -25,6 +25,8 @@ type Terminal struct { pty *os.File start chan interface{} vterm *vterm.VTerm + + OnTitle func(title string) } func NewTerminal(cmd *exec.Cmd) (*Terminal, error) { @@ -51,6 +53,7 @@ func NewTerminal(cmd *exec.Cmd) (*Terminal, error) { screen := term.vterm.ObtainScreen() screen.OnDamage = term.onDamage screen.OnMoveCursor = term.onMoveCursor + screen.OnSetTermProp = term.onSetTermProp screen.Reset(true) state := term.vterm.ObtainState() @@ -231,3 +234,13 @@ func (term *Terminal) onMoveCursor(old *vterm.Pos, term.resetCursor() return 1 } + +func (term *Terminal) onSetTermProp(prop int, val *vterm.VTermValue) int { + switch prop { + case vterm.VTERM_PROP_TITLE: + if term.OnTitle != nil { + term.OnTitle(val.String) + } + } + return 1 +} |