Completion#

class Completion(**properties: Any)#

Superclasses: Object

Main Completion Object.

The completion system helps the user when they writes some text, such as words, command names, functions, and suchlike. Proposals can be shown, to complete the text the user is writing. Each proposal can contain an additional piece of information (for example documentation), that is displayed when the “Details” button is clicked.

Proposals are created via a CompletionProvider. There can be for example a provider to complete words (see CompletionWords), another provider for the completion of function names, etc. To add a provider, call add_provider.

The CompletionProposal interface represents a proposal.

If a proposal contains extra information (see DETAILS), it will be displayed in a supplemental details window, which appears when the “Details” button is clicked.

Each View object is associated with a Completion instance. This instance can be obtained with get_completion. The View class contains also the show_completion signal.

A same CompletionProvider object can be used for several GtkSourceCompletion's.

Methods#

class Completion
add_provider(provider: CompletionProvider) None#

Adds a CompletionProvider to the list of providers to be queried for completion results.

Parameters:

provider – a CompletionProvider

block_interactive() None#
classmethod fuzzy_highlight(casefold_query: str) AttrList | None#

This will add <b> tags around matched characters in haystack based on casefold_query.

Parameters:

casefold_query – the typed-text used to highlight haystack

classmethod fuzzy_match(casefold_needle: str) Tuple[bool, int]#

This helper function can do a fuzzy match for you giving a haystack and casefolded needle.

Casefold your needle using utf8_casefold before running the query.

Score will be set with the score of the match upon success. Otherwise, it will be set to zero.

Parameters:

casefold_needle – A utf8_casefold() version of the needle.

get_buffer() Buffer#

Gets the connected View's Buffer

get_page_size() int#
get_view() View#

Gets the View that owns the Completion.

hide() None#

Emits the “hide” signal.

When the “hide” signal is emitted, the completion window will be dismissed.

remove_provider(provider: CompletionProvider) None#

Removes a CompletionProvider previously added with add_provider.

Parameters:

provider – a CompletionProvider

set_page_size(page_size: int) None#
Parameters:

page_size

show() None#

Emits the “show” signal.

When the “show” signal is emitted, the completion window will be displayed if there are any results available.

unblock_interactive() None#

Properties#

class Completion
props.buffer: TextView#

The type of the None singleton.

props.page_size: int#

The type of the None singleton.

props.remember_info_visibility: bool#

The type of the None singleton.

props.select_on_show: bool#

The type of the None singleton.

props.show_icons: bool#

The type of the None singleton.

props.view: View#

The type of the None singleton.

Signals#

class Completion.signals
hide() None#

The “hide” signal is emitted when the completion window should be hidden.

provider_added(provider: CompletionProvider) None#

The type of the None singleton.

Parameters:

provider – a CompletionProvider

provider_removed(provider: CompletionProvider) None#

The type of the None singleton.

Parameters:

provider – a CompletionProvider

show() None#

The “show” signal is emitted when the completion window should be shown.