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


Python application.get_app方法代码示例

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


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

示例1: enter_history

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def enter_history(self) -> None:
        """
        Display the history.
        """
        app = get_app()
        app.vi_state.input_mode = InputMode.NAVIGATION

        history = PythonHistory(self, self.default_buffer.document)

        from prompt_toolkit.application import in_terminal
        import asyncio

        async def do_in_terminal() -> None:
            async with in_terminal():
                result = await history.app.run_async()
                if result is not None:
                    self.default_buffer.text = result

                app.vi_state.input_mode = InputMode.INSERT

        asyncio.ensure_future(do_in_terminal()) 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:23,代码来源:python_input.py

示例2: buffer_should_be_handled

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def buffer_should_be_handled(pgcli):
    @Condition
    def cond():
        if not pgcli.multi_line:
            _logger.debug("Not in multi-line mode. Handle the buffer.")
            return True

        if pgcli.multiline_mode == "safe":
            _logger.debug("Multi-line mode is set to 'safe'. Do NOT handle the buffer.")
            return False

        doc = get_app().layout.get_buffer_by_name(DEFAULT_BUFFER).document
        text = doc.text.strip()

        return (
            text.startswith("\\")  # Special Command
            or text.endswith(r"\e")  # Special Command
            or text.endswith(r"\G")  # Ended with \e which should launch the editor
            or _is_complete(text)  # A complete SQL command
            or (text == "exit")  # Exit doesn't need semi-colon
            or (text == "quit")  # Quit doesn't need semi-colon
            or (text == ":q")  # To all the vim fans out there
            or (text == "")  # Just a plain enter without any text
        )

    return cond 
开发者ID:dbcli,项目名称:pgcli,代码行数:28,代码来源:pgbuffer.py

示例3: _get_vi_mode

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def _get_vi_mode():
    return {
        InputMode.INSERT: "I",
        InputMode.NAVIGATION: "N",
        InputMode.REPLACE: "R",
        InputMode.INSERT_MULTIPLE: "M",
    }[get_app().vi_state.input_mode] 
开发者ID:dbcli,项目名称:pgcli,代码行数:9,代码来源:pgtoolbar.py

示例4: is_multiline

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def is_multiline() -> bool:
    doc = pt_app.get_app().layout.get_buffer_by_name(
        pt_enums.DEFAULT_BUFFER).document

    if (doc.cursor_position and doc.text[doc.cursor_position:].strip()):
        return True

    return is_multiline_text(doc.text) 
开发者ID:edgedb,项目名称:edgedb,代码行数:10,代码来源:__init__.py

示例5: tab_should_insert_whitespace

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def tab_should_insert_whitespace():
    """
    When the 'tab' key is pressed with only whitespace character before the
    cursor, do autocompletion. Otherwise, insert indentation.

    Except for the first character at the first line. Then always do a
    completion. It doesn't make sense to start the first line with
    indentation.
    """
    b = get_app().current_buffer
    before_cursor = b.document.current_line_before_cursor

    return bool(b.text and (not before_cursor or before_cursor.isspace())) 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:15,代码来源:key_bindings.py

示例6: _accept_handler

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def _accept_handler(self, buff: Buffer) -> bool:
        app = get_app()
        app.exit(result=buff.text)
        app.pre_run_callables.append(buff.reset)
        return True  # Keep text, we call 'reset' later on. 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:7,代码来源:python_input.py

示例7: _get_vi_mode

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def _get_vi_mode():
    """Get the current vi mode for display."""
    return {
        InputMode.INSERT: "I",
        InputMode.NAVIGATION: "N",
        InputMode.REPLACE: "R",
        InputMode.INSERT_MULTIPLE: "M",
    }[get_app().vi_state.input_mode] 
开发者ID:dbcli,项目名称:litecli,代码行数:10,代码来源:clitoolbar.py

示例8: cli_is_multiline

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def cli_is_multiline(cli):
    @Condition
    def cond():
        doc = get_app().layout.get_buffer_by_name(DEFAULT_BUFFER).document

        if not cli.multi_line:
            return False
        else:
            return not _multiline_exception(doc.text)

    return cond 
