@@ -1,15 +1,11 @@
11package util
22
33import (
4− "log/slog"
5− "time"
6−
74 tea "charm.land/bubbletea/v2"
5+ "github.com/charmbracelet/crush/internal/uiutil"
86)
97
10−type Cursor interface {
11− Cursor() *tea.Cursor
12−}
8+type Cursor = uiutil.Cursor
139
1410type Model interface {
1511 Init() tea.Cmd
@@ -18,48 +14,32 @@ type Model interface {
1814}
1915
2016func CmdHandler(msg tea.Msg) tea.Cmd {
21− return func() tea.Msg {
22− return msg
23− }
17+ return uiutil.CmdHandler(msg)
2418}
2519
2620func ReportError(err error) tea.Cmd {
27− slog.Error("Error reported", "error", err)
28− return CmdHandler(InfoMsg{
29− Type: InfoTypeError,
30− Msg: err.Error(),
31− })
21+ return uiutil.ReportError(err)
3222}
3323
34−type InfoType int
24+type InfoType = uiutil.InfoType
3525
3626const (
37− InfoTypeInfo InfoType = iota
38− InfoTypeSuccess
39− InfoTypeWarn
40− InfoTypeError
41− InfoTypeUpdate
27+ InfoTypeInfo = uiutil.InfoTypeInfo
28+ InfoTypeSuccess = uiutil.InfoTypeSuccess
29+ InfoTypeWarn = uiutil.InfoTypeWarn
30+ InfoTypeError = uiutil.InfoTypeError
31+ InfoTypeUpdate = uiutil.InfoTypeUpdate
4232)
4333
4434func ReportInfo(info string) tea.Cmd {
45− return CmdHandler(InfoMsg{
46− Type: InfoTypeInfo,
47− Msg: info,
48− })
35+ return uiutil.ReportInfo(info)
4936}
5037
5138func ReportWarn(warn string) tea.Cmd {
52− return CmdHandler(InfoMsg{
53− Type: InfoTypeWarn,
54− Msg: warn,
55− })
39+ return uiutil.ReportWarn(warn)
5640}
5741
5842type (
59− InfoMsg struct {
60− Type InfoType
61− Msg string
62− TTL time.Duration
63− }
64− ClearStatusMsg struct{}
43+ InfoMsg = uiutil.InfoMsg
44+ ClearStatusMsg = uiutil.ClearStatusMsg
6545)