aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_dl/minicurses.py
diff options
context:
space:
mode:
Diffstat (limited to 'hypervideo_dl/minicurses.py')
-rw-r--r--hypervideo_dl/minicurses.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/hypervideo_dl/minicurses.py b/hypervideo_dl/minicurses.py
index f9f99e3..7db02cb 100644
--- a/hypervideo_dl/minicurses.py
+++ b/hypervideo_dl/minicurses.py
@@ -1,7 +1,7 @@
import functools
from threading import Lock
-from .utils import supports_terminal_sequences, write_string
+from .utils import supports_terminal_sequences, write_string
CONTROL_SEQUENCES = {
'DOWN': '\n',
@@ -34,7 +34,7 @@ def format_text(text, f):
'''
@param f String representation of formatting to apply in the form:
[style] [light] font_color [on [light] bg_color]
- Eg: "red", "bold green on light blue"
+ E.g. "red", "bold green on light blue"
'''
f = f.upper()
tokens = f.strip().split()
@@ -69,6 +69,7 @@ def format_text(text, f):
raise SyntaxError(f'Invalid format {" ".join(tokens)!r} in {f!r}')
if fg_color or bg_color:
+ text = text.replace(CONTROL_SEQUENCES['RESET'], f'{fg_color}{bg_color}')
return f'{fg_color}{bg_color}{text}{CONTROL_SEQUENCES["RESET"]}'
else:
return text
@@ -178,4 +179,4 @@ class MultilinePrinter(MultilinePrinterBase):
*text, CONTROL_SEQUENCES['ERASE_LINE'],
f'{CONTROL_SEQUENCES["UP"]}{CONTROL_SEQUENCES["ERASE_LINE"]}' * self.maximum)
else:
- self.write(*text, ' ' * self._lastlength)
+ self.write('\r', ' ' * self._lastlength, '\r')