From 93c919c84aa4cfc00c4da3b9563c10d48ff273ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Sampaio?= Date: Wed, 28 Apr 2021 02:31:17 -0300 Subject: [PATCH] cursor up 1 is ready --- alive_progress/animations/bars.py | 3 +-- alive_progress/animations/spinner_compiler.py | 3 +-- alive_progress/utils/terminal.py | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/alive_progress/animations/bars.py b/alive_progress/animations/bars.py index a1b4f7e..6fb8931 100644 --- a/alive_progress/animations/bars.py +++ b/alive_progress/animations/bars.py @@ -7,7 +7,7 @@ from ..utils.cells import VS_15, combine_cells, fix_cells, has_wide, is_wide, join_cells, \ mark_graphemes, split_graphemes, strip_marks, to_cells from ..utils.colors import BLUE, BLUE_BOLD, CYAN, DIM, GREEN, ORANGE, ORANGE_BOLD, RED, YELLOW_BOLD -from ..utils.terminal import clear_end, factory_cursor_up, hide_cursor, show_cursor +from ..utils.terminal import clear_end, cursor_up_1, hide_cursor, show_cursor def bar_factory(chars=None, *, tip=None, background=None, borders=None, errors=None): @@ -224,7 +224,6 @@ def animate(bar): # pragma: no cover bar_gen = exhibit_bar(bar, 15) hide_cursor() try: - cursor_up_1 = factory_cursor_up(1) while True: rendition, percent = next(bar_gen) print(f'\r{join_cells(rendition)}', CYAN(percent, "6.1%")) diff --git a/alive_progress/animations/spinner_compiler.py b/alive_progress/animations/spinner_compiler.py index 4126c52..4ab00f7 100644 --- a/alive_progress/animations/spinner_compiler.py +++ b/alive_progress/animations/spinner_compiler.py @@ -10,7 +10,7 @@ from .utils import fix_signature from ..utils.cells import fix_cells, is_wide, join_cells, strip_marks, to_cells from ..utils.colors import BLUE, BLUE_BOLD, CYAN, DIM, GREEN, ORANGE, ORANGE_BOLD, RED, YELLOW_BOLD -from ..utils.terminal import clear_end, factory_cursor_up, hide_cursor, show_cursor +from ..utils.terminal import clear_end, cursor_up_1, hide_cursor, show_cursor def spinner_controller(*, natural, skip_compiler=False): @@ -337,7 +337,6 @@ def animate(spec): # pragma: no cover cycles, frames = cycle(range(1, spec.cycles + 1)), cycle(range(1, spec.total_frames + 1)) hide_cursor() try: - cursor_up_1 = factory_cursor_up(1) while True: c = next(cycles) for i, f in enumerate(spec.runner(), 1): diff --git a/alive_progress/utils/terminal.py b/alive_progress/utils/terminal.py index a60ec5d..d4857a3 100644 --- a/alive_progress/utils/terminal.py +++ b/alive_progress/utils/terminal.py @@ -26,3 +26,4 @@ def terminal_cols(): # pragma: no cover hide_cursor = _send_ansi_escape('?25l') # hides the cursor: CSI ? 25 l. show_cursor = _send_ansi_escape('?25h') # shows the cursor: CSI ? 25 h. factory_cursor_up = partial(_send_ansi_escape, 'A') # sends cursor up: CSI {x}A. +cursor_up_1 = factory_cursor_up(1)