fix line feed movement behavior

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.
This commit is contained in:
Wez Furlong committed 2019-03-22 22:14:17 -07:00
1 parent 49467515d6
commit fa9bf57e86
5 files changed
+13 -13

No files matched your search

+1 -1
View File
@@ -1938,7 +1938,7 @@ impl<'a> Performer<'a> {
self.flush_print();
match control {
ControlCode::LineFeed | ControlCode::VerticalTab | ControlCode::FormFeed => {
self.new_line(true /* TODO: depend on terminal mode */)
self.new_line(false)
}
ControlCode::CarriageReturn => {
self.set_cursor_pos(&Position::Absolute(0), &Position::Relative(0));
+1 -1
View File
@@ -17,7 +17,7 @@ fn test_bs() {
fn test_lf() {
let mut term = TestTerm::new(3, 10, 0);
term.print("hello\n");
term.assert_cursor_pos(0, 1, Some("LF moves to new line"));
term.assert_cursor_pos(5, 1, Some("LF moves vertically only"));
}
#[test]
+4 -4
View File
@@ -5,7 +5,7 @@ use super::*;
#[test]
fn test_ind() {
let mut term = TestTerm::new(4, 4, 0);
term.print("a\nb\x1bD");
term.print("a\r\nb\x1bD");
term.assert_cursor_pos(1, 2, None);
assert_visible_contents(&term, &["a ", "b ", " ", " "]);
term.print("\x1bD");
@@ -18,7 +18,7 @@ fn test_ind() {
#[test]
fn test_nel() {
let mut term = TestTerm::new(4, 4, 0);
term.print("a\nb\x1bE");
term.print("a\r\nb\x1bE");
term.assert_cursor_pos(0, 2, None);
term.print("\x1bE");
term.assert_cursor_pos(0, 3, None);
@@ -31,7 +31,7 @@ fn test_nel() {
fn test_hts() {
let mut term = TestTerm::new(3, 25, 0);
term.print("boo");
term.print("\x1bH\n");
term.print("\x1bH\r\n");
term.assert_cursor_pos(0, 1, None);
term.print("\t");
term.assert_cursor_pos(3, 1, None);
@@ -56,7 +56,7 @@ fn test_hts() {
#[test]
fn test_ri() {
let mut term = TestTerm::new(4, 2, 0);
term.print("a\nb\nc\nd.");
term.print("a\r\nb\r\nc\r\nd.");
assert_visible_contents(&term, &["a ", "b ", "c ", "d."]);
term.assert_cursor_pos(1, 3, None);
term.print("\x1bM");
+5 -5
View File
@@ -4,11 +4,11 @@ use super::*;
fn test_vpa() {
let mut term = TestTerm::new(3, 4, 0);
term.assert_cursor_pos(0, 0, None);
term.print("a\nb\nc");
term.print("a\r\nb\r\nc");
term.assert_cursor_pos(1, 2, None);
term.print("\x1b[d");
term.assert_cursor_pos(1, 0, None);
term.print("\n\n");
term.print("\r\n\r\n");
term.assert_cursor_pos(0, 2, None);
// escapes are 1-based, so check that we're handling that
@@ -114,7 +114,7 @@ fn test_hvp() {
#[test]
fn test_dl() {
let mut term = TestTerm::new(3, 1, 0);
term.print("a\nb\nc");
term.print("a\r\nb\r\nc");
term.cup(0, 1);
term.delete_lines(1);
assert_visible_contents(&term, &["a", "c", " "]);
@@ -122,7 +122,7 @@ fn test_dl() {
term.cup(0, 0);
term.delete_lines(2);
assert_visible_contents(&term, &[" ", " ", " "]);
term.print("1\n2\n3");
term.print("1\r\n2\r\n3");
term.cup(0, 1);
term.delete_lines(-2);
assert_visible_contents(&term, &["1", "2", "3"]);
@@ -153,7 +153,7 @@ fn test_cha() {
#[test]
fn test_ed() {
let mut term = TestTerm::new(3, 3, 0);
term.print("abc\ndef\nghi");
term.print("abc\r\ndef\r\nghi");
term.cup(1, 2);
term.print("\x1b[J");
assert_visible_contents(&term, &["abc", "def", "g "]);
+2 -2
View File
@@ -4,7 +4,7 @@ use super::*;
#[test]
fn drag_selection() {
let mut term = TestTerm::new(3, 12, 0);
term.print("hello world\n");
term.print("hello world\r\n");
assert_visible_contents(&term, &["hello world ", " ", " "]);
term.drag_select(1, 0, 4, 0);
@@ -12,7 +12,7 @@ fn drag_selection() {
// Now check that we respect double-width boundaries reasonably sanely;
// here we're dragging from the middle of the skull emoji
term.print("\u{1F480}skull\n");
term.print("\u{1F480}skull\r\n");
assert_visible_contents(
&term,
&["hello world ", "\u{1F480}skull ", " "],