pingcap / diag

A tool to collect diagnostic data from TiDB Clusters
https://docs.pingcap.com/tidb/stable/clinic-introduction
Apache License 2.0
24 stars 9 forks source link

Hard to read default color scheme #275

Open dveeden opened 2 years ago

dveeden commented 2 years ago

Bug Report

On CentOS 7 with the default terminal configuration the light-yellow on white as seen here is hard to read:

image

What version of Diag are you using (tiup diag --version)?

$ tiup diag --version
Starting component `diag`: /home/dvaneeden/.tiup/components/diag/v0.5.1/diag --version
tiup diag v0.5.1 @master (53c4a871483dd8ff144b8fd18f812fe1cbbc86fe)
AstroProfundis commented 2 years ago

The UI was not adjusted for light color consoles, how would you think if we add a dark background for those light colored chars?

dveeden commented 2 years ago
package main

import (
    "bufio"
    "fmt"
    "os"

    "golang.org/x/crypto/ssh/terminal"
)

func main() {
    reader := bufio.NewReader(os.Stdin)
    s, _ := terminal.MakeRaw(int(os.Stdin.Fd()))
    fmt.Printf("\x1b]11;?\a")
    c := make([]byte, 23)
    reader.Read(c)
    terminal.Restore(int(os.Stdin.Fd()), s)
    fmt.Printf("Terminal Color: %s\n", c[5:])
}

This results in:

Black background:

$ ./bgcolor 
Terminal Color: rgb:0000/0000/0000

White background:

$ ./bgcolor 
Terminal Color: rgb:ffff/ffff/ffff

Yellow background:

$ ./bgcolor 
Terminal Color: rgb:ffff/ffff/dddd

We can use this to either select more appropriate colors or to set color.NoColor = true.

dveeden commented 2 years ago

The UI was not adjusted for light color consoles, how would you think if we add a dark background for those light colored chars?

That might move the problem as dark colors on a dark background might not be very readable as well. I think we should choose the right colors depending on the background color.

However a slightly darker color might work well enough on both white and black backgrounds.