Fix line lengths in terminfo

This commit is contained in:
Kevin Ballard 2013-06-14 13:02:24 -07:00
parent f31767df66
commit da4e614742
2 changed files with 12 additions and 6 deletions

View file

@ -105,7 +105,8 @@ impl Terminal {
}
pub fn reset(&self) {
if self.color_supported {
let s = expand(*self.ti.strings.find_equiv(&("op")).unwrap(), [], &mut Variables::new());
let mut vars = Variables::new();
let s = expand(*self.ti.strings.find_equiv(&("op")).unwrap(), [], &mut vars);
if s.is_ok() {
self.out.write(s.get());
} else {

View file

@ -176,19 +176,22 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
} else { return Err(~"stack is empty") },
'=' => if stack.len() > 1 {
match (stack.pop(), stack.pop()) {
(Number(y), Number(x)) => stack.push(Number(if x == y { 1 } else { 0 })),
(Number(y), Number(x)) => stack.push(Number(if x == y { 1 }
else { 0 })),
_ => return Err(~"non-numbers on stack with =")
}
} else { return Err(~"stack is empty") },
'>' => if stack.len() > 1 {
match (stack.pop(), stack.pop()) {
(Number(y), Number(x)) => stack.push(Number(if x > y { 1 } else { 0 })),
(Number(y), Number(x)) => stack.push(Number(if x > y { 1 }
else { 0 })),
_ => return Err(~"non-numbers on stack with >")
}
} else { return Err(~"stack is empty") },
'<' => if stack.len() > 1 {
match (stack.pop(), stack.pop()) {
(Number(y), Number(x)) => stack.push(Number(if x < y { 1 } else { 0 })),
(Number(y), Number(x)) => stack.push(Number(if x < y { 1 }
else { 0 })),
_ => return Err(~"non-numbers on stack with <")
}
} else { return Err(~"stack is empty") },
@ -353,12 +356,14 @@ mod test {
#[test]
fn test_basic_setabf() {
let s = bytes!("\\E[48;5;%p1%dm");
assert_eq!(expand(s, [Number(1)], &mut Variables::new()).unwrap(), bytes!("\\E[48;5;1m").to_owned());
assert_eq!(expand(s, [Number(1)], &mut Variables::new()).unwrap(),
bytes!("\\E[48;5;1m").to_owned());
}
#[test]
fn test_multiple_int_constants() {
assert_eq!(expand(bytes!("%{1}%{2}%d%d"), [], &mut Variables::new()).unwrap(), bytes!("21").to_owned());
assert_eq!(expand(bytes!("%{1}%{2}%d%d"), [], &mut Variables::new()).unwrap(),
bytes!("21").to_owned());
}
#[test]