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

Add new theme: base16-256 #1111

Merged
merged 3 commits into from
Aug 3, 2020
Merged

Add new theme: base16-256 #1111

merged 3 commits into from
Aug 3, 2020

Conversation

mk12
Copy link
Contributor

@mk12 mk12 commented Jul 19, 2020

See #1033 for the discussion that led to this.

In summary, the base16 theme introduced in #543 works great for users who configure their terminals with the base16 system in which the 16 ANSI colors are repurposed as base16 palette slots. But it doesn't work for users of base16-shell, which aims to solve problems with base16-unaware software by leaving the bright colors (ANSI 8-15) alone, and instead using codes 16-21 for extra base16 palette slots (requiring a 256-color terminal, hence base16-256).

Here is how terminal themes for regular base16 and 256-color/base16-shell differ:

ANSI code base16 base16-256
08 base03 base03
09 base09 base08
10 base01 base0B
11 base02 base0A
12 base04 base0D
13 base06 base0E
14 base0F base0C
15 base07 base07
16 base09
17 base0F
18 base01
19 base02
20 base04
21 base06

Notice codes 08 (bright black) and 15 (bright white) stay the same. But 09 (bright red) through 14 (bright cyan) are replaced with their non-bright counterparts, and those base16 colors are moved to ANSI codes 16-21.

So the new base16-256 theme is just like base16, but makes the following replacements:

  • base09 goes from ANSI 09 to 16: #09000000#10000000
  • base01 goes from ANSI 10 to 18: #0a000000#12000000
  • base02 goes from ANSI 11 to 19: #0b000000#13000000
  • base04 goes from ANSI 12 to 20: #0c000000#14000000
  • base06 goes from ANSI 13 to 21: #0d000000#15000000
  • base0F goes from ANSI 14 to 17: #0e000000#11000000

terminal.rs already maps any #RR000000 to the 256-color code RR, so no code change is needed.

Here is what base16 and base16-256 look like on macOS, kitty terminal with https://github.com/kdrag0n/base16-kitty/blob/master/colors/base16-solarized-light-256.conf, and fish shell with base16-shell/profile_helper.fish sourced:

Screen Shot 2020-07-19 at 5 22 08 PM

It's not so obvious in this example, but in this theme constants like 2.0 are supposed to be orange, not red. The base16 theme shows red because it's using ANSI bright red (which is just plain red in the 256-color terminal theme). The base16-256 theme correctly shows it as orange because it instead uses ANSI code 16.

Note: I have not regenerated themes.bin — I assume that will be done on release as before.

@antoineco
Copy link

Looks much better in 256-color terminal themes 👍

YAML example, to refer to the linked issue

before:
image

after:
image

antoineco added a commit to antoineco/dotfiles that referenced this pull request Jul 20, 2020
Copy link

@antoineco antoineco left a comment

Choose a reason for hiding this comment

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

LGTM

@mk12 mk12 force-pushed the base16-256 branch 2 times, most recently from b6500f0 to 62cf203 Compare August 1, 2020 16:34
@mk12
Copy link
Contributor Author

mk12 commented Aug 1, 2020

@sharkdp Please take a look when you have time :)

I've also updated the README with a section on the 8-bit color themes (ansi-dark, ansi-light, base16, and base16-256) to help avoid confusion about them.

@sharkdp
Copy link
Owner

sharkdp commented Aug 2, 2020

Thank you very much for your contribution and for the awesome documentation (and updating the README)!

I have only one minor request: Could you please add an entry to the "unreleased" section in the CHANGELOG.md? The format is:

- Description what has been changed, see #123 (@user)

where #123 links to the bug ticket and/or this PR and user is your username.

@sharkdp
Copy link
Owner

sharkdp commented Aug 2, 2020

I rebased your branch on master in order to run the new CI pipelines. I am expecting one (new) test to fail, which regenerates the binary caches before running the unit tests. We simply have to add the theme to tests/assets.rs to make it pass.

Note: I have not regenerated themes.bin — I assume that will be done on release as before.

yes 👍

mk12 and others added 2 commits August 2, 2020 17:44
Bat already has a base16 theme. The new base16-256 theme is for users
of base16-shell, who configure their terminal with a 256-color variant
of a base16 theme. These variants put some of the base16 colors in
elsewhere in the 256-color table to avoid clobbering bright color slots
(ansi codes 8 to 15) with colors that don't respect the ordinary meaning
of that slot (e.g. bright green in ordinary base16 is not green).

For more details, see https://github.com/chriskempson/base16-shell
@mk12
Copy link
Contributor Author

mk12 commented Aug 2, 2020

I have only one minor request: Could you please add an entry to the "unreleased" section in the CHANGELOG.md?

Done! (I amended the 1st commit and force pushed)

@sharkdp
Copy link
Owner

sharkdp commented Aug 3, 2020

Thank you for the update.

My new testing mechanism catches the (future) error, but now the tests for the old binary theme set fail, of course. I'm adding the updated themes.bin to this branch for now and will further work on my test suite 😄

@sharkdp sharkdp merged commit 3a85fd7 into sharkdp:master Aug 3, 2020
antoineco added a commit to antoineco/dotfiles that referenced this pull request Sep 22, 2020
@mk12 mk12 deleted the base16-256 branch September 27, 2020 21:01
@sharkdp
Copy link
Owner

sharkdp commented Oct 2, 2020

Added in v0.16.0.

antoineco added a commit to antoineco/dotfiles that referenced this pull request Aug 26, 2021
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.

3 participants