From 28e3db326549ae3c3da4e65421e1aaebba8f3d5b Mon Sep 17 00:00:00 2001 From: Louis Dutton <14442084-louisdutton@users.noreply.gitlab.com> Date: Tue, 5 Mar 2024 12:52:45 +0000 Subject: [PATCH] fix: support transparent background on all tui views --- commands/ci/view/view.go | 17 +++++++++++++---- commands/ci/view/view_test.go | 10 +++++++--- commands/issue/board/view/issue_board_view.go | 13 ++++++++++--- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/commands/ci/view/view.go b/commands/ci/view/view.go index 5b901af9..2fab537a 100644 --- a/commands/ci/view/view.go +++ b/commands/ci/view/view.go @@ -186,7 +186,9 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { func drawView(opts ViewOpts) error { root := tview.NewPages() - root.SetBorderPadding(1, 1, 2, 2). + root. + SetBackgroundColor(tcell.ColorDefault). + SetBorderPadding(1, 1, 2, 2). SetBorder(true). SetTitle(fmt.Sprintf(" Pipeline #%d triggered %s by %s ", opts.Commit.LastPipeline.ID, utils.TimeToPrettyTimeAgo(*opts.Commit.LastPipeline.CreatedAt), opts.Commit.AuthorName)) @@ -268,6 +270,7 @@ func inputCapture( if curJob.Kind == Job && (curJob.Status == "pending" || curJob.Status == "running") { modalVisible = true modal := tview.NewModal(). + SetBackgroundColor(tcell.ColorDefault). SetText(fmt.Sprintf("Are you sure you want to Cancel %s", curJob.Name)). AddButtons([]string{"✘ No", "✔ Yes"}). SetDoneFunc(func(buttonIndex int, buttonLabel string) { @@ -300,6 +303,7 @@ func inputCapture( } modalVisible = true modal := tview.NewModal(). + SetBackgroundColor(tcell.ColorDefault). SetText(fmt.Sprintf("Are you sure you want to run %s", curJob.Name)). AddButtons([]string{"✘ No", "✔ Yes"}). SetDoneFunc(func(buttonIndex int, buttonLabel string) { @@ -532,8 +536,11 @@ func jobsView( logsKey := "logs-" + curJob.Name if !root.SwitchToPage(logsKey).HasPage(logsKey) { tv := tview.NewTextView() - tv.SetDynamicColors(true) - tv.SetBorderPadding(0, 0, 1, 1).SetBorder(true) + tv. + SetDynamicColors(true). + SetBackgroundColor(tcell.ColorDefault). + SetBorderPadding(0, 0, 1, 1). + SetBorder(true) go func() { err := ciutils.RunTraceSha( @@ -677,7 +684,9 @@ func box(root *tview.Pages, key string, x, y, w, h int) *tview.TextView { b, ok := boxes[key] if !ok { b = tview.NewTextView() - b.SetBorder(true) + b. + SetBackgroundColor(tcell.ColorDefault). + SetBorder(true) boxes[key] = b } b.SetRect(x, y, w, h) diff --git a/commands/ci/view/view_test.go b/commands/ci/view/view_test.go index a59c3450..b9ebb424 100644 --- a/commands/ci/view/view_test.go +++ b/commands/ci/view/view_test.go @@ -144,8 +144,10 @@ func Test_line(t *testing.T) { func testbox(x, y, w, h int) *tview.TextView { b := tview.NewTextView() - b.SetBorder(true) - b.SetRect(x, y, w, h) + b. + SetBackgroundColor(tcell.ColorDefault). + SetBorder(true). + SetRect(x, y, w, h) return b } @@ -526,7 +528,9 @@ func Test_jobsView(t *testing.T) { jobsCh := make(chan []*ViewJob) inputCh := make(chan struct{}) root := tview.NewPages() - root.SetBorderPadding(1, 1, 2, 2) + root. + SetBackgroundColor(tcell.ColorDefault). + SetBorderPadding(1, 1, 2, 2) screen := tcell.NewSimulationScreen("UTF-8") err := screen.Init() diff --git a/commands/issue/board/view/issue_board_view.go b/commands/issue/board/view/issue_board_view.go index b4ca7f84..72ab5ab1 100644 --- a/commands/issue/board/view/issue_board_view.go +++ b/commands/issue/board/view/issue_board_view.go @@ -108,6 +108,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { } root := tview.NewFlex() + root.SetBackgroundColor(tcell.ColorDefault) for _, l := range boardLists { opts.state = "" var boardIssues, listTitle, listColor string @@ -147,9 +148,15 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { } boardIssues = filterIssues(boardLists, issues, l, opts) - bx := tview.NewTextView().SetDynamicColors(true) - bx.SetText(boardIssues).SetWrap(true) - bx.SetBorder(true).SetTitle(listTitle).SetTitleColor(tcell.GetColor(listColor)) + bx := tview.NewTextView() + bx. + SetDynamicColors(true). + SetText(boardIssues). + SetWrap(true). + SetBackgroundColor(tcell.ColorDefault). + SetBorder(true). + SetTitle(listTitle). + SetTitleColor(tcell.GetColor(listColor)) root.AddItem(bx, 0, 1, false) }