本文整理汇总了Python中blessed.Terminal.hidden_cursor方法的典型用法代码示例。如果您正苦于以下问题:Python Terminal.hidden_cursor方法的具体用法?Python Terminal.hidden_cursor怎么用?Python Terminal.hidden_cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blessed.Terminal
的用法示例。
在下文中一共展示了Terminal.hidden_cursor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def main(logfilepath):
term = Terminal()
mngr = Manager(term, num_divisions=1, logfilepath=logfilepath)
cursor, scrn = mngr.get_focus_cursor_and_screen()
with term.hidden_cursor(), \
term.raw(), \
term.location(), \
term.fullscreen(), \
term.keypad():
inp = None
while True:
inp = term.inkey(timeout=0.2)
if inp != u'':
signal = mngr.handle_input(inp)
if signal == -1:
# got exit signal
break
mngr.draw()
if mngr.logger != None:
mngr.logger.write_to_file()
示例2: start
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def start():
try:
t = Terminal()
with t.hidden_cursor():
view = Views(kodi,t)
view.nowPlayingView()
except (OSError,ConnectionError):
print(t.exit_fullscreen())
print("Can't connect to Kodi host. Is it running? Are host '{}' and port '{}' correct?".format(kodi.host,kodi.port))
except KeyboardInterrupt:
print(t.exit_fullscreen)
示例3: ascii_credits
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def ascii_credits():
"""
Asciimatics credits!
"""
term = Terminal()
with term.fullscreen():
with term.hidden_cursor():
with term.cbreak():
while True:
try:
_credits(term)
return
except ResizeScreenError:
pass
示例4: main
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def main():
term = Terminal()
csr = Cursor(0, 0, term)
screen = {}
with term.hidden_cursor(), \
term.raw(), \
term.location(), \
term.fullscreen(), \
term.keypad():
inp = None
while True:
echo_yx(csr, term.reverse(screen.get((csr.y, csr.x), u' ')))
inp = term.inkey()
if inp == chr(3):
# ^c exits
break
elif inp == chr(19):
# ^s saves
echo_yx(home(bottom(csr)),
term.ljust(term.bold_white('Filename: ')))
echo_yx(right_of(home(bottom(csr)), len('Filename: ')), u'')
save(screen, readline(term))
echo_yx(home(bottom(csr)), term.clear_eol)
redraw(term=term, screen=screen,
start=home(bottom(csr)),
end=end(bottom(csr)))
continue
elif inp == chr(12):
# ^l refreshes
redraw(term=term, screen=screen)
n_csr = lookup_move(inp.code, csr, term)
if n_csr != csr:
# erase old cursor,
echo_yx(csr, screen.get((csr.y, csr.x), u' '))
csr = n_csr
elif not inp.is_sequence and inp.isprintable():
echo_yx(csr, inp)
screen[(csr.y, csr.x)] = inp.__str__()
n_csr = right_of(csr, 1)
if n_csr == csr:
# wrap around margin
n_csr = home(below(csr, 1))
csr = n_csr
示例5: main
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def main(opts):
"""Program entry point."""
term = Terminal()
style = Style()
# if the terminal supports colors, use a Style instance with some
# standout colors (magenta, cyan).
if term.number_of_colors:
style = Style(attr_major=term.magenta, attr_minor=term.bright_cyan, alignment=opts["--alignment"])
style.name_len = term.width - 15
screen = Screen(term, style, wide=opts["--wide"])
pager = Pager(term, screen, opts["character_factory"])
with term.location(), term.cbreak(), term.fullscreen(), term.hidden_cursor():
pager.run(writer=echo, reader=term.inkey)
return 0
示例6: monitor
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def monitor(run_once=False):
term = Terminal()
r = redis_client
with term.fullscreen(), term.hidden_cursor(), term.cbreak():
val = None
start_width = int(term.width / 8)
while val not in (u'q', u'Q',):
col_width = int(term.width / 8)
# In case of resize
if col_width != start_width:
print(term.clear)
start_width = col_width
print(term.move(0, 0) + term.black_on_green(term.center('Host', width=col_width - 1)))
print(term.move(0, 1 * col_width) + term.black_on_green(term.center('Id', width=col_width - 1)))
print(term.move(0, 2 * col_width) + term.black_on_green(term.center('Status', width=col_width - 1)))
print(term.move(0, 3 * col_width) + term.black_on_green(term.center('Pool', width=col_width - 1)))
print(term.move(0, 4 * col_width) + term.black_on_green(term.center('TQ', width=col_width - 1)))
print(term.move(0, 5 * col_width) + term.black_on_green(term.center('RQ', width=col_width - 1)))
print(term.move(0, 6 * col_width) + term.black_on_green(term.center('RC', width=col_width - 1)))
print(term.move(0, 7 * col_width) + term.black_on_green(term.center('Up', width=col_width - 1)))
i = 2
stats = Stat.get_all(r=r)
print(term.clear_eos())
for stat in stats:
# color status
if stat.status == Conf.WORKING:
status = term.green(Conf.WORKING)
elif stat.status == Conf.STOPPED:
status = term.red(Conf.STOPPED)
elif stat.status == Conf.IDLE:
status = Conf.IDLE
else:
status = term.yellow(stat.status)
# color q's
tasks = stat.task_q_size
if tasks > 0:
tasks = term.cyan(str(tasks))
results = stat.done_q_size
if results > 0:
results = term.cyan(str(results))
# color workers
workers = len(stat.workers)
if workers < Conf.WORKERS:
workers = term.yellow(str(workers))
# format uptime
uptime = (timezone.now() - stat.tob).total_seconds()
hours, remainder = divmod(uptime, 3600)
minutes, seconds = divmod(remainder, 60)
uptime = '%d:%02d:%02d' % (hours, minutes, seconds)
# print to the terminal
print(term.move(i, 0) + term.center(stat.host[:col_width - 1], width=col_width - 1))
print(term.move(i, 1 * col_width) + term.center(stat.cluster_id, width=col_width - 1))
print(term.move(i, 2 * col_width) + term.center(status, width=col_width - 1))
print(term.move(i, 3 * col_width) + term.center(workers, width=col_width - 1))
print(term.move(i, 4 * col_width) + term.center(tasks, width=col_width - 1))
print(term.move(i, 5 * col_width) + term.center(results, width=col_width - 1))
print(term.move(i, 6 * col_width) + term.center(stat.reincarnations, width=col_width - 1))
print(term.move(i, 7 * col_width) + term.center(uptime, width=col_width - 1))
i += 1
# for testing
if run_once:
return Stat.get_all(r=r)
print(term.move(i + 2, 0) + term.center('[Press q to quit]'))
val = term.inkey(timeout=1)
示例7: main
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def main():
"""Program entry point."""
# pylint: disable=too-many-locals
# Too many local variables (20/15)
term = Terminal()
worm = [Location(x=term.width // 2, y=term.height // 2)]
worm_length = 2
bearing = Direction(*LEFT)
direction = left_of
nibble = Nibble(location=worm[0], value=0)
color_nibble = term.black_on_green
color_worm = term.yellow_reverse
color_head = term.red_reverse
color_bg = term.on_blue
echo(term.move(1, 1))
echo(color_bg(term.clear))
# speed is actually a measure of time; the shorter, the faster.
speed = 0.1
modifier = 0.93
inp = None
echo(term.move(term.height, 0))
with term.hidden_cursor(), term.cbreak(), term.location():
while inp not in (u'q', u'Q'):
# delete the tail of the worm at worm_length
if len(worm) > worm_length:
echo(term.move(*worm.pop(0)))
echo(color_bg(u' '))
# compute head location
head = worm.pop()
# check for hit against self; hitting a wall results in the (y, x)
# location being clipped, -- and death by hitting self (not wall).
if hit_any(head, worm):
break
# get the next nibble, which may be equal to ours unless this
# nibble has been struck by any portion of our worm body.
n_nibble = next_nibble(term, nibble, head, worm)
# get the next worm_length and speed, unless unchanged.
worm_length = next_wormlength(nibble, head, worm_length)
speed = next_speed(nibble, head, speed, modifier)
if n_nibble != nibble:
# erase the old one, careful to redraw the nibble contents
# with a worm color for those portions that overlay.
for (yloc, xloc) in nibble_locations(*nibble):
echo(u''.join((
term.move(yloc, xloc),
(color_worm if (yloc, xloc) == head
else color_bg)(u' '),
term.normal)))
# and draw the new,
echo(term.move(*n_nibble.location) + (
color_nibble('{}'.format(n_nibble.value))))
# display new worm head
echo(term.move(*head) + color_head(head_glyph(direction)))
# and its old head (now, a body piece)
if worm:
echo(term.move(*(worm[-1])))
echo(color_worm(u' '))
echo(term.move(*head))
# wait for keyboard input, which may indicate
# a new direction (up/down/left/right)
inp = term.inkey(timeout=speed)
# discover new direction, given keyboard input and/or bearing.
nxt_direction = next_bearing(term, inp.code, bearing)
# discover new bearing, given new direction compared to prev
nxt_bearing = change_bearing(nxt_direction, head, term)
# disallow new bearing/direction when flipped: running into
# oneself, for example traveling left while traveling right.
if not bearing_flipped(bearing, nxt_bearing):
direction = nxt_direction
bearing = nxt_bearing
# append the prior `head' onto the worm, then
# a new `head' for the given direction.
worm.extend([head, direction(head, term)])
# re-assign new nibble,
nibble = n_nibble
echo(term.normal)
score = (worm_length - 1) * 100
echo(u''.join((term.move(term.height - 1, 1), term.normal)))
echo(u''.join((u'\r\n', u'score: {}'.format(score), u'\r\n')))
示例8: monitor
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def monitor(run_once=False, broker=None):
if not broker:
broker = get_broker()
term = Terminal()
broker.ping()
with term.fullscreen(), term.hidden_cursor(), term.cbreak():
val = None
start_width = int(term.width / 8)
while val not in (u'q', u'Q',):
col_width = int(term.width / 8)
# In case of resize
if col_width != start_width:
print(term.clear())
start_width = col_width
print(term.move(0, 0) + term.black_on_green(term.center(_('Host'), width=col_width - 1)))
print(term.move(0, 1 * col_width) + term.black_on_green(term.center(_('Id'), width=col_width - 1)))
print(term.move(0, 2 * col_width) + term.black_on_green(term.center(_('State'), width=col_width - 1)))
print(term.move(0, 3 * col_width) + term.black_on_green(term.center(_('Pool'), width=col_width - 1)))
print(term.move(0, 4 * col_width) + term.black_on_green(term.center(_('TQ'), width=col_width - 1)))
print(term.move(0, 5 * col_width) + term.black_on_green(term.center(_('RQ'), width=col_width - 1)))
print(term.move(0, 6 * col_width) + term.black_on_green(term.center(_('RC'), width=col_width - 1)))
print(term.move(0, 7 * col_width) + term.black_on_green(term.center(_('Up'), width=col_width - 1)))
i = 2
stats = Stat.get_all(broker=broker)
print(term.clear_eos())
for stat in stats:
status = stat.status
# color status
if stat.status == Conf.WORKING:
status = term.green(str(Conf.WORKING))
elif stat.status == Conf.STOPPING:
status = term.yellow(str(Conf.STOPPING))
elif stat.status == Conf.STOPPED:
status = term.red(str(Conf.STOPPED))
elif stat.status == Conf.IDLE:
status = str(Conf.IDLE)
# color q's
tasks = str(stat.task_q_size)
if stat.task_q_size > 0:
tasks = term.cyan(str(stat.task_q_size))
if Conf.QUEUE_LIMIT and stat.task_q_size == Conf.QUEUE_LIMIT:
tasks = term.green(str(stat.task_q_size))
results = stat.done_q_size
if results > 0:
results = term.cyan(str(results))
# color workers
workers = len(stat.workers)
if workers < Conf.WORKERS:
workers = term.yellow(str(workers))
# format uptime
uptime = (timezone.now() - stat.tob).total_seconds()
hours, remainder = divmod(uptime, 3600)
minutes, seconds = divmod(remainder, 60)
uptime = '%d:%02d:%02d' % (hours, minutes, seconds)
# print to the terminal
print(term.move(i, 0) + term.center(stat.host[:col_width - 1], width=col_width - 1))
print(term.move(i, 1 * col_width) + term.center(stat.cluster_id, width=col_width - 1))
print(term.move(i, 2 * col_width) + term.center(status, width=col_width - 1))
print(term.move(i, 3 * col_width) + term.center(workers, width=col_width - 1))
print(term.move(i, 4 * col_width) + term.center(tasks, width=col_width - 1))
print(term.move(i, 5 * col_width) + term.center(results, width=col_width - 1))
print(term.move(i, 6 * col_width) + term.center(stat.reincarnations, width=col_width - 1))
print(term.move(i, 7 * col_width) + term.center(uptime, width=col_width - 1))
i += 1
# bottom bar
i += 1
queue_size = broker.queue_size()
lock_size = broker.lock_size()
if lock_size:
queue_size = '{}({})'.format(queue_size, lock_size)
print(term.move(i, 0) + term.white_on_cyan(term.center(broker.info(), width=col_width * 2)))
print(term.move(i, 2 * col_width) + term.black_on_cyan(term.center(_('Queued'), width=col_width)))
print(term.move(i, 3 * col_width) + term.white_on_cyan(term.center(queue_size, width=col_width)))
print(term.move(i, 4 * col_width) + term.black_on_cyan(term.center(_('Success'), width=col_width)))
print(term.move(i, 5 * col_width) + term.white_on_cyan(
term.center(models.Success.objects.count(), width=col_width)))
print(term.move(i, 6 * col_width) + term.black_on_cyan(term.center(_('Failures'), width=col_width)))
print(term.move(i, 7 * col_width) + term.white_on_cyan(
term.center(models.Failure.objects.count(), width=col_width)))
# for testing
if run_once:
return Stat.get_all(broker=broker)
print(term.move(i + 2, 0) + term.center(_('[Press q to quit]')))
val = term.inkey(timeout=1)
示例9: monitor
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def monitor(run_once=False):
term = Terminal()
r = redis_client
try:
redis_client.ping()
except Exception as e:
print(term.red("Can not connect to Redis server."))
logger.exception(e)
raise e
with term.fullscreen(), term.hidden_cursor(), term.cbreak():
val = None
start_width = int(term.width / 8)
while val not in (u"q", u"Q"):
col_width = int(term.width / 8)
# In case of resize
if col_width != start_width:
print(term.clear)
start_width = col_width
print(term.move(0, 0) + term.black_on_green(term.center(_("Host"), width=col_width - 1)))
print(term.move(0, 1 * col_width) + term.black_on_green(term.center(_("Id"), width=col_width - 1)))
print(term.move(0, 2 * col_width) + term.black_on_green(term.center(_("State"), width=col_width - 1)))
print(term.move(0, 3 * col_width) + term.black_on_green(term.center(_("Pool"), width=col_width - 1)))
print(term.move(0, 4 * col_width) + term.black_on_green(term.center(_("TQ"), width=col_width - 1)))
print(term.move(0, 5 * col_width) + term.black_on_green(term.center(_("RQ"), width=col_width - 1)))
print(term.move(0, 6 * col_width) + term.black_on_green(term.center(_("RC"), width=col_width - 1)))
print(term.move(0, 7 * col_width) + term.black_on_green(term.center(_("Up"), width=col_width - 1)))
i = 2
stats = Stat.get_all(r=r)
print(term.clear_eos())
for stat in stats:
status = stat.status
# color status
if stat.status == Conf.WORKING:
status = term.green(str(Conf.WORKING))
elif stat.status == Conf.STOPPING:
status = term.yellow(str(Conf.STOPPING))
elif stat.status == Conf.STOPPED:
status = term.red(str(Conf.STOPPED))
elif stat.status == Conf.IDLE:
status = str(Conf.IDLE)
# color q's
tasks = stat.task_q_size
if tasks > 0:
tasks = term.cyan(str(tasks))
results = stat.done_q_size
if results > 0:
results = term.cyan(str(results))
# color workers
workers = len(stat.workers)
if workers < Conf.WORKERS:
workers = term.yellow(str(workers))
# format uptime
uptime = (timezone.now() - stat.tob).total_seconds()
hours, remainder = divmod(uptime, 3600)
minutes, seconds = divmod(remainder, 60)
uptime = "%d:%02d:%02d" % (hours, minutes, seconds)
# print to the terminal
print(term.move(i, 0) + term.center(stat.host[: col_width - 1], width=col_width - 1))
print(term.move(i, 1 * col_width) + term.center(stat.cluster_id, width=col_width - 1))
print(term.move(i, 2 * col_width) + term.center(status, width=col_width - 1))
print(term.move(i, 3 * col_width) + term.center(workers, width=col_width - 1))
print(term.move(i, 4 * col_width) + term.center(tasks, width=col_width - 1))
print(term.move(i, 5 * col_width) + term.center(results, width=col_width - 1))
print(term.move(i, 6 * col_width) + term.center(stat.reincarnations, width=col_width - 1))
print(term.move(i, 7 * col_width) + term.center(uptime, width=col_width - 1))
i += 1
# for testing
if run_once:
return Stat.get_all(r=r)
print(term.move(i + 2, 0) + term.center(_("[Press q to quit]")))
val = term.inkey(timeout=1)
示例10: right_of
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
b.term.KEY_RIGHT: right_of(b, 1),
b.term.KEY_DOWN: below(b, 1),
b.term.KEY_UP: above(b, 1),
# shift + arrows
b.term.KEY_SLEFT: left_of(b, 10),
b.term.KEY_SRIGHT: right_of(b, 10),
b.term.KEY_SDOWN: below(b, 10),
b.term.KEY_SUP: above(b, 10),
# carriage return
b.term.KEY_ENTER: home(below(b, 1)),
b.term.KEY_HOME: home(b),
}.get(inp_code, b)
term = Terminal()
csr = Cursor(1, 1, term)
with term.hidden_cursor(), term.raw(), term.location(), term.fullscreen():
inp = None
while True:
echo_xy(csr, term.reverse(u' '))
inp = term.inkey()
if inp.code == term.KEY_ESCAPE or inp == chr(3):
break
echo_xy(csr, u' ')
n_csr = lookup_move(inp.code, csr)
if n_csr != csr:
echo_xy(n_csr, u' ')
csr = n_csr
elif not inp.is_sequence:
echo_xy(csr, inp)
csr = right_of(csr, 1)
示例11: main
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def main():
"""Program entry point."""
above = lambda csr, n: (
Cursor(y=max(0, csr.y - n),
x=csr.x,
term=csr.term))
below = lambda csr, n: (
Cursor(y=min(csr.term.height - 1, csr.y + n),
x=csr.x,
term=csr.term))
right_of = lambda csr, n: (
Cursor(y=csr.y,
x=min(csr.term.width - 1, csr.x + n),
term=csr.term))
left_of = lambda csr, n: (
Cursor(y=csr.y,
x=max(0, csr.x - n),
term=csr.term))
home = lambda csr: (
Cursor(y=csr.y,
x=0,
term=csr.term))
end = lambda csr: (
Cursor(y=csr.y,
x=csr.term.width - 1,
term=csr.term))
bottom = lambda csr: (
Cursor(y=csr.term.height - 1,
x=csr.x,
term=csr.term))
center = lambda csr: Cursor(
csr.term.height // 2,
csr.term.width // 2,
csr.term)
lookup_move = lambda inp_code, csr, term: {
# arrows, including angled directionals
csr.term.KEY_END: below(left_of(csr, 1), 1),
csr.term.KEY_KP_1: below(left_of(csr, 1), 1),
csr.term.KEY_DOWN: below(csr, 1),
csr.term.KEY_KP_2: below(csr, 1),
csr.term.KEY_PGDOWN: below(right_of(csr, 1), 1),
csr.term.KEY_LR: below(right_of(csr, 1), 1),
csr.term.KEY_KP_3: below(right_of(csr, 1), 1),
csr.term.KEY_LEFT: left_of(csr, 1),
csr.term.KEY_KP_4: left_of(csr, 1),
csr.term.KEY_CENTER: center(csr),
csr.term.KEY_KP_5: center(csr),
csr.term.KEY_RIGHT: right_of(csr, 1),
csr.term.KEY_KP_6: right_of(csr, 1),
csr.term.KEY_HOME: above(left_of(csr, 1), 1),
csr.term.KEY_KP_7: above(left_of(csr, 1), 1),
csr.term.KEY_UP: above(csr, 1),
csr.term.KEY_KP_8: above(csr, 1),
csr.term.KEY_PGUP: above(right_of(csr, 1), 1),
csr.term.KEY_KP_9: above(right_of(csr, 1), 1),
# shift + arrows
csr.term.KEY_SLEFT: left_of(csr, 10),
csr.term.KEY_SRIGHT: right_of(csr, 10),
csr.term.KEY_SDOWN: below(csr, 10),
csr.term.KEY_SUP: above(csr, 10),
# carriage return
csr.term.KEY_ENTER: home(below(csr, 1)),
}.get(inp_code, csr)
term = Terminal()
csr = Cursor(0, 0, term)
screen = {}
with term.hidden_cursor(), \
term.raw(), \
term.location(), \
term.fullscreen(), \
term.keypad():
inp = None
while True:
echo_yx(csr, term.reverse(screen.get((csr.y, csr.x), u' ')))
inp = term.inkey()
if inp == chr(3):
# ^c exits
break
elif inp == chr(19):
#.........这里部分代码省略.........
示例12: main
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
def main(argv=None):
""" Execute the application CLI.
Arguments are taken from sys.argv by default.
"""
args = _cmdline(argv)
logger.start(args.logging_level)
logger.debug("starting execution")
# get repo and initialize GitHeat instance
try:
g = Git(os.getcwd())
except (InvalidGitRepositoryError, GitCommandError, GitCommandNotFound):
print("Are you sure you're in an initialized git directory?")
return 0
githeat = Githeat(g, **vars(args))
githeat.parse_commits()
githeat.init_daily_contribution_map()
githeat.compute_daily_contribution_map()
githeat.normalize_daily_contribution_map()
matrix = githeat.compute_graph_matrix()
term = Terminal()
matrix_width = githeat.get_matrix_width(matrix)
if matrix_width > term.width:
print("Your terminal width is smaller than the heatmap. Please consider using "
"the --width {thin, reg, thick} argument, resizing your terminal, or "
"merging months by including --month-merge.")
return 0
new_width = (term.width - matrix_width) // 2
csr = Cursor(term.height // 2 - 3, new_width, term)
screen = {}
screen_dates = {}
with term.hidden_cursor(), \
term.raw(), \
term.location(), \
term.fullscreen(), \
term.keypad():
# Print header
print_header_left(term, unicode(os.getcwd()), screen)
text = u'GitHeat {}'.format(__version__)
print_header_center(term, text, screen)
text = u'ESC, ^c to exit'
print_header_right(term, text, screen)
# Print footer
text = u'Please move cursor to navigate through map'
print_footer_left(term, term.bold(text), screen)
graph_right_most_x = term.width # initialized at terminal width
graph_left_most_x = csr.x
graph_top_most_y = csr.y
graph_x, graph_y = csr.x, csr.y
# get graph boundaries
for i in range(7):
# for the week column in the matrix
for week in matrix:
if githeat.month_merge:
# check if value in that week is just empty spaces and not colorize
if week.col[i][1] == githeat.width:
continue
graph_x += len(githeat.width)
graph_right_most_x = graph_x
graph_x = graph_left_most_x # reset x
graph_y += 1
graph_bottom_most_y = graph_y - 1
# print graph
graph_x, graph_y = csr.x, csr.y
print_graph(term, screen, screen_dates, graph_x, graph_y,
graph_left_most_x, matrix, githeat)
# print legend
block_separation_width = 4
legend_x = (term.width - len(githeat.colors) * block_separation_width) // 2
legend_y = graph_bottom_most_y + 5
if not githeat.hide_legend:
print_graph_legend(legend_x, legend_y,
githeat.width,
block_separation_width,
githeat.colors,
screen,
term)
while True:
cursor_color = colorize(githeat.width, ansi=15, ansi_bg=15)
echo_yx(csr, cursor_color)
inp = term.inkey()
if inp in QUIT_KEYS:
# Esc or ^c pressed
break
elif inp == chr(99):
# c pressed, thus change color
#.........这里部分代码省略.........
示例13: range
# 需要导入模块: from blessed import Terminal [as 别名]
# 或者: from blessed.Terminal import hidden_cursor [as 别名]
line.append(True)
return line
for i in range(layers_length):
offset = 1 if i < last else 0
for j in range(term.height - offset):
layers[i].append(generate_line(i + 1))
for i in range(prog_len - 1):
progress[progress_template[i]] = progress_template[i + 1]
progress[progress_template[prog_len - 1]] = progress_template[prog_len - 1]
with term.fullscreen(), term.hidden_cursor():
while not term.inkey(timeout=0.15):
out = term.move(0, 0)
for i in range(term.height - 1):
for j in range(term.width):
any = False
for k in reversed(range(len(layers))):
if layers[k][i][j]:
any = True
out += snow[k]
break
if not any:
out += u' '