- Notifications
You must be signed in to change notification settings - Fork1.1k
fix: use ANSI colors codes instead of RGB#14665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
5e308df86175bf098d35d3d130605b8fa3b4ce84a4a75dbb2390a7ca7e6db79ce913a522a2d0b5e4211840eb24eccf174a1fbef1d44c3726d16f6251babe96ff3c3926d93c56506aa28997dc4324a838dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -37,17 +37,21 @@ var ( | ||
| ) | ||
| var ( | ||
| // ANSI color codes | ||
| red = Color("1") | ||
| green = Color("2") | ||
| yellow = Color("3") | ||
| magenta = Color("5") | ||
| white = Color("7") | ||
| brightBlue = Color("12") | ||
| brightMagenta = Color("13") | ||
Comment on lines +41 to +47 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. nit: indicate these are ANSI color codes | ||
| ) | ||
| // Color returns a color for the given string. | ||
| func Color(s string) termenv.Color { | ||
| colorOnce.Do(func() { | ||
| color = termenv.NewOutput(os.Stdout).EnvColorProfile() | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Good solution for disabling colors 👍🏻 | ||
| if flag.Lookup("test.v") != nil { | ||
| // Use a consistent colorless profile in tests so that results | ||
| // are deterministic. | ||
| @@ -123,42 +127,45 @@ func init() { | ||
| DefaultStyles = Styles{ | ||
| Code: pretty.Style{ | ||
| ifTerm(pretty.XPad(1, 1)), | ||
| pretty.FgColor(Color("#ED567A")), | ||
| pretty.BgColor(Color("#2C2C2C")), | ||
| }, | ||
| DateTimeStamp: pretty.Style{ | ||
| pretty.FgColor(brightBlue), | ||
| }, | ||
| Error: pretty.Style{ | ||
| pretty.FgColor(red), | ||
| }, | ||
| Field: pretty.Style{ | ||
| pretty.XPad(1, 1), | ||
| pretty.FgColor(Color("#FFFFFF")), | ||
| pretty.BgColor(Color("#2B2A2A")), | ||
| }, | ||
| Fuchsia: pretty.Style{ | ||
| pretty.FgColor(brightMagenta), | ||
| }, | ||
| FocusedPrompt: pretty.Style{ | ||
| pretty.FgColor(white), | ||
| pretty.Wrap("> ", ""), | ||
| pretty.FgColor(brightBlue), | ||
| }, | ||
| Keyword: pretty.Style{ | ||
| pretty.FgColor(green), | ||
| }, | ||
| Placeholder: pretty.Style{ | ||
| pretty.FgColor(magenta), | ||
| }, | ||
| Prompt: pretty.Style{ | ||
| pretty.FgColor(white), | ||
| pretty.Wrap(" ", ""), | ||
| }, | ||
| Warn: pretty.Style{ | ||
| pretty.FgColor(yellow), | ||
| }, | ||
| Wrap: pretty.Style{ | ||
| pretty.LineWrap(80), | ||
| }, | ||
| } | ||
| } | ||
| // ValidateNotEmpty is a helper function to disallow empty inputs! | ||