use highlighting::Style;
use std::fmt::Write;
use parsing::ScopeStackOp;
pub fn as_24_bit_terminal_escaped(v: &[(Style, &str)], bg: bool) -> String {
let mut s: String = String::new();
for &(ref style, text) in v.iter() {
if bg {
write!(s,
"\x1b[48;2;{};{};{}m",
style.background.r,
style.background.g,
style.background.b)
.unwrap();
}
write!(s,
"\x1b[38;2;{};{};{}m{}",
style.foreground.r,
style.foreground.g,
style.foreground.b,
text)
.unwrap();
}
s
}
pub fn debug_print_ops(line: &str, ops: &Vec<(usize, ScopeStackOp)>) {
for &(i, ref op) in ops.iter() {
println!("{}", line);
print!("{: <1$}", "", i);
match op {
&ScopeStackOp::Push(s) => {
println!("^ +{}", s);
}
&ScopeStackOp::Pop(count) => {
println!("^ pop {}", count);
}
&ScopeStackOp::Noop => println!("noop"),
}
}
}