当前位置: 首页>>代码示例>>Python>>正文


Python styles.get_style_by_name方法代码示例

本文整理汇总了Python中pygments.styles.get_style_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python styles.get_style_by_name方法的具体用法?Python styles.get_style_by_name怎么用?Python styles.get_style_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygments.styles的用法示例。


在下文中一共展示了styles.get_style_by_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_colors

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def get_colors(stylename):
    """Construct the keys to be used building the base stylesheet
    from a templatee."""
    style = get_style_by_name(stylename)
    fgcolor = style.style_for_token(Token.Text)['color'] or ''
    if len(fgcolor) in (3,6):
        # could be 'abcdef' or 'ace' hex, which needs '#' prefix
        try:
            int(fgcolor, 16)
        except TypeError:
            pass
        else:
            fgcolor = "#"+fgcolor

    return dict(
        bgcolor = style.background_color,
        select = style.highlight_color,
        fgcolor = fgcolor
    ) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:styles.py

示例2: __init__

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def __init__(self, **kwargs):
        stylename = kwargs.get('style_name', 'default')
        style = kwargs['style'] if 'style' in kwargs \
            else styles.get_style_by_name(stylename)
        self.formatter = BBCodeFormatter(style=style)
        self.lexer = lexers.PythonLexer()
        self.text_color = '#000000'
        self._label_cached = Label()
        self.use_text_color = True

        super(CodeInput, self).__init__(**kwargs)

        self._line_options = kw = self._get_line_options()
        self._label_cached = Label(**kw)
        # use text_color as foreground color
        text_color = kwargs.get('foreground_color')
        if text_color:
            self.text_color = get_hex_from_color(text_color)
        # set foreground to white to allow text colors to show
        # use text_color as the default color in bbcodes
        self.use_text_color = False
        self.foreground_color = [1, 1, 1, .999]
        if not kwargs.get('background_color'):
            self.background_color = [.9, .92, .92, 1] 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:26,代码来源:codeinput.py

示例3: __init__

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def __init__(self, style):
        """
        :param style: name of the pygments style to load
        """
        self._name = style
        self._brushes = {}
        #: Dictionary of formats colors (keys are the same as for
        #: :attr:`pyqode.core.api.COLOR_SCHEME_KEYS`
        self.formats = {}
        try:
            style = get_style_by_name(style)
        except ClassNotFound:
            if style == 'darcula':
                from pyqode.core.styles.darcula import DarculaStyle
                style = DarculaStyle
            else:
                from pyqode.core.styles.qt import QtStyle
                style = QtStyle
        self._load_formats_from_style(style) 
开发者ID:TuringApp,项目名称:Turing,代码行数:21,代码来源:syntax_highlighter.py

示例4: _update_style

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def _update_style(self):
        """ Sets the style to the specified Pygments style.
        """
        try:
            self._style = get_style_by_name(self._pygments_style)
        except ClassNotFound:
            # unknown style, also happen with plugins style when used from a
            # frozen app.
            if self._pygments_style == 'qt':
                from pyqode.core.styles import QtStyle
                self._style = QtStyle
            elif self._pygments_style == 'darcula':
                from pyqode.core.styles import DarculaStyle
                self._style = DarculaStyle
            else:
                self._style = get_style_by_name('default')
                self._pygments_style = 'default'
        self._clear_caches() 
开发者ID:TuringApp,项目名称:Turing,代码行数:20,代码来源:pygments_sh.py

示例5: style_from_pygments_cls

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def style_from_pygments_cls(pygments_style_cls: Type["PygmentsStyle"]) -> Style:
    """
    Shortcut to create a :class:`.Style` instance from a Pygments style class
    and a style dictionary.

    Example::

        from prompt_toolkit.styles.from_pygments import style_from_pygments_cls
        from pygments.styles import get_style_by_name
        style = style_from_pygments_cls(get_style_by_name('monokai'))

    :param pygments_style_cls: Pygments style class to start from.
    """
    # Import inline.
    from pygments.style import Style as PygmentsStyle

    assert issubclass(pygments_style_cls, PygmentsStyle)

    return style_from_pygments_dict(pygments_style_cls.styles) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:21,代码来源:pygments.py

示例6: pygments_style_from_name_or_cls

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def pygments_style_from_name_or_cls(name_or_cls, ishell):
    if name_or_cls == 'legacy':
        legacy = ishell.colors.lower()
        if legacy == 'linux':
            return get_style_by_name('monokai')
        elif legacy == 'lightbg':
            return get_style_by_name('pastie')
        elif legacy == 'neutral':
            return get_style_by_name('default')
        elif legacy == 'nocolor':
            return _NoStyle
        else:
            raise ValueError('Got unknown colors: ', legacy)
    else:
        if isinstance(name_or_cls, str):
            return get_style_by_name(name_or_cls)
        else:
            return name_or_cls 
开发者ID:tommikaikkonen,项目名称:prettyprinter,代码行数:20,代码来源:ipython.py

