We were incorrectly treating it as \r\n, but it should only have been moving vertically. This fixes the positioning of the cursor when using eg: `dialog --yesno hello 0 0` Without this change, the cursor would be way over to the left. With this change, the cursor is correctly positioned inside the "YES" box.
43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
//! Testing C0 control characters
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_bs() {
|
|
let mut term = TestTerm::new(3, 4, 0);
|
|
term.assert_cursor_pos(0, 0, None);
|
|
term.print("\x08");
|
|
term.assert_cursor_pos(0, 0, Some("cannot move left of the margin"));
|
|
term.print("ab\x08");
|
|
term.assert_cursor_pos(1, 0, None);
|
|
// TODO: when we can set the left margin, we should test that here
|
|
}
|
|
|
|
#[test]
|
|
fn test_lf() {
|
|
let mut term = TestTerm::new(3, 10, 0);
|
|
term.print("hello\n");
|
|
term.assert_cursor_pos(5, 1, Some("LF moves vertically only"));
|
|
}
|
|
|
|
#[test]
|
|
fn test_cr() {
|
|
let mut term = TestTerm::new(3, 10, 0);
|
|
term.print("hello\r");
|
|
term.assert_cursor_pos(0, 0, Some("CR moves to left margin on current line"));
|
|
// TODO: when we can set the left margin, we should test that here
|
|
}
|
|
|
|
#[test]
|
|
fn test_tab() {
|
|
let mut term = TestTerm::new(3, 25, 0);
|
|
term.print("\t");
|
|
term.assert_cursor_pos(8, 0, None);
|
|
term.print("\t");
|
|
term.assert_cursor_pos(16, 0, None);
|
|
term.print("\t");
|
|
term.assert_cursor_pos(24, 0, None);
|
|
term.print("\t");
|
|
term.assert_cursor_pos(24, 0, None);
|
|
}
|