diff --git a/options.go b/options.go index a060722..7a63c67 100644 --- a/options.go +++ b/options.go @@ -70,6 +70,14 @@ func WithoutCatchPanics() ProgramOption { } } +// WithoutSignals will ignore OS signals. +// This is mainly useful for testing. +func WithoutSignals() ProgramOption { + return func(p *Program) { + p.ignoreSignals = true + } +} + // WithAltScreen starts the program with the alternate screen buffer enabled // (i.e. the program starts in full window mode). Note that the altscreen will // be automatically exited when the program quits. diff --git a/options_test.go b/options_test.go index 71a3c6c..a66483d 100644 --- a/options_test.go +++ b/options_test.go @@ -35,6 +35,13 @@ func TestOptions(t *testing.T) { } }) + t.Run("without signals", func(t *testing.T) { + p := NewProgram(nil, WithoutSignals()) + if !p.ignoreSignals { + t.Errorf("ignore signals should have been set") + } + }) + t.Run("filter", func(t *testing.T) { p := NewProgram(nil, WithFilter(func(_ Model, msg Msg) Msg { return msg })) if p.filter == nil {