Skip to content

Commit

Permalink
Merge commit '059d54af4e47f1d16be7ee637ac5e5f4c99c269f'
Browse files Browse the repository at this point in the history
  • Loading branch information
jgardona committed Jan 10, 2024
2 parents 996e763 + 059d54a commit f843ca6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions examples/256color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
io::{Read, Seek},
};

use ansistream::{FC_WHITE, FC_BLACK};
use ansistream::{FC_BLACK, FC_WHITE};

fn flush<R: Read + Seek, W: Write>(reader: &mut R, writer: &mut W) -> std::io::Result<()> {
reader.seek(std::io::SeekFrom::Start(0))?;
Expand All @@ -30,7 +30,6 @@ fn main() -> std::io::Result<()> {
astream.write_text_bc256_fmt(ie, format_args!("{ie:<4}"))?;
}

astream.reset_all_attributes()?;
astream.write_string("\n\nPrinting 256 color:\n\n")?;

let mut fg = 0;
Expand All @@ -39,7 +38,6 @@ fn main() -> std::io::Result<()> {
if i != 0 {
if i % 18 == 0 {
fg = 0;
astream.reset_all_attributes()?;
writeln!(&mut *astream)?;
}
if i % 36 == 0 {
Expand All @@ -50,7 +48,6 @@ fn main() -> std::io::Result<()> {
astream.write_text_bc256_fmt(v, format_args!("{v:<4}"))?;
}

astream.reset_all_attributes()?;
astream.write_string("\n\nPrinting gray color:\n\n")?;

for i in 0..=23 {
Expand All @@ -64,7 +61,6 @@ fn main() -> std::io::Result<()> {
astream.write_text_fc(fg, "")?;
astream.write_text_bc256_fmt(ie, format_args!("{ie:<4}"))?;
}

flush(&mut *astream, &mut stdout)?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion examples/truecolor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> io::Result<()> {
}
astream.write_text_fc(FC_DARK_GRAY, "")?;
let (r, g, b) = hex2rgb(c);
astream.write_text_bcrgb_fmt(r, g, b, format_args!("{c:#06x}"))?;
astream.write_text_bcrgb_fmt(r, g, b, format_args!(" {c:#06x} "))?;
}

astream.reset_all_attributes()?;
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl AnsiEscapeStream {
BC_RICH_COLORS => self.write_attribute(BC_DEFAULT)?,
30..=37 | 90..=97 => self.write_attribute(FC_DEFAULT)?,
40..=47 | 100..=107 => self.write_attribute(BC_DEFAULT)?,
_ => panic!("code not implemented"),
_ => self.write_attribute(TS_DEFAULT)?,
};

Ok(())
Expand Down Expand Up @@ -299,7 +299,7 @@ impl AnsiEscapeStream {
self.buffer.write_all(&[ESC])?;
write!(self.buffer, "[{FC_RICH_COLORS};2;{r};{g};{b}m{text}")?;
if !text.is_empty() {
self.reset_attribute(FC_BLACK)?;
self.reset_attribute(FC_RICH_COLORS)?;
}
Ok(())
}
Expand All @@ -325,7 +325,7 @@ impl AnsiEscapeStream {
self.buffer.write_all(&[ESC])?;
write!(self.buffer, "[{BC_RICH_COLORS};2;{r};{g};{b}m{text}")?;
if !text.is_empty() {
self.reset_attribute(BC_BLACK)?;
self.reset_attribute(BC_RICH_COLORS)?;
}
Ok(())
}
Expand Down

0 comments on commit f843ca6

Please sign in to comment.