Render ellipses in a different color

This commit is contained in:
Richard Feldman 2023-01-10 01:36:58 -05:00
parent d9a582e447
commit 92f94a00b4
No known key found for this signature in database
GPG Key ID: F1F21AA5B1D9E43B
2 changed files with 16 additions and 4 deletions

View File

@ -3701,7 +3701,9 @@ mod report_text {
if fields_ommitted == 0 {
alloc.text("{}")
} else {
alloc.text("{ … }")
alloc
.text("{ ")
.append(alloc.ellipsis().append(alloc.text(" }")))
}
.append(ext_doc)
} else if entries.len() == 1 && fields_ommitted == 0 {
@ -3715,7 +3717,7 @@ mod report_text {
alloc.reflow("}")
} else {
alloc.vcat([
alloc.text("").indent(super::RECORD_FIELD_INDENT),
alloc.ellipsis().indent(super::RECORD_FIELD_INDENT),
alloc.reflow("}"),
])
};

View File

@ -183,6 +183,7 @@ pub struct Palette {
pub primary: &'static str,
pub code_block: &'static str,
pub keyword: &'static str,
pub ellipsis: &'static str,
pub variable: &'static str,
pub type_variable: &'static str,
pub structure: &'static str,
@ -209,6 +210,7 @@ const fn default_palette_from_style_codes(codes: StyleCodes) -> Palette {
primary: codes.white,
code_block: codes.white,
keyword: codes.green,
ellipsis: codes.green,
variable: codes.blue,
type_variable: codes.yellow,
structure: codes.green,
@ -359,6 +361,10 @@ impl<'a> RocDocAllocator<'a> {
self.text(string).annotate(Annotation::Keyword)
}
pub fn ellipsis(&'a self) -> DocBuilder<'a, Self, Annotation> {
self.text("").annotate(Annotation::Ellipsis)
}
pub fn parser_suggestion(&'a self, string: &'a str) -> DocBuilder<'a, Self, Annotation> {
self.text(string).annotate(Annotation::ParserSuggestion)
}
@ -811,6 +817,7 @@ pub enum Annotation {
Emphasized,
Url,
Keyword,
Ellipsis,
Tag,
RecordField,
TypeVariable,
@ -1009,6 +1016,9 @@ where
Keyword => {
self.write_str(self.palette.keyword)?;
}
Ellipsis => {
self.write_str(self.palette.ellipsis)?;
}
GutterBar => {
self.write_str(self.palette.gutter_bar)?;
}
@ -1049,8 +1059,8 @@ where
None => {}
Some(annotation) => match annotation {
Emphasized | Url | TypeVariable | Alias | Symbol | BinOp | Error | GutterBar
| Typo | TypoSuggestion | ParserSuggestion | Structure | CodeBlock | PlainText
| LineNumber | Tip | Module | Header | Keyword => {
| Ellipsis | Typo | TypoSuggestion | ParserSuggestion | Structure | CodeBlock
| PlainText | LineNumber | Tip | Module | Header | Keyword => {
self.write_str(self.palette.reset)?;
}