feat(theme): rename some theme items for clarity

BREAKING CHANGE: These were part of the public API, so if you were using theming, this might have broken for you
This commit is contained in:
Kat Marchán 2021-09-16 18:22:52 -07:00
parent 4244acacca
commit 12a9235bec
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
2 changed files with 43 additions and 20 deletions

View File

@ -162,9 +162,9 @@ impl GraphicalReportHandler {
fn render_causes(&self, f: &mut impl fmt::Write, diagnostic: &(dyn Diagnostic)) -> fmt::Result { fn render_causes(&self, f: &mut impl fmt::Write, diagnostic: &(dyn Diagnostic)) -> fmt::Result {
let (severity_style, severity_icon) = match diagnostic.severity() { let (severity_style, severity_icon) = match diagnostic.severity() {
Some(Severity::Error) | None => (self.theme.styles.error, self.theme.characters.x), Some(Severity::Error) | None => (self.theme.styles.error, self.theme.characters.error),
Some(Severity::Warning) => (self.theme.styles.warning, self.theme.characters.warning), Some(Severity::Warning) => (self.theme.styles.warning, self.theme.characters.warning),
Some(Severity::Advice) => (self.theme.styles.advice, self.theme.characters.point_right), Some(Severity::Advice) => (self.theme.styles.advice, self.theme.characters.advice),
}; };
let initial_indent = format!(" {} ", severity_icon.style(severity_style)); let initial_indent = format!(" {} ", severity_icon.style(severity_style));

View File

@ -82,8 +82,8 @@ pub struct ThemeStyles {
pub code: Style, pub code: Style,
/// Style to apply to the help text. /// Style to apply to the help text.
pub help: Style, pub help: Style,
/// Style to apply to the filename/source name. /// Style to apply to filenames/links/URLs.
pub filename: Style, pub link: Style,
/// Styles to cycle through (using `.iter().cycle()`), to render the lines /// Styles to cycle through (using `.iter().cycle()`), to render the lines
/// and text for diagnostic highlights. /// and text for diagnostic highlights.
pub highlights: Vec<Style>, pub highlights: Vec<Style>,
@ -102,8 +102,8 @@ impl ThemeStyles {
warning: style().fg_rgb::<244, 191, 117>(), warning: style().fg_rgb::<244, 191, 117>(),
advice: style().fg_rgb::<106, 159, 181>(), advice: style().fg_rgb::<106, 159, 181>(),
code: style().fg_rgb::<92, 157, 255>(), code: style().fg_rgb::<92, 157, 255>(),
help: style().fg_rgb::<117, 181, 170>(), help: style().fg_rgb::<106, 159, 181>(),
filename: style().fg_rgb::<92, 157, 255>().underline().bold(), link: style().fg_rgb::<92, 157, 255>().underline().bold(),
highlights: vec![ highlights: vec![
style().fg_rgb::<246, 87, 248>(), style().fg_rgb::<246, 87, 248>(),
style().fg_rgb::<30, 201, 212>(), style().fg_rgb::<30, 201, 212>(),
@ -120,7 +120,7 @@ impl ThemeStyles {
advice: style().cyan(), advice: style().cyan(),
code: style().yellow(), code: style().yellow(),
help: style().cyan(), help: style().cyan(),
filename: style().cyan().underline().bold(), link: style().cyan().underline().bold(),
highlights: vec![ highlights: vec![
style().red().bold(), style().red().bold(),
style().yellow().bold(), style().yellow().bold(),
@ -137,7 +137,7 @@ impl ThemeStyles {
advice: style(), advice: style(),
code: style(), code: style(),
help: style(), help: style(),
filename: style(), link: style(),
highlights: vec![style()], highlights: vec![style()],
} }
} }
@ -175,10 +175,9 @@ pub struct ThemeCharacters {
pub underbar: char, pub underbar: char,
pub underline: char, pub underline: char,
pub fyi: String, pub error: String,
pub x: char, pub warning: String,
pub warning: char, pub advice: String,
pub point_right: char,
} }
impl ThemeCharacters { impl ThemeCharacters {
@ -203,13 +202,38 @@ impl ThemeCharacters {
rcross: '', rcross: '',
underbar: '', underbar: '',
underline: '', underline: '',
fyi: "help:".into(), error: "×".into(),
x: '×', warning: "".into(),
warning: '', advice: "".into(),
point_right: '',
} }
} }
/// Emoji-heavy unicode characters.
pub fn emoji() -> Self {
Self {
hbar: '',
vbar: '',
xbar: '',
vbar_break: '·',
uarrow: '',
rarrow: '',
ltop: '',
mtop: '',
rtop: '',
lbot: '',
mbot: '',
rbot: '',
lbox: '[',
rbox: ']',
lcross: '',
rcross: '',
underbar: '',
underline: '',
error: "💥".into(),
warning: "⚠️".into(),
advice: "💡".into(),
}
}
/// ASCII-art-based graphical elements. Works well on older terminals. /// ASCII-art-based graphical elements. Works well on older terminals.
pub fn ascii() -> Self { pub fn ascii() -> Self {
Self { Self {
@ -231,10 +255,9 @@ impl ThemeCharacters {
rcross: '|', rcross: '|',
underbar: '|', underbar: '|',
underline: '^', underline: '^',
fyi: "help:".into(), error: "x".into(),
x: 'x', warning: "!".into(),
warning: '!', advice: ">".into(),
point_right: '>',
} }
} }
} }