Skip to content

Commit 285b7ce

Browse files
authored
Merge pull request #278 from Muscraft/fix-partial-rename
fix!: Rename Renderer::theme to decor_style
2 parents 6d2bd94 + 98db20f commit 285b7ce

File tree

6 files changed

+53
-53
lines changed

6 files changed

+53
-53
lines changed

examples/custom_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ pub static C: u32 = 0 - 1;
2929
),
3030
)];
3131

32-
let renderer = Renderer::styled().theme(DecorStyle::Unicode);
32+
let renderer = Renderer::styled().decor_style(DecorStyle::Unicode);
3333
anstream::println!("{}", renderer.render(message));
3434
}

examples/custom_level.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ fn main() {
6363
),
6464
];
6565

66-
let renderer = Renderer::styled().theme(DecorStyle::Unicode);
66+
let renderer = Renderer::styled().decor_style(DecorStyle::Unicode);
6767
anstream::println!("{}", renderer.render(message));
6868
}

examples/id_hyperlink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ fn main() {
2929
),
3030
)];
3131

32-
let renderer = Renderer::styled().theme(DecorStyle::Unicode);
32+
let renderer = Renderer::styled().decor_style(DecorStyle::Unicode);
3333
anstream::println!("{}", renderer.render(message));
3434
}

