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

Using style "bold" does not use the bold ansi escape sequence in the output #293

Closed
ilohmar opened this issue Dec 26, 2016 · 4 comments
Closed
Labels
bug A bug.

Comments

@ilohmar
Copy link

ilohmar commented Dec 26, 2016

As @BurntSushi described in #51, color customization with the style "bold" is interpreted as "use a high-intensity color", therefore (when using a terminal) the actual ANSI escape sequence for bold text never appears in the output.

It would be great if this were an optional translation, such that "bold" really meant "output bold ANSI sequence" by default.

This is especially important when the output is parsed by a 3rd party that expects the color customization to work this way (as it does, e.g., for git grep or GNU grep).

@BurntSushi
Copy link
Owner

BurntSushi commented Dec 26, 2016

Hmm, yes, I think this might be related to #266 (possibly even a dupe).

This is especially important when the output is parsed by a 3rd party that expects the color customization to work this way

This sounds like a really bad idea. It would be better to not rely on colors to parse the output. My guess is that the right fix for that is #244, but I don't know for sure because I don't know what problem you're trying to solve.

@BurntSushi BurntSushi added the bug A bug. label Dec 26, 2016
@ilohmar
Copy link
Author

ilohmar commented Dec 26, 2016

This sounds like a really bad idea. It would be better to not rely on colors to parse the output.

I agree, but it might be a 31-year-old code base. ;-) And the design will probably not change because it's targeting GNU grep (which does not offer another output format to my knowledge).

I see these issues discussed in #244 as well. I will also look into the other issues discussing editor integration. Thanks.

@BurntSushi
Copy link
Owner

@ilohmar Unfortunately, it can't be a goal of ripgrep to be completely interface compatible with GNU grep (or any other grep) since it takes a fundamentally different view on how searching works by default. So you already need to be able to tweak the CLI invocation itself, and at that point, it seems like it's not unreasonable to expect to parse the output specially too. With that said, I can understand how using the color codes as a common interface would be tempting. I expect that in practice, once we nail out these last color issues, that stuff won't change going forward.

BurntSushi added a commit that referenced this issue Jan 7, 2017
Previously, ripgrep would only emit the 'bold' ANSI escape sequence if
no foreground or background color was set. Instead, it would convert colors
to their "intense" versions if bold was set. The intent was to do the same
thing on Windows and Unix. However, this had a few negative side effects:

  1. Omitting the 'bold' ANSI escape when 'bold' was set is surprising.
  2. Intense colors can look quite bad and be hard to read.

To fix this, we introduce a new setting called 'intense' in the --colors
flag, and thread that down through to the public API of the `termcolor`
crate. The 'intense' setting has environment specific behavior:

  1. In ANSI mode, it will convert the selected color to its "intense"
     variant.
  2. In the Windows console, it will make the text "intense."

There is no longer any "smart" handling of the 'bold' style. The 'bold'
ANSI escape is always emitted when it is selected. In the Windows
console, the 'bold' setting now has no effect. Note that this is a
breaking change.

Fixes #266, #293
@BurntSushi
Copy link
Owner

Fixed in b187c1a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug.
Projects
None yet
Development

No branches or pull requests

2 participants