Skip to content

Add support for extended color palette #17

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.1] - 2020-04-27

### Changed

* Added support for extended colors

## [0.5.0] - 2019-04-28

Expand Down
3 changes: 2 additions & 1 deletion lib/ratatouille/renderer/attributes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ defmodule Ratatouille.Renderer.Attributes do
alias Ratatouille.Constants

@valid_color_codes Constants.colors() |> Map.values()
@valid_color_codes_extended 0x11..0xe8
@valid_attribute_codes Constants.attributes() |> Map.values()

def to_terminal_color(code)
when is_integer(code) and code in @valid_color_codes do
when is_integer(code) and code in @valid_color_codes or code in @valid_color_codes_extended do
code
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Ratatouille.Mixfile do
def project do
[
app: :ratatouille,
version: "0.5.0",
version: "0.5.1",
elixir: "~> 1.5",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
4 changes: 4 additions & 0 deletions test/ratatouille/renderer/attributes_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ defmodule Ratatouille.Renderer.AttributesTest do
Constants.color(:red)
end

test "with extended color" do
assert Attributes.to_terminal_color(17) == 17
end

test "when invalid" do
assert_raise KeyError, fn ->
Attributes.to_terminal_color(1000)
Expand Down