import termios
from collections import namedtuple
+from io import UnsupportedOperation
# Third party modules
from fb_tools.cfg_app import FbConfigApplication
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.9.0'
+__version__ = '0.9.1'
# =============================================================================
It returns these position as a CursorPosition object.
A position of (-1, -1) means, the position could not be evaluated.
"""
- old_stdin_mode = termios.tcgetattr(sys.stdin)
+ try:
+ old_stdin_mode = termios.tcgetattr(sys.stdin)
+ except UnsupportedOperation:
+ return CursorPosition(-1, -1)
+
stdin_mode = termios.tcgetattr(sys.stdin)
stdin_mode[3] = stdin_mode[3] & ~(termios.ECHO | termios.ICANON)
termios.tcsetattr(sys.stdin, termios.TCSAFLUSH, stdin_mode)
print('0123456789', end='', flush=True)
pos = BaseDPXApplication.cursor_position()
- print()
- if pos.x != -1 and pos.y != -1:
- LOG.debug("Got {}.".format(pos))
- self.assertEqual(pos.x, 11)
+ if pos.x == -1 and pos.y == -1:
+ LOG.info("Terminal has no cursor.")
else:
- LOG.info("Could not detect position of screen cursor.")
+ print()
+ if pos.x != -1 and pos.y != -1:
+ LOG.debug("Got {}.".format(pos))
+ self.assertEqual(pos.x, 11)
+ else:
+ LOG.info("Could not detect position of screen cursor.")
# =============================================================================