src/renderer/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub const DEFAULT_TERM_WIDTH: usize = 140;
6767
pub struct Renderer {
6868
anonymized_line_numbers: bool,
6969
term_width: usize,
70-
theme: DecorStyle,
70+
decor_style: DecorStyle,
7171
stylesheet: Stylesheet,
7272
short_message: bool,
7373
}
@@ -78,7 +78,7 @@ impl Renderer {
7878
Self {
7979
anonymized_line_numbers: false,
8080
term_width: DEFAULT_TERM_WIDTH,
81-
theme: DecorStyle::Ascii,
81+
decor_style: DecorStyle::Ascii,
8282
stylesheet: Stylesheet::plain(),
8383
short_message: false,
8484
}
@@ -153,8 +153,8 @@ impl Renderer {
153153
self
154154
}
155155

156-
pub const fn theme(mut self, output_theme: DecorStyle) -> Self {
157-
self.theme = output_theme;
156+
pub const fn decor_style(mut self, decor_style: DecorStyle) -> Self {
157+
self.decor_style = decor_style;
158158
self
159159
}
160160

@@ -606,7 +606,7 @@ impl Renderer {
606606
buffer.append(buffer_msg_line_offset + i, &padding, ElementStyle::NoStyle);
607607
if title_style == TitleStyle::Secondary
608608
&& is_cont
609-
&& matches!(self.theme, DecorStyle::Unicode)
609+
&& matches!(self.decor_style, DecorStyle::Unicode)
610610
{
611611
// There's another note after this one, associated to the subwindow above.
612612
// We write additional vertical lines to join them:
@@ -765,7 +765,7 @@ impl Renderer {
765765
} else {
766766
let buffer_msg_line_offset = buffer.num_lines();
767767
if is_primary {
768-
if self.theme == DecorStyle::Unicode {
768+
if self.decor_style == DecorStyle::Unicode {
769769
buffer.puts(
770770
buffer_msg_line_offset,
771771
max_line_num_len,
@@ -2330,7 +2330,7 @@ impl Renderer {
23302330
depth: usize,
23312331
style: ElementStyle,
23322332
) {
2333-
let chr = match (style, self.theme) {
2333+
let chr = match (style, self.decor_style) {
23342334
(ElementStyle::UnderlinePrimary | ElementStyle::LabelPrimary, DecorStyle::Ascii) => '|',
23352335
(_, DecorStyle::Ascii) => '|',
23362336
(ElementStyle::UnderlinePrimary | ElementStyle::LabelPrimary, DecorStyle::Unicode) => {
@@ -2342,14 +2342,14 @@ impl Renderer {
23422342
}
23432343

23442344
fn col_separator(&self) -> char {
2345-
match self.theme {
2345+
match self.decor_style {
23462346
DecorStyle::Ascii => '|',
23472347
DecorStyle::Unicode => '│',
23482348
}
23492349
}
23502350

23512351
fn multi_suggestion_separator(&self) -> &'static str {
2352-
match self.theme {
2352+
match self.decor_style {
23532353
DecorStyle::Ascii => "|",
23542354
DecorStyle::Unicode => "├╴",
23552355
}
@@ -2372,7 +2372,7 @@ impl Renderer {
23722372
}
23732373

23742374
fn draw_col_separator_start(&self, buffer: &mut StyledBuffer, line: usize, col: usize) {
2375-
match self.theme {
2375+
match self.decor_style {
23762376
DecorStyle::Ascii => {
23772377
self.draw_col_separator_no_space_with_style(
23782378
buffer,
@@ -2402,7 +2402,7 @@ impl Renderer {
24022402
}
24032403

24042404
fn draw_col_separator_end(&self, buffer: &mut StyledBuffer, line: usize, col: usize) {
2405-
match self.theme {
2405+
match self.decor_style {
24062406
DecorStyle::Ascii => {
24072407
self.draw_col_separator_no_space_with_style(
24082408
buffer,
@@ -2454,15 +2454,15 @@ impl Renderer {
24542454
}
24552455

24562456
fn file_start(&self, is_first: bool) -> &'static str {
2457-
match self.theme {
2457+
match self.decor_style {
24582458
DecorStyle::Ascii => "--> ",
24592459
DecorStyle::Unicode if is_first => " ╭▸ ",
24602460
DecorStyle::Unicode => " ├▸ ",
24612461
}
24622462
}
24632463

24642464
fn secondary_file_start(&self) -> &'static str {
2465-
match self.theme {
2465+
match self.decor_style {
24662466
DecorStyle::Ascii => "::: ",
24672467
DecorStyle::Unicode => " ⸬ ",
24682468
}
@@ -2475,7 +2475,7 @@ impl Renderer {
24752475
col: usize,
24762476
is_cont: bool,
24772477
) {
2478-
let chr = match self.theme {
2478+
let chr = match self.decor_style {
24792479
DecorStyle::Ascii => "= ",
24802480
DecorStyle::Unicode if is_cont => "├ ",
24812481
DecorStyle::Unicode => "╰ ",
@@ -2484,22 +2484,22 @@ impl Renderer {
24842484
}
24852485

24862486
fn diff(&self) -> char {
2487-
match self.theme {
2487+
match self.decor_style {
24882488
DecorStyle::Ascii => '~',
24892489
DecorStyle::Unicode => '±',
24902490
}
24912491
}
24922492

24932493
fn draw_line_separator(&self, buffer: &mut StyledBuffer, line: usize, col: usize) {
2494-
let (column, dots) = match self.theme {
2494+
let (column, dots) = match self.decor_style {
24952495
DecorStyle::Ascii => (0, "..."),
24962496
DecorStyle::Unicode => (col - 2, "‡"),
24972497
};
24982498
buffer.puts(line, column, dots, ElementStyle::LineNumber);
24992499
}
25002500

25012501
fn margin(&self) -> &'static str {
2502-
match self.theme {
2502+
match self.decor_style {
25032503
DecorStyle::Ascii => "...",
25042504
DecorStyle::Unicode => "…",
25052505
}
@@ -2530,7 +2530,7 @@ impl Renderer {
25302530
// ┃ ╿ < multiline_end_up
25312531
// ┗━━┛ < bottom_right
25322532

2533-
match (self.theme, is_primary) {
2533+
match (self.decor_style, is_primary) {
25342534
(DecorStyle::Ascii, true) => UnderlineParts {
25352535
style: ElementStyle::UnderlinePrimary,
25362536
underline: '^',

tests/formatter.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ error: bad
472472
╰╴━
473473
"#]];
474474

475-
let renderer = renderer.theme(DecorStyle::Unicode);
475+
let renderer = renderer.decor_style(DecorStyle::Unicode);
476476
assert_data_eq!(renderer.render(message), expected_unicode);
477477
}
478478

@@ -1747,7 +1747,7 @@ LL │ type Error = E;
17471747
"#]];
17481748
let renderer = Renderer::plain()
17491749
.term_width(40)
1750-
.theme(DecorStyle::Unicode)
1750+
.decor_style(DecorStyle::Unicode)
17511751
.anonymized_line_numbers(true);
17521752
assert_data_eq!(renderer.render(input_new), expected);
17531753
}
@@ -1835,7 +1835,7 @@ LL │ type Error = E;
18351835
"#]];
18361836
let renderer = Renderer::plain()
18371837
.term_width(40)
1838-
.theme(DecorStyle::Unicode)
1838+
.decor_style(DecorStyle::Unicode)
18391839
.anonymized_line_numbers(true);
18401840
assert_data_eq!(renderer.render(input_new), expected);
18411841
}
@@ -1996,7 +1996,7 @@ LL │ ┃ )))))))))))))))))))))))))))))];
19961996
"#]];
19971997
let renderer = Renderer::plain()
19981998
.term_width(60)
1999-
.theme(DecorStyle::Unicode)
1999+
.decor_style(DecorStyle::Unicode)
20002000
.anonymized_line_numbers(true);
20012001
assert_data_eq!(renderer.render(input_new), expected);
20022002
}
@@ -2076,7 +2076,7 @@ LL │ ┃ )>>) {}
20762076
╰╴┗━━━┛
20772077
"#]];
20782078
let renderer = Renderer::plain()
2079-
.theme(DecorStyle::Unicode)
2079+
.decor_style(DecorStyle::Unicode)
20802080
.anonymized_line_numbers(true);
20812081
assert_data_eq!(renderer.render(input_new), expected);
20822082
}
@@ -2122,7 +2122,7 @@ error: title
21222122
5 │ ┃ ]
21232123
╰╴┗━┛ annotation
21242124
"#]];
2125-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2125+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
21262126
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
21272127
}
21282128

