Completion#
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
- classmethod fuzzy_highlight(casefold_query: str) AttrList | None #
This will add
<b>
tags around matched characters inhaystack
based oncasefold_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_view() View #
Gets the
View
that owns theCompletion
.
- 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 withadd_provider
.- Parameters:
provider – a
CompletionProvider
Properties#
- class Completion
Signals#
- class Completion.signals
-
- 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