示例7: _syntax_highlighting

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def _syntax_highlighting(self, data):
        try:
            from pygments import highlight
            from pygments.lexers import GasLexer
            from pygments.formatters import TerminalFormatter, Terminal256Formatter
            from pygments.styles import get_style_by_name
            style = get_style_by_name('colorful')
            import curses
            curses.setupterm()
            if curses.tigetnum('colors') >= 256:
                FORMATTER = Terminal256Formatter(style=style)
            else:
                FORMATTER = TerminalFormatter()
            # When pygments is available, we
            # can print the disassembled
            # instructions with syntax
            # highlighting.
            data = highlight(data, GasLexer(), FORMATTER)
        except ImportError:
            pass
        finally:
            data = data.encode()
        return data 
开发者ID:takeshixx,项目名称:deen,代码行数:25,代码来源:arm.py

示例8: print_packets

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def print_packets(path: list, nodes: dict) -> None:
    tokens = []
    for e in path[:-1]:
        node = nodes[e.dst]
        p = node.render()
        line = '{} = {}'.format(node.name.replace('-', '_'), repr(p))
        tokens.extend(list(pygments.lex(line, lexer=Python3Lexer())))

    # p = self.fuzz_node.render()
    node = nodes[path[-1].dst]
    p = node.render()
    line = '{} = {}'.format(node.name.replace('-', '_'), repr(p))

    print(pygments.highlight(line, Python3Lexer(), Terminal256Formatter(style='rrt')))

    # tokens.extend(list(pygments.lex(line, lexer=Python3Lexer())))
    # style = style_from_pygments_cls(get_style_by_name('colorful'))
    # print_formatted_text(PygmentsTokens(tokens), style=style)


# --------------------------------------------------------------- # 
开发者ID:nccgroup,项目名称:fuzzowski,代码行数:23,代码来源:printers.py

示例9: dark_style

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def dark_style(stylename):
    """Guess whether the background of the style with name 'stylename'
    counts as 'dark'."""
    return dark_color(get_style_by_name(stylename).background_color) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:styles.py

示例10: set_style

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def set_style(self, style):
        """ Sets the style to the specified Pygments style.
        """
        if isinstance(style, basestring):
            style = get_style_by_name(style)
        self._style = style
        self._clear_caches() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:pygments_highlighter.py

示例11: __init__

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def __init__(
        self,
        code: str,
        lexer_name: str,
        *,
        theme: Union[str, Type[PygmentsStyle]] = DEFAULT_THEME,
        dedent: bool = False,
        line_numbers: bool = False,
        start_line: int = 1,
        line_range: Tuple[int, int] = None,
        highlight_lines: Set[int] = None,
        code_width: Optional[int] = None,
        tab_size: int = 4,
        word_wrap: bool = False
    ) -> None:
        self.code = code
        self.lexer_name = lexer_name
        self.dedent = dedent
        self.line_numbers = line_numbers
        self.start_line = start_line
        self.line_range = line_range
        self.highlight_lines = highlight_lines or set()
        self.code_width = code_width
        self.tab_size = tab_size
        self.word_wrap = word_wrap

        self._style_cache: Dict[Any, Style] = {}

        if not isinstance(theme, str) and issubclass(theme, PygmentsStyle):
            self._pygments_style_class = theme
        else:
            try:
                self._pygments_style_class = get_style_by_name(theme)
            except ClassNotFound:
                self._pygments_style_class = get_style_by_name("default")
        self._background_color = self._pygments_style_class.background_color 
开发者ID:willmcgugan,项目名称:rich,代码行数:38,代码来源:syntax.py

示例12: get_all_code_styles

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def get_all_code_styles() -> Dict[str, BaseStyle]:
    """
    Return a mapping from style names to their classes.
    """
    result: Dict[str, BaseStyle] = {
        name: style_from_pygments_cls(get_style_by_name(name))
        for name in get_all_styles()
    }
    result["win32"] = Style.from_dict(win32_code_style)
    return result 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:12,代码来源:style.py

示例13: __init__

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def __init__(self, *extras, style='default'):
        super().__init__(*extras)
        self.formatter.style = get_style(style) 
开发者ID:miyuchina,项目名称:mistletoe,代码行数:5,代码来源:pygments_renderer.py

示例14: _lookup_style

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def _lookup_style(style):
    if isinstance(style, string_types):
        return get_style_by_name(style)
    return style 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:6,代码来源:formatter.py

示例15: set_style

# 需要导入模块: from pygments import styles [as 别名]
# 或者: from pygments.styles import get_style_by_name [as 别名]
def set_style(self, style):
        """ Sets the style to the specified Pygments style.
        """
        if isinstance(style, string_types):
            style = get_style_by_name(style)
        self._style = style
        self._clear_caches() 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:9,代码来源:pygments_highlighter.py


注:本文中的pygments.styles.get_style_by_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。