예제 #1
0
 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'))
예제 #2
0
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
예제 #3
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
예제 #4
0
 def test_b_no_encoder(self):
     # b is not an encoder!
     if sys.version_info[0] < 3:
         self.assertTrue(isinstance(b(u'foo'), unicode))
예제 #5
0
 def test_b(self):
     self.assertFalse(isinstance(b('foo'), unicode))
예제 #6
0
 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))