Skip to content

Commit

Permalink
chore: remove deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Sep 19, 2024
1 parent d727a8c commit a7d49d0
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 370 deletions.
28 changes: 0 additions & 28 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,6 @@ func Tick(d time.Duration, fn func(time.Time) Msg) Cmd {
}
}

// Sequentially produces a command that sequentially executes the given
// commands.
// The Msg returned is the first non-nil message returned by a Cmd.
//
// func saveStateCmd() Msg {
// if err := save(); err != nil {
// return errMsg{err}
// }
// return nil
// }
//
// cmd := Sequentially(saveStateCmd, Quit)
//
// Deprecated: use Sequence instead.
func Sequentially(cmds ...Cmd) Cmd {
return func() Msg {
for _, cmd := range cmds {
if cmd == nil {
continue
}
if msg := cmd(); msg != nil {
return msg
}
}
return nil
}
}

// setWindowTitleMsg is an internal message used to set the window title.
type setWindowTitleMsg string

Expand Down
56 changes: 0 additions & 56 deletions commands_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tea

import (
"fmt"
"testing"
"time"
)
Expand All @@ -26,61 +25,6 @@ func TestTick(t *testing.T) {
}
}

func TestSequentially(t *testing.T) {
expectedErrMsg := fmt.Errorf("some err")
expectedStrMsg := "some msg"

nilReturnCmd := func() Msg {
return nil
}

tests := []struct {
name string
cmds []Cmd
expected Msg
}{
{
name: "all nil",
cmds: []Cmd{nilReturnCmd, nilReturnCmd},
expected: nil,
},
{
name: "null cmds",
cmds: []Cmd{nil, nil},
expected: nil,
},
{
name: "one error",
cmds: []Cmd{
nilReturnCmd,
func() Msg {
return expectedErrMsg
},
nilReturnCmd,
},
expected: expectedErrMsg,
},
{
name: "some msg",
cmds: []Cmd{
nilReturnCmd,
func() Msg {
return expectedStrMsg
},
nilReturnCmd,
},
expected: expectedStrMsg,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if msg := Sequentially(test.cmds...)(); msg != test.expected {
t.Fatalf("expected a msg %v but got %v", test.expected, msg)
}
})
}
}

func TestBatch(t *testing.T) {
t.Run("nil cmd", func(t *testing.T) {
if b := Batch(nil); b != nil {
Expand Down
14 changes: 0 additions & 14 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,6 @@ func WithoutRenderer() ProgramOption {
}
}

// WithANSICompressor removes redundant ANSI sequences to produce potentially
// smaller output, at the cost of some processing overhead.
//
// This feature is provisional, and may be changed or removed in a future version
// of this package.
//
// Deprecated: this incurs a noticable performance hit. A future release will
// optimize ANSI automatically without the performance penalty.
func WithANSICompressor() ProgramOption {
return func(p *Program) {
p.startupOptions |= withANSICompressor
}
}

// WithFilter supplies an event filter that will be invoked before Bubble Tea
// processes a tea.Msg. The event filter can return any tea.Msg which will then
// get handled by Bubble Tea instead of the original event. If the event filter
Expand Down
4 changes: 0 additions & 4 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ func TestOptions(t *testing.T) {
exercise(t, WithoutBracketedPaste(), withoutBracketedPaste)
})

t.Run("ansi compression", func(t *testing.T) {
exercise(t, WithANSICompressor(), withANSICompressor)
})

t.Run("without catch panics", func(t *testing.T) {
exercise(t, WithoutCatchPanics(), withoutCatchPanics)
})
Expand Down
63 changes: 0 additions & 63 deletions screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,66 +151,3 @@ type disableModeMsg string
func disableMode(mode string) Msg {
return disableModeMsg(mode)
}

// EnterAltScreen enters the alternate screen buffer, which consumes the entire
// terminal window. ExitAltScreen will return the terminal to its former state.
//
// Deprecated: Use the WithAltScreen ProgramOption instead.
func (p *Program) EnterAltScreen() {
if p.renderer != nil {
p.renderer.update(enableMode(ansi.AltScreenBufferMode))
} else {
p.startupOptions |= withAltScreen
}
}

// ExitAltScreen exits the alternate screen buffer.
//
// Deprecated: The altscreen will exited automatically when the program exits.
func (p *Program) ExitAltScreen() {
if p.renderer != nil {
p.renderer.update(disableMode(ansi.AltScreenBufferMode))
} else {
p.startupOptions &^= withAltScreen
}
}

// EnableMouseCellMotion enables mouse click, release, wheel and motion events
// if a mouse button is pressed (i.e., drag events).
//
// Deprecated: Use the WithMouseCellMotion ProgramOption instead.
func (p *Program) EnableMouseCellMotion() {
p.execute(ansi.EnableMouseCellMotion)
}

// DisableMouseCellMotion disables Mouse Cell Motion tracking. This will be
// called automatically when exiting a Bubble Tea program.
//
// Deprecated: The mouse will automatically be disabled when the program exits.
func (p *Program) DisableMouseCellMotion() {
p.execute(ansi.DisableMouseCellMotion)
}

// EnableMouseAllMotion enables mouse click, release, wheel and motion events,
// regardless of whether a mouse button is pressed. Many modern terminals
// support this, but not all.
//
// Deprecated: Use the WithMouseAllMotion ProgramOption instead.
func (p *Program) EnableMouseAllMotion() {
p.execute(ansi.EnableMouseAllMotion)
}

// DisableMouseAllMotion disables All Motion mouse tracking. This will be
// called automatically when exiting a Bubble Tea program.
//
// Deprecated: The mouse will automatically be disabled when the program exits.
func (p *Program) DisableMouseAllMotion() {
p.execute(ansi.DisableMouseAllMotion)
}

// SetWindowTitle sets the terminal window title.
//
// Deprecated: Use the SetWindowTitle command instead.
func (p *Program) SetWindowTitle(title string) {
p.execute(ansi.SetWindowTitle(title))
}
Loading

0 comments on commit a7d49d0

Please sign in to comment.