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 support for setting arbitrary colors ranging from 16 to 256. #1056

Merged
merged 5 commits into from Aug 23, 2021
Merged

Add support for setting arbitrary colors ranging from 16 to 256. #1056

merged 5 commits into from Aug 23, 2021

Conversation

potamides
Copy link
Contributor

@potamides potamides commented Aug 21, 2021

Hello there, I absolutely love this terminal emulator, however for my usecase I'd need support for setting all colors in the 256 color table, do you have any interest in that? This would be useful for colorschemes like gruvbox which define a lot of colors outside the standard 4-bit color range. This pull request is my attempt to address this shortcoming. I followed the approach of alacritty here which beside the ansi and bright tables allows to set arbitrary colors from 16 to 256 in an indexed table. This would for example make it possible to specify the whole gruvbox colorscheme like this:

local config = {
  color_scheme = "Gruvbox Dark Medium",
  color_schemes = {
    ["Gruvbox Dark Medium"] = {
      foreground = "#ebdbb2",
      background = "#282828",
      cursor_bg = "#ebdbb2",
      cursor_border = "#ebdbb2",
      cursor_fg = "#282828",
      selection_bg = "#ebdbb2",
      selection_fg = "#282828",

      ansi = {"#282828","#cc241d","#98971a","#d79921","#458588","#b16286","#689d6a","#a89984"},
      brights = {"#928374","#fb4934","#b8bb26","#fabd2f","#83a598","#d3869b","#8ec07c","#ebdbb2"},
      indexed = {
        [24]  = "#076678", [66]  = "#458588", [72]  = "#689d6a", [88]  = "#9d0006", [96]  = "#8f3f71",
        [100] = "#79740e", [106] = "#98971a", [108] = "#8ec07c", [109] = "#83a598", [124] = "#cc241d",
        [130] = "#af3a03", [132] = "#b16286", [136] = "#b57614", [142] = "#b8bb26", [166] = "#d65d0e",
        [167] = "#fb4934", [172] = "#d79921", [175] = "#d3869b", [208] = "#fe8019", [214] = "#fabd2f",
        [223] = "#ebdbb2", [228] = "#f2e5bc", [229] = "#fbf1c7", [230] = "#f9f5d7", [234] = "#1d2021",
        [235] = "#282828", [236] = "#32302f", [237] = "#3c3836", [239] = "#504945", [241] = "#665c54",
        [243] = "#7c6f64", [244] = "#928374", [245] = "#928374", [246] = "#a89984", [248] = "#bdae93",
        [250] = "#d5c4a1"
      }
    }
  }
}

This pull request would fix #841.

@wez
Copy link
Owner

wez commented Aug 21, 2021

Thanks for this! #841 is a feature request to do this, so you're not alone!

config/src/color.rs Outdated Show resolved Hide resolved
@potamides
Copy link
Contributor Author

potamides commented Aug 21, 2021

Thanks for this! #841 is a feature request to do this, so you're not alone!

Nice to see, I'll link this issue then.

config/src/color.rs Outdated Show resolved Hide resolved
config/src/color.rs Outdated Show resolved Hide resolved
@wez wez merged commit 57036d7 into wez:main Aug 23, 2021
@wez
Copy link
Owner

wez commented Aug 23, 2021

Thanks!

wez added a commit that referenced this pull request Aug 23, 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.

Replacing colours beyond the first 16
2 participants