Improve field names

This commit is contained in:
Brendan Zabarauskas
2019-06-24 10:54:11 +10:00
parent a06fee31a3
commit 95a07380d1
2 changed files with 23 additions and 15 deletions
+17 -9
View File
@@ -13,21 +13,24 @@ pub struct Config {
pub tab_width: usize,
/// Styles to use when rendering the diagnostic.
pub styles: Styles,
/// The character to use for the top-left corner of the source.
/// The character to use for the top-left border of the source.
/// Defaults to: `'┌'`.
pub border_top_left_char: char,
pub source_border_top_left_char: char,
/// The character to use for the top border of the source.
/// Defaults to: `'─'`.
pub border_top_char: char,
pub source_border_top_char: char,
/// The character to use for the left border of the source.
/// Defaults to: `'│'`.
pub border_left_char: char,
pub source_border_left_char: char,
/// The character to use for marking a primary label.
/// Defaults to: `'^'`.
pub primary_caret_char: char,
/// The character to use for marking a secondary label.
/// Defaults to: `'-'`.
pub secondary_caret_char: char,
/// The character to use for marking the ends of a multi-line primary label.
/// Defaults to: `'^'`.
pub multiline_primary_caret_char: char,
@@ -49,6 +52,7 @@ pub struct Config {
/// The character to use for the left of a multi-line label.
/// Defaults to: `'│'`.
pub multiline_left_char: char,
/// The character to use for the note bullet.
/// Defaults to: `'='`.
pub note_bullet_char: char,
@@ -60,11 +64,14 @@ impl Default for Config {
display_style: DisplayStyle::Rich,
tab_width: 4,
styles: Styles::default(),
border_top_left_char: '',
border_top_char: '',
border_left_char: '',
source_border_top_left_char: '',
source_border_top_char: '',
source_border_left_char: '',
primary_caret_char: '^',
secondary_caret_char: '-',
multiline_primary_caret_char: '^',
multiline_secondary_caret_char: '\'',
multiline_top_left_char: '',
@@ -72,6 +79,7 @@ impl Default for Config {
multiline_bottom_left_char: '',
multiline_bottom_char: '',
multiline_left_char: '',
note_bullet_char: '=',
}
}
@@ -167,7 +175,7 @@ pub struct Styles {
pub line_number: ColorSpec,
/// The style to use when rendering the source code borders.
/// Defaults `fg:blue` (or `fg:cyan` on windows).
pub border: ColorSpec,
pub source_border: ColorSpec,
/// The style to use when rendering the note bullets.
/// Defaults `fg:blue` (or `fg:cyan` on windows).
pub note_bullet: ColorSpec,
@@ -223,7 +231,7 @@ impl Default for Styles {
secondary_label: ColorSpec::new().set_fg(Some(BLUE)).clone(),
line_number: ColorSpec::new().set_fg(Some(BLUE)).clone(),
border: ColorSpec::new().set_fg(Some(BLUE)).clone(),
source_border: ColorSpec::new().set_fg(Some(BLUE)).clone(),
note_bullet: ColorSpec::new().set_fg(Some(BLUE)).clone(),
}
}
@@ -12,8 +12,8 @@ impl BorderTopLeft {
}
pub fn emit(&self, writer: &mut impl WriteColor, config: &Config) -> io::Result<()> {
writer.set_color(&config.styles.border)?;
write!(writer, "{top_left}", top_left = config.border_top_left_char)?;
writer.set_color(&config.styles.source_border)?;
write!(writer, "{top_left}", top_left = config.source_border_top_left_char)?;
writer.reset()?;
Ok(())
@@ -31,9 +31,9 @@ impl BorderTop {
}
pub fn emit(&self, writer: &mut impl WriteColor, config: &Config) -> io::Result<()> {
writer.set_color(&config.styles.border)?;
writer.set_color(&config.styles.source_border)?;
for _ in 0..self.width {
write!(writer, "{top}", top = config.border_top_char)?
write!(writer, "{top}", top = config.source_border_top_char)?
}
writer.reset()?;
@@ -50,8 +50,8 @@ impl BorderLeft {
}
pub fn emit(&self, writer: &mut impl WriteColor, config: &Config) -> io::Result<()> {
writer.set_color(&config.styles.border)?;
write!(writer, "{left}", left = config.border_left_char)?;
writer.set_color(&config.styles.source_border)?;
write!(writer, "{left}", left = config.source_border_left_char)?;
writer.reset()?;
Ok(())