pub enum AnsiColor {
Show 16 variants
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White,
BrightBlack,
BrightRed,
BrightGreen,
BrightYellow,
BrightBlue,
BrightMagenta,
BrightCyan,
BrightWhite,
}
Expand description
The 16 extended ANSI colors.
Rust code converts between 8-bit color codes and enumeration variants with
AnsiColor as TryFrom<u8>
and
u8 as From<AnsiColor>
.
In contrast, Python code uses the AnsiColor::try_from_8bit
and
AnsiColor::to_8bit
methods.
Since ANSI colors have no intrinsic color values, conversion from/to
high-resolution colors requires additional machinery, as provided by
Translator
.
The ANSI colors are ordered because they are ordered as theme colors and as indexed colors.
Variants§
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
BrightBlack
BrightRed
BrightGreen
BrightYellow
BrightBlue
BrightMagenta
BrightCyan
BrightWhite
Implementations§
Source§impl AnsiColor
impl AnsiColor
Sourcepub fn all() -> AnsiColorIterator ⓘ
pub fn all() -> AnsiColorIterator ⓘ
Get an iterator over all ANSI colors in order.
Sourcepub fn try_from_8bit(value: u8) -> Result<Self, OutOfBoundsError>
pub fn try_from_8bit(value: u8) -> Result<Self, OutOfBoundsError>
Instantiate an ANSI color from its 8-bit code. Python only!
This method offers the same functionality as AnsiColor as TryFrom<u8>
and is available in Python only.
Sourcepub fn to_8bit(&self) -> u8
pub fn to_8bit(&self) -> u8
Get the 8-bit code for this ANSI color. Python only!
This method offers the same functionality as u8 as From<AnsiColor>
and is available in Python only.
Sourcepub fn is_achromatic(&self) -> bool
pub fn is_achromatic(&self) -> bool
Determine whether this ANSI color is achromatic.
Sourcepub fn to_base(&self) -> Self
pub fn to_base(&self) -> Self
Get the base version of this ANSI color.
If this color is bright, this method returns its non-bright version. Otherwise, it returns the same color.
Sourcepub fn to_bright(&self) -> Self
pub fn to_bright(&self) -> Self
Get the bright version of this ANSI color.
If the color is not bright, this method returns its bright version. Otherwise, it returns the same color.
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Get this ANSI color’s name.
This method returns the human-readable name, e.g., "bright green"
for
AnsiColor::BrightGreen
.
Sourcepub fn abbr(&self) -> &'static str
pub fn abbr(&self) -> &'static str
Get an abbreviation for this ANSI color.
This method returns a two-letter abbreviation for this ANSI color. The abbreviations for each pair of nonbright and bright colors only differ in case, with the nonbright color’s abbreviation in lower case and the bright color’s abbreviation in upper case.
Trait Implementations§
Source§impl From<AnsiColor> for EightBitColor
impl From<AnsiColor> for EightBitColor
Source§impl From<AnsiColor> for ThemeEntry
impl From<AnsiColor> for ThemeEntry
Source§impl<'py> IntoPyObject<'py> for AnsiColor
impl<'py> IntoPyObject<'py> for AnsiColor
Source§impl Ord for AnsiColor
impl Ord for AnsiColor
Source§impl PartialOrd for AnsiColor
impl PartialOrd for AnsiColor
Source§impl PyClassImpl for AnsiColor
impl PyClassImpl for AnsiColor
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<AnsiColor>
type ThreadChecker = SendablePyClass<AnsiColor>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyMethods<AnsiColor> for PyClassImplCollector<AnsiColor>
impl PyMethods<AnsiColor> for PyClassImplCollector<AnsiColor>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for AnsiColor
impl PyTypeInfo for AnsiColor
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
PyTypeInfo::type_object
PyTypeInfo::type_object
].§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_type_of
PyTypeInfo::is_type_of
].§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_exact_type_of
PyTypeInfo::is_exact_type_of
].impl Copy for AnsiColor
impl Eq for AnsiColor
impl HasCustomRichCmp for AnsiColor
impl StructuralPartialEq for AnsiColor
Auto Trait Implementations§
impl Freeze for AnsiColor
impl RefUnwindSafe for AnsiColor
impl Send for AnsiColor
impl Sync for AnsiColor
impl Unpin for AnsiColor
impl UnwindSafe for AnsiColor
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,
§impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
§fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self
into an owned Python object, dropping type information and unbinding it
from the 'py
lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self
into a Python object. Read more