From 26305a754b0c6e9edc9ed620e58e8507a95d8dec Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 22 Oct 2014 11:41:30 -0400 Subject: default this to the whole screen --- t/control_test.py | 10 ++--- t/csi_test.py | 110 +++++++++++++++++++++++++++--------------------------- t/escape_test.py | 16 ++++---- t/init_test.py | 4 +- t/text_test.py | 5 +-- vt100/__init__.py | 12 +++++- 6 files changed, 82 insertions(+), 75 deletions(-) diff --git a/t/control_test.py b/t/control_test.py index 1aff5db..8bf8a7c 100644 --- a/t/control_test.py +++ b/t/control_test.py @@ -14,7 +14,7 @@ class ControlTest(VT100Test): assert self.vt.cell(0, 2).contents() == "a" assert self.vt.cell(0, 3).contents() == "" assert self.vt.cell(1, 0).contents() == "" - assert self.vt.window_contents(0, 0, 23, 79) == 'faa' + ('\n' * 24) + assert self.vt.window_contents() == 'faa' + ('\n' * 24) self.process("\r\nquux\b\b\b\b\b\bbar") assert self.vt.cell(1, 0).contents() == "b" assert self.vt.cell(1, 1).contents() == "a" @@ -22,7 +22,7 @@ class ControlTest(VT100Test): assert self.vt.cell(1, 3).contents() == "x" assert self.vt.cell(1, 4).contents() == "" assert self.vt.cell(2, 0).contents() == "" - assert self.vt.window_contents(0, 0, 23, 79) == 'faa\nbarx' + ('\n' * 23) + assert self.vt.window_contents() == 'faa\nbarx' + ('\n' * 23) def test_tab(self): self.process("foo\tbar") @@ -38,7 +38,7 @@ class ControlTest(VT100Test): assert self.vt.cell(0, 9).contents() == "a" assert self.vt.cell(0, 10).contents() == "r" assert self.vt.cell(0, 11).contents() == "" - assert self.vt.window_contents(0, 0, 23, 79) == 'foo bar' + ('\n' * 24) + assert self.vt.window_contents() == 'foo bar' + ('\n' * 24) def test_lf(self): self.process("foo\nbar") @@ -53,7 +53,7 @@ class ControlTest(VT100Test): assert self.vt.cell(1, 4).contents() == "a" assert self.vt.cell(1, 5).contents() == "r" assert self.vt.cell(1, 6).contents() == "" - assert self.vt.window_contents(0, 0, 23, 79) == 'foo\n bar' + ('\n' * 23) + assert self.vt.window_contents() == 'foo\n bar' + ('\n' * 23) def test_cr(self): self.process("fooo\rbar") @@ -63,4 +63,4 @@ class ControlTest(VT100Test): assert self.vt.cell(0, 3).contents() == "o" assert self.vt.cell(0, 4).contents() == "" assert self.vt.cell(1, 0).contents() == "" - assert self.vt.window_contents(0, 0, 23, 79) == 'baro' + ('\n' * 24) + assert self.vt.window_contents() == 'baro' + ('\n' * 24) diff --git a/t/csi_test.py b/t/csi_test.py index 8cc8675..6e1997e 100644 --- a/t/csi_test.py +++ b/t/csi_test.py @@ -86,188 +86,188 @@ class CSITest(VT100Test): assert self.vt.cursor_position() == (0, 0) def test_ed(self): - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("foo\033[5;5Hbar\033[10;10Hbaz\033[20;20Hquux") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[10;12H\033[0J") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) self.process("\033[5;7H\033[1J") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 4) + ' r' + ("\n" * 5) + ' ba' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 4) + ' r' + ("\n" * 5) + ' ba' + ("\n" * 15) self.process("\033[7;7H\033[2J") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("\033[2J\033[H") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("foo\033[5;5Hbar\033[10;10Hbaz\033[20;20Hquux") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[10;12H\033[J") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) self.process("\033[2J\033[H") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("foo\033[5;5Hbar\033[10;10Hbaz\033[20;20Hquux") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[10;12H\033[?0J") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) self.process("\033[5;7H\033[?1J") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 4) + ' r' + ("\n" * 5) + ' ba' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 4) + ' r' + ("\n" * 5) + ' ba' + ("\n" * 15) self.process("\033[7;7H\033[?2J") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("\033[2J\033[H") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("foo\033[5;5Hbar\033[10;10Hbaz\033[20;20Hquux") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[10;12H\033[?J") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' ba' + ("\n" * 15) def test_el(self): - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("foo\033[5;5Hbarbar\033[10;10Hbazbaz\033[20;20Hquux") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' barbar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' barbar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[5;8H\033[0K") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[10;13H\033[1K") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[20;22H\033[2K") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) self.process("\033[1;2H\033[K") - assert self.vt.window_contents(0, 0, 500, 500) == 'f' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) + assert self.vt.window_contents() == 'f' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) self.process("\033[2J\033[H") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("foo\033[5;5Hbarbar\033[10;10Hbazbaz\033[20;20Hquux") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' barbar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' barbar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[5;8H\033[?0K") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' bazbaz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[10;13H\033[?1K") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 10) + ' quux' + ("\n" * 5) self.process("\033[20;22H\033[?2K") - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) + assert self.vt.window_contents() == 'foo' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) self.process("\033[1;2H\033[?K") - assert self.vt.window_contents(0, 0, 500, 500) == 'f' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) + assert self.vt.window_contents() == 'f' + ("\n" * 4) + ' bar' + ("\n" * 5) + ' baz' + ("\n" * 15) def test_ich_dch_ech(self): - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("\033[10;10Hfoobar") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' foobar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' foobar' + ("\n" * 15) self.process("\033[10;12H\033[3@") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' fo obar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' fo obar' + ("\n" * 15) assert self.vt.cursor_position() == (9, 11) self.process("\033[4P") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' fobar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' fobar' + ("\n" * 15) assert self.vt.cursor_position() == (9, 11) self.process("\033[100@") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' fo' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' fo' + ("\n" * 15) assert self.vt.cursor_position() == (9, 11) self.process("obar") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' foobar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' foobar' + ("\n" * 15) assert self.vt.cursor_position() == (9, 15) self.process("\033[10;12H\033[100P") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' fo' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' fo' + ("\n" * 15) assert self.vt.cursor_position() == (9, 11) self.process("obar") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' foobar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' foobar' + ("\n" * 15) assert self.vt.cursor_position() == (9, 15) self.process("\033[10;13H\033[X") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' foo ar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' foo ar' + ("\n" * 15) assert self.vt.cursor_position() == (9, 12) self.process("\033[10;11H\033[4X") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' f r' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' f r' + ("\n" * 15) assert self.vt.cursor_position() == (9, 10) self.process("\033[10;11H\033[400X") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' f' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' f' + ("\n" * 15) assert self.vt.cursor_position() == (9, 10) def test_il_dl(self): - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("\033[10;10Hfoobar\033[3D") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' foobar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' foobar' + ("\n" * 15) assert self.vt.cursor_position() == (9, 12) self.process("\033[L") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 10) + ' foobar' + ("\n" * 14) + assert self.vt.window_contents() == ("\n" * 10) + ' foobar' + ("\n" * 14) assert self.vt.cursor_position() == (9, 12) self.process("\033[3L") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 13) + ' foobar' + ("\n" * 11) + assert self.vt.window_contents() == ("\n" * 13) + ' foobar' + ("\n" * 11) assert self.vt.cursor_position() == (9, 12) self.process("\033[500L") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) assert self.vt.cursor_position() == (9, 12) self.process("\033[10;10Hfoobar\033[3D\033[6A") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 9) + ' foobar' + ("\n" * 15) + assert self.vt.window_contents() == ("\n" * 9) + ' foobar' + ("\n" * 15) assert self.vt.cursor_position() == (3, 12) self.process("\033[M") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 8) + ' foobar' + ("\n" * 16) + assert self.vt.window_contents() == ("\n" * 8) + ' foobar' + ("\n" * 16) assert self.vt.cursor_position() == (3, 12) self.process("\033[3M") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 5) + ' foobar' + ("\n" * 19) + assert self.vt.window_contents() == ("\n" * 5) + ' foobar' + ("\n" * 19) assert self.vt.cursor_position() == (3, 12) self.process("\033[500M") - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) assert self.vt.cursor_position() == (3, 12) def test_scroll(self): - assert self.vt.window_contents(0, 0, 500, 500) == ("\n" * 24) + assert self.vt.window_contents() == ("\n" * 24) self.process("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24") - assert self.vt.window_contents(0, 0, 500, 500) == "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n" + assert self.vt.window_contents() == "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n" self.process("\033[15;15H") assert self.vt.cursor_position() == (14, 14) self.vt.process("\033[S") - print(self.vt.window_contents(0, 0, 500, 500).replace('\n', '\\n')) - assert self.vt.window_contents(0, 0, 500, 500) == "2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n\n" + print(self.vt.window_contents().replace('\n', '\\n')) + assert self.vt.window_contents() == "2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n\n" assert self.vt.cursor_position() == (14, 14) self.vt.process("\033[3S") - assert self.vt.window_contents(0, 0, 500, 500) == "5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n\n\n\n\n" + assert self.vt.window_contents() == "5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n\n\n\n\n" assert self.vt.cursor_position() == (14, 14) self.vt.process("\033[T") - assert self.vt.window_contents(0, 0, 500, 500) == "\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n\n\n\n" + assert self.vt.window_contents() == "\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n\n\n\n" assert self.vt.cursor_position() == (14, 14) self.vt.process("\033[5T") - assert self.vt.window_contents(0, 0, 500, 500) == "\n\n\n\n\n\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n" + assert self.vt.window_contents() == "\n\n\n\n\n\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n" assert self.vt.cursor_position() == (14, 14) diff --git a/t/escape_test.py b/t/escape_test.py index f657e29..25d7f18 100644 --- a/t/escape_test.py +++ b/t/escape_test.py @@ -10,7 +10,7 @@ class EscapeTest(VT100Test): def test_ri(self): self.process("foo\nbar\033Mbaz") - assert self.vt.window_contents(0, 0, 23, 79) == 'foo baz\n bar' + ('\n' * 23) + assert self.vt.window_contents() == 'foo baz\n bar' + ('\n' * 23) def test_ris(self): row, col = self.vt.cursor_position() @@ -20,8 +20,8 @@ class EscapeTest(VT100Test): cell = self.vt.cell(0, 0) assert cell.contents() == "" - assert self.vt.window_contents(0, 0, 500, 500) == ('\n' * 24) - assert self.vt.window_contents_formatted(0, 0, 500, 500) == ('\n' * 24) + assert self.vt.window_contents() == ('\n' * 24) + assert self.vt.window_contents_formatted() == ('\n' * 24) assert self.vt.title() == "" assert self.vt.icon_name() == "" @@ -54,8 +54,8 @@ class EscapeTest(VT100Test): cell = self.vt.cell(0, 0) assert cell.contents() == "f" - assert self.vt.window_contents(0, 0, 500, 500) == 'foo' + ('\n' * 24) - assert self.vt.window_contents_formatted(0, 0, 500, 500) == 'f\033[31;47;1;3;4moo' + ('\n' * 24) + assert self.vt.window_contents() == 'foo' + ('\n' * 24) + assert self.vt.window_contents_formatted() == 'f\033[31;47;1;3;4moo' + ('\n' * 24) assert self.vt.title() == "window title" assert self.vt.icon_name() == "window icon name" @@ -88,8 +88,8 @@ class EscapeTest(VT100Test): cell = self.vt.cell(0, 0) assert cell.contents() == "" - assert self.vt.window_contents(0, 0, 500, 500) == ('\n' * 24) - assert self.vt.window_contents_formatted(0, 0, 500, 500) == ('\n' * 24) + assert self.vt.window_contents() == ('\n' * 24) + assert self.vt.window_contents_formatted() == ('\n' * 24) # title and icon name don't change with reset assert self.vt.title() == "window title" @@ -122,4 +122,4 @@ class EscapeTest(VT100Test): def test_decsc(self): self.process("foo\0337\r\n\r\n\r\n bar\0338baz") - assert self.vt.window_contents(0, 0, 23, 79) == 'foobaz\n\n\n bar' + ('\n' * 21) + assert self.vt.window_contents() == 'foobaz\n\n\n bar' + ('\n' * 21) diff --git a/t/init_test.py b/t/init_test.py index e046ca5..4fded7f 100644 --- a/t/init_test.py +++ b/t/init_test.py @@ -17,8 +17,8 @@ class InitTest(VT100Test): cell = self.vt.cell(0, 80) assert cell is None - assert self.vt.window_contents(0, 0, 500, 500) == ('\n' * 24) - assert self.vt.window_contents_formatted(0, 0, 500, 500) == ('\n' * 24) + assert self.vt.window_contents() == ('\n' * 24) + assert self.vt.window_contents_formatted() == ('\n' * 24) assert self.vt.title() == "" assert self.vt.icon_name() == "" diff --git a/t/text_test.py b/t/text_test.py index 3e4c767..23f8cf9 100644 --- a/t/text_test.py +++ b/t/text_test.py @@ -49,7 +49,6 @@ class TextTest(VT100Test): assert self.vt.cell(0, 5).contents() == "" assert self.vt.cell(0, 6).contents() == "" assert self.vt.cell(1, 0).contents() == "" - print(self.vt.window_contents(0, 0, 0, 50)) assert self.vt.window_contents(0, 0, 23, 79) == u'aデbネ' + ('\n' * 24) assert self.vt.window_contents(0, 0, 500, 500) == u'aデbネ' + ('\n' * 24) @@ -70,7 +69,7 @@ class TextTest(VT100Test): def test_wrap(self): self.process("0123456789" * 10) - assert self.vt.window_contents(0, 0, 500, 500) == ("0123456789" * 10) + ("\n" * 23) + assert self.vt.window_contents() == ("0123456789" * 10) + ("\n" * 23) self.process("\033[5H" + "0123456789" * 8) self.process("\033[6H" + "0123456789" * 8) - assert self.vt.window_contents(0, 0, 500, 500) == ("0123456789" * 10) + ("\n" * 3) + ("0123456789" * 8) + "\n" + ("0123456789" * 8) + ("\n" * 19) + assert self.vt.window_contents() == ("0123456789" * 10) + ("\n" * 3) + ("0123456789" * 8) + "\n" + ("0123456789" * 8) + ("\n" * 19) diff --git a/vt100/__init__.py b/vt100/__init__.py index 5948696..422c296 100644 --- a/vt100/__init__.py +++ b/vt100/__init__.py @@ -169,7 +169,11 @@ class vt100(object): def process(self, string): return vt100_raw.process_string(addressof(self._screen), string) - def window_contents(self, row_start, col_start, row_end, col_end): + def window_contents(self, row_start=0, col_start=0, row_end=None, col_end=None): + if row_end is None: + row_end = self._rows - 1 + if col_end is None: + col_end = self._cols - 1 row_start = min(max(row_start, 0), self._rows - 1) col_start = min(max(col_start, 0), self._cols - 1) row_end = min(max(row_end, 0), self._rows - 1) @@ -178,7 +182,11 @@ class vt100(object): addressof(self._screen), row_start, col_start, row_end, col_end ).decode('utf-8') - def window_contents_formatted(self, row_start, col_start, row_end, col_end): + def window_contents_formatted(self, row_start=0, col_start=0, row_end=None, col_end=None): + if row_end is None: + row_end = self._rows - 1 + if col_end is None: + col_end = self._cols - 1 row_start = min(max(row_start, 0), self._rows - 1) col_start = min(max(col_start, 0), self._cols - 1) row_end = min(max(row_end, 0), self._rows - 1) -- cgit v1.2.3