Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

less colors and more contrast in terminal #6525

Merged
merged 10 commits into from
Feb 20, 2024
Merged

less colors and more contrast in terminal #6525

merged 10 commits into from
Feb 20, 2024

Conversation

Anton-4
Copy link
Collaborator

@Anton-4 Anton-4 commented Feb 14, 2024

I checked how our terminal colors looked on macos. ubuntu, nixOS and raspberryOS. The colors we internally call blue and magenta regularly did not meet the AA wcag standard so I removed them and used other colors instead. I also changed the colors we still use to their "improved visibility variants". Other popular languages and command line tools often use these variants as well.

after (left) and before (right) on raspberryOS:

pi_repl_screenshot

Closes #6512

Comment on lines +261 to +264
red: "\u{001b}[1;31m",
green: "\u{001b}[1;32m",
yellow: "\u{001b}[1;33m",
cyan: "\u{001b}[1;36m",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1; to use the increased visibility variants.

@Anton-4 Anton-4 mentioned this pull request Feb 14, 2024
Comment on lines -544 to +545
let (failed, passed) = roc_repl_expect::run::run_toplevel_expects(
let (failed_count, passed_count) = roc_repl_expect::run::run_toplevel_expects(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More self-evident names

println!(
"\x1B[{}m{}\x1B[39m {} and \x1B[{}m{}\x1B[39m {} found in {} ms.",
if problems.errors == 0 {
32 // green
} else {
33 // yellow
},
problems.errors,
if problems.errors == 1 {
"error"
} else {
"errors"
},
if problems.warnings == 0 {
32 // green
} else {
33 // yellow
},
problems.warnings,
if problems.warnings == 1 {
"warning"
} else {
"warnings"
},
total_time.as_millis(),
);

problems.print_to_stdout(total_time);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was duplicated in print_to_stdout.

Comment on lines -101 to -116
pub fn strip_colors(str: &str) -> String {
use roc_reporting::report::ANSI_STYLE_CODES;

str.replace(ANSI_STYLE_CODES.red, "")
.replace(ANSI_STYLE_CODES.green, "")
.replace(ANSI_STYLE_CODES.yellow, "")
.replace(ANSI_STYLE_CODES.blue, "")
.replace(ANSI_STYLE_CODES.magenta, "")
.replace(ANSI_STYLE_CODES.cyan, "")
.replace(ANSI_STYLE_CODES.white, "")
.replace(ANSI_STYLE_CODES.bold, "")
.replace(ANSI_STYLE_CODES.underline, "")
.replace(ANSI_STYLE_CODES.reset, "")
.replace(ANSI_STYLE_CODES.color_reset, "")
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved.

@rtfeldman
Copy link
Contributor

Very cool! Two thoughts:

  1. Let's just make the underline below The rockin' roc repl be the same color as the words roc repl, because the two colors there don't necessarily seem to go together well depending on the terminal.
  2. Does this still work on Windows? We've seen problems in the past where Windows terminal is missing features that other terminals have, which has been a problem sometimes.

@lukewilliamboswell
Copy link
Collaborator

  1. Does this still work on Windows? We've seen problems in the past where Windows terminal is missing features that other terminals have, which has been a problem sometimes.

This is what is looks like on Windows. Looks good to me. ❤️

image

p.s. I'm not sure what is going on with that debug statement in rustyline...

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Feb 19, 2024

Thanks for checking that @lukewilliamboswell :)

@rtfeldman I've changed the color of the underline to match roc repl.

@Anton-4 Anton-4 merged commit b5f68bc into main Feb 20, 2024
17 checks passed
@Anton-4 Anton-4 deleted the fix_text_contrast branch February 20, 2024 14:46
@rtfeldman
Copy link
Contributor

Great stuff, thanks for improving this @Anton-4! 😍

Anton-4 added a commit that referenced this pull request Feb 21, 2024
Anton-4 added a commit that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve repl contrast on (very) dark terminal background
3 participants