1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00
This commit is contained in:
Autumn Lamonte 2021-07-09 17:56:23 -05:00 committed by Wez Furlong
parent d100dded23
commit e3f1d15f5d
4 changed files with 61 additions and 4 deletions

View File

@ -695,6 +695,26 @@ fn test_dec_special_graphics() {
);
}
/// Test double-width / double-height sequences.
#[test]
fn test_dec_double_width() {
let mut term = TestTerm::new(4, 50, 0);
term.print("\u{1b}#3line1\r\nline2\u{1b}#4\r\nli\u{1b}#6ne3\r\n\u{1b}#5line4");
assert_visible_contents(
&term,
file!(),
line!(),
&["line1", "line2", "line3", "line4"],
);
let lines = term.screen().visible_lines();
assert!(lines[0].is_double_height_top());
assert!(lines[1].is_double_height_bottom());
assert!(lines[2].is_double_width());
assert!(lines[3].is_single_width());
}
/// Test the behavior of wrapped lines when we resize the terminal
/// wider and then narrower.
#[test]

View File

@ -591,7 +591,7 @@ impl Display for Mode {
TerminalMode::Code(mode) => mode.to_u16().ok_or_else(|| FmtError)?,
TerminalMode::Unspecified(mode) => *mode,
};
write!(f, "?{}{}", value, $flag)
write!(f, "{}{}", value, $flag)
}};
}
match self {
@ -2443,6 +2443,22 @@ mod test {
);
}
#[test]
fn blinks() {
assert_eq!(
parse('m', &[5], "\x1b[5m"),
vec![CSI::Sgr(Sgr::Blink(Blink::Slow))]
);
assert_eq!(
parse('m', &[6], "\x1b[6m"),
vec![CSI::Sgr(Sgr::Blink(Blink::Rapid))]
);
assert_eq!(
parse('m', &[25], "\x1b[25m"),
vec![CSI::Sgr(Sgr::Blink(Blink::None))]
);
}
#[test]
fn underlines() {
assert_eq!(
@ -2603,6 +2619,22 @@ mod test {
);
}
#[test]
fn ansiset() {
assert_eq!(
parse('h', &[20], "\x1b[20h"),
vec![CSI::Mode(Mode::SetMode(TerminalMode::Code(
TerminalModeCode::AutomaticNewline
)))]
);
assert_eq!(
parse('l', &[20], "\x1b[20l"),
vec![CSI::Mode(Mode::ResetMode(TerminalMode::Code(
TerminalModeCode::AutomaticNewline
)))]
);
}
#[test]
fn mouse() {
let res: Vec<_> = CSI::parse(

View File

@ -192,5 +192,12 @@ mod test {
assert_eq!(parse("(B"), Esc::Code(EscCode::AsciiCharacterSetG0));
assert_eq!(parse(")0"), Esc::Code(EscCode::DecLineDrawingG1));
assert_eq!(parse(")B"), Esc::Code(EscCode::AsciiCharacterSetG1));
assert_eq!(parse("#3"), Esc::Code(EscCode::DecDoubleHeightTopHalfLine));
assert_eq!(
parse("#4"),
Esc::Code(EscCode::DecDoubleHeightBottomHalfLine)
);
assert_eq!(parse("#5"), Esc::Code(EscCode::DecSingleWidthLine));
assert_eq!(parse("#6"), Esc::Code(EscCode::DecDoubleWidthLine));
}
}

View File

@ -743,9 +743,7 @@ impl super::TermWindow {
let mut bg_default = bg_is_default;
// Check the line reverse_video flag and flip.
if (attrs.reverse() && !params.line.is_reverse())
|| (!attrs.reverse() && params.line.is_reverse())
{
if attrs.reverse() == !params.line.is_reverse() {
std::mem::swap(&mut fg, &mut bg);
bg_default = false;
}