From 3c0961fe15a12493661d5c16137a53563e8c8d66 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 12 Nov 2024 15:43:45 -0500 Subject: [PATCH] feat: make the ferocious renderer opt-in The ferocious renderer is now opt-in. This commit adds a new option `WithFerociousRenderer` that enables the ferocious renderer. --- examples/simple/main_test.go | 3 --- options.go | 15 ++++++++++----- screen_test.go | 6 +----- tea.go | 8 ++++---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/examples/simple/main_test.go b/examples/simple/main_test.go index 87169e7169..e489658608 100644 --- a/examples/simple/main_test.go +++ b/examples/simple/main_test.go @@ -54,9 +54,6 @@ func TestApp(t *testing.T) { } func TestAppInteractive(t *testing.T) { - // TODO: Enable this test again - t.Skip("update this test to recognize the new renderer.") - m := model(10) tm := teatest.NewTestModel( t, m, diff --git a/options.go b/options.go index 7954e4d9fa..c0ae254158 100644 --- a/options.go +++ b/options.go @@ -286,8 +286,8 @@ func (e experimentalOptions) has(option string) bool { } const ( - // Unferocious disables the "ferocious" renderer. - experimentalUnferocious = "unferocious" + // Ferocious enables the "ferocious" renderer. + experimentalFerocious = "ferocious" ) // WithColorProfile sets the color profile that the program will use. This is @@ -302,9 +302,14 @@ func WithColorProfile(profile colorprofile.Profile) ProgramOption { } } -// withStandardRenderer tells Bubble Tea to use the standrad renderer. -func withStandardRenderer() ProgramOption { //nolint:unused +// WithFerociousRenderer tells Bubble Tea to use the new shiny "ferocious" +// renderer. This renderer is experimental and may change or be removed in +// future versions. +// +// The ferocious renderer is a new renderer that is faster and more efficient +// than the default renderer. It is also more ferocious ;) +func WithFerociousRenderer() ProgramOption { //nolint:unused return func(p *Program) { - p.startupOptions |= avecStandardRenderer + p.startupOptions |= withFerociousRenderer } } diff --git a/screen_test.go b/screen_test.go index 2fc48cc028..c60ae9e244 100644 --- a/screen_test.go +++ b/screen_test.go @@ -106,11 +106,7 @@ func TestClearMsg(t *testing.T) { m := &testModel{} p := NewProgram(m, WithInput(&in), WithOutput(&buf), // Use ANSI256 to increase test coverage. - WithColorProfile(colorprofile.ANSI256), - - // XXX: Use the standard renderer, for now. Ultiamtely we want - // to update the tests to use the Ferocious Renderer. - withStandardRenderer()) + WithColorProfile(colorprofile.ANSI256)) test.cmds = append([]Cmd{func() Msg { return WindowSizeMsg{80, 24} }}, test.cmds...) test.cmds = append(test.cmds, Quit) diff --git a/tea.go b/tea.go index 1e2a818eb6..82db0edec7 100644 --- a/tea.go +++ b/tea.go @@ -112,7 +112,7 @@ const ( withKeyboardEnhancements withGraphemeClustering - avecStandardRenderer + withFerociousRenderer ) // channelHandlers manages the series of channels returned by various processes. @@ -708,10 +708,10 @@ func (p *Program) Run() (Model, error) { go p.Send(ColorProfileMsg{p.profile}) if p.renderer == nil { // If no renderer is set use the ferocious one. - if p.startupOptions&avecStandardRenderer != 0 || p.exp.has(experimentalUnferocious) { - p.renderer = newStandardRenderer(p.profile) - } else { + if p.startupOptions&withFerociousRenderer != 0 || p.exp.has(experimentalFerocious) { p.renderer = newFerociousRenderer(p.profile) + } else { + p.renderer = newStandardRenderer(p.profile) } }