diff options
author | Matthäus G. Chajdas <dev@anteru.net> | 2020-01-07 21:10:52 +0100 |
---|---|---|
committer | Matthäus G. Chajdas <dev@anteru.net> | 2020-01-07 21:10:52 +0100 |
commit | c7751058ec70e380fa57b7a8db102c1a8a37c25c (patch) | |
tree | e1097d74aedbe4aef48f9fdcab0c3b74ce48ae9f /pygments/formatters/terminal256.py | |
parent | d55d8be8da86fb5a273263375fab90993ddb7e9e (diff) | |
parent | 4f8b0b66ebb7ea5695441d5a97ac836b75e97e7a (diff) | |
download | pygments-git-c7751058ec70e380fa57b7a8db102c1a8a37c25c.tar.gz |
Merge branch 'master' into 671/upsuper/webidl
This allows us to resolve the merge conflict properly.
Diffstat (limited to 'pygments/formatters/terminal256.py')
-rw-r--r-- | pygments/formatters/terminal256.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pygments/formatters/terminal256.py b/pygments/formatters/terminal256.py index 43ec01c2..b6bf9376 100644 --- a/pygments/formatters/terminal256.py +++ b/pygments/formatters/terminal256.py @@ -35,11 +35,12 @@ __all__ = ['Terminal256Formatter', 'TerminalTrueColorFormatter'] class EscapeSequence: - def __init__(self, fg=None, bg=None, bold=False, underline=False): + def __init__(self, fg=None, bg=None, bold=False, underline=False, italic=False): self.fg = fg self.bg = bg self.bold = bold self.underline = underline + self.italic = italic def escape(self, attrs): if len(attrs): @@ -68,6 +69,8 @@ class EscapeSequence: attrs.append("01") if self.underline: attrs.append("04") + if self.italic: + attrs.append("03") return self.escape(attrs) def true_color_string(self): @@ -80,6 +83,8 @@ class EscapeSequence: attrs.append("01") if self.underline: attrs.append("04") + if self.italic: + attrs.append("03") return self.escape(attrs) def reset_string(self): @@ -88,7 +93,7 @@ class EscapeSequence: attrs.append("39") if self.bg is not None: attrs.append("49") - if self.bold or self.underline: + if self.bold or self.underline or self.italic: attrs.append("00") return self.escape(attrs) @@ -135,6 +140,7 @@ class Terminal256Formatter(Formatter): self.usebold = 'nobold' not in options self.useunderline = 'nounderline' not in options + self.useitalic = 'noitalic' not in options self._build_color_table() # build an RGB-to-256 color conversion table self._setup_styles() # convert selected style's colors to term. colors @@ -227,6 +233,8 @@ class Terminal256Formatter(Formatter): escape.bold = True if self.useunderline and ndef['underline']: escape.underline = True + if self.useitalic and ndef['italic']: + escape.italic = True self.style_string[str(ttype)] = (escape.color_string(), escape.reset_string()) @@ -311,5 +319,7 @@ class TerminalTrueColorFormatter(Terminal256Formatter): escape.bold = True if self.useunderline and ndef['underline']: escape.underline = True + if self.useitalic and ndef['italic']: + escape.italic = True self.style_string[str(ttype)] = (escape.true_color_string(), escape.reset_string()) |