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


Python EditingMode.VI属性代码示例

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


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

示例1: run

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def run():
    # Create a `KeyBindings` that contains the default key bindings.
    bindings = KeyBindings()

    # Add an additional key binding for toggling this flag.
    @bindings.add("f4")
    def _(event):
        " Toggle between Emacs and Vi mode. "
        if event.app.editing_mode == EditingMode.VI:
            event.app.editing_mode = EditingMode.EMACS
        else:
            event.app.editing_mode = EditingMode.VI

    def bottom_toolbar():
        " Display the current input mode. "
        if get_app().editing_mode == EditingMode.VI:
            return " [F4] Vi "
        else:
            return " [F4] Emacs "

    prompt("> ", key_bindings=bindings, bottom_toolbar=bottom_toolbar) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:23,代码来源:switch-between-vi-emacs.py

示例2: vi_navigation_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [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: vi_insert_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def vi_insert_mode() -> bool:
    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
        or app.vi_state.temporary_navigation_mode
        or app.current_buffer.read_only()
    ):
        return False

    return app.vi_state.input_mode == InputMode.INSERT 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:18,代码来源:app.py

示例4: vi_replace_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def vi_replace_mode() -> bool:
    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
        or app.vi_state.temporary_navigation_mode
        or app.current_buffer.read_only()
    ):
        return False

    return app.vi_state.input_mode == InputMode.REPLACE 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:18,代码来源:app.py

示例5: test_vi_text_objects

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def test_vi_text_objects():
    feed = partial(_feed_cli_with_input, editing_mode=EditingMode.VI)

    # Esc gUgg
    result, cli = feed("hello\x1bgUgg\r")
    assert result.text == "HELLO"

    # Esc gUU
    result, cli = feed("hello\x1bgUU\r")
    assert result.text == "HELLO"

    # Esc di(
    result, cli = feed("before(inside)after\x1b8hdi(\r")
    assert result.text == "before()after"

    # Esc di[
    result, cli = feed("before[inside]after\x1b8hdi[\r")
    assert result.text == "before[]after"

    # Esc da(
    result, cli = feed("before(inside)after\x1b8hda(\r")
    assert result.text == "beforeafter" 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:24,代码来源:test_cli.py

示例6: test_vi_digraphs

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def test_vi_digraphs():
    feed = partial(_feed_cli_with_input, editing_mode=EditingMode.VI)

    # C-K o/
    result, cli = feed("hello\x0bo/\r")
    assert result.text == "helloø"

    # C-K /o  (reversed input.)
    result, cli = feed("hello\x0b/o\r")
    assert result.text == "helloø"

    # C-K e:
    result, cli = feed("hello\x0be:\r")
    assert result.text == "helloë"

    # C-K xxy (Unknown digraph.)
    result, cli = feed("hello\x0bxxy\r")
    assert result.text == "helloy" 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:20,代码来源:test_cli.py

示例7: test_vi_character_delete_after_cursor

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def test_vi_character_delete_after_cursor():
    " Test 'x' keypress. "
    feed = partial(_feed_cli_with_input, editing_mode=EditingMode.VI, multiline=True)

    # Delete one character.
    result, cli = feed("abcd\x1bHx\r")
    assert result.text == "bcd"

    # Delete multiple character.s
    result, cli = feed("abcd\x1bH3x\r")
    assert result.text == "d"

    # Delete on empty line.
    result, cli = feed("\x1bo\x1bo\x1bggx\r")
    assert result.text == "\n\n"

    # Delete multiple on empty line.
    result, cli = feed("\x1bo\x1bo\x1bgg10x\r")
    assert result.text == "\n\n"

    # Delete multiple on empty line.
    result, cli = feed("hello\x1bo\x1bo\x1bgg3x\r")
    assert result.text == "lo\n\n" 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:25,代码来源:test_cli.py

示例8: test_vi_character_delete_before_cursor

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def test_vi_character_delete_before_cursor():
    " Test 'X' keypress. "
    feed = partial(_feed_cli_with_input, editing_mode=EditingMode.VI, multiline=True)

    # Delete one character.
    result, cli = feed("abcd\x1bX\r")
    assert result.text == "abd"

    # Delete multiple character.
    result, cli = feed("hello world\x1b3X\r")
    assert result.text == "hello wd"

    # Delete multiple character on multiple lines.
    result, cli = feed("hello\x1boworld\x1bgg$3X\r")
    assert result.text == "ho\nworld"

    result, cli = feed("hello\x1boworld\x1b100X\r")
    assert result.text == "hello\nd"

    # Delete on empty line.
    result, cli = feed("\x1bo\x1bo\x1b10X\r")
    assert result.text == "\n\n" 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:24,代码来源:test_cli.py

示例9: vi_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def vi_mode(self, value: bool) -> None:
        if value:
            self.editing_mode = EditingMode.VI
        else:
            self.editing_mode = EditingMode.EMACS 
开发者ID:prompt-toolkit,项目名称:ptpython,代码行数:7,代码来源:python_input.py

示例10: create_toolbar_tokens_func

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def create_toolbar_tokens_func(cli, show_fish_help):
    """
    Return a function that generates the toolbar tokens.
    """

    def get_toolbar_tokens():
        result = []
        result.append(("class:bottom-toolbar", " "))

        if cli.multi_line:
            result.append(
                ("class:bottom-toolbar", " (Semi-colon [;] will end the line) ")
            )

        if cli.multi_line:
            result.append(("class:bottom-toolbar.on", "[F3] Multiline: ON  "))
        else:
            result.append(("class:bottom-toolbar.off", "[F3] Multiline: OFF  "))
        if cli.prompt_app.editing_mode == EditingMode.VI:
            result.append(
                ("class:botton-toolbar.on", "Vi-mode ({})".format(_get_vi_mode()))
            )

        if show_fish_help():
            result.append(
                ("class:bottom-toolbar", "  Right-arrow to complete suggestion")
            )

        if cli.completion_refresher.is_refreshing():
            result.append(("class:bottom-toolbar", "     Refreshing completions..."))

        return result

    return get_toolbar_tokens 
开发者ID:dbcli,项目名称:litecli,代码行数:36,代码来源:clitoolbar.py

示例11: _get_editing_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def _get_editing_mode():
    files = ['/etc/inputrc', os.path.expanduser('~/.inputrc')]
    for filepath in files:
        try:
            with open(filepath, 'r') as f:
                for line in f:
                    if line.strip() == 'set editing-mode vi':
                        return EditingMode.VI
        except IOError:
            continue
    return EditingMode.EMACS 
开发者ID:crate,项目名称:crash,代码行数:13,代码来源:repl.py

示例12: create_toolbar_tokens_func

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def create_toolbar_tokens_func(cli, show_fish_help):
    """Return a function that generates the toolbar tokens."""
    def get_toolbar_tokens():
        result = []
        result.append(('class:bottom-toolbar', ' '))

        if cli.multi_line:
            result.append(
                ('class:bottom-toolbar', ' (Semi-colon [;] will end the line) ')
            )
        if cli.multi_line:
            result.append(('class:bottom-toolbar.on', '[F3] Multiline: ON '))
        else:
            result.append(('class:bottom-toolbar.off', '[F3] Multiline: OFF'))
        
        if cli.prompt_app.editing_mode == EditingMode.VI:
            result.append((
                'class:bottom-toolbar.on',
                'Vi-mode ({})'.format(_get_vi_mode())
            ))
        
        if show_fish_help():
            result.append(
                ('class:bottom-toolbar', ' Right-arrow to complete suggestion')
            )
        
        if cli.completion_refresher.is_refreshing():
            result.append(
                ('class:bottom-toolbar', '     Refreshing completions...')
            )
        return result
    return get_toolbar_tokens 
开发者ID:dbcli,项目名称:athenacli,代码行数:34,代码来源:clitoolbar.py

示例13: _leave_vi_temp_navigation_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def _leave_vi_temp_navigation_mode(self, event: "KeyPressEvent") -> None:
        """
        If we're in Vi temporary navigation (normal) mode, return to
        insert/replace mode after executing one action.
        """
        app = event.app

        if app.editing_mode == EditingMode.VI:
            # Not waiting for a text object and no argument has been given.
            if app.vi_state.operator_func is None and self.arg is None:
                app.vi_state.temporary_navigation_mode = False 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:13,代码来源:key_processor.py

示例14: vi_selection_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def vi_selection_mode() -> bool:
    app = get_app()
    if app.editing_mode != EditingMode.VI:
        return False

    return bool(app.current_buffer.selection_state) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:8,代码来源:app.py

示例15: vi_waiting_for_text_object_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import VI [as 别名]
def vi_waiting_for_text_object_mode() -> bool:
    app = get_app()
    if app.editing_mode != EditingMode.VI:
        return False

    return app.vi_state.operator_func is not None 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:8,代码来源:app.py


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