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


Python EditingMode.EMACS属性代码示例

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


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

示例1: run

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

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def yank_pop(event: E) -> None:
    """
    Rotate the kill ring, and yank the new top. Only works following yank or
    yank-pop.
    """
    buff = event.current_buffer
    doc_before_paste = buff.document_before_paste
    clipboard = event.app.clipboard

    if doc_before_paste is not None:
        buff.document = doc_before_paste
        clipboard.rotate()
        buff.paste_clipboard_data(clipboard.get_data(), paste_mode=PasteMode.EMACS)


#
# Completion.
# 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:20,代码来源:named_commands.py

示例3: yank_pop

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def yank_pop(event):
    """
    Rotate the kill ring, and yank the new top. Only works following yank or
    yank-pop.
    """
    buff = event.current_buffer
    doc_before_paste = buff.document_before_paste
    clipboard = event.cli.clipboard

    if doc_before_paste is not None:
        buff.document = doc_before_paste
        clipboard.rotate()
        buff.paste_clipboard_data(
            clipboard.get_data(), paste_mode=PasteMode.EMACS)

#
# Completion.
# 
开发者ID:bkerler,项目名称:android_universal,代码行数:20,代码来源:named_commands.py

示例4: yank

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def yank(event: E) -> None:
    """
    Paste before cursor.
    """
    event.current_buffer.paste_clipboard_data(
        event.app.clipboard.get_data(), count=event.arg, paste_mode=PasteMode.EMACS
    ) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:9,代码来源:named_commands.py

示例5: emacs_insert_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def emacs_insert_mode() -> bool:
    app = get_app()
    if (
        app.editing_mode != EditingMode.EMACS
        or app.current_buffer.selection_state
        or app.current_buffer.read_only()
    ):
        return False
    return True 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:11,代码来源:app.py

示例6: emacs_selection_mode

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def emacs_selection_mode() -> bool:
    app = get_app()
    return bool(
        app.editing_mode == EditingMode.EMACS and app.current_buffer.selection_state
    ) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:7,代码来源:app.py

示例7: create_application

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def create_application(self, completer, history,
                           display_completions_in_columns):
        self.key_manager = self.create_key_manager()
        toolbar = Toolbar(
            lambda: self.model_completer.match_fuzzy,
            lambda: self.enable_vi_bindings,
            lambda: self.show_completion_columns,
            lambda: self.show_help)
        style_factory = StyleFactory(self.theme)
        buffers = {
            'clidocs': Buffer(read_only=True)
        }

        if self.enable_vi_bindings:
            editing_mode = EditingMode.VI
        else:
            editing_mode = EditingMode.EMACS

        return Application(
            editing_mode=editing_mode,
            layout=self.create_layout(display_completions_in_columns, toolbar),
            mouse_support=False,
            style=style_factory.style,
            buffers=buffers,
            buffer=self.create_buffer(completer, history),
            on_abort=AbortAction.RETRY,
            on_exit=AbortAction.RAISE_EXCEPTION,
            on_input_timeout=self.on_input_timeout,
            key_bindings_registry=self.key_manager.manager.registry,
        ) 
开发者ID:awslabs,项目名称:aws-shell,代码行数:32,代码来源:app.py

示例8: yank

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def yank(event):
    """
    Paste before cursor.
    """
    event.current_buffer.paste_clipboard_data(
        event.cli.clipboard.get_data(), count=event.arg, paste_mode=PasteMode.EMACS) 
开发者ID:bkerler,项目名称:android_universal,代码行数:8,代码来源:named_commands.py

示例9: __call__

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [as 别名]
def __call__(self, cli):
        if (cli.editing_mode != EditingMode.EMACS
                or cli.current_buffer.selection_state
                or cli.current_buffer.read_only()):
            return False
        return True 
开发者ID:bkerler,项目名称:android_universal,代码行数:8,代码来源:cli.py

示例10: _build_prompt_app

# 需要导入模块: from prompt_toolkit.enums import EditingMode [as 别名]
# 或者: from prompt_toolkit.enums.EditingMode import EMACS [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.enums.EditingMode.EMACS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。