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


Python styles.merge_styles方法代码示例

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


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

示例1: style_factory

# 需要导入模块: from prompt_toolkit import styles [as 别名]
# 或者: from prompt_toolkit.styles import merge_styles [as 别名]
def style_factory(name, cli_style):
    try:
        style = pygments.styles.get_style_by_name(name)
    except ClassNotFound:
        style = pygments.styles.get_style_by_name("native")

    prompt_styles = []
    # prompt-toolkit used pygments tokens for styling before, switched to style
    # names in 2.0. Convert old token types to new style names, for backwards compatibility.
    for token in cli_style:
        if token.startswith("Token."):
            # treat as pygments token (1.0)
            token_type, style_value = parse_pygments_style(token, style, cli_style)
            if token_type in TOKEN_TO_PROMPT_STYLE:
                prompt_style = TOKEN_TO_PROMPT_STYLE[token_type]
                prompt_styles.append((prompt_style, style_value))
            else:
                # we don't want to support tokens anymore
                logger.error("Unhandled style / class name: %s", token)
        else:
            # treat as prompt style name (2.0). See default style names here:
            # https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/prompt_toolkit/styles/defaults.py
            prompt_styles.append((token, cli_style[token]))

    override_style = Style([("bottom-toolbar", "noreverse")])
    return merge_styles(
        [style_from_pygments_cls(style), override_style, Style(prompt_styles)]
    ) 
开发者ID:dbcli,项目名称:pgcli,代码行数:30,代码来源:pgstyle.py

示例2: generate_style

# 需要导入模块: from prompt_toolkit import styles [as 别名]
# 或者: from prompt_toolkit.styles import merge_styles [as 别名]
def generate_style(python_style: BaseStyle, ui_style: BaseStyle) -> BaseStyle:
    """
    Generate Pygments Style class from two dictionaries
    containing style rules.
    """
    return merge_styles([python_style, ui_style])


# Code style for Windows consoles. They support only 16 colors,
# so we choose a combination that displays nicely. 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:12,代码来源:style.py

示例3: style_factory

# 需要导入模块: from prompt_toolkit import styles [as 别名]
# 或者: from prompt_toolkit.styles import merge_styles [as 别名]
def style_factory(name, cli_style):
    try:
        style = pygments.styles.get_style_by_name(name)
    except ClassNotFound:
        style = pygments.styles.get_style_by_name('native')

    prompt_styles = []
    # prompt-toolkit used pygments tokens for styling before, switched to style
    # names in 2.0. Convert old token types to new style names, for backwards compatibility.
    for token in cli_style:
        if token.startswith('Token.'):
            # treat as pygments token (1.0)
            token_type, style_value = parse_pygments_style(
                token, style, cli_style)
            if token_type in TOKEN_TO_PROMPT_STYLE:
                prompt_style = TOKEN_TO_PROMPT_STYLE[token_type]
                prompt_styles.append((prompt_style, style_value))
            else:
                # we don't want to support tokens anymore
                logger.error('Unhandled style / class name: %s', token)
        else:
            # treat as prompt style name (2.0). See default style names here:
            # https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/prompt_toolkit/styles/defaults.py
            prompt_styles.append((token, cli_style[token]))

    override_style = Style([('bottom-toolbar', 'noreverse')])
    return merge_styles([
        style_from_pygments_cls(style),
        override_style,
        Style(prompt_styles)
    ]) 
开发者ID:dbcli,项目名称:athenacli,代码行数:33,代码来源:clistyle.py

示例4: get_editor_style_by_name

# 需要导入模块: from prompt_toolkit import styles [as 别名]
# 或者: from prompt_toolkit.styles import merge_styles [as 别名]
def get_editor_style_by_name(name):
    """
    Get Style class.
    This raises `pygments.util.ClassNotFound` when there is no style with this
    name.
    """
    if name == 'vim':
        vim_style = Style.from_dict(default_vim_style)
    else:
        vim_style = style_from_pygments_cls(get_style_by_name(name))

    return merge_styles([
        vim_style,
        Style.from_dict(style_extensions),
    ]) 
开发者ID:prompt-toolkit,项目名称:pyvim,代码行数:17,代码来源:style.py

示例5: get_style

# 需要导入模块: from prompt_toolkit import styles [as 别名]
# 或者: from prompt_toolkit.styles import merge_styles [as 别名]
def get_style(self):
        return merge_styles([super().get_style(), Style.from_dict(constants.STYLE)])

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

示例6: text

# 需要导入模块: from prompt_toolkit import styles [as 别名]
# 或者: from prompt_toolkit.styles import merge_styles [as 别名]
def text(
    message: Text,
    default: Text = "",
    validate: Any = None,
    qmark: Text = DEFAULT_QUESTION_PREFIX,
    style: Optional[Style] = None,
    **kwargs: Any
) -> Question:
    """Prompt the user to enter a free text message.

       This question type can be used to prompt the user for some text input.

       Args:
           message: Question text

           default: Default value will be returned if the user just hits
                    enter.

           validate: Require the entered value to pass a validation. The
                     value can not be submited until the validator accepts
                     it (e.g. to check minimum password length).

                     This can either be a function accepting the input and
                     returning a boolean, or an class reference to a
                     subclass of the prompt toolkit Validator class.

           qmark: Question prefix displayed in front of the question.
                  By default this is a `?`

           style: A custom color and style for the question parts. You can
                  configure colors as well as font types for different elements.

       Returns:
           Question: Question instance, ready to be prompted (using `.ask()`).
    """

    merged_style = merge_styles([DEFAULT_STYLE, style])

    validator = build_validator(validate)

    def get_prompt_tokens() -> List[Tuple[Text, Text]]:
        return [("class:qmark", qmark), ("class:question", " {} ".format(message))]

    p = PromptSession(
        get_prompt_tokens, style=merged_style, validator=validator, **kwargs
    )
    p.default_buffer.reset(Document(default))

    return Question(p.app) 
开发者ID:tmbo,项目名称:questionary,代码行数:51,代码来源:text.py


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