mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
chore: conform to the proposed bubble tea API
This commit is contained in:
+7
-4
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user