diff --git a/go.mod b/go.mod index 21f2774a..209269b0 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/jahvon/glamour v0.8.1-patch3 github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef - github.com/jahvon/tuikit v0.0.27 + github.com/jahvon/tuikit v0.1.2 github.com/mattn/go-runewidth v0.0.16 github.com/onsi/ginkgo/v2 v2.23.4 github.com/onsi/gomega v1.37.0 @@ -23,7 +23,7 @@ require ( go.etcd.io/bbolt v1.4.0 go.uber.org/mock v0.5.2 golang.org/x/crypto v0.38.0 - golang.org/x/exp v0.0.0-20250215185904-eff6e970281f + golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 golang.org/x/sync v0.14.0 gopkg.in/yaml.v3 v3.0.1 mvdan.cc/sh/v3 v3.11.0 @@ -37,11 +37,11 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/catppuccin/go v0.3.0 // indirect - github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect - github.com/charmbracelet/huh v0.6.0 // indirect - github.com/charmbracelet/log v0.4.0 // indirect + github.com/charmbracelet/colorprofile v0.3.1 // indirect + github.com/charmbracelet/huh v0.7.0 // indirect + github.com/charmbracelet/log v0.4.2 // indirect github.com/charmbracelet/x/ansi v0.8.0 // indirect - github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect + github.com/charmbracelet/x/cellbuf v0.0.14-0.20250501183327-ad3bc78c6a81 // indirect github.com/charmbracelet/x/exp/strings v0.0.0-20250213125511-a0c32e22e4fc // indirect github.com/charmbracelet/x/term v0.2.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect @@ -82,9 +82,9 @@ require ( github.com/yuin/goldmark v1.7.8 // indirect github.com/yuin/goldmark-emoji v1.0.4 // indirect go.uber.org/automaxprocs v1.6.0 // indirect - golang.org/x/net v0.38.0 // indirect + golang.org/x/net v0.40.0 // indirect golang.org/x/sys v0.33.0 // indirect golang.org/x/term v0.32.0 // indirect golang.org/x/text v0.25.0 // indirect - golang.org/x/tools v0.31.0 // indirect + golang.org/x/tools v0.33.0 // indirect ) diff --git a/go.sum b/go.sum index 302e1550..659ac330 100644 --- a/go.sum +++ b/go.sum @@ -28,26 +28,34 @@ github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= github.com/charmbracelet/bubbletea v1.3.5 h1:JAMNLTbqMOhSwoELIr0qyP4VidFq72/6E9j7HHmRKQc= github.com/charmbracelet/bubbletea v1.3.5/go.mod h1:TkCnmH+aBd4LrXhXcqrKiYwRs7qyQx5rBgH5fVY3v54= -github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= -github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= -github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8= -github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU= +github.com/charmbracelet/colorprofile v0.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40= +github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0= +github.com/charmbracelet/huh v0.7.0 h1:W8S1uyGETgj9Tuda3/JdVkc3x7DBLZYPZc4c+/rnRdc= +github.com/charmbracelet/huh v0.7.0/go.mod h1:UGC3DZHlgOKHvHC07a5vHag41zzhpPFj34U92sOmyuk= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= -github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= -github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= +github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= +github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE= github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= -github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= -github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= +github.com/charmbracelet/x/cellbuf v0.0.14-0.20250501183327-ad3bc78c6a81 h1:iGrflaL5jQW6crML+pZx/ulWAVZQR3CQoRGvFsr2Tyg= +github.com/charmbracelet/x/cellbuf v0.0.14-0.20250501183327-ad3bc78c6a81/go.mod h1:poPFOXFTsJsnLbkV3H2KxAAXT7pdjxxLujLocWjkyzM= +github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= +github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ= +github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA= +github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= +github.com/charmbracelet/x/exp/golden v0.0.0-20250207160936-21c02780d27a h1:FsHEJ52OC4VuTzU8t+n5frMjLvpYWEznSr/u8tnkCYw= +github.com/charmbracelet/x/exp/golden v0.0.0-20250207160936-21c02780d27a/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20250213125511-a0c32e22e4fc h1:k2jFXp3mIsJ1lqGzpABadj9sGInRyk7kTxXfM/Lo1d0= github.com/charmbracelet/x/exp/strings v0.0.0-20250213125511-a0c32e22e4fc/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ= -github.com/charmbracelet/x/exp/teatest v0.0.0-20240919170804-a4978c8e603a h1:sS42HbmCab8rCehUwNO/bQEZQoJ6GavhZyO+245mBwA= -github.com/charmbracelet/x/exp/teatest v0.0.0-20240919170804-a4978c8e603a/go.mod h1:NDRRSMP6bZbCs4jyc4i1/4UG4M+0PEiQdpivQgD0Mio= +github.com/charmbracelet/x/exp/teatest v0.0.0-20250623112707-45752038d08d h1:b8GXylLbV6WaBxHjj4fyBqVzWW66vScY5bbJCwoMBOA= +github.com/charmbracelet/x/exp/teatest v0.0.0-20250623112707-45752038d08d/go.mod h1:MhV4atqUTcHvdaA7Qbkgb0Tvvr+BrH6IW7/i2XW39R8= github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= +github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= +github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= +github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI= +github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= @@ -96,8 +104,8 @@ github.com/jahvon/glamour v0.8.1-patch3 h1:LfyMACZavV8yxK4UsPENNQQOqafWuq4ZdLuEA github.com/jahvon/glamour v0.8.1-patch3/go.mod h1:30MVJwG3rcEHrN277NrA4DKzndSL9lBtEmpcfOygwCQ= github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef h1:4PS/MNVT6Rsv15x5Rtwaw971e6kFvNUAf9nvUsZ5hcc= github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef/go.mod h1:dUmuT5CN6osIeLSRtTPJOf0Yz+qAbcyU6omnCzI+ZfQ= -github.com/jahvon/tuikit v0.0.27 h1:NV+Zzput4twGch+KTwpAOFlR+R/MKtS9DYs3p1sONwg= -github.com/jahvon/tuikit v0.0.27/go.mod h1:zUysbTPUE0tAEB5DfdWvL6AT3g8AZQ+fcwrfUhVXuwA= +github.com/jahvon/tuikit v0.1.2 h1:BGN942W8S89d+hkKxMsUUB50+63T1VgkBamsKwzXpLc= +github.com/jahvon/tuikit v0.1.2/go.mod h1:Bi6zph90IAONRweA/9eUKjVNaxCstxhwubnhFOthEFs= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -182,10 +190,10 @@ go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= -golang.org/x/exp v0.0.0-20250215185904-eff6e970281f h1:oFMYAjX0867ZD2jcNiLBrI9BdpmEkvPyi5YrBGXbamg= -golang.org/x/exp v0.0.0-20250215185904-eff6e970281f/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -196,8 +204,8 @@ golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= -golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= -golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/context/context.go b/internal/context/context.go index b1416023..c303d709 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -8,10 +8,9 @@ import ( "runtime" "strings" - "github.com/charmbracelet/lipgloss" "github.com/jahvon/tuikit" "github.com/jahvon/tuikit/io" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/pkg/errors" "github.com/jahvon/flow/internal/cache" @@ -81,9 +80,14 @@ func NewContext(ctx context.Context, stdIn, stdOut *os.File) *Context { CurrentWorkspace: wsConfig, WorkspacesCache: workspaceCache, ExecutableCache: executableCache, - Logger: io.NewLogger(stdOut, flowIO.Theme(cfg.Theme.String()), logMode, filesystem.LogsDir()), - stdOut: stdOut, - stdIn: stdIn, + Logger: io.NewLogger( + io.WithOutput(stdOut), + io.WithTheme(flowIO.Theme(cfg.Theme.String())), + io.WithMode(logMode), + io.WithArchiveDirectory(filesystem.LogsDir()), + ), + stdOut: stdOut, + stdIn: stdIn, } app := tuikit.NewApplication( @@ -225,48 +229,48 @@ func currentWorkspace(cfg *config.Config) (*workspace.Workspace, error) { return filesystem.LoadWorkspaceConfig(ws, wsPath) } -func overrideThemeColor(theme styles.Theme, palette *config.ColorPalette) styles.Theme { +func overrideThemeColor(theme themes.Theme, palette *config.ColorPalette) themes.Theme { if palette == nil { return theme } if palette.Primary != nil { - theme.PrimaryColor = lipgloss.Color(*palette.Primary) + theme.ColorPalette().Primary = *palette.Primary } if palette.Secondary != nil { - theme.SecondaryColor = lipgloss.Color(*palette.Secondary) + theme.ColorPalette().Secondary = *palette.Secondary } if palette.Tertiary != nil { - theme.TertiaryColor = lipgloss.Color(*palette.Tertiary) + theme.ColorPalette().Tertiary = *palette.Tertiary } if palette.Success != nil { - theme.SuccessColor = lipgloss.Color(*palette.Success) + theme.ColorPalette().Success = *palette.Success } if palette.Warning != nil { - theme.WarningColor = lipgloss.Color(*palette.Warning) + theme.ColorPalette().Warning = *palette.Warning } if palette.Error != nil { - theme.ErrorColor = lipgloss.Color(*palette.Error) + theme.ColorPalette().Error = *palette.Error } if palette.Info != nil { - theme.InfoColor = lipgloss.Color(*palette.Info) + theme.ColorPalette().Info = *palette.Info } if palette.Body != nil { - theme.BodyColor = lipgloss.Color(*palette.Body) + theme.ColorPalette().Body = *palette.Body } if palette.Emphasis != nil { - theme.EmphasisColor = lipgloss.Color(*palette.Emphasis) + theme.ColorPalette().Emphasis = *palette.Emphasis } if palette.White != nil { - theme.White = lipgloss.Color(*palette.White) + theme.ColorPalette().White = *palette.White } if palette.Black != nil { - theme.Black = lipgloss.Color(*palette.Black) + theme.ColorPalette().Black = *palette.Black } if palette.Gray != nil { - theme.Gray = lipgloss.Color(*palette.Gray) + theme.ColorPalette().Gray = *palette.Gray } if palette.CodeStyle != nil { - theme.ChromaCodeStyle = *palette.CodeStyle + theme.ColorPalette().ChromaCodeStyle = *palette.CodeStyle } return theme } diff --git a/internal/context/context_test.go b/internal/context/context_test.go index 2a5d7e01..1043d561 100644 --- a/internal/context/context_test.go +++ b/internal/context/context_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/charmbracelet/lipgloss" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -69,14 +69,14 @@ var _ = ginkgo.Describe("Context", func() { }) ginkgo.Describe("overrideThemeColor", func() { - var theme styles.Theme + var theme themes.Theme var palette *config.ColorPalette ginkgo.BeforeEach(func() { - theme = styles.Theme{ - PrimaryColor: "#000000", - SecondaryColor: "#FFFFFF", - } + theme = themes.NewTheme("theme", themes.ColorPalette{ + Primary: "#000000", + Secondary: "#FFFFFF", + }) palette = &config.ColorPalette{ Primary: strPtr("#FF0000"), Secondary: strPtr("#00FF00"), @@ -85,8 +85,8 @@ var _ = ginkgo.Describe("Context", func() { ginkgo.It("should override the theme colors with the palette colors", func() { newTheme := overrideThemeColor(theme, palette) - Expect(newTheme.PrimaryColor).To(Equal(lipgloss.Color("#FF0000"))) - Expect(newTheme.SecondaryColor).To(Equal(lipgloss.Color("#00FF00"))) + Expect(newTheme.ColorPalette().PrimaryColor()).To(Equal(lipgloss.Color("#FF0000"))) + Expect(newTheme.ColorPalette().SecondaryColor()).To(Equal(lipgloss.Color("#00FF00"))) }) ginkgo.It("should not change the theme if the palette is nil", func() { diff --git a/internal/io/executable/views.go b/internal/io/executable/views.go index 85578710..f2e13069 100644 --- a/internal/io/executable/views.go +++ b/internal/io/executable/views.go @@ -6,7 +6,7 @@ import ( "github.com/atotto/clipboard" "github.com/jahvon/tuikit" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/jahvon/tuikit/types" "github.com/jahvon/tuikit/views" @@ -40,7 +40,7 @@ func NewExecutableView( if err := clipboard.WriteAll(exec.Ref().String()); err != nil { container.HandleError(fmt.Errorf("unable to copy reference to clipboard: %w", err)) } else { - container.SetNotice("copied reference to clipboard", styles.OutputLevelInfo) + container.SetNotice("copied reference to clipboard", themes.OutputLevelInfo) } return nil }, @@ -109,7 +109,7 @@ func NewTemplateView( if err := clipboard.WriteAll(template.Location()); err != nil { container.HandleError(fmt.Errorf("unable to copy location to clipboard: %w", err)) } else { - container.SetNotice("copied location to clipboard", styles.OutputLevelInfo) + container.SetNotice("copied location to clipboard", themes.OutputLevelInfo) } return nil }, diff --git a/internal/io/library/library.go b/internal/io/library/library.go index 02ae3945..21985512 100644 --- a/internal/io/library/library.go +++ b/internal/io/library/library.go @@ -5,7 +5,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" "github.com/jahvon/tuikit" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/jahvon/tuikit/views" "github.com/jahvon/flow/internal/context" @@ -30,7 +30,7 @@ type Library struct { allWorkspaces workspace.WorkspaceList allExecutables executable.ExecutableList filter Filter - theme styles.Theme + theme themes.Theme currentPane, currentWorkspace, currentNamespace, currentExecutable uint currentFormat, currentHelpPage uint @@ -51,7 +51,7 @@ func NewLibrary( workspaces workspace.WorkspaceList, execs executable.ExecutableList, filter Filter, - theme styles.Theme, + theme themes.Theme, runFunc func(string) error, ) *Library { p1 := viewport.New(0, 0) @@ -78,7 +78,7 @@ func NewLibraryView( workspaces workspace.WorkspaceList, execs executable.ExecutableList, filter Filter, - theme styles.Theme, + theme themes.Theme, runFunc func(string) error, ) tuikit.View { l := NewLibrary(ctx, workspaces, execs, filter, theme, runFunc) diff --git a/internal/io/library/styles.go b/internal/io/library/styles.go index 084e8575..0a1f91ff 100644 --- a/internal/io/library/styles.go +++ b/internal/io/library/styles.go @@ -6,51 +6,51 @@ import ( "strings" "github.com/charmbracelet/lipgloss" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/mattn/go-runewidth" "github.com/jahvon/flow/types/executable" ) -func renderSelection(s string, theme styles.Theme) string { - style := lipgloss.NewStyle().Foreground(theme.PrimaryColor) +func renderSelection(s string, theme themes.Theme) string { + style := lipgloss.NewStyle().Foreground(theme.ColorPalette().PrimaryColor()) return style.Render(s) } -func renderSecondarySelection(s string, theme styles.Theme) string { - style := lipgloss.NewStyle().Foreground(theme.TertiaryColor) +func renderSecondarySelection(s string, theme themes.Theme) string { + style := lipgloss.NewStyle().Foreground(theme.ColorPalette().SecondaryColor()) return style.Render(s) } -func renderInactive(s string, theme styles.Theme) string { - style := lipgloss.NewStyle().Foreground(theme.Gray) +func renderInactive(s string, theme themes.Theme) string { + style := lipgloss.NewStyle().Foreground(theme.ColorPalette().GrayColor()) return style.Render(s) } -func renderDescription(s string, theme styles.Theme) string { - style := lipgloss.NewStyle().Foreground(theme.BodyColor) +func renderDescription(s string, theme themes.Theme) string { + style := lipgloss.NewStyle().Foreground(theme.ColorPalette().BodyColor()) return style.Render(s) } -func renderPaneTitle(s string, count int, active bool, theme styles.Theme) string { +func renderPaneTitle(s string, count int, active bool, theme themes.Theme) string { var title string if count == 0 { title = s } else { title = fmt.Sprintf("%s (%d)", s, count) } - style := lipgloss.NewStyle().Foreground(theme.SecondaryColor).Padding(0, 1).Bold(true) + style := lipgloss.NewStyle().Foreground(theme.ColorPalette().SecondaryColor()).Padding(0, 1).Bold(true) if active { style = style.Underline(true) } return style.Render(title) + "\n\n" } -func paneStyle(pos int, theme styles.Theme, splitView bool) lipgloss.Style { +func paneStyle(pos int, theme themes.Theme, splitView bool) lipgloss.Style { style := lipgloss.NewStyle().Padding(0, 1) if pos == 2 && splitView { style = style.BorderStyle(lipgloss.OuterHalfBlockBorder()). - BorderForeground(theme.BorderColor).BorderLeft(true) + BorderForeground(theme.ColorPalette().BorderColor()).BorderLeft(true) } return style diff --git a/internal/io/library/update.go b/internal/io/library/update.go index da9c3637..d3b9bb71 100644 --- a/internal/io/library/update.go +++ b/internal/io/library/update.go @@ -8,7 +8,7 @@ import ( "github.com/atotto/clipboard" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/jahvon/flow/internal/filesystem" "github.com/jahvon/flow/internal/io/common" @@ -119,17 +119,17 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) { } case "o": if curWsCfg == nil { - l.SetNotice("no workspace selected", styles.OutputLevelError) + l.SetNotice("no workspace selected", themes.OutputLevelError) break } if err := open.Open(curWsCfg.Location(), false); err != nil { l.ctx.Logger.Error(err, "unable to open workspace") - l.SetNotice("unable to open workspace", styles.OutputLevelError) + l.SetNotice("unable to open workspace", themes.OutputLevelError) } case "e": if curWsCfg == nil { - l.SetNotice("no workspace selected", styles.OutputLevelError) + l.SetNotice("no workspace selected", themes.OutputLevelError) break } @@ -138,18 +138,18 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) { l.ctx.StdIn(), l.ctx.StdOut(), ); err != nil { l.ctx.Logger.Error(err, "unable to open workspace in editor") - l.SetNotice("unable to open workspace in editor", styles.OutputLevelError) + l.SetNotice("unable to open workspace in editor", themes.OutputLevelError) } case "s": if curWsCfg == nil { - l.SetNotice("no workspace selected", styles.OutputLevelError) + l.SetNotice("no workspace selected", themes.OutputLevelError) break } curCfg, err := filesystem.LoadConfig() if err != nil { l.ctx.Logger.Error(err, "unable to load user config") - l.SetNotice("unable to load user config", styles.OutputLevelError) + l.SetNotice("unable to load user config", themes.OutputLevelError) break } @@ -157,14 +157,14 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) { case l.showNamespaces && curNs == withoutNamespaceLabel: curCfg.CurrentNamespace = "" case l.showNamespaces && curNs == allNamespacesLabel: - l.SetNotice("no namespace selected", styles.OutputLevelError) + l.SetNotice("no namespace selected", themes.OutputLevelError) case l.showNamespaces && curNs != "": curCfg.CurrentNamespace = curNs case !l.showNamespaces && curWs == allWorkspacesLabel: - l.SetNotice("no workspace selected", styles.OutputLevelError) + l.SetNotice("no workspace selected", themes.OutputLevelError) case !l.showNamespaces && curWs != "": if curWs != curWsCfg.AssignedName() { - l.SetNotice("current workspace out of sync", styles.OutputLevelError) + l.SetNotice("current workspace out of sync", themes.OutputLevelError) break } curCfg.CurrentWorkspace = curWsCfg.AssignedName() @@ -172,13 +172,13 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) { if err := filesystem.WriteConfig(curCfg); err != nil { l.ctx.Logger.Error(err, "unable to write user config") - l.SetNotice("unable to write user config", styles.OutputLevelError) + l.SetNotice("unable to write user config", themes.OutputLevelError) break } l.ctx.Config.CurrentWorkspace = curCfg.CurrentWorkspace l.ctx.Config.CurrentNamespace = curCfg.CurrentNamespace - l.SetNotice("context updated", styles.OutputLevelInfo) + l.SetNotice("context updated", themes.OutputLevelInfo) } } @@ -222,29 +222,29 @@ func (l *Library) updateExecPanes(msg tea.Msg) (viewport.Model, tea.Cmd) { } case "e": if curExec == nil { - l.SetNotice("no executable selected", styles.OutputLevelError) + l.SetNotice("no executable selected", themes.OutputLevelError) break } if err := common.OpenInEditor(curExec.FlowFilePath(), l.ctx.StdIn(), l.ctx.StdOut()); err != nil { l.ctx.Logger.Error(err, "unable to open executable in editor") - l.SetNotice("unable to open executable in editor", styles.OutputLevelError) + l.SetNotice("unable to open executable in editor", themes.OutputLevelError) } case "c": if curExec == nil { - l.SetNotice("no executable selected", styles.OutputLevelError) + l.SetNotice("no executable selected", themes.OutputLevelError) break } if err := clipboard.WriteAll(curExec.Ref().String()); err != nil { l.ctx.Logger.Error(err, "unable to copy reference to clipboard") - l.SetNotice("unable to copy reference to clipboard", styles.OutputLevelError) + l.SetNotice("unable to copy reference to clipboard", themes.OutputLevelError) } else { - l.SetNotice("copied reference to clipboard", styles.OutputLevelInfo) + l.SetNotice("copied reference to clipboard", themes.OutputLevelInfo) } case "r": if curExec == nil { - l.SetNotice("no executable selected", styles.OutputLevelError) + l.SetNotice("no executable selected", themes.OutputLevelError) break } diff --git a/internal/io/library/view.go b/internal/io/library/view.go index 2ec88864..e1448288 100644 --- a/internal/io/library/view.go +++ b/internal/io/library/view.go @@ -10,7 +10,7 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/jahvon/glamour" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/jahvon/flow/types/common" "github.com/jahvon/flow/types/workspace" @@ -35,7 +35,7 @@ const ( var ( // heightPadding is used when determining the height of the panes. // It is used to account for the header and footer - heightPadding = styles.HeaderHeight + styles.FooterHeight + heightPadding = themes.HeaderHeight + themes.FooterHeight ) func (l *Library) View() string { @@ -76,9 +76,9 @@ func (l *Library) View() string { return lipgloss.JoinVertical(lipgloss.Top, header, panes, footer) } -func (l *Library) SetNotice(notice string, level styles.OutputLevel) { +func (l *Library) SetNotice(notice string, level themes.OutputLevel) { if level == "" { - level = styles.OutputLevelInfo + level = themes.OutputLevelInfo } l.noticeText = l.theme.RenderLevel(notice, level) } @@ -190,7 +190,7 @@ func (l *Library) paneTwoContent() string { _, _, maxWidth := calculateViewportWidths(l.termWidth, l.splitView) paneTwoMaxWidth := math.Floor(float64(maxWidth) * 0.95) - mdStyles, err := l.theme.MarkdownStyleJSON() + mdStyles, err := l.theme.GlamourMarkdownStyleJSON() if err != nil { return l.theme.RenderError(fmt.Sprintf("unable to render markdown: %s", err.Error())) } diff --git a/internal/io/secret/views.go b/internal/io/secret/views.go index 6d167e67..a37b7f58 100644 --- a/internal/io/secret/views.go +++ b/internal/io/secret/views.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/jahvon/tuikit" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/jahvon/tuikit/types" "github.com/jahvon/tuikit/views" @@ -44,7 +44,7 @@ func NewSecretView( return nil } LoadSecretListView(ctx, asPlainText) - container.SetNotice("secret renamed", styles.OutputLevelInfo) + container.SetNotice("secret renamed", themes.OutputLevelInfo) return nil }, }, @@ -73,7 +73,7 @@ func NewSecretView( return nil } LoadSecretListView(ctx, asPlainText) - container.SetNotice("secret value updated", styles.OutputLevelInfo) + container.SetNotice("secret value updated", themes.OutputLevelInfo) return nil }, }, @@ -85,7 +85,7 @@ func NewSecretView( return nil } LoadSecretListView(ctx, asPlainText) - container.SetNotice("secret deleted", styles.OutputLevelInfo) + container.SetNotice("secret deleted", themes.OutputLevelInfo) return nil }, }, diff --git a/internal/io/styles.go b/internal/io/styles.go index 0f653c30..4ded95f8 100644 --- a/internal/io/styles.go +++ b/internal/io/styles.go @@ -1,10 +1,10 @@ package io -import "github.com/jahvon/tuikit/styles" +import "github.com/jahvon/tuikit/themes" -func Theme(name string) styles.Theme { - theme := styles.EverforestTheme() - themeFunc, ok := styles.AllThemes()[name] +func Theme(name string) themes.Theme { + theme := themes.EverforestTheme() + themeFunc, ok := themes.AllThemes()[name] if ok { theme = themeFunc() } diff --git a/internal/io/workspace/views.go b/internal/io/workspace/views.go index 1035ac6d..621ecc45 100644 --- a/internal/io/workspace/views.go +++ b/internal/io/workspace/views.go @@ -5,7 +5,7 @@ import ( "path/filepath" "github.com/jahvon/tuikit" - "github.com/jahvon/tuikit/styles" + "github.com/jahvon/tuikit/themes" "github.com/jahvon/tuikit/types" "github.com/jahvon/tuikit/views" @@ -54,7 +54,7 @@ func NewWorkspaceView( container.HandleError(err) } container.SetState(common.HeaderContextKey, fmt.Sprintf("%s/*", ws.AssignedName())) - container.SetNotice("workspace updated", styles.OutputLevelInfo) + container.SetNotice("workspace updated", themes.OutputLevelInfo) return nil }, }, diff --git a/tests/utils/context.go b/tests/utils/context.go index 388e5b20..39d2c9fa 100644 --- a/tests/utils/context.go +++ b/tests/utils/context.go @@ -37,7 +37,14 @@ const ( // Test environment variables are set the config and cache directories override paths. func NewContext(ctx stdCtx.Context, t ginkgo.FullGinkgoTInterface) *context.Context { stdOut, stdIn := createTempIOFiles(t) - logger := tuikitIO.NewLogger(stdOut, io.Theme(""), tuikitIO.Text, "") + logger := tuikitIO.NewLogger( + tuikitIO.WithOutput(stdOut), + tuikitIO.WithTheme(io.Theme("")), + tuikitIO.WithMode(tuikitIO.Text), + tuikitIO.WithExitFunc(func() { + t.Fatalf("logger exit called") + }), + ) ctxx := newTestContext(ctx, t, logger, stdIn, stdOut) return ctxx } @@ -94,7 +101,14 @@ func ResetTestContext(ctx *context.Context, t ginkgo.FullGinkgoTInterface) { ctx.Ctx = stdCtx.Background() stdIn, stdOut := createTempIOFiles(t) ctx.SetIO(stdIn, stdOut) - logger := tuikitIO.NewLogger(stdOut, io.Theme(""), tuikitIO.Text, "") + logger := tuikitIO.NewLogger( + tuikitIO.WithOutput(stdOut), + tuikitIO.WithTheme(io.Theme("")), + tuikitIO.WithMode(tuikitIO.Text), + tuikitIO.WithExitFunc(func() { + t.Fatalf("unexpected logger exit called") + }), + ) ctx.Logger = logger }