summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Halberstadt <halbersa@gmail.com>2017-12-18 10:10:15 -0500
committerAndrew Halberstadt <halbersa@gmail.com>2017-12-18 10:10:15 -0500
commit24073ca628342d2c99369117197791602c60e415 (patch)
treeabe59ce4cdef4e2d35edc1b0c32f13dd720ced9d
parent979988cb7322140f637c7308fe40ec47b82b5cf4 (diff)
downloadblessings-24073ca628342d2c99369117197791602c60e415.tar.gz
Return 0 from 'number_of_colors' when does_styling is False
-rw-r--r--blessings/__init__.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/blessings/__init__.py b/blessings/__init__.py
index a2254b1..810d367 100644
--- a/blessings/__init__.py
+++ b/blessings/__init__.py
@@ -337,6 +337,9 @@ class Terminal(object):
# don't name it after the underlying capability, because we deviate
# slightly from its behavior, and we might someday wish to give direct
# access to it.
+ if not self._does_styling:
+ return 0
+
colors = tigetnum('colors') # Returns -1 if no color support, -2 if no
# such cap.
# self.__dict__['colors'] = ret # Cache it. It's not changing.