Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ The only ANSI sequences that colorama converts into win32 calls are::
ESC [ 0 m # reset all (colors and brightness)
ESC [ 1 m # bright
ESC [ 2 m # dim (looks same as normal brightness)
ESC [ 7 m # swap foreground and background
ESC [ 22 m # normal brightness

# FOREGROUND:
Expand Down
1 change: 1 addition & 0 deletions colorama/ansi.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class AnsiStyle(AnsiCodes):
DIM = 2
NORMAL = 22
RESET_ALL = 0
REVERSE_FORE_BACK = 7

Fore = AnsiFore()
Back = AnsiBack()
Expand Down
1 change: 1 addition & 0 deletions colorama/ansitowin32.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def get_win32_calls(self):
if self.convert and winterm:
return {
AnsiStyle.RESET_ALL: (winterm.reset_all, ),
AnsiStyle.REVERSE_FORE_BACK: (winterm.reverse_fore_back, ),
AnsiStyle.BRIGHT: (winterm.style, WinStyle.BRIGHT),
AnsiStyle.DIM: (winterm.style, WinStyle.NORMAL),
AnsiStyle.NORMAL: (winterm.style, WinStyle.NORMAL),
Expand Down
6 changes: 6 additions & 0 deletions colorama/winterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def reset_all(self, on_stderr=None):
self.set_attrs(self._default)
self.set_console(attrs=self._default)

def reverse_fore_back(self, on_stderr=None):
self._back, self._fore = self._fore, self._back
self._style = ((self._style & 0xF) << 4) | ((self._style >> 4) & 0xF)
self._light = ((self._light & 0xF) << 4) | ((self._light >> 4) & 0xF)
self.set_console(on_stderr=on_stderr)

def fore(self, fore=None, light=False, on_stderr=False):
if fore is None:
fore = self._default_fore
Expand Down