euporie.core.suggest

Suggest line completions from kernel history.

Functions

to_filter(bool_or_filter)

Accept both booleans and Filters as input and turn it into a Filter.

Classes

AutoSuggest()

Base class for auto suggestion implementations.

ConditionalAutoSuggest(auto_suggest, filter)

Auto suggest that can be turned on and of according to a certain condition.

ConditionalAutoSuggestAsync(auto_suggest, filter)

Auto suggest that can be turned on and of according to a certain condition.

HistoryAutoSuggest(history[, cache_size])

Suggest line completions from a History object.

KernelAutoSuggest(kernel)

Suggest line completions from kernel history.

Suggestion(text)

Suggestion returned by an auto-suggest algorithm.

deque

deque([iterable[, maxlen]]) --> deque object

class euporie.core.suggest.ConditionalAutoSuggestAsync(auto_suggest: AutoSuggest, filter: bool | Filter)

Bases: prompt_toolkit.auto_suggest.ConditionalAutoSuggest

Auto suggest that can be turned on and of according to a certain condition.

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
async get_suggestion_async(buffer: Buffer, document: Document) Suggestion | None

Get suggestions asynchronously if the filter allows.

class euporie.core.suggest.HistoryAutoSuggest(history: History, cache_size: int = 100000)

Bases: prompt_toolkit.auto_suggest.AutoSuggest

Suggest line completions from a History object.

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

Get a line completion suggestion.

async get_suggestion_async(buff: Buffer, document: Document) Suggestion | None

Return a Future which is set when the suggestions are ready. This function can be overloaded in order to provide an asynchronous implementation.

lookup_suggestion(line: str) prompt_toolkit.auto_suggest.Suggestion | None

Find the most recent matching line in the history.

class euporie.core.suggest.KernelAutoSuggest(kernel: Kernel)

Bases: prompt_toolkit.auto_suggest.AutoSuggest

Suggest line completions from kernel history.

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

Doe nothing.

async get_suggestion_async(buff: Buffer, document: Document) Suggestion | None

Return suggestions based on matching kernel history.