[~] Refactor
This commit is contained in:
parent
1530fcf108
commit
d4ed93961b
@ -210,6 +210,11 @@ class TerminalInteractiveShell(InteractiveShell):
|
|||||||
help="Shortcut style to use at the prompt. 'vi' or 'emacs'.",
|
help="Shortcut style to use at the prompt. 'vi' or 'emacs'.",
|
||||||
).tag(config=True)
|
).tag(config=True)
|
||||||
|
|
||||||
|
fast_prompt = Bool(
|
||||||
|
False,
|
||||||
|
help="fast prompt with dynamic slow down",
|
||||||
|
).tag(config=True)
|
||||||
|
|
||||||
emacs_bindings_in_vi_insert_mode = Bool(
|
emacs_bindings_in_vi_insert_mode = Bool(
|
||||||
True,
|
True,
|
||||||
help="Add shortcuts from 'emacs' insert mode to 'vi' insert mode.",
|
help="Add shortcuts from 'emacs' insert mode to 'vi' insert mode.",
|
||||||
@ -430,8 +435,10 @@ class TerminalInteractiveShell(InteractiveShell):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Set up keyboard shortcuts
|
# Set up keyboard shortcuts
|
||||||
key_bindings = create_ipython_shortcuts(self)
|
key_bindings = create_ipython_shortcuts(
|
||||||
|
self,
|
||||||
|
enable_escape_shortcuts=not self.fast_prompt,
|
||||||
|
)
|
||||||
|
|
||||||
# Pre-populate history from IPython's history database
|
# Pre-populate history from IPython's history database
|
||||||
history = PtkHistoryAdapter(self)
|
history = PtkHistoryAdapter(self)
|
||||||
@ -601,9 +608,12 @@ class TerminalInteractiveShell(InteractiveShell):
|
|||||||
policy.set_event_loop(self.pt_loop)
|
policy.set_event_loop(self.pt_loop)
|
||||||
try:
|
try:
|
||||||
with patch_stdout(raw=True):
|
with patch_stdout(raw=True):
|
||||||
|
extra_options = self._extra_prompt_options()
|
||||||
|
|
||||||
text = self.pt_app.prompt(
|
text = self.pt_app.prompt(
|
||||||
default=default,
|
default=default,
|
||||||
**self._extra_prompt_options())
|
**extra_options
|
||||||
|
)
|
||||||
finally:
|
finally:
|
||||||
# Restore the original event loop.
|
# Restore the original event loop.
|
||||||
if old_loop is not None and old_loop is not self.pt_loop:
|
if old_loop is not None and old_loop is not self.pt_loop:
|
||||||
|
481
deps/ipython-fork/IPython/terminal/shortcuts.py
vendored
481
deps/ipython-fork/IPython/terminal/shortcuts.py
vendored
@ -48,7 +48,13 @@ def _apply_autosuggest(event):
|
|||||||
else:
|
else:
|
||||||
nc.end_of_line(event)
|
nc.end_of_line(event)
|
||||||
|
|
||||||
def create_ipython_shortcuts(shell):
|
def create_ipython_shortcuts(
|
||||||
|
shell,
|
||||||
|
enable_escape_shortcuts=None,
|
||||||
|
):
|
||||||
|
if enable_escape_shortcuts is None:
|
||||||
|
enable_escape_shortcuts = True
|
||||||
|
|
||||||
"""Set up the prompt_toolkit keyboard shortcuts for IPython"""
|
"""Set up the prompt_toolkit keyboard shortcuts for IPython"""
|
||||||
|
|
||||||
kb = KeyBindings()
|
kb = KeyBindings()
|
||||||
@ -64,283 +70,284 @@ def create_ipython_shortcuts(shell):
|
|||||||
& insert_mode
|
& insert_mode
|
||||||
))(return_handler)
|
))(return_handler)
|
||||||
|
|
||||||
def reformat_and_execute(event):
|
if enable_escape_shortcuts:
|
||||||
reformat_text_before_cursor(event.current_buffer, event.current_buffer.document, shell)
|
def reformat_and_execute(event):
|
||||||
event.current_buffer.validate_and_handle()
|
reformat_text_before_cursor(event.current_buffer, event.current_buffer.document, shell)
|
||||||
|
event.current_buffer.validate_and_handle()
|
||||||
|
|
||||||
kb.add('escape', 'enter', filter=(has_focus(DEFAULT_BUFFER)
|
kb.add('escape', 'enter', filter=(has_focus(DEFAULT_BUFFER)
|
||||||
& ~has_selection
|
& ~has_selection
|
||||||
& insert_mode
|
& insert_mode
|
||||||
))(reformat_and_execute)
|
))(reformat_and_execute)
|
||||||
|
|
||||||
kb.add("c-\\")(quit)
|
kb.add("c-\\")(quit)
|
||||||
|
|
||||||
kb.add('c-p', filter=(vi_insert_mode & has_focus(DEFAULT_BUFFER))
|
kb.add('c-p', filter=(vi_insert_mode & has_focus(DEFAULT_BUFFER))
|
||||||
)(previous_history_or_previous_completion)
|
)(previous_history_or_previous_completion)
|
||||||
|
|
||||||
kb.add('c-n', filter=(vi_insert_mode & has_focus(DEFAULT_BUFFER))
|
kb.add('c-n', filter=(vi_insert_mode & has_focus(DEFAULT_BUFFER))
|
||||||
)(next_history_or_next_completion)
|
)(next_history_or_next_completion)
|
||||||
|
|
||||||
kb.add('c-g', filter=(has_focus(DEFAULT_BUFFER) & has_completions)
|
kb.add('c-g', filter=(has_focus(DEFAULT_BUFFER) & has_completions)
|
||||||
)(dismiss_completion)
|
)(dismiss_completion)
|
||||||
|
|
||||||
kb.add('c-c', filter=has_focus(DEFAULT_BUFFER))(reset_buffer)
|
kb.add('c-c', filter=has_focus(DEFAULT_BUFFER))(reset_buffer)
|
||||||
|
|
||||||
kb.add('c-c', filter=has_focus(SEARCH_BUFFER))(reset_search_buffer)
|
kb.add('c-c', filter=has_focus(SEARCH_BUFFER))(reset_search_buffer)
|
||||||
|
|
||||||
supports_suspend = Condition(lambda: hasattr(signal, 'SIGTSTP'))
|
supports_suspend = Condition(lambda: hasattr(signal, 'SIGTSTP'))
|
||||||
kb.add('c-z', filter=supports_suspend)(suspend_to_bg)
|
kb.add('c-z', filter=supports_suspend)(suspend_to_bg)
|
||||||
|
|
||||||
# Ctrl+I == Tab
|
# Ctrl+I == Tab
|
||||||
kb.add('tab', filter=(has_focus(DEFAULT_BUFFER)
|
kb.add('tab', filter=(has_focus(DEFAULT_BUFFER)
|
||||||
& ~has_selection
|
& ~has_selection
|
||||||
& insert_mode
|
& insert_mode
|
||||||
& cursor_in_leading_ws
|
& cursor_in_leading_ws
|
||||||
))(indent_buffer)
|
))(indent_buffer)
|
||||||
kb.add('c-o', filter=(has_focus(DEFAULT_BUFFER) & emacs_insert_mode)
|
kb.add('c-o', filter=(has_focus(DEFAULT_BUFFER) & emacs_insert_mode)
|
||||||
)(newline_autoindent_outer(shell.input_transformer_manager))
|
)(newline_autoindent_outer(shell.input_transformer_manager))
|
||||||
|
|
||||||
kb.add('f2', filter=has_focus(DEFAULT_BUFFER))(open_input_in_editor)
|
kb.add('f2', filter=has_focus(DEFAULT_BUFFER))(open_input_in_editor)
|
||||||
|
|
||||||
@Condition
|
@Condition
|
||||||
def auto_match():
|
def auto_match():
|
||||||
return shell.auto_match
|
return shell.auto_match
|
||||||
|
|
||||||
focused_insert = (vi_insert_mode | emacs_insert_mode) & has_focus(DEFAULT_BUFFER)
|
focused_insert = (vi_insert_mode | emacs_insert_mode) & has_focus(DEFAULT_BUFFER)
|
||||||
_preceding_text_cache = {}
|
_preceding_text_cache = {}
|
||||||
_following_text_cache = {}
|
_following_text_cache = {}
|
||||||
|
|
||||||
def preceding_text(pattern):
|
def preceding_text(pattern):
|
||||||
try:
|
try:
|
||||||
return _preceding_text_cache[pattern]
|
return _preceding_text_cache[pattern]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
m = re.compile(pattern)
|
m = re.compile(pattern)
|
||||||
|
|
||||||
def _preceding_text():
|
def _preceding_text():
|
||||||
app = get_app()
|
app = get_app()
|
||||||
return bool(m.match(app.current_buffer.document.current_line_before_cursor))
|
return bool(m.match(app.current_buffer.document.current_line_before_cursor))
|
||||||
|
|
||||||
condition = Condition(_preceding_text)
|
condition = Condition(_preceding_text)
|
||||||
_preceding_text_cache[pattern] = condition
|
_preceding_text_cache[pattern] = condition
|
||||||
return condition
|
return condition
|
||||||
|
|
||||||
def following_text(pattern):
|
def following_text(pattern):
|
||||||
try:
|
try:
|
||||||
return _following_text_cache[pattern]
|
return _following_text_cache[pattern]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
m = re.compile(pattern)
|
m = re.compile(pattern)
|
||||||
|
|
||||||
def _following_text():
|
def _following_text():
|
||||||
app = get_app()
|
app = get_app()
|
||||||
return bool(m.match(app.current_buffer.document.current_line_after_cursor))
|
return bool(m.match(app.current_buffer.document.current_line_after_cursor))
|
||||||
|
|
||||||
condition = Condition(_following_text)
|
condition = Condition(_following_text)
|
||||||
_following_text_cache[pattern] = condition
|
_following_text_cache[pattern] = condition
|
||||||
return condition
|
return condition
|
||||||
|
|
||||||
# auto match
|
# auto match
|
||||||
@kb.add("(", filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
|
@kb.add("(", filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
|
||||||
def _(event):
|
def _(event):
|
||||||
event.current_buffer.insert_text("()")
|
event.current_buffer.insert_text("()")
|
||||||
event.current_buffer.cursor_left()
|
event.current_buffer.cursor_left()
|
||||||
|
|
||||||
@kb.add("[", filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
|
@kb.add("[", filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
|
||||||
def _(event):
|
def _(event):
|
||||||
event.current_buffer.insert_text("[]")
|
event.current_buffer.insert_text("[]")
|
||||||
event.current_buffer.cursor_left()
|
event.current_buffer.cursor_left()
|
||||||
|
|
||||||
@kb.add("{", filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
|
@kb.add("{", filter=focused_insert & auto_match & following_text(r"[,)}\]]|$"))
|
||||||
def _(event):
|
def _(event):
|
||||||
event.current_buffer.insert_text("{}")
|
event.current_buffer.insert_text("{}")
|
||||||
event.current_buffer.cursor_left()
|
event.current_buffer.cursor_left()
|
||||||
|
|
||||||
@kb.add(
|
@kb.add(
|
||||||
'"',
|
'"',
|
||||||
filter=focused_insert
|
filter=focused_insert
|
||||||
& auto_match
|
& auto_match
|
||||||
& preceding_text(r'^([^"]+|"[^"]*")*$')
|
& preceding_text(r'^([^"]+|"[^"]*")*$')
|
||||||
& following_text(r"[,)}\]]|$"),
|
& following_text(r"[,)}\]]|$"),
|
||||||
)
|
|
||||||
def _(event):
|
|
||||||
event.current_buffer.insert_text('""')
|
|
||||||
event.current_buffer.cursor_left()
|
|
||||||
|
|
||||||
@kb.add(
|
|
||||||
"'",
|
|
||||||
filter=focused_insert
|
|
||||||
& auto_match
|
|
||||||
& preceding_text(r"^([^']+|'[^']*')*$")
|
|
||||||
& following_text(r"[,)}\]]|$"),
|
|
||||||
)
|
|
||||||
def _(event):
|
|
||||||
event.current_buffer.insert_text("''")
|
|
||||||
event.current_buffer.cursor_left()
|
|
||||||
|
|
||||||
# raw string
|
|
||||||
@kb.add(
|
|
||||||
"(", filter=focused_insert & auto_match & preceding_text(r".*(r|R)[\"'](-*)$")
|
|
||||||
)
|
|
||||||
def _(event):
|
|
||||||
matches = re.match(
|
|
||||||
r".*(r|R)[\"'](-*)",
|
|
||||||
event.current_buffer.document.current_line_before_cursor,
|
|
||||||
)
|
)
|
||||||
dashes = matches.group(2) or ""
|
def _(event):
|
||||||
event.current_buffer.insert_text("()" + dashes)
|
event.current_buffer.insert_text('""')
|
||||||
event.current_buffer.cursor_left(len(dashes) + 1)
|
event.current_buffer.cursor_left()
|
||||||
|
|
||||||
@kb.add(
|
@kb.add(
|
||||||
"[", filter=focused_insert & auto_match & preceding_text(r".*(r|R)[\"'](-*)$")
|
"'",
|
||||||
)
|
filter=focused_insert
|
||||||
def _(event):
|
& auto_match
|
||||||
matches = re.match(
|
& preceding_text(r"^([^']+|'[^']*')*$")
|
||||||
r".*(r|R)[\"'](-*)",
|
& following_text(r"[,)}\]]|$"),
|
||||||
event.current_buffer.document.current_line_before_cursor,
|
|
||||||
)
|
)
|
||||||
dashes = matches.group(2) or ""
|
def _(event):
|
||||||
event.current_buffer.insert_text("[]" + dashes)
|
event.current_buffer.insert_text("''")
|
||||||
event.current_buffer.cursor_left(len(dashes) + 1)
|
event.current_buffer.cursor_left()
|
||||||
|
|
||||||
@kb.add(
|
# raw string
|
||||||
"{", filter=focused_insert & auto_match & preceding_text(r".*(r|R)[\"'](-*)$")
|
@kb.add(
|
||||||
)
|
"(", filter=focused_insert & auto_match & preceding_text(r".*(r|R)[\"'](-*)$")
|
||||||
def _(event):
|
|
||||||
matches = re.match(
|
|
||||||
r".*(r|R)[\"'](-*)",
|
|
||||||
event.current_buffer.document.current_line_before_cursor,
|
|
||||||
)
|
)
|
||||||
dashes = matches.group(2) or ""
|
def _(event):
|
||||||
event.current_buffer.insert_text("{}" + dashes)
|
matches = re.match(
|
||||||
event.current_buffer.cursor_left(len(dashes) + 1)
|
r".*(r|R)[\"'](-*)",
|
||||||
|
event.current_buffer.document.current_line_before_cursor,
|
||||||
|
)
|
||||||
|
dashes = matches.group(2) or ""
|
||||||
|
event.current_buffer.insert_text("()" + dashes)
|
||||||
|
event.current_buffer.cursor_left(len(dashes) + 1)
|
||||||
|
|
||||||
# just move cursor
|
@kb.add(
|
||||||
@kb.add(")", filter=focused_insert & auto_match & following_text(r"^\)"))
|
"[", filter=focused_insert & auto_match & preceding_text(r".*(r|R)[\"'](-*)$")
|
||||||
@kb.add("]", filter=focused_insert & auto_match & following_text(r"^\]"))
|
)
|
||||||
@kb.add("}", filter=focused_insert & auto_match & following_text(r"^\}"))
|
def _(event):
|
||||||
@kb.add('"', filter=focused_insert & auto_match & following_text('^"'))
|
matches = re.match(
|
||||||
@kb.add("'", filter=focused_insert & auto_match & following_text("^'"))
|
r".*(r|R)[\"'](-*)",
|
||||||
def _(event):
|
event.current_buffer.document.current_line_before_cursor,
|
||||||
event.current_buffer.cursor_right()
|
)
|
||||||
|
dashes = matches.group(2) or ""
|
||||||
|
event.current_buffer.insert_text("[]" + dashes)
|
||||||
|
event.current_buffer.cursor_left(len(dashes) + 1)
|
||||||
|
|
||||||
@kb.add(
|
@kb.add(
|
||||||
"backspace",
|
"{", filter=focused_insert & auto_match & preceding_text(r".*(r|R)[\"'](-*)$")
|
||||||
filter=focused_insert
|
)
|
||||||
& preceding_text(r".*\($")
|
def _(event):
|
||||||
& auto_match
|
matches = re.match(
|
||||||
& following_text(r"^\)"),
|
r".*(r|R)[\"'](-*)",
|
||||||
)
|
event.current_buffer.document.current_line_before_cursor,
|
||||||
@kb.add(
|
)
|
||||||
"backspace",
|
dashes = matches.group(2) or ""
|
||||||
filter=focused_insert
|
event.current_buffer.insert_text("{}" + dashes)
|
||||||
& preceding_text(r".*\[$")
|
event.current_buffer.cursor_left(len(dashes) + 1)
|
||||||
& auto_match
|
|
||||||
& following_text(r"^\]"),
|
|
||||||
)
|
|
||||||
@kb.add(
|
|
||||||
"backspace",
|
|
||||||
filter=focused_insert
|
|
||||||
& preceding_text(r".*\{$")
|
|
||||||
& auto_match
|
|
||||||
& following_text(r"^\}"),
|
|
||||||
)
|
|
||||||
@kb.add(
|
|
||||||
"backspace",
|
|
||||||
filter=focused_insert
|
|
||||||
& preceding_text('.*"$')
|
|
||||||
& auto_match
|
|
||||||
& following_text('^"'),
|
|
||||||
)
|
|
||||||
@kb.add(
|
|
||||||
"backspace",
|
|
||||||
filter=focused_insert
|
|
||||||
& preceding_text(r".*'$")
|
|
||||||
& auto_match
|
|
||||||
& following_text(r"^'"),
|
|
||||||
)
|
|
||||||
def _(event):
|
|
||||||
event.current_buffer.delete()
|
|
||||||
event.current_buffer.delete_before_cursor()
|
|
||||||
|
|
||||||
if shell.display_completions == "readlinelike":
|
# just move cursor
|
||||||
kb.add(
|
@kb.add(")", filter=focused_insert & auto_match & following_text(r"^\)"))
|
||||||
"c-i",
|
@kb.add("]", filter=focused_insert & auto_match & following_text(r"^\]"))
|
||||||
filter=(
|
@kb.add("}", filter=focused_insert & auto_match & following_text(r"^\}"))
|
||||||
has_focus(DEFAULT_BUFFER)
|
@kb.add('"', filter=focused_insert & auto_match & following_text('^"'))
|
||||||
& ~has_selection
|
@kb.add("'", filter=focused_insert & auto_match & following_text("^'"))
|
||||||
& insert_mode
|
def _(event):
|
||||||
& ~cursor_in_leading_ws
|
event.current_buffer.cursor_right()
|
||||||
),
|
|
||||||
)(display_completions_like_readline)
|
|
||||||
|
|
||||||
if sys.platform == "win32":
|
@kb.add(
|
||||||
kb.add("c-v", filter=(has_focus(DEFAULT_BUFFER) & ~vi_mode))(win_paste)
|
"backspace",
|
||||||
|
filter=focused_insert
|
||||||
|
& preceding_text(r".*\($")
|
||||||
|
& auto_match
|
||||||
|
& following_text(r"^\)"),
|
||||||
|
)
|
||||||
|
@kb.add(
|
||||||
|
"backspace",
|
||||||
|
filter=focused_insert
|
||||||
|
& preceding_text(r".*\[$")
|
||||||
|
& auto_match
|
||||||
|
& following_text(r"^\]"),
|
||||||
|
)
|
||||||
|
@kb.add(
|
||||||
|
"backspace",
|
||||||
|
filter=focused_insert
|
||||||
|
& preceding_text(r".*\{$")
|
||||||
|
& auto_match
|
||||||
|
& following_text(r"^\}"),
|
||||||
|
)
|
||||||
|
@kb.add(
|
||||||
|
"backspace",
|
||||||
|
filter=focused_insert
|
||||||
|
& preceding_text('.*"$')
|
||||||
|
& auto_match
|
||||||
|
& following_text('^"'),
|
||||||
|
)
|
||||||
|
@kb.add(
|
||||||
|
"backspace",
|
||||||
|
filter=focused_insert
|
||||||
|
& preceding_text(r".*'$")
|
||||||
|
& auto_match
|
||||||
|
& following_text(r"^'"),
|
||||||
|
)
|
||||||
|
def _(event):
|
||||||
|
event.current_buffer.delete()
|
||||||
|
event.current_buffer.delete_before_cursor()
|
||||||
|
|
||||||
@Condition
|
if shell.display_completions == "readlinelike":
|
||||||
def ebivim():
|
kb.add(
|
||||||
return shell.emacs_bindings_in_vi_insert_mode
|
"c-i",
|
||||||
|
filter=(
|
||||||
|
has_focus(DEFAULT_BUFFER)
|
||||||
|
& ~has_selection
|
||||||
|
& insert_mode
|
||||||
|
& ~cursor_in_leading_ws
|
||||||
|
),
|
||||||
|
)(display_completions_like_readline)
|
||||||
|
|
||||||
focused_insert_vi = has_focus(DEFAULT_BUFFER) & vi_insert_mode
|
if sys.platform == "win32":
|
||||||
|
kb.add("c-v", filter=(has_focus(DEFAULT_BUFFER) & ~vi_mode))(win_paste)
|
||||||
|
|
||||||
@kb.add("end", filter=has_focus(DEFAULT_BUFFER) & (ebivim | ~vi_insert_mode))
|
@Condition
|
||||||
def _(event):
|
def ebivim():
|
||||||
_apply_autosuggest(event)
|
return shell.emacs_bindings_in_vi_insert_mode
|
||||||
|
|
||||||
@kb.add("c-e", filter=focused_insert_vi & ebivim)
|
focused_insert_vi = has_focus(DEFAULT_BUFFER) & vi_insert_mode
|
||||||
def _(event):
|
|
||||||
_apply_autosuggest(event)
|
|
||||||
|
|
||||||
@kb.add("c-f", filter=focused_insert_vi)
|
@kb.add("end", filter=has_focus(DEFAULT_BUFFER) & (ebivim | ~vi_insert_mode))
|
||||||
def _(event):
|
def _(event):
|
||||||
b = event.current_buffer
|
_apply_autosuggest(event)
|
||||||
suggestion = b.suggestion
|
|
||||||
if suggestion:
|
|
||||||
b.insert_text(suggestion.text)
|
|
||||||
else:
|
|
||||||
nc.forward_char(event)
|
|
||||||
|
|
||||||
@kb.add("escape", "f", filter=focused_insert_vi & ebivim)
|
@kb.add("c-e", filter=focused_insert_vi & ebivim)
|
||||||
def _(event):
|
def _(event):
|
||||||
b = event.current_buffer
|
_apply_autosuggest(event)
|
||||||
suggestion = b.suggestion
|
|
||||||
if suggestion:
|
|
||||||
t = re.split(r"(\S+\s+)", suggestion.text)
|
|
||||||
b.insert_text(next((x for x in t if x), ""))
|
|
||||||
else:
|
|
||||||
nc.forward_word(event)
|
|
||||||
|
|
||||||
# Simple Control keybindings
|
@kb.add("c-f", filter=focused_insert_vi)
|
||||||
key_cmd_dict = {
|
def _(event):
|
||||||
"c-a": nc.beginning_of_line,
|
b = event.current_buffer
|
||||||
"c-b": nc.backward_char,
|
suggestion = b.suggestion
|
||||||
"c-k": nc.kill_line,
|
if suggestion:
|
||||||
"c-w": nc.backward_kill_word,
|
b.insert_text(suggestion.text)
|
||||||
"c-y": nc.yank,
|
else:
|
||||||
"c-_": nc.undo,
|
nc.forward_char(event)
|
||||||
}
|
|
||||||
|
|
||||||
for key, cmd in key_cmd_dict.items():
|
@kb.add("escape", "f", filter=focused_insert_vi & ebivim)
|
||||||
kb.add(key, filter=focused_insert_vi & ebivim)(cmd)
|
def _(event):
|
||||||
|
b = event.current_buffer
|
||||||
|
suggestion = b.suggestion
|
||||||
|
if suggestion:
|
||||||
|
t = re.split(r"(\S+\s+)", suggestion.text)
|
||||||
|
b.insert_text(next((x for x in t if x), ""))
|
||||||
|
else:
|
||||||
|
nc.forward_word(event)
|
||||||
|
|
||||||
# Alt and Combo Control keybindings
|
# Simple Control keybindings
|
||||||
keys_cmd_dict = {
|
key_cmd_dict = {
|
||||||
# Control Combos
|
"c-a": nc.beginning_of_line,
|
||||||
("c-x", "c-e"): nc.edit_and_execute,
|
"c-b": nc.backward_char,
|
||||||
("c-x", "e"): nc.edit_and_execute,
|
"c-k": nc.kill_line,
|
||||||
# Alt
|
"c-w": nc.backward_kill_word,
|
||||||
("escape", "b"): nc.backward_word,
|
"c-y": nc.yank,
|
||||||
("escape", "c"): nc.capitalize_word,
|
"c-_": nc.undo,
|
||||||
("escape", "d"): nc.kill_word,
|
}
|
||||||
("escape", "h"): nc.backward_kill_word,
|
|
||||||
("escape", "l"): nc.downcase_word,
|
|
||||||
("escape", "u"): nc.uppercase_word,
|
|
||||||
("escape", "y"): nc.yank_pop,
|
|
||||||
("escape", "."): nc.yank_last_arg,
|
|
||||||
}
|
|
||||||
|
|
||||||
for keys, cmd in keys_cmd_dict.items():
|
for key, cmd in key_cmd_dict.items():
|
||||||
kb.add(*keys, filter=focused_insert_vi & ebivim)(cmd)
|
kb.add(key, filter=focused_insert_vi & ebivim)(cmd)
|
||||||
|
|
||||||
|
# Alt and Combo Control keybindings
|
||||||
|
keys_cmd_dict = {
|
||||||
|
# Control Combos
|
||||||
|
("c-x", "c-e"): nc.edit_and_execute,
|
||||||
|
("c-x", "e"): nc.edit_and_execute,
|
||||||
|
# Alt
|
||||||
|
("escape", "b"): nc.backward_word,
|
||||||
|
("escape", "c"): nc.capitalize_word,
|
||||||
|
("escape", "d"): nc.kill_word,
|
||||||
|
("escape", "h"): nc.backward_kill_word,
|
||||||
|
("escape", "l"): nc.downcase_word,
|
||||||
|
("escape", "u"): nc.uppercase_word,
|
||||||
|
("escape", "y"): nc.yank_pop,
|
||||||
|
("escape", "."): nc.yank_last_arg,
|
||||||
|
}
|
||||||
|
|
||||||
|
for keys, cmd in keys_cmd_dict.items():
|
||||||
|
kb.add(*keys, filter=focused_insert_vi & ebivim)(cmd)
|
||||||
|
|
||||||
def get_input_mode(self):
|
def get_input_mode(self):
|
||||||
app = get_app()
|
app = get_app()
|
||||||
|
@ -5,3 +5,4 @@ c.InteractiveShell.history_load_length = 100 * 1000 * 1000
|
|||||||
c.InteractiveShell.pdb = True
|
c.InteractiveShell.pdb = True
|
||||||
c.TerminalInteractiveShell.editing_mode = 'vi'
|
c.TerminalInteractiveShell.editing_mode = 'vi'
|
||||||
c.TerminalInteractiveShell.modal_cursor = False
|
c.TerminalInteractiveShell.modal_cursor = False
|
||||||
|
c.TerminalInteractiveShell.fast_prompt = True
|
||||||
|
Loading…
Reference in New Issue
Block a user