pub enum VB6Color {
RGB {
red: u8,
green: u8,
blue: u8,
},
System {
index: u8,
},
}Expand description
VB6Colors are 24 bits with 8 bits for red, green, and blue.
VB6Colors are stored and used within VB6 as text formatted as ‘&H00BBGGRR&’.
if, instead, the value begins with ‘&H80’ such as in ‘&H80000000&’, then
the color is a system color. and the value is not the elements of the color,
but rather the index of a system color.
Variants§
Implementations§
Source§impl VB6Color
impl VB6Color
Sourcepub fn rgb(red: u8, green: u8, blue: u8) -> Self
pub fn rgb(red: u8, green: u8, blue: u8) -> Self
Creates a new VB6Color with an RGB value.
This is the same as calling VB6Color::new(red, green, blue).
§Arguments
red- The red value.green- The green value.blue- The blue value.
§Returns
A new RGB VB6Color.
§Example
use std::matches;
use vb6parse::language::VB6Color;
let color = VB6Color::rgb(0xFF, 0x33, 0x12);
assert!(matches!(color, VB6Color::RGB { .. } ));
assert_eq!(color, VB6Color::RGB { red: 0xFF, green: 0x33, blue: 0x12 });Sourcepub fn from_hex(input: &str) -> Result<VB6Color, VB6ErrorKind>
pub fn from_hex(input: &str) -> Result<VB6Color, VB6ErrorKind>
Parses a VB6Color.
The color is represented as a 24-bit RGB value. The red, green, and blue values are each 8-bits. This is stored and used in VB6 as a formatted hex text value &H00BBGGRR&.
§Arguments
input- The input to parse.
§Errors
If the input is not a valid hex color of either a ‘&H00BBGGRR&’ or ‘&H800000II&’ format, an error is returned.
The ‘&H00BBGGRR&’ format is a 24-bit RGB color in the order of blue, green, red. where each element is in hex format.
The ‘&H800000II&’ format is a system color with the index value of ‘II’. Again, where ‘II’ is in hex format.
§Returns
The VB6Color.
§Example
use vb6parse::language::VB6Color;
// Of course, VB6 being as it is...
// the color is stored in a 'special' order.
// blue, green, red
let mut input = "&H00BBCCFF&";
let color = VB6Color::from_hex(&input).unwrap();
assert!(matches!(color, VB6Color::RGB { .. } ));
assert_eq!(color, VB6Color::RGB { red: 0xFF, green: 0xCC, blue: 0xBB });Trait Implementations§
impl Eq for VB6Color
impl StructuralPartialEq for VB6Color
Auto Trait Implementations§
impl Freeze for VB6Color
impl RefUnwindSafe for VB6Color
impl Send for VB6Color
impl Sync for VB6Color
impl Unpin for VB6Color
impl UnwindSafe for VB6Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);