Skip to content

Commit 676610b

Browse files
author
Sergei Lebedev
committed
Yet another fix of Screen.set_margins
for the case of CSI with no arguments. See #61.
1 parent 06ad67f commit 676610b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Here you can see the full list of changes between each pyte release.
66
Version 0.8.1-dev
77
-----------------
88

9+
- Yet another fix of ``Screen.set_margins`` for the case of CSI
10+
with no arguments. See issue #61 on GitHub.
11+
12+
913
Version 0.8.0
1014
-------------
1115

pyte/screens.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ def set_margins(self, top=None, bottom=None):
331331
:param int top: the smallest line number that is scrolled.
332332
:param int bottom: the biggest line number that is scrolled.
333333
"""
334-
if top is None and bottom is None:
334+
# XXX 0 corresponds to the CSI with no parameters.
335+
if (top is None or top == 0) and bottom is None:
335336
self.margins = None
336337
return
337338

tests/test_screen.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,15 @@ def test_set_margins():
14571457
assert screen.margins is None
14581458

14591459

1460+
def test_set_margins_zero():
1461+
# See https://github.com/selectel/pyte/issues/61
1462+
screen = pyte.Screen(80, 24)
1463+
screen.set_margins(1, 5)
1464+
assert screen.margins == (0, 4)
1465+
screen.set_margins(0)
1466+
assert screen.margins is None
1467+
1468+
14601469
def test_hide_cursor():
14611470
screen = pyte.Screen(10, 10)
14621471

0 commit comments

Comments
 (0)