Skip to content

Commit

Permalink
Fix special ansi sequences not ignored and producing wrong colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed May 25, 2019
1 parent b71bec9 commit cfa0ce1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions colorama/ansitowin32.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit cfa0ce1

Please sign in to comment.