1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-01 00:35:46 +03:00

vttest: respect dec auto wrap mode

refs: https://github.com/wez/wezterm/issues/133
This commit is contained in:
Wez Furlong 2020-01-25 20:41:53 -08:00
parent 2de60e3791
commit 1bb39835c0
2 changed files with 30 additions and 7 deletions

View File

@ -1062,22 +1062,18 @@ impl TerminalState {
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::AutoWrap)) => { Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::AutoWrap)) => {
self.dec_auto_wrap = true; self.dec_auto_wrap = true;
log::error!("dec_auto_wrap -> {}", self.dec_auto_wrap);
} }
Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::AutoWrap)) => { Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::AutoWrap)) => {
self.dec_auto_wrap = false; self.dec_auto_wrap = false;
log::error!("dec_auto_wrap -> {}", self.dec_auto_wrap);
} }
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::OriginMode)) => { Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::OriginMode)) => {
self.dec_origin_mode = true; self.dec_origin_mode = true;
log::error!("dec_origin_mode -> {}", self.dec_origin_mode);
} }
Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::OriginMode)) => { Mode::ResetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::OriginMode)) => {
self.dec_origin_mode = false; self.dec_origin_mode = false;
log::error!("dec_origin_mode -> {}", self.dec_origin_mode);
} }
Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::SmoothScroll)) Mode::SetDecPrivateMode(DecPrivateMode::Code(DecPrivateModeCode::SmoothScroll))
@ -1670,7 +1666,7 @@ impl<'a> Performer<'a> {
self.cursor.x += print_width; self.cursor.x += print_width;
self.wrap_next = false; self.wrap_next = false;
} else { } else {
self.wrap_next = true; self.wrap_next = self.dec_auto_wrap;
} }
} }
} }

View File

@ -107,10 +107,14 @@ impl TestTerm {
let clip: Arc<dyn Clipboard> = Arc::new(LocalClip::new()); let clip: Arc<dyn Clipboard> = Arc::new(LocalClip::new());
term.set_clipboard(&clip); term.set_clipboard(&clip);
Self { let mut term = Self {
term, term,
host: TestHost::new(), host: TestHost::new(),
} };
term.set_auto_wrap(true);
term
} }
fn print<B: AsRef<[u8]>>(&mut self, bytes: B) { fn print<B: AsRef<[u8]>>(&mut self, bytes: B) {
@ -124,6 +128,10 @@ impl TestTerm {
self.print(if enable { b"h" } else { b"l" }); self.print(if enable { b"h" } else { b"l" });
} }
fn set_auto_wrap(&mut self, enable: bool) {
self.set_mode("?7", enable);
}
#[allow(dead_code)] #[allow(dead_code)]
fn set_scroll_region(&mut self, top: usize, bottom: usize) { fn set_scroll_region(&mut self, top: usize, bottom: usize) {
self.print(CSI); self.print(CSI);
@ -326,6 +334,25 @@ fn assert_all_contents(term: &Terminal, file: &str, line: u32, expect_lines: &[&
fn basic_output() { fn basic_output() {
let mut term = TestTerm::new(5, 10, 0); let mut term = TestTerm::new(5, 10, 0);
term.cup(1, 1);
term.set_auto_wrap(false);
term.print("hello, world!");
assert_visible_contents(
&term,
file!(),
line!(),
&[
" ",
" hello, w!",
" ",
" ",
" ",
],
);
term.set_auto_wrap(true);
term.erase_in_display(EraseInDisplay::EraseToStartOfDisplay);
term.cup(1, 1); term.cup(1, 1);
term.print("hello, world!"); term.print("hello, world!");
assert_visible_contents( assert_visible_contents(