當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。