From 999e61224c1efe49496d6d84ba255544e74c524a Mon Sep 17 00:00:00 2001 From: Zdenek Crha Date: Mon, 21 Sep 2020 12:11:39 +0200 Subject: [PATCH] Fix 'no description' readability in terminal with bright background The rendering of color for 'No description provided' text is broken on bright terminals - it sets black background which together with default black forground color renders opaque rectangle. The GreyBold color alias is broken too - name suggests bold gray forground color, but actually sets bold default fg color with black bacground. First make color alias consistent. Rename it to BlackBold and have it set bold black fg color (same as similar *Bold aliases). Second, update all places which use it to render text to also use white background to prevent it from disappering in terminals with black background color. --- commands/show.go | 2 +- termui/show_bug.go | 2 +- util/colors/colors.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/show.go b/commands/show.go index 77f315cc4a691cce1740c16a46fa122cb50ec066..9ebd1926df5f4d51c664d472189b4e90b262589a 100644 --- a/commands/show.go +++ b/commands/show.go @@ -166,7 +166,7 @@ func showDefaultFormatter(env *Env, snapshot *bug.Snapshot) error { ) if comment.Message == "" { - message = colors.GreyBold("No description provided.") + message = colors.BlackBold(colors.WhiteBg("No description provided.")) } else { message = comment.Message } diff --git a/termui/show_bug.go b/termui/show_bug.go index 6296c445c41931dcea11e9ec94ef4c1630bdab1b..0710fa34b38e70fbb75c9cfe06b88418bd835532 100644 --- a/termui/show_bug.go +++ b/termui/show_bug.go @@ -378,7 +378,7 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error { // emptyMessagePlaceholder return a formatted placeholder for an empty message func emptyMessagePlaceholder() string { - return colors.GreyBold("No description provided.") + return colors.BlackBold(colors.WhiteBg("No description provided.")) } func (sb *showBug) createOpView(g *gocui.Gui, name string, x0 int, y0 int, maxX int, height int, selectable bool) (*gocui.View, error) { diff --git a/util/colors/colors.go b/util/colors/colors.go index f8c6d188edd59230ef945e8f98ed883092c9e02f..6d2ad35a536792f08535d55a4f57d0710bbe15fc 100644 --- a/util/colors/colors.go +++ b/util/colors/colors.go @@ -5,15 +5,16 @@ import "github.com/fatih/color" var ( Bold = color.New(color.Bold).SprintFunc() Black = color.New(color.FgBlack).SprintFunc() + BlackBold = color.New(color.FgBlack, color.Bold).SprintfFunc() BlackBg = color.New(color.BgBlack, color.FgWhite).SprintFunc() White = color.New(color.FgWhite).SprintFunc() WhiteBold = color.New(color.FgWhite, color.Bold).SprintFunc() + WhiteBg = color.New(color.BgWhite).SprintFunc() Yellow = color.New(color.FgYellow).SprintFunc() YellowBold = color.New(color.FgYellow, color.Bold).SprintFunc() YellowBg = color.New(color.BgYellow, color.FgBlack).SprintFunc() Green = color.New(color.FgGreen).SprintFunc() GreenBg = color.New(color.BgGreen, color.FgBlack).SprintFunc() - GreyBold = color.New(color.BgBlack, color.Bold).SprintfFunc() Red = color.New(color.FgRed).SprintFunc() Cyan = color.New(color.FgCyan).SprintFunc() CyanBg = color.New(color.BgCyan, color.FgBlack).SprintFunc()