aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/terminal.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-03-15 20:38:37 +0100
committerRobin Jarry <robin@jarry.cc>2023-04-01 01:01:07 +0200
commit088d63ce934c34e113a5b3154dfcf91b49132067 (patch)
treea743b7f5f563d7382ebde83cac5ba498b3f6b1e7 /widgets/terminal.go
parentaec90650f63ff0195599dae817016db137964bcb (diff)
downloadaerc-088d63ce934c34e113a5b3154dfcf91b49132067.tar.gz
tabs: make sure to close tab content
Rework how tabs are closed. Change the aerc.RemoveTab and aerc.ReplaceTab functions to accept a new boolean argument. If true, make sure to close the tab content. Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/terminal.go')
-rw-r--r--widgets/terminal.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 9a2ebbef..0e31bf71 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -35,7 +35,11 @@ func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
return term, nil
}
-func (term *Terminal) Close(err error) {
+func (term *Terminal) Close() {
+ term.closeErr(nil)
+}
+
+func (term *Terminal) closeErr(err error) {
if term.closed {
return
}
@@ -62,7 +66,7 @@ func (term *Terminal) Destroy() {
}
// If we destroy, we don't want to call the OnClose callback
term.OnClose = nil
- term.Close(nil)
+ term.Close()
term.vterm = nil
term.destroyed = true
}
@@ -82,7 +86,7 @@ func (term *Terminal) Draw(ctx *ui.Context) {
attr := &syscall.SysProcAttr{Setsid: true, Setctty: true, Ctty: 1}
if err := term.vterm.StartWithAttrs(term.cmd, attr); err != nil {
log.Errorf("error running terminal: %v", err)
- term.Close(err)
+ term.closeErr(err)
return
}
term.running = true
@@ -152,7 +156,7 @@ func (term *Terminal) HandleEvent(ev tcell.Event) bool {
term.OnTitle(ev.Title())
}
case *tcellterm.EventClosed:
- term.Close(nil)
+ term.Close()
ui.QueueRedraw()
}
return false