def child(kind): from blessed.sequences import iter_parse term = TestTerminal(kind=kind) if term.clear_eol: assert not next(iter_parse(term, term.clear_eol))[1].will_move if term.clear_bol: assert not next(iter_parse(term, term.clear_bol))[1].will_move if term.clear_eos: assert not next(iter_parse(term, term.clear_eos))[1].will_move if term.bold: assert not next(iter_parse(term, term.bold))[1].will_move if term.red: assert not next(iter_parse(term, term.red))[1].will_move if term.civis: assert not next(iter_parse(term, term.civis))[1].will_move if term.cvvis: assert not next(iter_parse(term, term.cvvis))[1].will_move if term.underline: assert not next(iter_parse(term, term.underline))[1].will_move if term.reverse: assert not next(iter_parse(term, term.reverse))[1].will_move if term.color(0): assert not next(iter_parse(term, term.color(0)))[1].will_move if term.normal_cursor: assert not next(iter_parse(term, term.normal_cursor))[1].will_move if term.save: assert not next(iter_parse(term, term.save))[1].will_move if term.italic: assert not next(iter_parse(term, term.italic))[1].will_move if term.standout: assert not next(iter_parse(term, term.standout))[1].will_move
def child_mnemonics_wontmove(kind): from blessed.sequences import measure_length t = TestTerminal(kind=kind) assert 0 == measure_length(u"", t) # not even a mbs assert 0 == measure_length(u"xyzzy", t) # negative numbers, though printable as %d, do not result # in movement; just garbage. Also not a valid sequence. assert 0 == measure_length(t.cuf(-333), t) assert len(t.clear_eol) == measure_length(t.clear_eol, t) # various erases don't *move* assert len(t.clear_bol) == measure_length(t.clear_bol, t) assert len(t.clear_eos) == measure_length(t.clear_eos, t) assert len(t.bold) == measure_length(t.bold, t) # various paints don't move assert len(t.red) == measure_length(t.red, t) assert len(t.civis) == measure_length(t.civis, t) if t.cvvis: assert len(t.cvvis) == measure_length(t.cvvis, t) assert len(t.underline) == measure_length(t.underline, t) assert len(t.reverse) == measure_length(t.reverse, t) for _num in range(t.number_of_colors): assert len(t.color(_num)) == measure_length(t.color(_num), t) assert len(t.normal) == measure_length(t.normal, t) assert len(t.normal_cursor) == measure_length(t.normal_cursor, t) assert len(t.hide_cursor) == measure_length(t.hide_cursor, t) assert len(t.save) == measure_length(t.save, t) assert len(t.italic) == measure_length(t.italic, t) assert len(t.standout) == measure_length(t.standout, t), (t.standout, t._wont_move)
def child(kind): from blessed.sequences import measure_length term = TestTerminal(kind=kind) assert (0 == measure_length(u'', term)) # not even a mbs assert (0 == measure_length(u'xyzzy', term)) # negative numbers, though printable as %d, do not result # in movement; just garbage. Also not a valid sequence. assert (0 == measure_length(term.cuf(-333), term)) assert (len(term.clear_eol) == measure_length(term.clear_eol, term)) # various erases don't *move* assert (len(term.clear_bol) == measure_length(term.clear_bol, term)) assert (len(term.clear_eos) == measure_length(term.clear_eos, term)) assert (len(term.bold) == measure_length(term.bold, term)) # various paints don't move assert (len(term.red) == measure_length(term.red, term)) assert (len(term.civis) == measure_length(term.civis, term)) if term.cvvis: assert (len(term.cvvis) == measure_length(term.cvvis, term)) assert (len(term.underline) == measure_length(term.underline, term)) assert (len(term.reverse) == measure_length(term.reverse, term)) for _num in (0, term.number_of_colors): expected = len(term.color(_num)) given = measure_length(term.color(_num), term) assert (expected == given) assert (len(term.normal_cursor) == measure_length( term.normal_cursor, term)) assert (len(term.hide_cursor) == measure_length( term.hide_cursor, term)) assert (len(term.save) == measure_length(term.save, term)) assert (len(term.italic) == measure_length(term.italic, term)) assert (len(term.standout) == measure_length(term.standout, term)), (term.standout, term._wont_move)
def child(kind): from blessed.sequences import measure_length term = TestTerminal(kind=kind) assert (0 == measure_length(u'', term)) # not even a mbs assert (0 == measure_length(u'xyzzy', term)) # negative numbers, though printable as %d, do not result # in movement; just garbage. Also not a valid sequence. assert (0 == measure_length(term.cuf(-333), term)) assert (len(term.clear_eol) == measure_length(term.clear_eol, term)) # various erases don't *move* assert (len(term.clear_bol) == measure_length(term.clear_bol, term)) assert (len(term.clear_eos) == measure_length(term.clear_eos, term)) assert (len(term.bold) == measure_length(term.bold, term)) # various paints don't move assert (len(term.red) == measure_length(term.red, term)) assert (len(term.civis) == measure_length(term.civis, term)) if term.cvvis: assert (len(term.cvvis) == measure_length(term.cvvis, term)) assert (len(term.underline) == measure_length(term.underline, term)) assert (len(term.reverse) == measure_length(term.reverse, term)) for _num in (0, term.number_of_colors): expected = len(term.color(_num)) given = measure_length(term.color(_num), term) assert (expected == given) assert (len(term.normal_cursor) == measure_length(term.normal_cursor, term)) assert (len(term.hide_cursor) == measure_length(term.hide_cursor, term)) assert (len(term.save) == measure_length(term.save, term)) assert (len(term.italic) == measure_length(term.italic, term)) assert (len(term.standout) == measure_length(term.standout, term) ), (term.standout, term._wont_move)
def child(kind, lines=25, cols=80): # set the pty's virtual window size val = struct.pack('HHHH', lines, cols, 0, 0) fcntl.ioctl(sys.__stdout__.fileno(), termios.TIOCSWINSZ, val) term = TestTerminal(kind=kind) pony_msg = 'pony express, all aboard, choo, choo!' pony_len = len(pony_msg) pony_colored = u''.join([ '%s%s' % ( term.color(n % 7), ch, ) for n, ch in enumerate(pony_msg) ]) pony_colored += term.normal ladjusted = term.ljust(pony_colored) radjusted = term.rjust(pony_colored) centered = term.center(pony_colored) assert (term.length(pony_colored) == pony_len) assert (term.length(centered.strip()) == pony_len) assert (term.length(centered) == len(pony_msg.center(term.width))) assert (term.length(ladjusted.strip()) == pony_len) assert (term.length(ladjusted) == len(pony_msg.ljust(term.width))) assert (term.length(radjusted.strip()) == pony_len) assert (term.length(radjusted) == len(pony_msg.rjust(term.width)))
def child(kind): t = TestTerminal(kind=kind) pony_msg = "pony express, all aboard, choo, choo!" pony_len = len(pony_msg) pony_colored = u"".join(["%s%s" % (t.color(n % 7), ch) for n, ch in enumerate(pony_msg)]) pony_colored += t.normal ladjusted = t.ljust(pony_colored, 88) radjusted = t.rjust(pony_colored, 88) centered = t.center(pony_colored, 88) assert t.length(pony_colored) == pony_len assert t.length(centered.strip()) == pony_len assert t.length(centered) == len(pony_msg.center(88)) assert t.length(ladjusted.strip()) == pony_len assert t.length(ladjusted) == len(pony_msg.ljust(88)) assert t.length(radjusted.strip()) == pony_len assert t.length(radjusted) == len(pony_msg.rjust(88))
def child(kind): term = TestTerminal(kind=kind) pony_msg = 'pony express, all aboard, choo, choo!' pony_len = len(pony_msg) pony_colored = u''.join( ['%s%s' % (term.color(n % 7), ch,) for n, ch in enumerate(pony_msg)]) pony_colored += term.normal ladjusted = term.ljust(pony_colored, 88) radjusted = term.rjust(pony_colored, 88) centered = term.center(pony_colored, 88) assert (term.length(pony_colored) == pony_len) assert (term.length(centered.strip()) == pony_len) assert (term.length(centered) == len(pony_msg.center(88))) assert (term.length(ladjusted.strip()) == pony_len) assert (term.length(ladjusted) == len(pony_msg.ljust(88))) assert (term.length(radjusted.strip()) == pony_len) assert (term.length(radjusted) == len(pony_msg.rjust(88)))
def child(kind, lines=25, cols=80): # set the pty's virtual window size val = struct.pack("HHHH", lines, cols, 0, 0) fcntl.ioctl(sys.__stdout__.fileno(), termios.TIOCSWINSZ, val) t = TestTerminal(kind=kind) pony_msg = "pony express, all aboard, choo, choo!" pony_len = len(pony_msg) pony_colored = u"".join(["%s%s" % (t.color(n % 7), ch) for n, ch in enumerate(pony_msg)]) pony_colored += t.normal ladjusted = t.ljust(pony_colored) radjusted = t.rjust(pony_colored) centered = t.center(pony_colored) assert t.length(pony_colored) == pony_len assert t.length(centered.strip()) == pony_len assert t.length(centered) == len(pony_msg.center(t.width)) assert t.length(ladjusted.strip()) == pony_len assert t.length(ladjusted) == len(pony_msg.ljust(t.width)) assert t.length(radjusted.strip()) == pony_len assert t.length(radjusted) == len(pony_msg.rjust(t.width))
def child(kind): term = TestTerminal(kind=kind) pony_msg = 'pony express, all aboard, choo, choo!' pony_len = len(pony_msg) pony_colored = u''.join([ '%s%s' % ( term.color(n % 7), ch, ) for n, ch in enumerate(pony_msg) ]) pony_colored += term.normal ladjusted = term.ljust(pony_colored, 88) radjusted = term.rjust(pony_colored, 88) centered = term.center(pony_colored, 88) assert (term.length(pony_colored) == pony_len) assert (term.length(centered.strip()) == pony_len) assert (term.length(centered) == len(pony_msg.center(88))) assert (term.length(ladjusted.strip()) == pony_len) assert (term.length(ladjusted) == len(pony_msg.ljust(88))) assert (term.length(radjusted.strip()) == pony_len) assert (term.length(radjusted) == len(pony_msg.rjust(88)))