Improved spinner

This commit is contained in:
Sven Heidemann 2021-03-05 16:27:38 +01:00
parent 570ede237e
commit 1dfae27d88
3 changed files with 16 additions and 16 deletions

View File

@ -22,10 +22,10 @@
<select /> <select />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="Improved workspace"> <list default="true" id="7e2256bc-a6b8-4880-83a6-8b0e3372d0a4" name="Default Changelist" comment="Added spinner">
<change afterPath="$PROJECT_DIR$/src/cpl/console/spinner_thread.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/cpl/console/console.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/console/console.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/cpl/console/console.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/console/console.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/cpl/console/spinner_thread.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl/console/spinner_thread.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/cpl_cli/publish/publisher.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl_cli/publish/publisher.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/cpl_cli/publish/publisher.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cpl_cli/publish/publisher.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -487,13 +487,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1605881914521</updated> <updated>1605881914521</updated>
</task> </task>
<task id="LOCAL-00046" summary="Bugfixes and improved setup logic">
<created>1608070231599</created>
<option name="number" value="00046" />
<option name="presentableId" value="LOCAL-00046" />
<option name="project" value="LOCAL" />
<updated>1608070231599</updated>
</task>
<task id="LOCAL-00047" summary="Improved cli"> <task id="LOCAL-00047" summary="Improved cli">
<created>1608122289003</created> <created>1608122289003</created>
<option name="number" value="00047" /> <option name="number" value="00047" />
@ -830,7 +823,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1614896795653</updated> <updated>1614896795653</updated>
</task> </task>
<option name="localTasksCounter" value="95" /> <task id="LOCAL-00095" summary="Added spinner">
<created>1614956114719</created>
<option name="number" value="00095" />
<option name="presentableId" value="LOCAL-00095" />
<option name="project" value="LOCAL" />
<updated>1614956114719</updated>
</task>
<option name="localTasksCounter" value="96" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -846,7 +846,6 @@
<option name="oldMeFiltersMigrated" value="true" /> <option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="Added init file for build command package" />
<MESSAGE value="Added pycharm files to gitignore" /> <MESSAGE value="Added pycharm files to gitignore" />
<MESSAGE value="Added more development tests" /> <MESSAGE value="Added more development tests" />
<MESSAGE value="Added new tester and CredentialManager TestCase" /> <MESSAGE value="Added new tester and CredentialManager TestCase" />
@ -871,7 +870,8 @@
<MESSAGE value="Improved application" /> <MESSAGE value="Improved application" />
<MESSAGE value="Readded workspace.xml" /> <MESSAGE value="Readded workspace.xml" />
<MESSAGE value="Improved workspace" /> <MESSAGE value="Improved workspace" />
<option name="LAST_COMMIT_MESSAGE" value="Improved workspace" /> <MESSAGE value="Added spinner" />
<option name="LAST_COMMIT_MESSAGE" value="Added spinner" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View File

@ -75,11 +75,10 @@ class Console:
args = [] args = []
colored_args = [] colored_args = []
if x is not None and y is not None: if x is not None and y is not None:
args.append(f'\033[{x};{y}H') args.append(f'\033[{y};{x}H')
elif cls._x is not None and cls._y is not None: elif cls._x is not None and cls._y is not None:
args.append(f'\033[{cls._x};{cls._y}H') args.append(f'\033[{cls._y};{cls._x}H')
colored_args.append(string) colored_args.append(string)
if cls._foreground_color != ForegroundColor.default and cls._background_color == BackgroundColor.default: if cls._foreground_color != ForegroundColor.default and cls._background_color == BackgroundColor.default:
@ -96,7 +95,6 @@ class Console:
""" """
Useful public methods Useful public methods
""" """
@classmethod @classmethod
def banner(cls, string: str): def banner(cls, string: str):
if cls._disabled: if cls._disabled:

View File

@ -17,11 +17,13 @@ class SpinnerThread(threading.Thread):
yield cursor yield cursor
def run(self) -> None: def run(self) -> None:
self._console.write('\t')
spinner = self._spinner() spinner = self._spinner()
while self._is_spinning: while self._is_spinning:
self._console.write(next(spinner)) self._console.write(next(spinner))
time.sleep(0.1) time.sleep(0.1)
self._console.write('\b') self._console.write('\b')
self._console.flush() self._console.flush()
self._console.write(' ') self._console.write(' ')