-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.go
More file actions
53 lines (47 loc) · 1.06 KB
/
command.go
File metadata and controls
53 lines (47 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package orvyn
import (
"time"
tea "github.com/charmbracelet/bubbletea"
)
// TickMsg simplify and assure the right tick msg management with a unique Tag.
type TickMsg struct {
Time time.Time
Tag uint
}
// TickCmd should be returned in update function to ensure the tick continues.
// Be sure to check and increment the tick tag when responding to the message.
//
// func (s *Screen) Update(msg tea.Msg) tea.Cmd {
// switch msg := msg.(type) {
// case orvyn.TickMsg:
// if msg.Tag != s.tickTag {
// return nil
// }
//
// s.updateData()
//
// s.tickTag++
// return orvyn.TickCmd(tick, s.tickTag)
// }
// }
func TickCmd(seconds time.Duration, tag uint) tea.Cmd {
return tea.Tick(seconds*time.Second, func(t time.Time) tea.Msg {
return TickMsg{
Time: t,
Tag: tag,
}
})
}
// DialogExitMsg is the message sent when an Orvyn dialog is exited.
type DialogExitMsg struct {
DialogID ScreenID
Param any
}
func dialogExitCmd(id ScreenID, param any) tea.Cmd {
return func() tea.Msg {
return DialogExitMsg{
DialogID: id,
Param: param,
}
}
}