mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
cleanup
This commit is contained in:
parent
51a3c72424
commit
05db8c0a48
1 changed files with 39 additions and 41 deletions
|
@ -219,36 +219,6 @@ pub const UNDERLINE_CODE: &str = "\u{001b}[4m";
|
||||||
|
|
||||||
pub const RESET_CODE: &str = "\u{001b}[0m";
|
pub const RESET_CODE: &str = "\u{001b}[0m";
|
||||||
|
|
||||||
pub struct CiWrite<W> {
|
|
||||||
style_stack: Vec<Annotation>,
|
|
||||||
upstream: W,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<W> CiWrite<W> {
|
|
||||||
pub fn new(upstream: W) -> CiWrite<W> {
|
|
||||||
CiWrite {
|
|
||||||
style_stack: vec![],
|
|
||||||
upstream,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ColorWrite<'a, W> {
|
|
||||||
style_stack: Vec<Annotation>,
|
|
||||||
palette: &'a Palette<'a>,
|
|
||||||
upstream: W,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, W> ColorWrite<'a, W> {
|
|
||||||
pub fn new(palette: &'a Palette, upstream: W) -> ColorWrite<'a, W> {
|
|
||||||
ColorWrite {
|
|
||||||
style_stack: vec![],
|
|
||||||
palette,
|
|
||||||
upstream,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub enum Annotation {
|
pub enum Annotation {
|
||||||
Emphasized,
|
Emphasized,
|
||||||
|
@ -270,6 +240,38 @@ pub enum Annotation {
|
||||||
Module,
|
Module,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Render with minimal formatting
|
||||||
|
pub struct CiWrite<W> {
|
||||||
|
style_stack: Vec<Annotation>,
|
||||||
|
upstream: W,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<W> CiWrite<W> {
|
||||||
|
pub fn new(upstream: W) -> CiWrite<W> {
|
||||||
|
CiWrite {
|
||||||
|
style_stack: vec![],
|
||||||
|
upstream,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Render with fancy formatting
|
||||||
|
pub struct ColorWrite<'a, W> {
|
||||||
|
style_stack: Vec<Annotation>,
|
||||||
|
palette: &'a Palette<'a>,
|
||||||
|
upstream: W,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, W> ColorWrite<'a, W> {
|
||||||
|
pub fn new(palette: &'a Palette, upstream: W) -> ColorWrite<'a, W> {
|
||||||
|
ColorWrite {
|
||||||
|
style_stack: vec![],
|
||||||
|
palette,
|
||||||
|
upstream,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<W> Render for CiWrite<W>
|
impl<W> Render for CiWrite<W>
|
||||||
where
|
where
|
||||||
W: fmt::Write,
|
W: fmt::Write,
|
||||||
|
@ -392,9 +394,7 @@ where
|
||||||
Module => {
|
Module => {
|
||||||
self.write_str(self.palette.module_name)?;
|
self.write_str(self.palette.module_name)?;
|
||||||
}
|
}
|
||||||
GlobalTag | PrivateTag | RecordField | Keyword => {
|
GlobalTag | PrivateTag | RecordField | Keyword => { /* nothing yet */ }
|
||||||
self.write_str("`")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.style_stack.push(*annotation);
|
self.style_stack.push(*annotation);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -411,9 +411,7 @@ where
|
||||||
self.write_str(RESET_CODE)?;
|
self.write_str(RESET_CODE)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalTag | PrivateTag | RecordField | Keyword => {
|
GlobalTag | PrivateTag | RecordField | Keyword => { /* nothing yet */ }
|
||||||
self.write_str("`")?;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -477,18 +475,18 @@ impl ReportText {
|
||||||
use ReportText::*;
|
use ReportText::*;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
|
Url(url) => alloc.text(url.into_string()).annotate(Annotation::Url),
|
||||||
Plain(string) => alloc
|
Plain(string) => alloc
|
||||||
.text(format!("{}", string))
|
.text(string.into_string())
|
||||||
.annotate(Annotation::PlainText),
|
.annotate(Annotation::PlainText),
|
||||||
EmText(string) => alloc
|
EmText(string) => alloc
|
||||||
.text(format!("{}", string))
|
.text(string.into_string())
|
||||||
.annotate(Annotation::Emphasized),
|
.annotate(Annotation::Emphasized),
|
||||||
Url(url) => alloc.text(format!("{}", url)).annotate(Annotation::Url),
|
|
||||||
Keyword(string) => alloc
|
Keyword(string) => alloc
|
||||||
.text(format!("{}", string))
|
.text(string.into_string())
|
||||||
.annotate(Annotation::Keyword),
|
.annotate(Annotation::Keyword),
|
||||||
GlobalTag(string) => alloc
|
GlobalTag(string) => alloc
|
||||||
.text(format!("{}", string))
|
.text(string.into_string())
|
||||||
.annotate(Annotation::GlobalTag),
|
.annotate(Annotation::GlobalTag),
|
||||||
RecordField(string) => alloc
|
RecordField(string) => alloc
|
||||||
.text(format!(".{}", string))
|
.text(format!(".{}", string))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue