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


Python InputMode.NAVIGATION属性代码示例

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


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

示例1: enter_history

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [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: vi_navigation_mode

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [as 别名]
def vi_navigation_mode() -> bool:
    """
    Active when the set for Vi navigation key bindings are active.
    """
    from prompt_toolkit.key_binding.vi_state import InputMode

    app = get_app()

    if (
        app.editing_mode != EditingMode.VI
        or app.vi_state.operator_func
        or app.vi_state.waiting_for_digraph
        or app.current_buffer.selection_state
    ):
        return False

    return (
        app.vi_state.input_mode == InputMode.NAVIGATION
        or app.vi_state.temporary_navigation_mode
        or app.current_buffer.read_only()
    ) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:23,代码来源:app.py

示例3: _get_vi_mode

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [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: _get_vi_mode

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [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

示例5: _get_vi_mode

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [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

示例6: _get_vi_mode

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [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

示例7: run

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [as 别名]
def run(self):
        """
        Run the event loop for the interface.
        This starts the interaction.
        """
        # Make sure everything is in sync, before starting.
        self.sync_with_prompt_toolkit()

        def pre_run():
            # Start in navigation mode.
            self.application.vi_state.input_mode = InputMode.NAVIGATION

        # Run eventloop of prompt_toolkit.
        self.application.run(pre_run=pre_run) 
开发者ID:prompt-toolkit,项目名称:pyvim,代码行数:16,代码来源:editor.py

示例8: leave_command_mode

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [as 别名]
def leave_command_mode(self, append_to_history=False):
        """
        Leave command mode. Focus document window again.
        """
        self.previewer.restore()

        self.application.layout.focus_last()
        self.application.vi_state.input_mode = InputMode.NAVIGATION

        self.command_buffer.reset(append_to_history=append_to_history) 
开发者ID:prompt-toolkit,项目名称:pyvim,代码行数:12,代码来源:editor.py

示例9: load_vi_system_bindings

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [as 别名]
def load_vi_system_bindings():
    registry = ConditionalRegistry(Registry(), ViMode())
    handle = registry.add_binding

    has_focus = filters.HasFocus(SYSTEM_BUFFER)
    navigation_mode = ViNavigationMode()

    @handle('!', filter=~has_focus & navigation_mode)
    def _(event):
        """
        '!' opens the system prompt.
        """
        event.cli.push_focus(SYSTEM_BUFFER)
        event.cli.vi_state.input_mode = InputMode.INSERT

    @handle(Keys.Escape, filter=has_focus)
    @handle(Keys.ControlC, filter=has_focus)
    def _(event):
        """
        Cancel system prompt.
        """
        event.cli.vi_state.input_mode = InputMode.NAVIGATION
        event.cli.buffers[SYSTEM_BUFFER].reset()
        event.cli.pop_focus()

    @handle(Keys.ControlJ, filter=has_focus)
    def _(event):
        """
        Run system command.
        """
        event.cli.vi_state.input_mode = InputMode.NAVIGATION

        system_buffer = event.cli.buffers[SYSTEM_BUFFER]
        event.cli.run_system_command(system_buffer.text)
        system_buffer.reset(append_to_history=True)

        # Focus previous buffer again.
        event.cli.pop_focus()

    return registry 
开发者ID:bkerler,项目名称:android_universal,代码行数:42,代码来源:vi.py

示例10: __call__

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [as 别名]
def __call__(self, cli):
        if (cli.editing_mode != EditingMode.VI
                or cli.vi_state.operator_func
                or cli.vi_state.waiting_for_digraph
                or cli.current_buffer.selection_state):
            return False

        return (cli.vi_state.input_mode == ViInputMode.NAVIGATION or
                cli.current_buffer.read_only()) 
开发者ID:bkerler,项目名称:android_universal,代码行数:11,代码来源:cli.py

示例11: get_inputmode_fragments

# 需要导入模块: from prompt_toolkit.key_binding.vi_state import InputMode [as 别名]
# 或者: from prompt_toolkit.key_binding.vi_state.InputMode import NAVIGATION [as 别名]
def get_inputmode_fragments(python_input: "PythonInput") -> StyleAndTextTuples:
    """
    Return current input mode as a list of (token, text) tuples for use in a
    toolbar.
    """
    app = get_app()

    @if_mousedown
    def toggle_vi_mode(mouse_event: MouseEvent) -> None:
        python_input.vi_mode = not python_input.vi_mode

    token = "class:status-toolbar"
    input_mode_t = "class:status-toolbar.input-mode"

    mode = app.vi_state.input_mode
    result: StyleAndTextTuples = []
    append = result.append

    if python_input.title:
        result.extend(to_formatted_text(python_input.title))

    append((input_mode_t, "[F4] ", toggle_vi_mode))

    # InputMode
    if python_input.vi_mode:
        recording_register = app.vi_state.recording_register
        if recording_register:
            append((token, " "))
            append((token + " class:record", "RECORD({})".format(recording_register)))
            append((token, " - "))

        if app.current_buffer.selection_state is not None:
            if app.current_buffer.selection_state.type == SelectionType.LINES:
                append((input_mode_t, "Vi (VISUAL LINE)", toggle_vi_mode))
            elif app.current_buffer.selection_state.type == SelectionType.CHARACTERS:
                append((input_mode_t, "Vi (VISUAL)", toggle_vi_mode))
                append((token, " "))
            elif app.current_buffer.selection_state.type == SelectionType.BLOCK:
                append((input_mode_t, "Vi (VISUAL BLOCK)", toggle_vi_mode))
                append((token, " "))
        elif mode in (InputMode.INSERT, "vi-insert-multiple"):
            append((input_mode_t, "Vi (INSERT)", toggle_vi_mode))
            append((token, "  "))
        elif mode == InputMode.NAVIGATION:
            append((input_mode_t, "Vi (NAV)", toggle_vi_mode))
            append((token, "     "))
        elif mode == InputMode.REPLACE:
            append((input_mode_t, "Vi (REPLACE)", toggle_vi_mode))
            append((token, " "))
    else:
        if app.emacs_state.is_recording:
            append((token, " "))
            append((token + " class:record", "RECORD"))
            append((token, " - "))

        append((input_mode_t, "Emacs", toggle_vi_mode))
        append((token, " "))

    return result 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:61,代码来源:layout.py


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