mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-17 22:58:08 -05:00
Deduplicate code for printing keys
This commit is contained in:
parent
ea85c1b46e
commit
e8c2a79516
1 changed files with 12 additions and 26 deletions
|
@ -177,39 +177,25 @@ impl<'a> WatchState<'a> {
|
||||||
stdout.write_all(b" / ")?;
|
stdout.write_all(b" / ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.manual_run {
|
let mut show_key = |key, postfix| {
|
||||||
stdout.queue(SetAttribute(Attribute::Bold))?;
|
stdout.queue(SetAttribute(Attribute::Bold))?;
|
||||||
stdout.write_all(b"r")?;
|
stdout.write_all(&[key])?;
|
||||||
stdout.queue(ResetColor)?;
|
stdout.queue(ResetColor)?;
|
||||||
stdout.write_all(b":run / ")?;
|
stdout.write_all(postfix)
|
||||||
|
};
|
||||||
|
|
||||||
|
if self.manual_run {
|
||||||
|
show_key(b'r', b":run / ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.show_hint {
|
if !self.show_hint {
|
||||||
stdout.queue(SetAttribute(Attribute::Bold))?;
|
show_key(b'h', b":hint / ")?;
|
||||||
stdout.write_all(b"h")?;
|
|
||||||
stdout.queue(ResetColor)?;
|
|
||||||
stdout.write_all(b":hint / ")?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout.queue(SetAttribute(Attribute::Bold))?;
|
show_key(b'l', b":list / ")?;
|
||||||
stdout.write_all(b"l")?;
|
show_key(b'c', b":check all / ")?;
|
||||||
stdout.queue(ResetColor)?;
|
show_key(b'x', b":reset / ")?;
|
||||||
stdout.write_all(b":list / ")?;
|
show_key(b'q', b":quit ? ")?;
|
||||||
|
|
||||||
stdout.queue(SetAttribute(Attribute::Bold))?;
|
|
||||||
stdout.write_all(b"c")?;
|
|
||||||
stdout.queue(ResetColor)?;
|
|
||||||
stdout.write_all(b":check all / ")?;
|
|
||||||
|
|
||||||
stdout.queue(SetAttribute(Attribute::Bold))?;
|
|
||||||
stdout.write_all(b"x")?;
|
|
||||||
stdout.queue(ResetColor)?;
|
|
||||||
stdout.write_all(b":reset / ")?;
|
|
||||||
|
|
||||||
stdout.queue(SetAttribute(Attribute::Bold))?;
|
|
||||||
stdout.write_all(b"q")?;
|
|
||||||
stdout.queue(ResetColor)?;
|
|
||||||
stdout.write_all(b":quit ? ")?;
|
|
||||||
|
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue