mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-04 03:17:45 +03:00
Merge b732be4693
into 7ebf650029
This commit is contained in:
commit
3a3d173bca
1 changed files with 9 additions and 16 deletions
|
@ -298,25 +298,18 @@ impl Theme {
|
||||||
const RGB_START: usize = (usize::MAX << (8 + 8 + 8)) - 1;
|
const RGB_START: usize = (usize::MAX << (8 + 8 + 8)) - 1;
|
||||||
|
|
||||||
/// Interpret a Highlight with the RGB foreground
|
/// Interpret a Highlight with the RGB foreground
|
||||||
fn decode_rgb_highlight(rgb: usize) -> Option<(u8, u8, u8)> {
|
const fn decode_rgb_highlight(rgb: usize) -> Option<(u8, u8, u8)> {
|
||||||
(rgb > Self::RGB_START).then(|| {
|
if rgb > Self::RGB_START {
|
||||||
let [b, g, r, ..] = rgb.to_ne_bytes();
|
let [.., r, g, b] = rgb.to_be_bytes();
|
||||||
(r, g, b)
|
Some((r, g, b))
|
||||||
})
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a Highlight that represents an RGB color
|
/// Create a Highlight that represents an RGB color
|
||||||
pub fn rgb_highlight(r: u8, g: u8, b: u8) -> Highlight {
|
pub const fn rgb_highlight(r: u8, g: u8, b: u8) -> Highlight {
|
||||||
Highlight(usize::from_ne_bytes([
|
Highlight(Self::RGB_START + 1 + ((r as usize) << 16) + ((g as usize) << 8) + b as usize)
|
||||||
b,
|
|
||||||
g,
|
|
||||||
r,
|
|
||||||
u8::MAX,
|
|
||||||
u8::MAX,
|
|
||||||
u8::MAX,
|
|
||||||
u8::MAX,
|
|
||||||
u8::MAX,
|
|
||||||
]))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue