diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-30 11:58:24 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-30 11:58:24 -0400 |
commit | 700dea23fa75f213af2f99449db994008eab9d21 (patch) | |
tree | fa142784bf4ccb6aba1cd2b8513228dd4b968b28 /widgets | |
parent | 4465646fedc5dd3efa680a7cc8d06671350b75b9 (diff) | |
download | aerc-700dea23fa75f213af2f99449db994008eab9d21.tar.gz |
Implement :pipe
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/terminal.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go index e7286f96..45e35912 100644 --- a/widgets/terminal.go +++ b/widgets/terminal.go @@ -9,8 +9,8 @@ import ( "git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/go-libvterm" + "git.sr.ht/~sircmpwn/pty" "github.com/gdamore/tcell" - "github.com/kr/pty" ) type vtermKey struct { @@ -105,6 +105,7 @@ type Terminal struct { vterm *vterm.VTerm OnClose func(err error) + OnStart func() OnTitle func(title string) } @@ -192,6 +193,9 @@ func (term *Terminal) flushTerminal() { } func (term *Terminal) Close(err error) { + if term.closed { + return + } term.mutex.Lock() defer term.mutex.Unlock() term.err = err @@ -226,11 +230,6 @@ func (term *Terminal) Invalidate() { func (term *Terminal) Draw(ctx *ui.Context) { if term.closed { - if term.err != nil { - ui.NewText(term.err.Error()).Strategy(ui.TEXT_CENTER).Draw(ctx) - } else { - ui.NewText("Terminal closed").Strategy(ui.TEXT_CENTER).Draw(ctx) - } return } @@ -252,6 +251,9 @@ func (term *Terminal) Draw(ctx *ui.Context) { return } term.start <- nil + if term.OnStart != nil { + term.OnStart() + } } term.ctx = ctx // gross @@ -309,6 +311,9 @@ func (term *Terminal) Draw(ctx *ui.Context) { } func (term *Terminal) Focus(focus bool) { + if term.closed { + return + } term.focus = focus if term.ctx != nil { if !term.focus { @@ -339,6 +344,9 @@ func convertMods(mods tcell.ModMask) vterm.Modifier { } func (term *Terminal) Event(event tcell.Event) bool { + if term.closed { + return false + } switch event := event.(type) { case *tcell.EventKey: if event.Key() == tcell.KeyRune { |