unwind_context/
color_scheme.rs

1/// The default ANSI color scheme, which is used if colorization is enabled but
2/// no custom color scheme is set.
3///
4/// # Examples
5#[cfg_attr(feature = "custom-default-colors", doc = "```rust")]
6#[cfg_attr(not(feature = "custom-default-colors"), doc = "```rust,compile_fail")]
7/// static CUSTOM_DEFAULT_COLOR_SCHEME: unwind_context::AnsiColorScheme =
8///     unwind_context::AnsiColorScheme {
9///         item: "\u{1b}[37m",
10///         ..unwind_context::DEFAULT_DEFAULT_COLOR_SCHEME
11///     };
12///
13/// unwind_context::set_default_color_scheme(&CUSTOM_DEFAULT_COLOR_SCHEME);
14#[doc = "```"]
15pub static DEFAULT_DEFAULT_COLOR_SCHEME: AnsiColorScheme = AnsiColorScheme {
16    default: "\u{1b}[0m",
17    location: "\u{1b}[94m",
18    fn_keyword: "\u{1b}[33m",
19    func_name: "\u{1b}[93m",
20    func_braces: "\u{1b}[0m",
21    value_braces: "\u{1b}[0m",
22    ident: "\u{1b}[0;33m",
23    item: "\u{1b}[0;33m",
24    boolean: "\u{1b}[1;93m",
25    number: "\u{1b}[0;96m",
26    quoted: "\u{1b}[0;32m",
27    escaped: "\u{1b}[0;95m",
28};
29
30#[doc(hidden)]
31#[deprecated(since = "0.2.0", note = "renamed to `DEFAULT_DEFAULT_COLOR_SCHEME`.")]
32pub use DEFAULT_DEFAULT_COLOR_SCHEME as DEFAULT_ANSI_COLOR_SCHEME;
33
34/// A structure representing an ANSI color scheme used by [`DebugAnsiColored`]
35/// formatter.
36///
37/// # Examples
38#[cfg_attr(feature = "custom-default-colors", doc = "```rust")]
39#[cfg_attr(not(feature = "custom-default-colors"), doc = "```rust,compile_fail")]
40/// unwind_context::set_default_color_scheme(&unwind_context::AnsiColorScheme {
41///     default: "\u{1b}[0m",
42///     location: "\u{1b}[31m",
43///     fn_keyword: "\u{1b}[32m",
44///     func_name: "\u{1b}[33m",
45///     func_braces: "\u{1b}[34m",
46///     value_braces: "\u{1b}[35m",
47///     ident: "\u{1b}[36m",
48///     item: "\u{1b}[37m",
49///     boolean: "\u{1b}[91m",
50///     number: "\u{1b}[92m",
51///     quoted: "\u{1b}[93m",
52///     escaped: "\u{1b}[94m",
53/// });
54#[doc = "```"]
55#[doc = ""]
56/// [`DebugAnsiColored`]: crate::DebugAnsiColored
57#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
58pub struct AnsiColorScheme {
59    /// The ANSI escape sequence used for default text styling.
60    pub default: &'static str,
61    /// The ANSI escape sequence used before code location.
62    pub location: &'static str,
63    /// The ANSI escape sequence used before `fn` keyword.
64    pub fn_keyword: &'static str,
65    /// The ANSI escape sequence used before function name.
66    pub func_name: &'static str,
67    /// The ANSI escape sequence used before function braces.
68    pub func_braces: &'static str,
69    /// The ANSI escape sequence used before any value braces.
70    pub value_braces: &'static str,
71    /// The ANSI escape sequence used before identifiers.
72    pub ident: &'static str,
73    /// The ANSI escape sequence used before struct, enum and const names.
74    pub item: &'static str,
75    /// The ANSI escape sequence used before `false` or `true` keywords.
76    pub boolean: &'static str,
77    /// The ANSI escape sequence used before numbers.
78    pub number: &'static str,
79    /// The ANSI escape sequence used before quoted strings.
80    pub quoted: &'static str,
81    /// The ANSI escape sequence used before escaped characters in quoted
82    /// strings.
83    pub escaped: &'static str,
84}