diff --git a/CHANGELOG.md b/CHANGELOG.md index c039516..fae8b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ Procedure when bumping the version number: ## Unreleased +### Changed +- Respect colon-delimited emoji when calculating nick hue + ## v0.5.2 - 2023-01-14 ### Added diff --git a/Cargo.lock b/Cargo.lock index 3d86a8a..650c4f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -179,6 +179,7 @@ dependencies = [ "euphoxide", "linkify", "log", + "once_cell", "open", "parking_lot", "rusqlite", diff --git a/Cargo.toml b/Cargo.toml index 7394fa2..bf0469b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ directories = "4.0.1" edit = "0.1.4" linkify = "0.9.0" log = { version = "0.4.17", features = ["std"] } +once_cell = "1.17.0" open = "3.2.0" parking_lot = "0.12.1" rusqlite = { version = "0.28.0", features = ["bundled", "time"] } diff --git a/src/euph/util.rs b/src/euph/util.rs index cf05c76..3285a07 100644 --- a/src/euph/util.rs +++ b/src/euph/util.rs @@ -1,4 +1,8 @@ use crossterm::style::{Color, ContentStyle, Stylize}; +use euphoxide::emoji::Emoji; +use once_cell::sync::Lazy; + +static EMOJI: Lazy = Lazy::new(Emoji::load); /// Convert HSL to RGB following [this approach from wikipedia][1]. /// @@ -33,8 +37,7 @@ fn hsl_to_rgb(h: f32, s: f32, l: f32) -> (u8, u8, u8) { } pub fn nick_color(nick: &str) -> (u8, u8, u8) { - // TODO Use nick hue with emoji (lazy init emoji?) - let hue = euphoxide::nick_hue_without_removing_emoji(nick) as f32; + let hue = euphoxide::nick_hue(&EMOJI, nick) as f32; hsl_to_rgb(hue, 1.0, 0.72) }