You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/WPy64-3720/python-3.7.2.amd64/Lib/site-packages/prompt_toolkit/key_binding/bindings/open_in_editor.py

47 lines
1.2 KiB

"""
Open in editor key bindings.
"""
from __future__ import unicode_literals
from ..key_bindings import KeyBindings, merge_key_bindings
from prompt_toolkit.filters import emacs_mode, vi_navigation_mode, has_selection
from .named_commands import get_by_name
__all__ = [
'load_open_in_editor_bindings',
'load_emacs_open_in_editor_bindings',
'load_vi_open_in_editor_bindings',
]
def load_open_in_editor_bindings():
"""
Load both the Vi and emacs key bindings for handling edit-and-execute-command.
"""
return merge_key_bindings([
load_emacs_open_in_editor_bindings(),
load_vi_open_in_editor_bindings(),
])
def load_emacs_open_in_editor_bindings():
"""
Pressing C-X C-E will open the buffer in an external editor.
"""
key_bindings = KeyBindings()
key_bindings.add('c-x', 'c-e',
filter=emacs_mode & ~has_selection)(
get_by_name('edit-and-execute-command'))
return key_bindings
def load_vi_open_in_editor_bindings():
"""
Pressing 'v' in navigation mode will open the buffer in an external editor.
"""
key_bindings = KeyBindings()
key_bindings.add('v', filter=vi_navigation_mode)(
get_by_name('edit-and-execute-command'))
return key_bindings