Important

This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

Module: terminal.shortcuts.auto_suggest

2 Classes

class IPython.terminal.shortcuts.auto_suggest.AppendAutoSuggestionInAnyLine(style: str = 'class:auto-suggestion')

Bases: Processor

Append the auto suggestion to lines other than the last (appending to the last line is natively supported by the prompt toolkit).

This has a private _debug attribute that can be set to True to display debug information as virtual suggestion on the end of any line. You can do so with:

>>> from IPython.terminal.shortcuts.auto_suggest import AppendAutoSuggestionInAnyLine
>>> AppendAutoSuggestionInAnyLine._debug = True
__init__(style: str = 'class:auto-suggestion') None
apply_transformation(ti: TransformationInput) Transformation

Apply transformation to the line that is currently being edited.

This is a variation of the original implementation in prompt toolkit that allows to not only append suggestions to any line, but also to show multi-line suggestions.

As transformation are applied on a line-by-line basis; we need to trick a bit, and elide any line that is after the line we are currently editing, until we run out of completions. We cannot shift the existing lines

There are multiple cases to handle:

The completions ends before the end of the buffer:

We can resume showing the normal line, and say that some code may be hidden.

The completions ends at the end of the buffer

We can just say that some code may be hidden.

And separately:

The completions ends beyond the end of the buffer

We need to both say that some code may be hidden, and that some lines are not shown.

class IPython.terminal.shortcuts.auto_suggest.NavigableAutoSuggestFromHistory

Bases: AutoSuggestFromHistory

A subclass of AutoSuggestFromHistory that allow navigation to next/previous suggestion from history. To do so it remembers the current position, but it state need to carefully be cleared on the right events.

__init__()
get_suggestion(buffer: Buffer, document: Document) Suggestion | None

Return None or a Suggestion instance.

We receive both Buffer and Document. The reason is that auto suggestions are retrieved asynchronously. (Like completions.) The buffer text could be changed in the meantime, but document contains the buffer document like it was at the start of the auto suggestion call. So, from here, don’t access buffer.text, but use document.text instead.

Parameters:

14 Functions

IPython.terminal.shortcuts.auto_suggest.accept_or_jump_to_end(event: KeyPressEvent)

Apply autosuggestion or jump to end of line.

IPython.terminal.shortcuts.auto_suggest.accept(event: KeyPressEvent)

Accept autosuggestion

IPython.terminal.shortcuts.auto_suggest.discard(event: KeyPressEvent)

Discard autosuggestion

IPython.terminal.shortcuts.auto_suggest.accept_word(event: KeyPressEvent)

Fill partial autosuggestion by word

IPython.terminal.shortcuts.auto_suggest.accept_character(event: KeyPressEvent)

Fill partial autosuggestion by character

IPython.terminal.shortcuts.auto_suggest.accept_and_keep_cursor(event: KeyPressEvent)

Accept autosuggestion and keep cursor in place

IPython.terminal.shortcuts.auto_suggest.accept_and_move_cursor_left(event: KeyPressEvent)

Accept autosuggestion and move cursor left in place

IPython.terminal.shortcuts.auto_suggest.backspace_and_resume_hint(event: KeyPressEvent)

Resume autosuggestions after deleting last character

IPython.terminal.shortcuts.auto_suggest.resume_hinting(event: KeyPressEvent)

Resume autosuggestions

IPython.terminal.shortcuts.auto_suggest.up_and_update_hint(event: KeyPressEvent)

Go up and update hint

IPython.terminal.shortcuts.auto_suggest.down_and_update_hint(event: KeyPressEvent)

Go down and update hint

IPython.terminal.shortcuts.auto_suggest.accept_token(event: KeyPressEvent)

Fill partial autosuggestion by token

IPython.terminal.shortcuts.auto_suggest.swap_autosuggestion_up(event: KeyPressEvent)

Get next autosuggestion from history.

IPython.terminal.shortcuts.auto_suggest.swap_autosuggestion_down(event: KeyPressEvent)

Get previous autosuggestion from history.