summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-10-10 16:15:47 +0300
committerLars Wirzenius <liw@liw.fi>2015-10-10 16:17:57 +0300
commit06f8f64cdc5a32f2f188efbe86b24c93ec73c7ac (patch)
tree5b4f02be2690e17ed54f08910cabb0ccbcb629ba
parent6e63409277f25faafc6ba357d495fae73645d944 (diff)
downloadttystatus-06f8f64cdc5a32f2f188efbe86b24c93ec73c7ac.tar.gz
Fix query of terminal settings
This will work when TERM is set to an incapable terminal.
-rw-r--r--NEWS6
-rw-r--r--ttystatus/tty.py8
2 files changed, 12 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 259dc88..a0c5e0c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
NEWS file for ttystatus
=======================
+Version 0.28, released 2015-10-10
+---------------------------------
+
+* Fix another case where terminal capabilities are queried and the
+ terminal isn't capable.
+
Version 0.27, released 2015-10-10
---------------------------------
diff --git a/ttystatus/tty.py b/ttystatus/tty.py
index 580401b..31a9036 100644
--- a/ttystatus/tty.py
+++ b/ttystatus/tty.py
@@ -34,8 +34,12 @@ class PhysicalTerminal(object):
def open_tty(self):
self._terminal = open('/dev/tty', 'wb')
curses.setupterm(None, self._terminal.fileno())
- self._cuu = curses.tparm(curses.tigetstr('cuu'), 1)
- self._cud = curses.tparm(curses.tigetstr('cud'), 1)
+
+ for name in ['cuu', 'cud']:
+ s = curses.tigetstr(name)
+ if s is not None:
+ setattr(self, '_' + name, curses.tparm(s, 1))
+
self._cr = curses.tigetstr('cr')
self._el = curses.tigetstr('el')