Skip to content

Commit

Permalink
Merge branch 'master' into ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jam1garner authored Oct 12, 2023
2 parents 8d3bdf6 + fd77066 commit 0f01a19
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 290 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: ["1.51.0", "stable", "nightly"]
rust: ["1.56.0", "stable", "nightly"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -54,3 +54,11 @@ jobs:
run: |
cargo test --all-targets --all-features
cargo test --all-targets --no-default-features
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack

- name: Run tests with feature powerset
# Note: you might think that we can also pass in `--exclude-all-features` here, but that
# isn't the case because if you pass in a --example, it doesn't run doctests. The below
# expression will run doctests as well.
run: cargo hack --feature-powerset
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "owo-colors"
version = "3.6.0"
rust-version = "1.51"
rust-version = "1.56"
authors = ["jam1garner <8260240+jam1garner@users.noreply.github.com>"]
edition = "2018"
documentation = "https://docs.rs/owo-colors"
Expand All @@ -26,7 +26,9 @@ required-features = ["supports-colors"]

[features]
supports-colors = ["supports-color"]
supports-colors-2 = ["supports-color-2"]
alloc = []

[dependencies]
supports-color = { version = "2.0", optional = true }
supports-color = { version = "1.3", optional = true }
supports-color-2 = { package = "supports-color", version = "2.0", optional = true }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Current Crates.io Version](https://img.shields.io/crates/v/owo-colors.svg)](https://crates.io/crates/owo-colors)
[![docs-rs](https://docs.rs/owo-colors/badge.svg)](https://docs.rs/owo-colors)
![MSRV 1.51+](https://img.shields.io/badge/rustc-1.51+-blue.svg)
![MSRV 1.56+](https://img.shields.io/badge/rustc-1.56+-blue.svg)
![Downloads](https://img.shields.io/crates/d/owo-colors)

A zero-allocation no_std-compatible zero-cost way to add color to your Rust
Expand Down
275 changes: 17 additions & 258 deletions src/colors/custom.rs
Original file line number Diff line number Diff line change
@@ -1,263 +1,22 @@
use crate::Color;

const U8_TO_STR: [[u8; 3]; 256] = [
[48, 48, 48],
[48, 48, 49],
[48, 48, 50],
[48, 48, 51],
[48, 48, 52],
[48, 48, 53],
[48, 48, 54],
[48, 48, 55],
[48, 48, 56],
[48, 48, 57],
[48, 49, 48],
[48, 49, 49],
[48, 49, 50],
[48, 49, 51],
[48, 49, 52],
[48, 49, 53],
[48, 49, 54],
[48, 49, 55],
[48, 49, 56],
[48, 49, 57],
[48, 50, 48],
[48, 50, 49],
[48, 50, 50],
[48, 50, 51],
[48, 50, 52],
[48, 50, 53],
[48, 50, 54],
[48, 50, 55],
[48, 50, 56],
[48, 50, 57],
[48, 51, 48],
[48, 51, 49],
[48, 51, 50],
[48, 51, 51],
[48, 51, 52],
[48, 51, 53],
[48, 51, 54],
[48, 51, 55],
[48, 51, 56],
[48, 51, 57],
[48, 52, 48],
[48, 52, 49],
[48, 52, 50],
[48, 52, 51],
[48, 52, 52],
[48, 52, 53],
[48, 52, 54],
[48, 52, 55],
[48, 52, 56],
[48, 52, 57],
[48, 53, 48],
[48, 53, 49],
[48, 53, 50],
[48, 53, 51],
[48, 53, 52],
[48, 53, 53],
[48, 53, 54],
[48, 53, 55],
[48, 53, 56],
[48, 53, 57],
[48, 54, 48],
[48, 54, 49],
[48, 54, 50],
[48, 54, 51],
[48, 54, 52],
[48, 54, 53],
[48, 54, 54],
[48, 54, 55],
[48, 54, 56],
[48, 54, 57],
[48, 55, 48],
[48, 55, 49],
[48, 55, 50],
[48, 55, 51],
[48, 55, 52],
[48, 55, 53],
[48, 55, 54],
[48, 55, 55],
[48, 55, 56],
[48, 55, 57],
[48, 56, 48],
[48, 56, 49],
[48, 56, 50],
[48, 56, 51],
[48, 56, 52],
[48, 56, 53],
[48, 56, 54],
[48, 56, 55],
[48, 56, 56],
[48, 56, 57],
[48, 57, 48],
[48, 57, 49],
[48, 57, 50],
[48, 57, 51],
[48, 57, 52],
[48, 57, 53],
[48, 57, 54],
[48, 57, 55],
[48, 57, 56],
[48, 57, 57],
[49, 48, 48],
[49, 48, 49],
[49, 48, 50],
[49, 48, 51],
[49, 48, 52],
[49, 48, 53],
[49, 48, 54],
[49, 48, 55],
[49, 48, 56],
[49, 48, 57],
[49, 49, 48],
[49, 49, 49],
[49, 49, 50],
[49, 49, 51],
[49, 49, 52],
[49, 49, 53],
[49, 49, 54],
[49, 49, 55],
[49, 49, 56],
[49, 49, 57],
[49, 50, 48],
[49, 50, 49],
[49, 50, 50],
[49, 50, 51],
[49, 50, 52],
[49, 50, 53],
[49, 50, 54],
[49, 50, 55],
[49, 50, 56],
[49, 50, 57],
[49, 51, 48],
[49, 51, 49],
[49, 51, 50],
[49, 51, 51],
[49, 51, 52],
[49, 51, 53],
[49, 51, 54],
[49, 51, 55],
[49, 51, 56],
[49, 51, 57],
[49, 52, 48],
[49, 52, 49],
[49, 52, 50],
[49, 52, 51],
[49, 52, 52],
[49, 52, 53],
[49, 52, 54],
[49, 52, 55],
[49, 52, 56],
[49, 52, 57],
[49, 53, 48],
[49, 53, 49],
[49, 53, 50],
[49, 53, 51],
[49, 53, 52],
[49, 53, 53],
[49, 53, 54],
[49, 53, 55],
[49, 53, 56],
[49, 53, 57],
[49, 54, 48],
[49, 54, 49],
[49, 54, 50],
[49, 54, 51],
[49, 54, 52],
[49, 54, 53],
[49, 54, 54],
[49, 54, 55],
[49, 54, 56],
[49, 54, 57],
[49, 55, 48],
[49, 55, 49],
[49, 55, 50],
[49, 55, 51],
[49, 55, 52],
[49, 55, 53],
[49, 55, 54],
[49, 55, 55],
[49, 55, 56],
[49, 55, 57],
[49, 56, 48],
[49, 56, 49],
[49, 56, 50],
[49, 56, 51],
[49, 56, 52],
[49, 56, 53],
[49, 56, 54],
[49, 56, 55],
[49, 56, 56],
[49, 56, 57],
[49, 57, 48],
[49, 57, 49],
[49, 57, 50],
[49, 57, 51],
[49, 57, 52],
[49, 57, 53],
[49, 57, 54],
[49, 57, 55],
[49, 57, 56],
[49, 57, 57],
[50, 48, 48],
[50, 48, 49],
[50, 48, 50],
[50, 48, 51],
[50, 48, 52],
[50, 48, 53],
[50, 48, 54],
[50, 48, 55],
[50, 48, 56],
[50, 48, 57],
[50, 49, 48],
[50, 49, 49],
[50, 49, 50],
[50, 49, 51],
[50, 49, 52],
[50, 49, 53],
[50, 49, 54],
[50, 49, 55],
[50, 49, 56],
[50, 49, 57],
[50, 50, 48],
[50, 50, 49],
[50, 50, 50],
[50, 50, 51],
[50, 50, 52],
[50, 50, 53],
[50, 50, 54],
[50, 50, 55],
[50, 50, 56],
[50, 50, 57],
[50, 51, 48],
[50, 51, 49],
[50, 51, 50],
[50, 51, 51],
[50, 51, 52],
[50, 51, 53],
[50, 51, 54],
[50, 51, 55],
[50, 51, 56],
[50, 51, 57],
[50, 52, 48],
[50, 52, 49],
[50, 52, 50],
[50, 52, 51],
[50, 52, 52],
[50, 52, 53],
[50, 52, 54],
[50, 52, 55],
[50, 52, 56],
[50, 52, 57],
[50, 53, 48],
[50, 53, 49],
[50, 53, 50],
[50, 53, 51],
[50, 53, 52],
[50, 53, 53],
];
const U8_TO_STR: [[u8; 3]; 256] = generate_lookup();

const fn generate_lookup() -> [[u8; 3]; 256] {
let mut table = [[0, 0, 0]; 256];

let mut i = 0;
while i < 256 {
table[i] = [
b'0' + (i / 100) as u8,
b'0' + (i / 10 % 10) as u8,
b'0' + (i % 10) as u8,
];
i += 1;
}

table
}

const fn rgb_to_ansi(r: u8, g: u8, b: u8, is_fg: bool) -> [u8; 19] {
let mut buf = if is_fg {
Expand Down
Loading

0 comments on commit 0f01a19

Please sign in to comment.