Skip to content

Commit

Permalink
suiro: Add ng output
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jun 17, 2022
1 parent d355628 commit d85d7f5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions suiro/src/main.rs
Expand Up @@ -10,15 +10,12 @@ use self::point::Point;

use cursor::Cursor;
use std::io::{self, StdoutLock, Write};
use termion::{
input::TermRead,
raw::{IntoRawMode, RawTerminal},
};
use termion::{input::TermRead, raw::IntoRawMode};

fn print(stdout: &mut StdoutLock, area: &Area, cursor: Cursor) -> anyhow::Result<()> {
let w = area.width();
let h = area.height();
let (_, flow) = area.test();
let (ng, flow) = area.test();
for y in 0..h {
write!(stdout, "{}", termion::cursor::Goto(1, 1 + u16::from(y)))?;

Expand Down Expand Up @@ -60,6 +57,13 @@ fn print(stdout: &mut StdoutLock, area: &Area, cursor: Cursor) -> anyhow::Result
} else {
format!("{}", p)
};
if ng[usize::from(y) * usize::from(w) + usize::from(x)] {
let _ = write!(
stdout,
"{}",
termion::color::Fg(termion::color::Rgb(255, 0, 0))
)?;
}
let _ = stdout.write(
format!(
"{}{}",
Expand All @@ -74,6 +78,9 @@ fn print(stdout: &mut StdoutLock, area: &Area, cursor: Cursor) -> anyhow::Result
)
.as_bytes(),
)?;
if ng[usize::from(y) * usize::from(w) + usize::from(x)] {
let _ = write!(stdout, "{}", termion::color::Fg(termion::color::Reset))?;
}
}
}
Ok(())
Expand Down

0 comments on commit d85d7f5

Please sign in to comment.