Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix animation of long lines #247

Merged
merged 19 commits into from
Oct 29, 2019
Merged
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a26b2bb
Truncate long lines with animation, to prevent multi-line.
itsayellow Oct 20, 2019
0fefbf2
Remove unused TERM_ROWS.
itsayellow Oct 20, 2019
4bcce89
Tailor truncation depending on animate_at_beginning_of_line.
itsayellow Oct 20, 2019
6bfe12c
Make if test correspond to string format precision.
itsayellow Oct 21, 2019
c7ef9d8
Move get_terminal_size() inside of animate().
itsayellow Oct 21, 2019
4f31d46
Fix bug from last commit.
itsayellow Oct 21, 2019
58cbefb
Make max message length method a bit clearer.
itsayellow Oct 22, 2019
9fdf83f
Add tests for message truncation.
itsayellow Oct 24, 2019
aec4c98
Deleted unused import sys.
itsayellow Oct 24, 2019
9e1eb97
Add HIDE_CURSOR, SHOW_CURSOR, CLEAR_LINE global strings to animate.py.
itsayellow Oct 27, 2019
29a058a
Add EMOJI_ANIMATION_FRAMES, NONEMOJI_ANIMATION_FRAMES globals to anim…
itsayellow Oct 27, 2019
f3aa77a
Add EMOJI_ANIMATION_PERIOD, NONEMOJI_ANIMATION_PERIOD globals to anim…
itsayellow Oct 27, 2019
c9be0a7
Remove python shebang.
itsayellow Oct 27, 2019
73b861f
Implement teardown to re-do original terminal state.
itsayellow Oct 28, 2019
49228e5
Use monkeypatch instead of terminal_state fixture.
itsayellow Oct 28, 2019
9f60dc5
Refactor and remove unused import pytest.
itsayellow Oct 28, 2019
443b621
Increase sleep time to ensure all frames print.
itsayellow Oct 28, 2019
f60e310
Merge remote-tracking branch 'upstream/master' into animate_long_lines
itsayellow Oct 28, 2019
8f89f97
Merge branch 'animate_long_lines' of github.com:itsayellow/pipx into …
itsayellow Oct 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pipx/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from contextlib import contextmanager
from threading import Event, Thread
from typing import Generator, List
import shutil

from pipx.constants import emoji_support

Expand Down Expand Up @@ -59,12 +60,17 @@ def print_animation(
period: float,
animate_at_beginning_of_line: bool,
):
(term_cols, _) = shutil.get_terminal_size(fallback=(9999, 24))
while not event.wait(0):
for s in symbols:
if animate_at_beginning_of_line:
cur_line = f"{s} {message}"
max_message_len = term_cols - len(f"{s} ... ")
cur_line = f"{s} {message:.{max_message_len}}"
if len(message) > max_message_len:
cur_line += "..."
gaborbernat marked this conversation as resolved.
Show resolved Hide resolved
else:
cur_line = f"{message}{s}"
max_message_len = term_cols - len("... ")
cur_line = f"{message:.{max_message_len}}{s}"

clear_line()
sys.stderr.write("\r")
Expand Down