Python pygments.style.ansicolors() Examples
The following are 14
code examples of pygments.style.ansicolors().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygments.style
, or try the search function
.
Example #1
Source File: terminal256.py From pySINDy with MIT License | 6 votes |
def color_string(self): attrs = [] if self.fg is not None: if self.fg in ansicolors: esc = codes[self.fg[5:]] 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[5:]] # 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: attrs.append("04") return self.escape(attrs)
Example #2
Source File: terminal256.py From pySINDy with MIT License | 6 votes |
def _color_index(self, color): index = self.best_match.get(color, None) if color in ansicolors: # strip the `#ansi` part and look up code index = color self.best_match[color] = index if index is None: try: rgb = int(str(color), 16) except ValueError: rgb = 0 r = (rgb >> 16) & 0xff g = (rgb >> 8) & 0xff b = rgb & 0xff index = self._closest_color(r, g, b) self.best_match[color] = index return index
Example #3
Source File: terminal256.py From pygments with BSD 2-Clause "Simplified" License | 6 votes |
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.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.bold: attrs.append("01") if self.underline: attrs.append("04") if self.italic: attrs.append("03") return self.escape(attrs)
Example #4
Source File: terminal256.py From pygments with BSD 2-Clause "Simplified" License | 6 votes |
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 index is None: try: rgb = int(str(color), 16) except ValueError: rgb = 0 r = (rgb >> 16) & 0xff g = (rgb >> 8) & 0xff b = rgb & 0xff index = self._closest_color(r, g, b) self.best_match[color] = index return index
Example #5
Source File: terminal256.py From komodo-wakatime with BSD 3-Clause "New" or "Revised" License | 6 votes |
def color_string(self): attrs = [] if self.fg is not None: if self.fg in ansicolors: esc = codes[self.fg[5:]] 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[5:]] # 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: attrs.append("04") return self.escape(attrs)
Example #6
Source File: terminal256.py From komodo-wakatime with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _color_index(self, color): index = self.best_match.get(color, None) if color in ansicolors: # strip the `#ansi` part and look up code index = color self.best_match[color] = index if index is None: try: rgb = int(str(color), 16) except ValueError: rgb = 0 r = (rgb >> 16) & 0xff g = (rgb >> 8) & 0xff b = rgb & 0xff index = self._closest_color(r, g, b) self.best_match[color] = index return index
Example #7
Source File: terminal256.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def color_string(self): attrs = [] if self.fg is not None: if self.fg in ansicolors: esc = codes[self.fg[5:]] 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[5:]] # 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: attrs.append("04") return self.escape(attrs)
Example #8
Source File: terminal256.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _color_index(self, color): index = self.best_match.get(color, None) if color in ansicolors: # strip the `#ansi` part and look up code index = color self.best_match[color] = index if index is None: try: rgb = int(str(color), 16) except ValueError: rgb = 0 r = (rgb >> 16) & 0xff g = (rgb >> 8) & 0xff b = rgb & 0xff index = self._closest_color(r, g, b) self.best_match[color] = index return index
Example #9
Source File: terminal256.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
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.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.bold: attrs.append("01") if self.underline: attrs.append("04") if self.italic: attrs.append("03") return self.escape(attrs)
Example #10
Source File: terminal256.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
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 index is None: try: rgb = int(str(color), 16) except ValueError: rgb = 0 r = (rgb >> 16) & 0xff g = (rgb >> 8) & 0xff b = rgb & 0xff index = self._closest_color(r, g, b) self.best_match[color] = index return index
Example #11
Source File: terminal256.py From android_universal with MIT License | 6 votes |
def color_string(self): attrs = [] if self.fg is not None: if self.fg in ansicolors: esc = codes[self.fg[5:]] 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[5:]] # 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: attrs.append("04") return self.escape(attrs)
Example #12
Source File: terminal256.py From android_universal with MIT License | 6 votes |
def _color_index(self, color): index = self.best_match.get(color, None) if color in ansicolors: # strip the `#ansi` part and look up code index = color self.best_match[color] = index if index is None: try: rgb = int(str(color), 16) except ValueError: rgb = 0 r = (rgb >> 16) & 0xff g = (rgb >> 8) & 0xff b = rgb & 0xff index = self._closest_color(r, g, b) self.best_match[color] = index return index
Example #13
Source File: terminal256.py From syntax-highlighting with GNU Affero General Public License v3.0 | 6 votes |
def color_string(self): attrs = [] if self.fg is not None: if self.fg in ansicolors: esc = codes[self.fg[5:]] 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[5:]] # 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: attrs.append("04") return self.escape(attrs)
Example #14
Source File: terminal256.py From syntax-highlighting with GNU Affero General Public License v3.0 | 6 votes |
def _color_index(self, color): index = self.best_match.get(color, None) if color in ansicolors: # strip the `#ansi` part and look up code index = color self.best_match[color] = index if index is None: try: rgb = int(str(color), 16) except ValueError: rgb = 0 r = (rgb >> 16) & 0xff g = (rgb >> 8) & 0xff b = rgb & 0xff index = self._closest_color(r, g, b) self.best_match[color] = index return index