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

Support mapping 24 bit colors to 8 bit approximation #110

Closed
dandavison opened this issue Mar 1, 2020 · 0 comments · Fixed by #111
Closed

Support mapping 24 bit colors to 8 bit approximation #110

dandavison opened this issue Mar 1, 2020 · 0 comments · Fixed by #111

Comments

@dandavison
Copy link
Owner

See initial work by @jscheid in #46. It looks like we should be able to use the ansi_colours crate, as bat does.

cc @jesseduffield ref jesseduffield/lazygit#690, which needs this feature.

@dandavison dandavison changed the title Support mapping 24 bit colors to 256 color approximation Support mapping 24 bit colors to 8 bit approximation Mar 1, 2020
dandavison added a commit that referenced this issue Mar 1, 2020
Fixes #110

With this commit, delta emits 24 bit color codes iff either of the
following are true:

1. The --24-bit-color command line option value is "always"

2. The --24-bit-color command line option value is "auto" and the
   COLORTERM environment variable is set to "truecolor" or "24bit".
   See
   https://gist.github.com/XVilka/8346728#true-color-detection
   https://github.com/sharkdp/bat/blob/7779d9f6221b3e98c43a43ceb5596ba285fdf4f8/src/bin/bat/app.rs#L29-L33
dandavison added a commit that referenced this issue Mar 1, 2020
Fixes #110

With this commit, delta enters "24 bit color mode" iff either of the
following are true:

1. The --24-bit-color command line option value is "always"

2. The --24-bit-color command line option value is "auto" and the
   COLORTERM environment variable is set to "truecolor" or "24bit".
   See
   https://gist.github.com/XVilka/8346728#true-color-detection
   https://github.com/sharkdp/bat/blob/7779d9f6221b3e98c43a43ceb5596ba285fdf4f8/src/bin/bat/app.rs#L29-L33

Otherwise, delta enters "8-bit color mode".

In "24 bit color mode", delta will

1. Emit 24-bit RGB color shell escape sequences that will only be
   displayed correctly by a terminal application that supports 24 bit
   colors.

2. Select default background colors that will only be displayed
   correctly by a terminal application that supports 24 bit colors.

In "8-bit color mode", delta will

1. Emit color shell escape sequences specifying the entry in the ANSI
   256 color palette that is closest (according to the ansi_colours
   library) to the requested color.

2. Select default background colors that will work well in a terminal
   application that suports 8-bit color but not 24-bit color.
dandavison added a commit that referenced this issue Mar 1, 2020
Fixes #110

With this commit, delta enters "24 bit color mode" iff either of the
following are true:

1. The --24-bit-color command line option value is "always"

2. The --24-bit-color command line option value is "auto" and the
   COLORTERM environment variable is set to "truecolor" or "24bit".
   See
   https://gist.github.com/XVilka/8346728#true-color-detection
   https://github.com/sharkdp/bat/blob/7779d9f6221b3e98c43a43ceb5596ba285fdf4f8/src/bin/bat/app.rs#L29-L33

Otherwise, delta enters "8-bit color mode".

In "24 bit color mode", delta will

1. Emit 24-bit RGB color shell escape sequences that will only be
   displayed correctly by a terminal application that supports 24 bit
   colors.

2. Select default background colors that will only be displayed
   correctly by a terminal application that supports 24 bit colors.

In "8-bit color mode", delta will

1. Emit color shell escape sequences specifying the entry in the ANSI
   256 color palette that is closest (according to the ansi_colours
   library) to the requested color.

2. Select default background colors that will work well in a terminal
   application that suports 8-bit color but not 24-bit color.
dandavison added a commit that referenced this issue Mar 1, 2020
Fixes #110

With this commit, delta enters "24 bit color mode" iff either of the
following are true:

1. The --24-bit-color command line option value is "always"

2. The --24-bit-color command line option value is "auto" and the
   COLORTERM environment variable is set to "truecolor" or "24bit".
   See
   https://gist.github.com/XVilka/8346728#true-color-detection
   https://github.com/sharkdp/bat/blob/7779d9f6221b3e98c43a43ceb5596ba285fdf4f8/src/bin/bat/app.rs#L29-L33

Otherwise, delta enters "8-bit color mode".

In "24 bit color mode", delta will

1. Emit 24-bit RGB color shell escape sequences that will only be
   displayed correctly by a terminal application that supports 24 bit
   colors.

2. Select default background colors that will only be displayed
   correctly by a terminal application that supports 24 bit colors.

In "8-bit color mode", delta will

1. Emit color shell escape sequences specifying the entry in the ANSI
   256 color palette that is closest (according to the ansi_colours
   library) to the requested color.

2. Select default background colors that will work well in a terminal
   application that supports 8-bit color but not 24-bit color.
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 a pull request may close this issue.

1 participant