chore: conform to the proposed bubble tea API

This commit is contained in:
Ayman Bagabas
2024-05-13 14:39:34 -04:00
parent f4f674440a
commit d115a6d4d6
17 changed files with 183 additions and 194 deletions
+7 -4
View File
@@ -75,21 +75,24 @@ type Model struct {
}
// New creates a new model with default settings.
func New() Model {
func New(ctx tea.Context) Model {
return Model{
Style: ctx.NewStyle(),
TextStyle: ctx.NewStyle(),
BlinkSpeed: defaultBlinkSpeed,
Blink: true,
mode: CursorBlink,
blinkCtx: &blinkCtx{
ctx: context.Background(),
ctx: ctx,
},
}
}
// Update updates the cursor.
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
func (m Model) Update(ctx tea.Context, msg tea.Msg) (Model, tea.Cmd) {
switch msg := msg.(type) {
case initialBlinkMsg:
// We accept all initialBlinkMsgs generated by the Blink command.
@@ -203,7 +206,7 @@ func (m *Model) SetChar(char string) {
}
// View displays the cursor.
func (m Model) View() string {
func (m Model) View(tea.Context) string {
if m.Blink {
return m.TextStyle.Inline(true).Render(m.char)
}