Skip to content
Open
Changes from 2 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
130 changes: 127 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ pub enum Color {
Blue,
Magenta,
Cyan,
Silver,
Grey,
Maroon,
Lime,
Fuchsia,
Navy,
Aqua,
Olive,
White,
Color256(u8),
}
Expand All @@ -95,11 +103,19 @@ impl Color {
Color::Black => 0,
Color::Red => 1,
Color::Green => 2,
Color::Yellow => 3,
Color::Blue => 4,
Color::Yellow => 11,
Color::Blue => 12,
Color::Magenta => 5,
Color::Cyan => 6,
Color::White => 7,
Color::Silver => 7,
Color::Grey => 8,
Color::Maroon => 9,
Color::Lime => 10,
Color::Fuchsia => 13,
Color::Navy => 4,
Color::Olive => 3,
Color::Aqua => 14,
Color::White => 15,
Color::Color256(x) => x as usize,
}
}
Expand Down Expand Up @@ -203,6 +219,14 @@ impl Style {
"blue" => rv.blue(),
"magenta" => rv.magenta(),
"cyan" => rv.cyan(),
"silver" => rv.silver(),
"aqua" => rv.aqua(),
"grey" => rv.grey(),
"maroon" => rv.maroon(),
"lime" => rv.lime(),
"fuchsia" => rv.fuchsia(),
"navy" => rv.navy(),
"olive" => rv.olive(),
"white" => rv.white(),
"bright" => rv.bright(),
"on_black" => rv.on_black(),
Expand All @@ -212,6 +236,14 @@ impl Style {
"on_blue" => rv.on_blue(),
"on_magenta" => rv.on_magenta(),
"on_cyan" => rv.on_cyan(),
"on_silver" => rv.on_silver(),
"on_grey" => rv.on_grey(),
"on_maroon" => rv.on_maroon(),
"on_lime" => rv.on_lime(),
"on_fuchsia" => rv.on_fuchsia(),
"on_navy" => rv.on_navy(),
"on_olive" => rv.on_olive(),
"on_aqua" => rv.on_aqua(),
"on_white" => rv.on_white(),
"on_bright" => rv.on_bright(),
"bold" => rv.bold(),
Expand Down Expand Up @@ -324,6 +356,38 @@ impl Style {
self.fg(Color::Cyan)
}
#[inline]
pub fn aqua(self) -> Style {
self.fg(Color::Aqua)
}
#[inline]
pub fn silver(self) -> Style {
self.fg(Color::Silver)
}
#[inline]
pub fn grey(self) -> Style {
self.fg(Color::Grey)
}
#[inline]
pub fn maroon(self) -> Style {
self.fg(Color::Maroon)
}
#[inline]
pub fn lime(self) -> Style {
self.fg(Color::Lime)
}
#[inline]
pub fn fuchsia(self) -> Style {
self.fg(Color::Fuchsia)
}
#[inline]
pub fn navy(self) -> Style {
self.fg(Color::Navy)
}
#[inline]
pub fn olive(self) -> Style {
self.fg(Color::Olive)
}
#[inline]
pub fn white(self) -> Style {
self.fg(Color::White)
}
Expand Down Expand Up @@ -367,6 +431,38 @@ impl Style {
self.bg(Color::Cyan)
}
#[inline]
pub fn on_aqua(self) -> Style {
self.bg(Color::Aqua)
}
#[inline]
pub fn on_silver(self) -> Style {
self.bg(Color::Silver)
}
#[inline]
pub fn on_grey(self) -> Style {
self.bg(Color::Grey)
}
#[inline]
pub fn on_maroon(self) -> Style {
self.bg(Color::Maroon)
}
#[inline]
pub fn on_lime(self) -> Style {
self.bg(Color::Lime)
}
#[inline]
pub fn on_fuchsia(self) -> Style {
self.bg(Color::Fuchsia)
}
#[inline]
pub fn on_navy(self) -> Style {
self.bg(Color::Navy)
}
#[inline]
pub fn on_olive(self) -> Style {
self.bg(Color::Olive)
}
#[inline]
pub fn on_white(self) -> Style {
self.bg(Color::White)
}
Expand Down Expand Up @@ -565,6 +661,34 @@ impl<D> StyledObject<D> {
self.bg(Color::Cyan)
}
#[inline]
pub fn on_silver(self) -> StyledObject<D> {
self.bg(Color::Silver)
}
#[inline]
pub fn on_grey(self) -> StyledObject<D> {
self.bg(Color::Grey)
}
#[inline]
pub fn on_maroon(self) -> StyledObject<D> {
self.bg(Color::Maroon)
}
#[inline]
pub fn on_lime(self) -> StyledObject<D> {
self.bg(Color::Lime)
}
#[inline]
pub fn on_fuchsia(self) -> StyledObject<D> {
self.bg(Color::Fuchsia)
}
#[inline]
pub fn on_navy(self) -> StyledObject<D> {
self.bg(Color::Navy)
}
#[inline]
pub fn on_olive(self) -> StyledObject<D> {
self.bg(Color::Olive)
}
#[inline]
pub fn on_white(self) -> StyledObject<D> {
self.bg(Color::White)
}
Expand Down