From cfa0ce109a6831e08224177229efa033d6219ee5 Mon Sep 17 00:00:00 2001 From: Delgan Date: Sat, 25 May 2019 11:16:20 +0200 Subject: [PATCH] Fix special ansi sequences not ignored and producing wrong colors --- colorama/ansitowin32.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/colorama/ansitowin32.py b/colorama/ansitowin32.py index 359c92b..5aec081 100644 --- a/colorama/ansitowin32.py +++ b/colorama/ansitowin32.py @@ -222,13 +222,26 @@ def extract_params(self, command, paramstring): def call_win32(self, command, params): if command == 'm': + # Ansi sequences started by specific param may need to be ignored, see #217 + skip = False for param in params: + if skip: + if skip is not True: + skip -= 1 + continue + if skip is True and param in (2, 5): + skip = 1 if param == 5 else 3 + continue + skip = False if param in self.win32_calls: func_args = self.win32_calls[param] func = func_args[0] args = func_args[1:] kwargs = dict(on_stderr=self.on_stderr) func(*args, **kwargs) + elif param in (38, 48): + skip = True + elif command in 'J': winterm.erase_screen(params[0], on_stderr=self.on_stderr) elif command in 'K':