本文整理汇总了Python中accessories.TestTerminal.color方法的典型用法代码示例。如果您正苦于以下问题:Python TestTerminal.color方法的具体用法?Python TestTerminal.color怎么用?Python TestTerminal.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accessories.TestTerminal
的用法示例。
在下文中一共展示了TestTerminal.color方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: child_mnemonics_wontmove
# 需要导入模块: from accessories import TestTerminal [as 别名]
# 或者: from accessories.TestTerminal import color [as 别名]
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)
示例2: child
# 需要导入模块: from accessories import TestTerminal [as 别名]
# 或者: from accessories.TestTerminal import color [as 别名]
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)
# build a test paragraph, along with a very colorful version
t = TestTerminal(kind=kind)
pgraph = u' '.join(
('a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefgh',
'abcdefghi', 'abcdefghij', 'abcdefghijk', 'abcdefghijkl',
'abcdefghijklm', 'abcdefghijklmn', 'abcdefghijklmno',) * 4)
pgraph_colored = u''.join([
t.color(n % 7) + t.bold + ch
for n, ch in enumerate(pgraph)])
internal_wrapped = textwrap.wrap(pgraph, t.width,
break_long_words=False)
my_wrapped = t.wrap(pgraph)
my_wrapped_colored = t.wrap(pgraph_colored)
# ensure we textwrap ascii the same as python
assert (internal_wrapped == my_wrapped)
# ensure our first and last line wraps at its ends
first_l = internal_wrapped[0]
last_l = internal_wrapped[-1]
my_first_l = my_wrapped_colored[0]
my_last_l = my_wrapped_colored[-1]
assert (len(first_l) == t.length(my_first_l))
assert (len(last_l) == t.length(my_last_l))
assert (len(internal_wrapped[-1]) == t.length(my_wrapped_colored[-1]))
示例3: child
# 需要导入模块: from accessories import TestTerminal [as 别名]
# 或者: from accessories.TestTerminal import color [as 别名]
def child(kind):
t = TestTerminal(kind=kind)
if t.magenta:
assert t.color(5)('smoo') == t.magenta + 'smoo' + t.normal
else:
assert t.color(5)('smoo') == 'smoo'
if t.on_magenta:
assert t.on_color(5)('smoo') == t.on_magenta + 'smoo' + t.normal
else:
assert t.color(5)(u'smoo') == 'smoo'
if t.color(4):
assert t.color(4)(u'smoo') == t.color(4) + u'smoo' + t.normal
else:
assert t.color(4)(u'smoo') == 'smoo'
if t.on_green:
assert t.on_color(2)('smoo') == t.on_green + u'smoo' + t.normal
else:
assert t.on_color(2)('smoo') == 'smoo'
if t.on_color(6):
assert t.on_color(6)('smoo') == t.on_color(6) + u'smoo' + t.normal
else:
assert t.on_color(6)('smoo') == 'smoo'
示例4: child
# 需要导入模块: from accessories import TestTerminal [as 别名]
# 或者: from accessories.TestTerminal import color [as 别名]
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)))
示例5: child
# 需要导入模块: from accessories import TestTerminal [as 别名]
# 或者: from accessories.TestTerminal import color [as 别名]
def child(kind):
t = TestTerminal(kind=kind, force_styling=None)
assert t.save == ""
assert t.color(9) == ""
assert t.bold("oi") == "oi"