code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def beginning_of_line(event: E) -> None:
"""
Move to the start of the current line.
"""
buff = event.current_buffer
buff.cursor_position += buff.document.get_start_of_line_position(
after_whitespace=False
) |
Move to the start of the current line.
| beginning_of_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def end_of_line(event: E) -> None:
"""
Move to the end of the line.
"""
buff = event.current_buffer
buff.cursor_position += buff.document.get_end_of_line_position() |
Move to the end of the line.
| end_of_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def forward_word(event: E) -> None:
"""
Move forward to the end of the next word. Words are composed of letters and
digits.
"""
buff = event.current_buffer
pos = buff.document.find_next_word_ending(count=event.arg)
if pos:
buff.cursor_position += pos |
Move forward to the end of the next word. Words are composed of letters and
digits.
| forward_word | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def backward_word(event: E) -> None:
"""
Move back to the start of the current or previous word. Words are composed
of letters and digits.
"""
buff = event.current_buffer
pos = buff.document.find_previous_word_beginning(count=event.arg)
if pos:
buff.cursor_position += pos |
Move back to the start of the current or previous word. Words are composed
of letters and digits.
| backward_word | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def end_of_history(event: E) -> None:
"""
Move to the end of the input history, i.e., the line currently being entered.
"""
event.current_buffer.history_forward(count=10**100)
buff = event.current_buffer
buff.go_to_history(len(buff._working_lines) - 1) |
Move to the end of the input history, i.e., the line currently being entered.
| end_of_history | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def reverse_search_history(event: E) -> None:
"""
Search backward starting at the current line and moving `up` through
the history as necessary. This is an incremental search.
"""
control = event.app.layout.current_control
if isinstance(control, BufferControl) and control.search_buffer_control:... |
Search backward starting at the current line and moving `up` through
the history as necessary. This is an incremental search.
| reverse_search_history | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def backward_delete_char(event: E) -> None:
"""
Delete the character behind the cursor.
"""
if event.arg < 0:
# When a negative argument has been given, this should delete in front
# of the cursor.
deleted = event.current_buffer.delete(count=-event.arg)
else:
deleted ... |
Delete the character behind the cursor.
| backward_delete_char | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def transpose_chars(event: E) -> None:
"""
Emulate Emacs transpose-char behavior: at the beginning of the buffer,
do nothing. At the end of a line or buffer, swap the characters before
the cursor. Otherwise, move the cursor right, and then swap the
characters before the cursor.
"""
b = eve... |
Emulate Emacs transpose-char behavior: at the beginning of the buffer,
do nothing. At the end of a line or buffer, swap the characters before
the cursor. Otherwise, move the cursor right, and then swap the
characters before the cursor.
| transpose_chars | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def uppercase_word(event: E) -> None:
"""
Uppercase the current (or following) word.
"""
buff = event.current_buffer
for i in range(event.arg):
pos = buff.document.find_next_word_ending()
words = buff.document.text_after_cursor[:pos]
buff.insert_text(words.upper(), overwrite... |
Uppercase the current (or following) word.
| uppercase_word | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def downcase_word(event: E) -> None:
"""
Lowercase the current (or following) word.
"""
buff = event.current_buffer
for i in range(event.arg): # XXX: not DRY: see meta_c and meta_u!!
pos = buff.document.find_next_word_ending()
words = buff.document.text_after_cursor[:pos]
b... |
Lowercase the current (or following) word.
| downcase_word | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def capitalize_word(event: E) -> None:
"""
Capitalize the current (or following) word.
"""
buff = event.current_buffer
for i in range(event.arg):
pos = buff.document.find_next_word_ending()
words = buff.document.text_after_cursor[:pos]
buff.insert_text(words.title(), overwri... |
Capitalize the current (or following) word.
| capitalize_word | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def kill_line(event: E) -> None:
"""
Kill the text from the cursor to the end of the line.
If we are at the end of the line, this should remove the newline.
(That way, it is possible to delete multiple lines by executing this
command multiple times.)
"""
buff = event.current_buffer
if e... |
Kill the text from the cursor to the end of the line.
If we are at the end of the line, this should remove the newline.
(That way, it is possible to delete multiple lines by executing this
command multiple times.)
| kill_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def kill_word(event: E) -> None:
"""
Kill from point to the end of the current word, or if between words, to the
end of the next word. Word boundaries are the same as forward-word.
"""
buff = event.current_buffer
pos = buff.document.find_next_word_ending(count=event.arg)
if pos:
del... |
Kill from point to the end of the current word, or if between words, to the
end of the next word. Word boundaries are the same as forward-word.
| kill_word | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def unix_word_rubout(event: E, WORD: bool = True) -> None:
"""
Kill the word behind point, using whitespace as a word boundary.
Usually bound to ControlW.
"""
buff = event.current_buffer
pos = buff.document.find_start_of_previous_word(count=event.arg, WORD=WORD)
if pos is None:
# No... |
Kill the word behind point, using whitespace as a word boundary.
Usually bound to ControlW.
| unix_word_rubout | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def delete_horizontal_space(event: E) -> None:
"""
Delete all spaces and tabs around point.
"""
buff = event.current_buffer
text_before_cursor = buff.document.text_before_cursor
text_after_cursor = buff.document.text_after_cursor
delete_before = len(text_before_cursor) - len(text_before_cur... |
Delete all spaces and tabs around point.
| delete_horizontal_space | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def unix_line_discard(event: E) -> None:
"""
Kill backward from the cursor to the beginning of the current line.
"""
buff = event.current_buffer
if buff.document.cursor_position_col == 0 and buff.document.cursor_position > 0:
buff.delete_before_cursor(count=1)
else:
deleted = bu... |
Kill backward from the cursor to the beginning of the current line.
| unix_line_discard | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
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 = d... |
Rotate the kill ring, and yank the new top. Only works following yank or
yank-pop.
| yank_pop | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def call_last_kbd_macro(event: E) -> None:
"""
Re-execute the last keyboard macro defined, by making the characters in the
macro appear as if typed at the keyboard.
Notice that we pass `record_in_macro=False`. This ensures that the 'c-x e'
key sequence doesn't appear in the recording itself. This f... |
Re-execute the last keyboard macro defined, by making the characters in the
macro appear as if typed at the keyboard.
Notice that we pass `record_in_macro=False`. This ensures that the 'c-x e'
key sequence doesn't appear in the recording itself. This function inserts
the body of the called macro b... | call_last_kbd_macro | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def insert_comment(event: E) -> None:
"""
Without numeric argument, comment all lines.
With numeric argument, uncomment all lines.
In any case accept the input.
"""
buff = event.current_buffer
# Transform all lines.
if event.arg != 1:
def change(line: str) -> str:
r... |
Without numeric argument, comment all lines.
With numeric argument, uncomment all lines.
In any case accept the input.
| insert_comment | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def prefix_meta(event: E) -> None:
"""
Metafy the next character typed. This is for keyboards without a meta key.
Sometimes people also want to bind other keys to Meta, e.g. 'jj'::
key_bindings.add_key_binding('j', 'j', filter=ViInsertMode())(prefix_meta)
"""
# ('first' should be true, bec... |
Metafy the next character typed. This is for keyboards without a meta key.
Sometimes people also want to bind other keys to Meta, e.g. 'jj'::
key_bindings.add_key_binding('j', 'j', filter=ViInsertMode())(prefix_meta)
| prefix_meta | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def operate_and_get_next(event: E) -> None:
"""
Accept the current line for execution and fetch the next line relative to
the current line from the history for editing.
"""
buff = event.current_buffer
new_index = buff.working_index + 1
# Accept the current input. (This will also redraw the ... |
Accept the current line for execution and fetch the next line relative to
the current line from the history for editing.
| operate_and_get_next | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/named_commands.py | BSD-3-Clause |
def load_open_in_editor_bindings() -> KeyBindingsBase:
"""
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(),
]
) |
Load both the Vi and emacs key bindings for handling edit-and-execute-command.
| load_open_in_editor_bindings | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/open_in_editor.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/open_in_editor.py | BSD-3-Clause |
def load_emacs_open_in_editor_bindings() -> KeyBindings:
"""
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_bindin... |
Pressing C-X C-E will open the buffer in an external editor.
| load_emacs_open_in_editor_bindings | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/open_in_editor.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/open_in_editor.py | BSD-3-Clause |
def load_vi_open_in_editor_bindings() -> KeyBindings:
"""
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 |
Pressing 'v' in navigation mode will open the buffer in an external editor.
| load_vi_open_in_editor_bindings | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/open_in_editor.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/open_in_editor.py | BSD-3-Clause |
def load_page_navigation_bindings() -> KeyBindingsBase:
"""
Load both the Vi and Emacs bindings for page navigation.
"""
# Only enable when a `Buffer` is focused, otherwise, we would catch keys
# when another widget is focused (like for instance `c-d` in a
# ptterm.Terminal).
return Conditio... |
Load both the Vi and Emacs bindings for page navigation.
| load_page_navigation_bindings | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/page_navigation.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/page_navigation.py | BSD-3-Clause |
def load_emacs_page_navigation_bindings() -> KeyBindingsBase:
"""
Key bindings, for scrolling up and down through pages.
This are separate bindings, because GNU readline doesn't have them.
"""
key_bindings = KeyBindings()
handle = key_bindings.add
handle("c-v")(scroll_page_down)
handle(... |
Key bindings, for scrolling up and down through pages.
This are separate bindings, because GNU readline doesn't have them.
| load_emacs_page_navigation_bindings | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/page_navigation.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/page_navigation.py | BSD-3-Clause |
def scroll_page_down(event: E) -> None:
"""
Scroll page down. (Prefer the cursor at the top of the page, after scrolling.)
"""
w = event.app.layout.current_window
b = event.app.current_buffer
if w and w.render_info:
# Scroll down one page.
line_index = max(w.render_info.last_vis... |
Scroll page down. (Prefer the cursor at the top of the page, after scrolling.)
| scroll_page_down | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/scroll.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/scroll.py | BSD-3-Clause |
def scroll_page_up(event: E) -> None:
"""
Scroll page up. (Prefer the cursor at the bottom of the page, after scrolling.)
"""
w = event.app.layout.current_window
b = event.app.current_buffer
if w and w.render_info:
# Put cursor at the first visible line. (But make sure that the cursor
... |
Scroll page up. (Prefer the cursor at the bottom of the page, after scrolling.)
| scroll_page_up | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/scroll.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/scroll.py | BSD-3-Clause |
def _previous_buffer_is_returnable() -> bool:
"""
True if the previously focused buffer has a return handler.
"""
prev_control = get_app().layout.search_target_buffer_control
return bool(prev_control and prev_control.buffer.is_returnable) |
True if the previously focused buffer has a return handler.
| _previous_buffer_is_returnable | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/search.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/search.py | BSD-3-Clause |
def sorted(self) -> tuple[int, int]:
"""
Return a (start, end) tuple where start <= end.
"""
if self.start < self.end:
return self.start, self.end
else:
return self.end, self.start |
Return a (start, end) tuple where start <= end.
| sorted | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def operator_range(self, document: Document) -> tuple[int, int]:
"""
Return a (start, end) tuple with start <= end that indicates the range
operators should operate on.
`buffer` is used to get start and end of line positions.
This should return something that can be used in a sl... |
Return a (start, end) tuple with start <= end that indicates the range
operators should operate on.
`buffer` is used to get start and end of line positions.
This should return something that can be used in a slice, so the `end`
position is *not* included.
| operator_range | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def cut(self, buffer: Buffer) -> tuple[Document, ClipboardData]:
"""
Turn text object into `ClipboardData` instance.
"""
from_, to = self.operator_range(buffer.document)
from_ += buffer.cursor_position
to += buffer.cursor_position
# For Vi mode, the SelectionSta... |
Turn text object into `ClipboardData` instance.
| cut | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def create_text_object_decorator(
key_bindings: KeyBindings,
) -> Callable[..., Callable[[_TOF], _TOF]]:
"""
Create a decorator that can be used to register Vi text object implementations.
"""
def text_object_decorator(
*keys: Keys | str,
filter: Filter = Always(),
no_move_h... |
Create a decorator that can be used to register Vi text object implementations.
| create_text_object_decorator | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def text_object_decorator(
*keys: Keys | str,
filter: Filter = Always(),
no_move_handler: bool = False,
no_selection_handler: bool = False,
eager: bool = False,
) -> Callable[[_TOF], _TOF]:
"""
Register a text object function.
Usage::
@te... |
Register a text object function.
Usage::
@text_object('w', filter=..., no_move_handler=False)
def handler(event):
# Return a text object for this key.
return TextObject(...)
:param no_move_handler: Disable the move handler in navigation... | text_object_decorator | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def create_operator_decorator(
key_bindings: KeyBindings,
) -> Callable[..., Callable[[_OF], _OF]]:
"""
Create a decorator that can be used for registering Vi operators.
"""
def operator_decorator(
*keys: Keys | str, filter: Filter = Always(), eager: bool = False
) -> Callable[[_OF], _O... |
Create a decorator that can be used for registering Vi operators.
| create_operator_decorator | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def operator_decorator(
*keys: Keys | str, filter: Filter = Always(), eager: bool = False
) -> Callable[[_OF], _OF]:
"""
Register a Vi operator.
Usage::
@operator('d', filter=...)
def handler(event, text_object):
# Do something with the text ... |
Register a Vi operator.
Usage::
@operator('d', filter=...)
def handler(event, text_object):
# Do something with the text object here.
| operator_decorator | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def search_buffer_is_empty() -> bool:
"Returns True when the search buffer is empty."
return get_app().current_buffer.text == "" | Returns True when the search buffer is empty. | search_buffer_is_empty | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def load_vi_bindings() -> KeyBindingsBase:
"""
Vi extensions.
# Overview of Readline Vi commands:
# http://www.catonmat.net/download/bash-vi-editing-mode-cheat-sheet.pdf
"""
# Note: Some key bindings have the "~IsReadOnly()" filter added. This
# prevents the handler to be executed whe... |
Vi extensions.
# Overview of Readline Vi commands:
# http://www.catonmat.net/download/bash-vi-editing-mode-cheat-sheet.pdf
| load_vi_bindings | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _back_to_navigation(event: E) -> None:
"""
Escape goes to vi navigation mode.
"""
buffer = event.current_buffer
vi_state = event.app.vi_state
if vi_state.input_mode in (InputMode.INSERT, InputMode.REPLACE):
buffer.cursor_position += buffer.document.get_cu... |
Escape goes to vi navigation mode.
| _back_to_navigation | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _go_up(event: E) -> None:
"""
Go up, but if we enter a new history entry, move to the start of the
line.
"""
event.current_buffer.auto_up(
count=event.arg, go_to_start_of_line_if_history_changes=True
) |
Go up, but if we enter a new history entry, move to the start of the
line.
| _go_up | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _go_down2(event: E) -> None:
"""
Go down, but if we enter a new history entry, go to the start of the line.
"""
event.current_buffer.auto_down(
count=event.arg, go_to_start_of_line_if_history_changes=True
) |
Go down, but if we enter a new history entry, go to the start of the line.
| _go_down2 | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _start_of_next_line(event: E) -> None:
"""
Go to the beginning of next line.
"""
b = event.current_buffer
b.cursor_down(count=event.arg)
b.cursor_position += b.document.get_start_of_line_position(
after_whitespace=True
) |
Go to the beginning of next line.
| _start_of_next_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _change_until_end_of_line(event: E) -> None:
"""
Change to end of line.
Same as 'c$' (which is implemented elsewhere.)
"""
buffer = event.current_buffer
deleted = buffer.delete(count=buffer.document.get_end_of_line_position())
event.app.clipboard.set_text(del... |
Change to end of line.
Same as 'c$' (which is implemented elsewhere.)
| _change_until_end_of_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _delete_until_end_of_line(event: E) -> None:
"""
Delete from cursor position until the end of the line.
"""
buffer = event.current_buffer
deleted = buffer.delete(count=buffer.document.get_end_of_line_position())
event.app.clipboard.set_text(deleted) |
Delete from cursor position until the end of the line.
| _delete_until_end_of_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _delete_line(event: E) -> None:
"""
Delete line. (Or the following 'n' lines.)
"""
buffer = event.current_buffer
# Split string in before/deleted/after text.
lines = buffer.document.lines
before = "\n".join(lines[: buffer.document.cursor_position_row])
... |
Delete line. (Or the following 'n' lines.)
| _delete_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _substitute(event: E) -> None:
"""
Substitute with new text
(Delete character(s) and go to insert mode.)
"""
text = event.current_buffer.delete(count=event.arg)
event.app.clipboard.set_text(text)
event.app.vi_state.input_mode = InputMode.INSERT |
Substitute with new text
(Delete character(s) and go to insert mode.)
| _substitute | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _visual_line2(event: E) -> None:
"""
Exit line selection mode, or go from non line selection mode to line
selection mode.
"""
selection_state = event.current_buffer.selection_state
if selection_state is not None:
if selection_state.type != SelectionType.L... |
Exit line selection mode, or go from non line selection mode to line
selection mode.
| _visual_line2 | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _visual2(event: E) -> None:
"""
Exit character selection mode, or go from non-character-selection mode
to character selection mode.
"""
selection_state = event.current_buffer.selection_state
if selection_state is not None:
if selection_state.type != Selec... |
Exit character selection mode, or go from non-character-selection mode
to character selection mode.
| _visual2 | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _visual_block2(event: E) -> None:
"""
Exit block selection mode, or go from non block selection mode to block
selection mode.
"""
selection_state = event.current_buffer.selection_state
if selection_state is not None:
if selection_state.type != SelectionTy... |
Exit block selection mode, or go from non block selection mode to block
selection mode.
| _visual_block2 | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _visual_auto_word(event: E) -> None:
"""
Switch from visual linewise mode to visual characterwise mode.
"""
buffer = event.current_buffer
if (
buffer.selection_state
and buffer.selection_state.type == SelectionType.LINES
):
buffer.... |
Switch from visual linewise mode to visual characterwise mode.
| _visual_auto_word | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _next_line(event: E) -> None:
"""
Move to first non whitespace of next line
"""
buffer = event.current_buffer
buffer.cursor_position += buffer.document.get_cursor_down_position(
count=event.arg
)
buffer.cursor_position += buffer.document.get_start_... |
Move to first non whitespace of next line
| _next_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _prev_line(event: E) -> None:
"""
Move to first non whitespace of previous line
"""
buffer = event.current_buffer
buffer.cursor_position += buffer.document.get_cursor_up_position(
count=event.arg
)
buffer.cursor_position += buffer.document.get_star... |
Move to first non whitespace of previous line
| _prev_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _open_above(event: E) -> None:
"""
Open line above and enter insertion mode
"""
event.current_buffer.insert_line_above(copy_margin=not in_paste_mode())
event.app.vi_state.input_mode = InputMode.INSERT |
Open line above and enter insertion mode
| _open_above | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _open_below(event: E) -> None:
"""
Open line below and enter insertion mode
"""
event.current_buffer.insert_line_below(copy_margin=not in_paste_mode())
event.app.vi_state.input_mode = InputMode.INSERT |
Open line below and enter insertion mode
| _open_below | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _reverse_case(event: E) -> None:
"""
Reverse case of current character and move cursor forward.
"""
buffer = event.current_buffer
c = buffer.document.current_char
if c is not None and c != "\n":
buffer.insert_text(c.swapcase(), overwrite=True) |
Reverse case of current character and move cursor forward.
| _reverse_case | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _swapcase_line(event: E) -> None:
"""
Swap case of the current line.
"""
buff = event.current_buffer
buff.transform_current_line(lambda s: s.swapcase()) |
Swap case of the current line.
| _swapcase_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _prev_occurrence(event: E) -> None:
"""
Go to previous occurrence of this word.
"""
b = event.current_buffer
search_state = event.app.current_search_state
search_state.text = b.document.get_word_under_cursor()
search_state.direction = SearchDirection.BACKWARD... |
Go to previous occurrence of this word.
| _prev_occurrence | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _next_occurrence(event: E) -> None:
"""
Go to next occurrence of this word.
"""
b = event.current_buffer
search_state = event.app.current_search_state
search_state.text = b.document.get_word_under_cursor()
search_state.direction = SearchDirection.FORWARD
... |
Go to next occurrence of this word.
| _next_occurrence | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def create_delete_and_change_operators(
delete_only: bool, with_register: bool = False
) -> None:
"""
Delete and change operators.
:param delete_only: Create an operator that deletes, but doesn't go to insert mode.
:param with_register: Copy the deleted text to this named re... |
Delete and change operators.
:param delete_only: Create an operator that deletes, but doesn't go to insert mode.
:param with_register: Copy the deleted text to this named register instead of the clipboard.
| create_delete_and_change_operators | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _(event: E, text_object: TextObject) -> None:
"""
Apply transformation (uppercase, lowercase, rot13, swap case).
"""
buff = event.current_buffer
start, end = text_object.operator_range(buff.document)
if start < end:
# Transform... |
Apply transformation (uppercase, lowercase, rot13, swap case).
| _ | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _b(event: E) -> TextObject:
"""
Move one word or token left.
"""
return TextObject(
event.current_buffer.document.find_start_of_previous_word(count=event.arg)
or 0
) |
Move one word or token left.
| _b | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _B(event: E) -> TextObject:
"""
Move one non-blank word left
"""
return TextObject(
event.current_buffer.document.find_start_of_previous_word(
count=event.arg, WORD=True
)
or 0
) |
Move one non-blank word left
| _B | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _word_forward(event: E) -> TextObject:
"""
'word' forward. 'cw', 'dw', 'w': Delete/change/move one word.
"""
return TextObject(
event.current_buffer.document.find_next_word_beginning(count=event.arg)
or event.current_buffer.document.get_end_of_document_positio... |
'word' forward. 'cw', 'dw', 'w': Delete/change/move one word.
| _word_forward | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _WORD_forward(event: E) -> TextObject:
"""
'WORD' forward. 'cW', 'dW', 'W': Delete/change/move one WORD.
"""
return TextObject(
event.current_buffer.document.find_next_word_beginning(
count=event.arg, WORD=True
)
or event.current_bu... |
'WORD' forward. 'cW', 'dW', 'W': Delete/change/move one WORD.
| _WORD_forward | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _start_of_line(event: E) -> TextObject:
"""'c^', 'd^' and '^': Soft start of line, after whitespace."""
return TextObject(
event.current_buffer.document.get_start_of_line_position(
after_whitespace=True
)
) | 'c^', 'd^' and '^': Soft start of line, after whitespace. | _start_of_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _hard_start_of_line(event: E) -> TextObject:
"""
'c0', 'd0': Hard start of line, before whitespace.
(The move '0' key is implemented elsewhere, because a '0' could also change the `arg`.)
"""
return TextObject(
event.current_buffer.document.get_start_of_line_posit... |
'c0', 'd0': Hard start of line, before whitespace.
(The move '0' key is implemented elsewhere, because a '0' could also change the `arg`.)
| _hard_start_of_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def create_ci_ca_handles(
ci_start: str, ci_end: str, inner: bool, key: str | None = None
) -> None:
# TODO: 'dat', 'dit', (tags (like xml)
"""
Delete/Change string between this start and stop character. But keep these characters.
This implements all the ci", ci<, ci{, ci(, d... |
Delete/Change string between this start and stop character. But keep these characters.
This implements all the ci", ci<, ci{, ci(, di", di<, ca", ca<, ... combinations.
| create_ci_ca_handles | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _previous_section(event: E) -> TextObject:
"""
Move to previous blank-line separated section.
Implements '{', 'c{', 'd{', 'y{'
"""
index = event.current_buffer.document.start_of_paragraph(
count=event.arg, before=True
)
return TextObject(index) |
Move to previous blank-line separated section.
Implements '{', 'c{', 'd{', 'y{'
| _previous_section | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _next_section(event: E) -> TextObject:
"""
Move to next blank-line separated section.
Implements '}', 'c}', 'd}', 'y}'
"""
index = event.current_buffer.document.end_of_paragraph(
count=event.arg, after=True
)
return TextObject(index) |
Move to next blank-line separated section.
Implements '}', 'c}', 'd}', 'y}'
| _next_section | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _find_next_occurrence(event: E) -> TextObject:
"""
Go to next occurrence of character. Typing 'fx' will move the
cursor to the next occurrence of character. 'x'.
"""
event.app.vi_state.last_character_find = CharacterFind(event.data, False)
match = event.current_buffer... |
Go to next occurrence of character. Typing 'fx' will move the
cursor to the next occurrence of character. 'x'.
| _find_next_occurrence | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _find_previous_occurrence(event: E) -> TextObject:
"""
Go to previous occurrence of character. Typing 'Fx' will move the
cursor to the previous occurrence of character. 'x'.
"""
event.app.vi_state.last_character_find = CharacterFind(event.data, True)
return TextObject... |
Go to previous occurrence of character. Typing 'Fx' will move the
cursor to the previous occurrence of character. 'x'.
| _find_previous_occurrence | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _t(event: E) -> TextObject:
"""
Move right to the next occurrence of c, then one char backward.
"""
event.app.vi_state.last_character_find = CharacterFind(event.data, False)
match = event.current_buffer.document.find(
event.data, in_current_line=True, count=event.... |
Move right to the next occurrence of c, then one char backward.
| _t | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _T(event: E) -> TextObject:
"""
Move left to the previous occurrence of c, then one char forward.
"""
event.app.vi_state.last_character_find = CharacterFind(event.data, True)
match = event.current_buffer.document.find_backwards(
event.data, in_current_line=True, c... |
Move left to the previous occurrence of c, then one char forward.
| _T | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _top_of_screen(event: E) -> TextObject:
"""
Moves to the start of the visible region. (Below the scroll offset.)
Implements 'cH', 'dH', 'H'.
"""
w = event.app.layout.current_window
b = event.current_buffer
if w and w.render_info:
# When we find a ... |
Moves to the start of the visible region. (Below the scroll offset.)
Implements 'cH', 'dH', 'H'.
| _top_of_screen | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _middle_of_screen(event: E) -> TextObject:
"""
Moves cursor to the vertical center of the visible region.
Implements 'cM', 'dM', 'M'.
"""
w = event.app.layout.current_window
b = event.current_buffer
if w and w.render_info:
# When we find a Window ... |
Moves cursor to the vertical center of the visible region.
Implements 'cM', 'dM', 'M'.
| _middle_of_screen | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _end_of_screen(event: E) -> TextObject:
"""
Moves to the end of the visible region. (Above the scroll offset.)
"""
w = event.app.layout.current_window
b = event.current_buffer
if w and w.render_info:
# When we find a Window that has BufferControl showing ... |
Moves to the end of the visible region. (Above the scroll offset.)
| _end_of_screen | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _search_next2(event: E) -> None:
"""
Search next in navigation mode. (This goes through the history.)
"""
search_state = event.app.current_search_state
event.current_buffer.apply_search(
search_state, include_current_position=False, count=event.arg
) |
Search next in navigation mode. (This goes through the history.)
| _search_next2 | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _search_previous2(event: E) -> None:
"""
Search previous in navigation mode. (This goes through the history.)
"""
search_state = event.app.current_search_state
event.current_buffer.apply_search(
~search_state, include_current_position=False, count=event.arg
... |
Search previous in navigation mode. (This goes through the history.)
| _search_previous2 | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _scroll_top(event: E) -> None:
"""
Scrolls the window to makes the current line the first line in the visible region.
"""
b = event.current_buffer
event.app.layout.current_window.vertical_scroll = b.document.cursor_position_row |
Scrolls the window to makes the current line the first line in the visible region.
| _scroll_top | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _scroll_bottom(event: E) -> None:
"""
Scrolls the window to makes the current line the last line in the visible region.
"""
# We can safely set the scroll offset to zero; the Window will make
# sure that it scrolls at least enough to make the cursor visible
# again.
... |
Scrolls the window to makes the current line the last line in the visible region.
| _scroll_bottom | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _goto_corresponding_bracket(event: E) -> TextObject:
"""
Implements 'c%', 'd%', '%, 'y%' (Move to corresponding bracket.)
If an 'arg' has been given, go this this % position in the file.
"""
buffer = event.current_buffer
if event._arg:
# If 'arg' has been... |
Implements 'c%', 'd%', '%, 'y%' (Move to corresponding bracket.)
If an 'arg' has been given, go this this % position in the file.
| _goto_corresponding_bracket | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _to_column(event: E) -> TextObject:
"""
Move to the n-th column (you may specify the argument n by typing it on
number keys, for example, 20|).
"""
return TextObject(
event.current_buffer.document.get_column_cursor_position(event.arg - 1)
) |
Move to the n-th column (you may specify the argument n by typing it on
number keys, for example, 20|).
| _to_column | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _goto_first_line(event: E) -> TextObject:
"""
Go to the start of the very first line.
Implements 'gg', 'cgg', 'ygg'
"""
d = event.current_buffer.document
if event._arg:
# Move to the given line.
return TextObject(
d.translate_r... |
Go to the start of the very first line.
Implements 'gg', 'cgg', 'ygg'
| _goto_first_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _goto_last_line(event: E) -> TextObject:
"""
Go to last non-blank of line.
'g_', 'cg_', 'yg_', etc..
"""
return TextObject(
event.current_buffer.document.last_non_blank_of_current_line_position(),
type=TextObjectType.INCLUSIVE,
) |
Go to last non-blank of line.
'g_', 'cg_', 'yg_', etc..
| _goto_last_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _ge(event: E) -> TextObject:
"""
Go to last character of previous word.
'ge', 'cge', 'yge', etc..
"""
prev_end = event.current_buffer.document.find_previous_word_ending(
count=event.arg
)
return TextObject(
prev_end - 1 if prev_end is n... |
Go to last character of previous word.
'ge', 'cge', 'yge', etc..
| _ge | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _gE(event: E) -> TextObject:
"""
Go to last character of previous WORD.
'gE', 'cgE', 'ygE', etc..
"""
prev_end = event.current_buffer.document.find_previous_word_ending(
count=event.arg, WORD=True
)
return TextObject(
prev_end - 1 if pr... |
Go to last character of previous WORD.
'gE', 'cgE', 'ygE', etc..
| _gE | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _gm(event: E) -> TextObject:
"""
Like g0, but half a screenwidth to the right. (Or as much as possible.)
"""
w = event.app.layout.current_window
buff = event.current_buffer
if w and w.render_info:
width = w.render_info.window_width
start = buf... |
Like g0, but half a screenwidth to the right. (Or as much as possible.)
| _gm | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _last_line(event: E) -> TextObject:
"""
Go to the end of the document. (If no arg has been given.)
"""
buf = event.current_buffer
return TextObject(
buf.document.translate_row_col_to_index(buf.document.line_count - 1, 0)
- buf.cursor_position,
... |
Go to the end of the document. (If no arg has been given.)
| _last_line | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _replace_single(event: E) -> None:
"""
Replace single character at cursor position.
"""
event.current_buffer.insert_text(event.data, overwrite=True)
event.current_buffer.cursor_position -= 1
event.app.vi_state.input_mode = InputMode.NAVIGATION |
Replace single character at cursor position.
| _replace_single | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _insert_text_multiple_cursors(event: E) -> None:
"""
Insert data at multiple cursor positions at once.
(Usually a result of pressing 'I' or 'A' in block-selection mode.)
"""
buff = event.current_buffer
original_text = buff.text
# Construct new text.
t... |
Insert data at multiple cursor positions at once.
(Usually a result of pressing 'I' or 'A' in block-selection mode.)
| _insert_text_multiple_cursors | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _left_multiple(event: E) -> None:
"""
Move all cursors to the left.
(But keep all cursors on the same line.)
"""
buff = event.current_buffer
new_positions = []
for p in buff.multiple_cursor_positions:
if buff.document.translate_index_to_position(p... |
Move all cursors to the left.
(But keep all cursors on the same line.)
| _left_multiple | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _right_multiple(event: E) -> None:
"""
Move all cursors to the right.
(But keep all cursors on the same line.)
"""
buff = event.current_buffer
new_positions = []
for p in buff.multiple_cursor_positions:
row, column = buff.document.translate_index_... |
Move all cursors to the right.
(But keep all cursors on the same line.)
| _right_multiple | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _updown_multiple(event: E) -> None:
"""
Ignore all up/down key presses when in multiple cursor mode.
""" |
Ignore all up/down key presses when in multiple cursor mode.
| _updown_multiple | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def _execute_macro(event: E) -> None:
"""
Execute macro.
Notice that we pass `record_in_macro=False`. This ensures that the `@x`
keys don't appear in the recording itself. This function inserts the
body of the called macro back into the KeyProcessor, so these keys will
b... |
Execute macro.
Notice that we pass `record_in_macro=False`. This ensures that the `@x`
keys don't appear in the recording itself. This function inserts the
body of the called macro back into the KeyProcessor, so these keys will
be added later on to the macro of their handlers h... | _execute_macro | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/key_binding/bindings/vi.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/key_binding/bindings/vi.py | BSD-3-Clause |
def reset(self) -> None:
"""
Reset the state of this container and all the children.
(E.g. reset scroll offsets, etc...)
""" |
Reset the state of this container and all the children.
(E.g. reset scroll offsets, etc...)
| reset | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/layout/containers.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/layout/containers.py | BSD-3-Clause |
def preferred_width(self, max_available_width: int) -> Dimension:
"""
Return a :class:`~prompt_toolkit.layout.Dimension` that represents the
desired width for this container.
""" |
Return a :class:`~prompt_toolkit.layout.Dimension` that represents the
desired width for this container.
| preferred_width | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/layout/containers.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/layout/containers.py | BSD-3-Clause |
def preferred_height(self, width: int, max_available_height: int) -> Dimension:
"""
Return a :class:`~prompt_toolkit.layout.Dimension` that represents the
desired height for this container.
""" |
Return a :class:`~prompt_toolkit.layout.Dimension` that represents the
desired height for this container.
| preferred_height | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/layout/containers.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/layout/containers.py | BSD-3-Clause |
def write_to_screen(
self,
screen: Screen,
mouse_handlers: MouseHandlers,
write_position: WritePosition,
parent_style: str,
erase_bg: bool,
z_index: int | None,
) -> None:
"""
Write the actual content to the screen.
:param screen: :cla... |
Write the actual content to the screen.
:param screen: :class:`~prompt_toolkit.layout.screen.Screen`
:param mouse_handlers: :class:`~prompt_toolkit.layout.mouse_handlers.MouseHandlers`.
:param parent_style: Style string to pass to the :class:`.Window`
object. This will be a... | write_to_screen | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/layout/containers.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/layout/containers.py | BSD-3-Clause |
def _window_too_small() -> Window:
"Create a `Window` that displays the 'Window too small' text."
return Window(
FormattedTextControl(text=[("class:window-too-small", " Window too small... ")])
) | Create a `Window` that displays the 'Window too small' text. | _window_too_small | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/layout/containers.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/layout/containers.py | BSD-3-Clause |
def _all_children(self) -> list[Container]:
"""
List of child objects, including padding.
"""
def get() -> list[Container]:
result: list[Container] = []
# Padding Top.
if self.align in (VerticalAlign.CENTER, VerticalAlign.BOTTOM):
res... |
List of child objects, including padding.
| _all_children | python | prompt-toolkit/python-prompt-toolkit | src/prompt_toolkit/layout/containers.py | https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/src/prompt_toolkit/layout/containers.py | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.