From 676610b43954b644c05823371df6daf87caafdad Mon Sep 17 00:00:00 2001 From: Sergei Lebedev Date: Sun, 8 Apr 2018 20:11:13 +0200 Subject: [PATCH] Yet another fix of ``Screen.set_margins`` for the case of CSI with no arguments. See #61. --- CHANGES | 4 ++++ pyte/screens.py | 3 ++- tests/test_screen.py | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 2d452d3..6173b30 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,10 @@ Here you can see the full list of changes between each pyte release. Version 0.8.1-dev ----------------- +- Yet another fix of ``Screen.set_margins`` for the case of CSI + with no arguments. See issue #61 on GitHub. + + Version 0.8.0 ------------- diff --git a/pyte/screens.py b/pyte/screens.py index 648358f..e9adef0 100644 --- a/pyte/screens.py +++ b/pyte/screens.py @@ -331,7 +331,8 @@ def set_margins(self, top=None, bottom=None): :param int top: the smallest line number that is scrolled. :param int bottom: the biggest line number that is scrolled. """ - if top is None and bottom is None: + # XXX 0 corresponds to the CSI with no parameters. + if (top is None or top == 0) and bottom is None: self.margins = None return diff --git a/tests/test_screen.py b/tests/test_screen.py index 6ff062a..5351c9e 100644 --- a/tests/test_screen.py +++ b/tests/test_screen.py @@ -1457,6 +1457,15 @@ def test_set_margins(): assert screen.margins is None +def test_set_margins_zero(): + # See https://github.com/selectel/pyte/issues/61 + screen = pyte.Screen(80, 24) + screen.set_margins(1, 5) + assert screen.margins == (0, 4) + screen.set_margins(0) + assert screen.margins is None + + def test_hide_cursor(): screen = pyte.Screen(10, 10)