本文整理汇总了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)
示例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.
#
示例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.
#
示例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
)
示例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
示例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
)
示例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,
)
示例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)
示例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
示例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
)