feat: make signal handler optional

You can now initialize a tea app without a signal handler:

p := NewProgram(model, WithoutSignalHandler())
This commit is contained in:
Christian Muehlhaeuser
2022-10-07 20:24:23 +02:00
parent 2696b2f339
commit 0ac6702e11
3 changed files with 19 additions and 1 deletions

8
tea.go
View File

@@ -71,6 +71,7 @@ const (
withInputTTY
withCustomInput
withANSICompressor
withoutSignalHandler
)
// Program is a terminal user interface.
@@ -375,7 +376,12 @@ func (p *Program) StartReturningModel() (Model, error) {
}
// Handle signals.
sigintLoopDone := p.handleSignals()
sigintLoopDone := make(chan struct{})
if !p.startupOptions.has(withoutSignalHandler) {
sigintLoopDone = p.handleSignals()
} else {
close(sigintLoopDone)
}
if p.CatchPanics {
defer func() {