Skip to content

Commit

Permalink
Yet another fix of Screen.set_margins
Browse files Browse the repository at this point in the history
for the case of CSI with no arguments. See #61.
  • Loading branch information
Sergei Lebedev committed Apr 8, 2018
1 parent 06ad67f commit 676610b
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
-------------

3 changes: 2 additions & 1 deletion pyte/screens.py
Original file line number Diff line number Diff line change
@@ -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

9 changes: 9 additions & 0 deletions tests/test_screen.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 676610b

Please sign in to comment.