@@ -2159,7 +2159,7 @@ error: expected item, found `?`
21592159
21602160
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
21612161
"#]];
2162-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2162+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
21632163
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
21642164
}
21652165

@@ -2196,7 +2196,7 @@ error: expected item, found `?`
21962196
21972197
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
21982198
"#]];
2199-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2199+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
22002200
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
22012201
}
22022202

@@ -2233,7 +2233,7 @@ error: expected item, found `?`
22332233
22342234
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
22352235
"#]];
2236-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2236+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
22372237
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
22382238
}
22392239

@@ -2285,7 +2285,7 @@ LL │ …♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻
22852285
│ │
22862286
╰╴ expected due to this
22872287
"#]];
2288-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2288+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
22892289
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
22902290
}
22912291

@@ -2368,7 +2368,7 @@ LL │ let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓
23682368
╰╴ +++++++++++
23692369
"#]];
23702370

2371-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2371+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
23722372
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
23732373
}
23742374

@@ -2432,7 +2432,7 @@ LL │ �|�␂!5�cc␕␂�Ӻi��WWj�ȥ�'�}�␒�J�ȉ��W
24322432
│ ━
24332433
╰ note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
24342434
"#]];
2435-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2435+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
24362436
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
24372437
}
24382438

@@ -2634,7 +2634,7 @@ LL - });
26342634
LL + break;
26352635
╰╴
26362636
"#]];
2637-
let renderer_unicode = renderer_ascii.theme(DecorStyle::Unicode);
2637+
let renderer_unicode = renderer_ascii.decor_style(DecorStyle::Unicode);
26382638
assert_data_eq!(renderer_unicode.render(input), expected_unicode);
26392639
}
26402640

@@ -2841,7 +2841,7 @@ error:
28412841
1 │ def __call__(self, *vals: bytes, maxlen: int | None = None) -> list[bytes]: ...
28422842
╰╴ ━━━━━━━━ annotation
28432843
"#]];
2844-
let renderer = Renderer::plain().theme(DecorStyle::Unicode);
2844+
let renderer = Renderer::plain().decor_style(DecorStyle::Unicode);
28452845
assert_data_eq!(renderer.render(input), expected_unicode);
28462846
}
28472847

@@ -2883,7 +2883,7 @@ error:
28832883
1 │ def __call__(self, *vals: bytes, maxlen: int | None = None) -> list[bytes]: ...
28842884
╰╴ ━━━━━━━━ annotation
28852885
"#]];
2886-
let renderer = Renderer::plain().theme(DecorStyle::Unicode);
2886+
let renderer = Renderer::plain().decor_style(DecorStyle::Unicode);
28872887
assert_data_eq!(renderer.render(input), expected_unicode);
28882888
}
28892889

@@ -2941,7 +2941,7 @@ LL │ .sum::<_>() //~ ERROR type annotations needed
29412941
│ ━━━ cannot infer type of the type parameter `S` declared on the method `sum`
29422942
╰╴
29432943
"#]];
2944-
let renderer = renderer.theme(DecorStyle::Unicode);
2944+
let renderer = renderer.decor_style(DecorStyle::Unicode);
29452945
assert_data_eq!(renderer.render(input), expected_unicode);
29462946
}
29472947

@@ -3018,7 +3018,7 @@ LL - .sum::<_>() //~ ERROR type annotations needed
30183018
LL + .sum::<GENERIC_ARG>() //~ ERROR type annotations needed
30193019
╰╴
30203020
"#]];
3021-
let renderer = renderer.theme(DecorStyle::Unicode);
3021+
let renderer = renderer.decor_style(DecorStyle::Unicode);
30223022
assert_data_eq!(renderer.render(input), expected_unicode);
30233023
}
30243024

@@ -3220,6 +3220,6 @@ error[E0609]: no field `field` on type `Thing`
32203220
LL │ t.field;
32213221
╰╴ ━━━━━ unknown field
32223222
"#]];
3223-
let renderer = renderer.theme(DecorStyle::Unicode);
3223+
let renderer = renderer.decor_style(DecorStyle::Unicode);
32243224
assert_data_eq!(renderer.render(input), expected_unicode);
32253225
}

0 commit comments

Comments
 (0)