forked from Mirrors/bubbletea
feat: allow to disable signals (#721)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
9cc3861bab
commit
5326d76c40
|
@ -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
|
// WithAltScreen starts the program with the alternate screen buffer enabled
|
||||||
// (i.e. the program starts in full window mode). Note that the altscreen will
|
// (i.e. the program starts in full window mode). Note that the altscreen will
|
||||||
// be automatically exited when the program quits.
|
// be automatically exited when the program quits.
|
||||||
|
|
|
@ -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) {
|
t.Run("filter", func(t *testing.T) {
|
||||||
p := NewProgram(nil, WithFilter(func(_ Model, msg Msg) Msg { return msg }))
|
p := NewProgram(nil, WithFilter(func(_ Model, msg Msg) Msg { return msg }))
|
||||||
if p.filter == nil {
|
if p.filter == nil {
|
||||||
|
|
Loading…
Reference in New Issue