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


Python filters.IsDone方法代码示例

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


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

示例1: create_inquirer_layout

# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import IsDone [as 别名]
def create_inquirer_layout(
    ic: InquirerControl,
    get_prompt_tokens: Callable[[], List[Tuple[Text, Text]]],
    **kwargs
) -> Layout:
    """Create a layout combining question and inquirer selection."""

    ps = PromptSession(get_prompt_tokens, reserve_space_for_menu=0, **kwargs)

    _fix_unecessary_blank_lines(ps)

    return Layout(
        HSplit(
            [ps.layout.container, ConditionalContainer(Window(ic), filter=~IsDone())]
        )
    ) 
开发者ID:tmbo,项目名称:questionary,代码行数:18,代码来源:common.py

示例2: __init__

# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import IsDone [as 别名]
def __init__(self, max_height=None, scroll_offset=0, extra_filter=True, display_arrows=False):
        extra_filter = to_cli_filter(extra_filter)
        display_arrows = to_cli_filter(display_arrows)

        super(CompletionsMenu, self).__init__(
            content=Window(
                content=CompletionsMenuControl(),
                width=LayoutDimension(min=8),
                height=LayoutDimension(min=1, max=max_height),
                scroll_offsets=ScrollOffsets(top=scroll_offset, bottom=scroll_offset),
                right_margins=[ScrollbarMargin(display_arrows=display_arrows)],
                dont_extend_width=True,
            ),
            # Show when there are completions but not at the point we are
            # returning the input.
            filter=HasCompletions() & ~IsDone() & extra_filter) 
开发者ID:bkerler,项目名称:android_universal,代码行数:18,代码来源:menus.py

示例3: create_tutorial_layout

# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import IsDone [as 别名]
def create_tutorial_layout(lex):
    """ layout for example tutorial """
    lexer, _, _ = get_lexers(lex, None, None)
    layout_full = HSplit([
        FloatContainer(
            Window(
                BufferControl(
                    input_processors=input_processors,
                    lexer=lexer,
                    preview_search=Always()),
                get_height=get_height),
            [
                Float(xcursor=True,
                      ycursor=True,
                      content=CompletionsMenu(
                          max_height=MAX_COMPLETION,
                          scroll_offset=1,
                          extra_filter=(HasFocus(DEFAULT_BUFFER))))]),
        ConditionalContainer(
            HSplit([
                get_hline(),
                get_param(lexer),
                get_hline(),
                Window(
                    content=BufferControl(
                        buffer_name='example_line',
                        lexer=lexer
                    ),
                ),
                Window(
                    TokenListControl(
                        get_tutorial_tokens,
                        default_char=Char(' ', Token.Toolbar)),
                    height=D.exact(1)),
            ]),
            filter=~IsDone() & RendererHeightIsKnown()
        )
    ])
    return layout_full 
开发者ID:Azure,项目名称:azure-cli-shell,代码行数:41,代码来源:layout.py

示例4: __init__

# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import IsDone [as 别名]
def __init__(self):
        super(SystemToolbar, self).__init__(
            content=Window(
                SystemToolbarControl(),
                height=LayoutDimension.exact(1)),
            filter=HasFocus(SYSTEM_BUFFER) & ~IsDone()) 
开发者ID:bkerler,项目名称:android_universal,代码行数:8,代码来源:toolbars.py

示例5: loop

# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import IsDone [as 别名]
def loop(cmd, history_file):
    buf = create_buffer(cmd, history_file)
    key_bindings = KeyBindings()
    bind_keys(buf, key_bindings)
    layout = create_layout(
        buffer=buf,
        multiline=True,
        lexer=PostgresLexer,
        extra_input_processors=[
            ConditionalProcessor(
                processor=HighlightMatchingBracketProcessor(chars='[](){}'),
                filter=HasFocus(DEFAULT_BUFFER) & ~IsDone())
        ],
        get_bottom_toolbar_tokens=lambda: get_toolbar_tokens(cmd),
        get_prompt_tokens=lambda: [('class:prompt', 'cr> ')]
    )
    output = get_default_output()
    app = Application(
        layout=layout,
        style=style_from_pygments_cls(CrateStyle),
        key_bindings=merge_key_bindings([
            key_bindings,
            load_open_in_editor_bindings()
        ]),
        editing_mode=_get_editing_mode(),
        output=output
    )
    cmd.get_num_columns = lambda: output.get_size().columns

    while True:
        try:
            text = app.run()
            if text:
                cmd.process(text)
            buf.reset()
        except ProgrammingError as e:
            if '401' in e.message:
                username = cmd.username
                password = cmd.password
                cmd.username = input('Username: ')
                cmd.password = getpass()
                try:
                    cmd.process(text)
                except ProgrammingError as ex:
                    # fallback to existing user/pw
                    cmd.username = username
                    cmd.password = password
                    cmd.logger.warn(str(ex))
            else:
                cmd.logger.warn(str(e))
        except KeyboardInterrupt:
            if isinstance(app.layout.current_control, SearchBufferControl):
                app.layout.current_control = app.layout.previous_control
            else:
                cmd.logger.warn("Query not cancelled. Run KILL <jobId> to cancel it")
                buf.reset()
        except EOFError:
            cmd.logger.warn('Bye!')
            return 
开发者ID:crate,项目名称:crash,代码行数:61,代码来源:repl.py

示例6: _build_prompt_app

# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import IsDone [as 别名]
def _build_prompt_app(self, history):
        key_bindings = cli_bindings(self)

        def get_message():
            prompt = self.get_prompt(self.prompt)
            if len(prompt) > self.MAX_LEN_PROMPT:
                prompt = self.get_prompt('\\r:\\d> ')
            return [('class:prompt', prompt)]

        def get_continuation(width, line_number, is_soft_wrap):
            continuation = ' ' * (width -1) + ' '
            return [('class:continuation', continuation)]

        def show_suggestion_tip():
            return self.iterations < 2

        get_toolbar_tokens = create_toolbar_tokens_func(
            self, show_suggestion_tip)

        with self._completer_lock:
            if self.key_bindings == 'vi':
                editing_mode = EditingMode.VI
            else:
                editing_mode = EditingMode.EMACS

            self.prompt_app = PromptSession(
                lexer=PygmentsLexer(Lexer),
                reserve_space_for_menu=self.get_reserved_space(),
                message=get_message,
                prompt_continuation=get_continuation,
                bottom_toolbar=get_toolbar_tokens,
                complete_style=CompleteStyle.COLUMN,
                input_processors=[ConditionalProcessor(
                    processor=HighlightMatchingBracketProcessor(
                        chars='[](){}'),
                    filter=HasFocus(DEFAULT_BUFFER) & ~IsDone()
                )],
                tempfile_suffix='.sql',
                completer=DynamicCompleter(lambda: self.completer),
                history=history,
                auto_suggest=AutoSuggestFromHistory(),
                complete_while_typing=True,
                multiline=cli_is_multiline(self),
                style=style_factory(self.syntax_style, self.cli_style),
                include_default_pygments_style=False,
                key_bindings=key_bindings,
                enable_open_in_editor=True,
                enable_system_prompt=True,
                editing_mode=editing_mode,
                search_ignore_case=True
            ) 
开发者ID:dbcli,项目名称:athenacli,代码行数:53,代码来源:main.py


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