def test_defaults(self): mode = tcgetattr(sys.stdin) self.assertEqual(mode[LFLAG] & ECHO, ECHO) self.assertEqual(mode[LFLAG] & ICANON, ICANON) self.assertEqual(mode[LFLAG] & IEXTEN, IEXTEN) self.assertEqual(mode[LFLAG] & ISIG, ISIG) self.assertEqual(mode[CC][VMIN], b('\x01')) self.assertEqual(mode[CC][VTIME], b('\x00'))
def _readyx(stream): """Read a CSI R response from stream.""" p = b('') c = stream.read(1) while c: p += c if c == b('R'): break c = stream.read(1) if p: m = re.search(b('\[(\d+);(\d+)R'), p) if m is not None: return int(m.group(1), 10), int(m.group(2), 10) return 0, 0
def getyx(): """Return the cursor position as 1-based (line, col) tuple. line and col are 0 if the terminal does not support DSR 6. """ with opentty() as tty: line = col = 0 if tty is not None: with cbreakmode(tty, min=0, time=MAX_WAIT): tty.write(b('\033[6n')) line, col = _readyx(tty) return line, col
def test_b_no_encoder(self): # b is not an encoder! if sys.version_info[0] < 3: self.assertTrue(isinstance(b(u'foo'), unicode))
def test_b(self): self.assertFalse(isinstance(b('foo'), unicode))
def test_b(self): self.assertFalse(isinstance(b("foo"), unicode)) if sys.version_info[0] < 3: # b is not an encoder! self.assertTrue(isinstance(b(u"foo"), unicode))