diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/python/Pygments/py3/pygments/formatters/terminal256.py | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters/terminal256.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/formatters/terminal256.py | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/contrib/python/Pygments/py3/pygments/formatters/terminal256.py b/contrib/python/Pygments/py3/pygments/formatters/terminal256.py index be6f890f44..60add14f9c 100644 --- a/contrib/python/Pygments/py3/pygments/formatters/terminal256.py +++ b/contrib/python/Pygments/py3/pygments/formatters/terminal256.py @@ -24,8 +24,8 @@ # to "white background, black foreground", etc... from pygments.formatter import Formatter -from pygments.console import codes -from pygments.style import ansicolors +from pygments.console import codes +from pygments.style import ansicolors __all__ = ['Terminal256Formatter', 'TerminalTrueColorFormatter'] @@ -47,21 +47,21 @@ class EscapeSequence: def color_string(self): attrs = [] if self.fg is not None: - if self.fg in ansicolors: - esc = codes[self.fg.replace('ansi','')] - if ';01m' in esc: - self.bold = True - # extract fg color code. - attrs.append(esc[2:4]) - else: - attrs.extend(("38", "5", "%i" % self.fg)) + if self.fg in ansicolors: + esc = codes[self.fg.replace('ansi','')] + if ';01m' in esc: + self.bold = True + # extract fg color code. + attrs.append(esc[2:4]) + else: + attrs.extend(("38", "5", "%i" % self.fg)) if self.bg is not None: - if self.bg in ansicolors: - esc = codes[self.bg.replace('ansi','')] - # extract fg color code, add 10 for bg. - attrs.append(str(int(esc[2:4])+10)) - else: - attrs.extend(("48", "5", "%i" % self.bg)) + if self.bg in ansicolors: + esc = codes[self.bg.replace('ansi','')] + # extract fg color code, add 10 for bg. + attrs.append(str(int(esc[2:4])+10)) + else: + attrs.extend(("48", "5", "%i" % self.bg)) if self.bold: attrs.append("01") if self.underline: @@ -107,17 +107,17 @@ class Terminal256Formatter(Formatter): .. versionadded:: 0.9 - .. versionchanged:: 2.2 - If the used style defines foreground colors in the form ``#ansi*``, then - `Terminal256Formatter` will map these to non extended foreground color. - See :ref:`AnsiTerminalStyle` for more information. - - .. versionchanged:: 2.4 - The ANSI color names have been updated with names that are easier to - understand and align with colornames of other projects and terminals. - See :ref:`this table <new-ansi-color-names>` for more information. - - + .. versionchanged:: 2.2 + If the used style defines foreground colors in the form ``#ansi*``, then + `Terminal256Formatter` will map these to non extended foreground color. + See :ref:`AnsiTerminalStyle` for more information. + + .. versionchanged:: 2.4 + The ANSI color names have been updated with names that are easier to + understand and align with colornames of other projects and terminals. + See :ref:`this table <new-ansi-color-names>` for more information. + + Options accepted: `style` @@ -204,10 +204,10 @@ class Terminal256Formatter(Formatter): def _color_index(self, color): index = self.best_match.get(color, None) - if color in ansicolors: - # strip the `ansi/#ansi` part and look up code - index = color - self.best_match[color] = index + if color in ansicolors: + # strip the `ansi/#ansi` part and look up code + index = color + self.best_match[color] = index if index is None: try: rgb = int(str(color), 16) @@ -224,14 +224,14 @@ class Terminal256Formatter(Formatter): def _setup_styles(self): for ttype, ndef in self.style: escape = EscapeSequence() - # get foreground from ansicolor if set - if ndef['ansicolor']: - escape.fg = self._color_index(ndef['ansicolor']) - elif ndef['color']: + # get foreground from ansicolor if set + if ndef['ansicolor']: + escape.fg = self._color_index(ndef['ansicolor']) + elif ndef['color']: escape.fg = self._color_index(ndef['color']) - if ndef['bgansicolor']: - escape.bg = self._color_index(ndef['bgansicolor']) - elif ndef['bgcolor']: + if ndef['bgansicolor']: + escape.bg = self._color_index(ndef['bgansicolor']) + elif ndef['bgcolor']: escape.bg = self._color_index(ndef['bgcolor']) if self.usebold and ndef['bold']: escape.bold = True |