开发者ID:dbcli,项目名称:litecli,代码行数:13,代码来源:clibuffer.py

示例9: _get_vi_mode

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def _get_vi_mode():
    """Get the current vi mode for display."""
    return {
        InputMode.INSERT: 'I',
        InputMode.NAVIGATION: 'N',
        InputMode.REPLACE: 'R',
        InputMode.INSERT_MULTIPLE: 'M',
    }[get_app().vi_state.input_mode] 
开发者ID:dbcli,项目名称:athenacli,代码行数:10,代码来源:clitoolbar.py

示例10: cli_is_multiline

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def cli_is_multiline(cli):
    @Condition
    def cond():
        doc = get_app().layout.get_buffer_by_name(DEFAULT_BUFFER).document
        if not cli.multi_line:
            return False
        else:
            return not _multiline_exception(doc.text)
    return cond 
开发者ID:dbcli,项目名称:athenacli,代码行数:11,代码来源:clibuffer.py

示例11: get_prompt

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def get_prompt() -> HTML:
    """
    Build the prompt dynamically every time its rendered.
    """
    left_part = HTML(
        "<left-part>"
        " <username>root</username> "
        " abc "
        "<path>~/.oh-my-zsh/themes</path>"
        "</left-part>"
    )
    right_part = HTML(
        "<right-part> "
        "<branch> master<exclamation-mark>!</exclamation-mark> </branch> "
        " <env> py36 </env> "
        " <time>%s</time> "
        "</right-part>"
    ) % (datetime.datetime.now().isoformat(),)

    used_width = sum(
        [
            fragment_list_width(to_formatted_text(left_part)),
            fragment_list_width(to_formatted_text(right_part)),
        ]
    )

    total_width = get_app().output.get_size().columns
    padding_size = total_width - used_width

    padding = HTML("<padding>%s</padding>") % (" " * padding_size,)

    return merge_formatted_text([left_part, padding, right_part, "\n", "# "]) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:34,代码来源:fancy-zsh-prompt.py

示例12: has_selected_completion

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def has_selected_completion():
    """Enable when the current buffer has a selected completion."""
    complete_state = get_app().current_buffer.complete_state
    return (complete_state is not None and
            complete_state.current_completion is not None) 
开发者ID:dbcli,项目名称:mssql-cli,代码行数:7,代码来源:filters.py

示例13: mssql_is_multiline

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def mssql_is_multiline(mssql_cli):
    @Condition
    def cond():
        doc = get_app().layout.get_buffer_by_name(DEFAULT_BUFFER).document

        if not mssql_cli.multiline:
            return False
        if mssql_cli.multiline_mode == 'safe':
            return True
        return not _multiline_exception(doc.text)

    return cond 
开发者ID:dbcli,项目名称:mssql-cli,代码行数:14,代码来源:mssqlbuffer.py

示例14: _get_vi_mode

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def _get_vi_mode():
    return {
        InputMode.INSERT: 'I',
        InputMode.NAVIGATION: 'N',
        InputMode.REPLACE: 'R',
        InputMode.INSERT_MULTIPLE: 'M',
    }[get_app().vi_state.input_mode] 
开发者ID:dbcli,项目名称:mssql-cli,代码行数:9,代码来源:mssqltoolbar.py

示例15: whitespace_before_cursor_on_line

# 需要导入模块: from prompt_toolkit import application [as 别名]
# 或者: from prompt_toolkit.application import get_app [as 别名]
def whitespace_before_cursor_on_line():
    """
    Filter which evaluates to True when the characters before the cursor are
    whitespace, or we are at the start of te line.
    """
    b = get_app().current_buffer
    before_cursor = b.document.current_line_before_cursor

    return bool(not before_cursor or before_cursor[-1].isspace()) 
开发者ID:prompt-toolkit,项目名称:pyvim,代码行数:11,代码来源:key_bindings.py


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