diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 668ef93..624bd67 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - uses: erlef/setup-beam@v1 with: otp-version: "26.1" - gleam-version: "0.33.0" + gleam-version: "1.4.1" - run: | version="v$(cat gleam.toml | grep -m 1 "version" | sed -r "s/version *= *\"([[:digit:].]+)\"/\1/")" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3f7019..c3898c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: - uses: erlef/setup-beam@v1 with: otp-version: "26.1" - gleam-version: "0.33.0" + gleam-version: "1.4.1" - run: gleam format --check diff --git a/gleam.toml b/gleam.toml index e609c08..c5a1fce 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "gleam_community_ansi" -version = "1.4.0" +version = "1.4.1" licences = ["Apache-2.0"] description = "ANSI colours, formatting, and control codes" repository = { type = "github", user = "gleam-community", repo = "ansi" } diff --git a/src/gleam_community/ansi.gleam b/src/gleam_community/ansi.gleam index 3dc7305..e99d0ab 100644 --- a/src/gleam_community/ansi.gleam +++ b/src/gleam_community/ansi.gleam @@ -97,8 +97,8 @@ import gleam/int import gleam/list -import gleam/string import gleam/regex +import gleam/string import gleam_community/colour.{type Colour} as gc_colour // CONSTS --------------------------------------------------------------------- @@ -119,18 +119,9 @@ fn code(open: List(Int), close: Int) -> Code { let open_strs = list.map(open, int.to_string) Code( - open: asci_escape_character - <> "[" - <> string.join(open_strs, ";") - <> "m", - close: asci_escape_character - <> "[" - <> close_str - <> "m", - regexp: asci_escape_character - <> "[" - <> close_str - <> "m", + open: asci_escape_character <> "[" <> string.join(open_strs, ";") <> "m", + close: asci_escape_character <> "[" <> close_str <> "m", + regexp: asci_escape_character <> "[" <> close_str <> "m", ) } @@ -1265,7 +1256,7 @@ pub fn bright_white(text: String) -> String { /// /// fn example() { /// ansi.pink("lucy") -/// // => "\x1B[38;2;255;175;243mlucy\x1B[39m" +/// // => "\x1B[38;5;219mlucy\x1B[39m" /// } /// ``` /// @@ -1298,7 +1289,7 @@ pub fn bright_white(text: String) -> String { /// /// pub fn pink(text: String) -> String { - hex(text, 0xffaff3) + run(text, code([38, 5, 219], 39)) } /// Colour the given text the given colour represented by a hex `Int`. @@ -1357,9 +1348,9 @@ pub fn hex(text: String, colour: Int) -> String { 38, 2, int.bitwise_shift_right(colour, 16) - |> int.bitwise_and(0xff), + |> int.bitwise_and(0xff), int.bitwise_shift_right(colour, 8) - |> int.bitwise_and(0xff), + |> int.bitwise_and(0xff), int.bitwise_and(colour, 0xff), ], 39, @@ -2171,7 +2162,7 @@ pub fn bg_bright_white(text: String) -> String { /// /// fn example() { /// ansi.bg_pink("lucy") -/// // => "\x1B[48;2;255;175;243mlucy\x1B[49m" +/// // => "\x1B[48;5;219mlucy\x1B[49m" /// } /// ``` /// @@ -2204,7 +2195,7 @@ pub fn bg_bright_white(text: String) -> String { /// /// pub fn bg_pink(text: String) -> String { - bg_hex(text, 0xffaff3) + run(text, code([48, 5, 219], 49)) } /// Colour the given text's background the given colour represented by a hex `Int`. @@ -2262,9 +2253,9 @@ pub fn bg_hex(text: String, colour: Int) -> String { 48, 2, int.bitwise_shift_right(colour, 16) - |> int.bitwise_and(0xff), + |> int.bitwise_and(0xff), int.bitwise_shift_right(colour, 8) - |> int.bitwise_and(0xff), + |> int.bitwise_and(0xff), int.bitwise_and(colour, 0xff), ], 49, diff --git a/test/gleam_community_ansi_test.gleam b/test/gleam_community_ansi_test.gleam index 920ed9b..e460b21 100644 --- a/test/gleam_community_ansi_test.gleam +++ b/test/gleam_community_ansi_test.gleam @@ -1,7 +1,7 @@ -import gleeunit -import gleeunit/should import gleam_community/ansi import gleam_community/colour +import gleeunit +import gleeunit/should pub fn main() { gleeunit.main() @@ -284,13 +284,13 @@ pub fn bg_hex_test() { pub fn colour_test() { "foo bar" |> ansi.colour(colour.pink) - |> should.equal(ansi.pink("foo bar")) + |> should.equal(ansi.hex("foo bar", 0xffaff3)) } pub fn bg_colour_test() { "foo bar" |> ansi.bg_colour(colour.pink) - |> should.equal(ansi.bg_pink("foo bar")) + |> should.equal(ansi.bg_hex("foo bar", 0xffaff3)) } pub fn strip_test() {