summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--commands/term.go21
-rw-r--r--config/aerc.conf2
-rw-r--r--go.mod3
-rw-r--r--go.sum11
-rw-r--r--widgets/aerc.go1
-rw-r--r--widgets/terminal.go13
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]
 #
diff --git a/go.mod b/go.mod
index 42b932f..c70fa24 100644
--- a/go.mod
+++ b/go.mod
@@ -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
 )
diff --git a/go.sum b/go.sum
index dc3ccf1..8ee8cab 100644
--- a/go.sum
+++ b/go.sum
@@ -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
+}
2' href='#n432'>432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724