:right-sidebar: True CompletionContext =================================================================== .. currentmodule:: gi.repository.GtkSource .. class:: CompletionContext(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.ListModel` The context of a completion. ``GtkSourceCompletionContext`` contains information about an attept to display completion proposals to the user based on typed text in the :obj:`~gi.repository.GtkSource.View`\. When typing, :obj:`~gi.repository.GtkSource.Completion` may use registered :obj:`~gi.repository.GtkSource.CompletionProvider` to determine if there may be results which could be displayed. If so, a ``GtkSourceCompletionContext`` is created with information that is provided to the :obj:`~gi.repository.GtkSource.CompletionProvider` to populate results which might be useful to the user. :obj:`~gi.repository.GtkSource.CompletionProvider` are expected to provide :obj:`~gi.repository.Gio.ListModel` with :obj:`~gi.repository.GtkSource.CompletionProposal` which may be joined together in a list of results for the user. They are also responsible for how the contents are displayed using :obj:`~gi.repository.GtkSource.CompletionCell` which allows for some level of customization. Methods ------- .. rst-class:: interim-class .. class:: CompletionContext :no-index: .. method:: get_activation() -> ~gi.repository.GtkSource.CompletionActivation Gets the mode for which the context was activated. .. method:: get_bounds() -> ~typing.Tuple[bool, ~gi.repository.Gtk.TextIter, ~gi.repository.Gtk.TextIter] Gets the bounds for the completion, which is the beginning of the current word (taking break characters into account) to the current insertion cursor. If ``begin`` is non-:const:`None`, it will be set to the start position of the current word being completed. If ``end`` is non-:const:`None`, it will be set to the insertion cursor for the current word being completed. .. method:: get_buffer() -> ~gi.repository.GtkSource.Buffer | None Gets the underlying buffer used by the context. This is a convenience function to get the buffer via the :obj:`~gi.repository.GtkSource.Completion` property. .. method:: get_busy() -> bool Gets the "busy" property. This is set to :const:`True` while the completion context is actively fetching proposals from registered :obj:`~gi.repository.GtkSource.CompletionProvider`\'s. .. method:: get_completion() -> ~gi.repository.GtkSource.Completion | None Gets the :obj:`~gi.repository.GtkSource.Completion` that created the context. .. method:: get_empty() -> bool Checks if any proposals have been provided to the context. Out of convenience, this function will return :const:`True` if ``self`` is :const:`None`. .. method:: get_language() -> ~gi.repository.GtkSource.Language | None Gets the language of the underlying buffer, if any. .. method:: get_proposals_for_provider(provider: ~gi.repository.GtkSource.CompletionProvider) -> ~gi.repository.Gio.ListModel | None Gets the :obj:`~gi.repository.Gio.ListModel` associated with the provider. You can connect to :obj:`~gi.repository.GtkSource.CompletionContext`\::model-changed to receive notifications about when the model has been replaced by a new model. .. versionadded:: 5.6 :param provider: a :obj:`~gi.repository.GtkSource.CompletionProvider` .. method:: get_view() -> ~gi.repository.GtkSource.View | None Gets the text view for the context. .. method:: get_word() -> str Gets the word that is being completed up to the position of the insert mark. .. method:: list_providers() -> ~gi.repository.Gio.ListModel Gets the providers that are associated with the context. .. versionadded:: 5.6 .. method:: set_proposals_for_provider(provider: ~gi.repository.GtkSource.CompletionProvider, results: ~gi.repository.Gio.ListModel | None = None) -> None This function allows providers to update their results for a context outside of a call to :obj:`~gi.repository.CompletionProvider.populate_async`\. This can be used to immediately return results for a provider while it does additional asynchronous work. Doing so will allow the completions to update while the operation is in progress. :param provider: an :obj:`~gi.repository.GtkSource.CompletionProvider` :param results: a :obj:`~gi.repository.Gio.ListModel` or :const:`None` Properties ---------- .. rst-class:: interim-class .. class:: CompletionContext :no-index: .. attribute:: props.busy :type: bool The type of the None singleton. .. attribute:: props.completion :type: ~gi.repository.GtkSource.Completion The type of the None singleton. .. attribute:: props.empty :type: bool The type of the None singleton. Signals ------- .. rst-class:: interim-class .. class:: CompletionContext.signals :no-index: .. method:: provider_model_changed(provider: ~gi.repository.GtkSource.CompletionProvider, model: ~gi.repository.Gio.ListModel | None = None) -> None The type of the None singleton. .. versionadded:: 5.6 :param provider: a :obj:`~gi.repository.GtkSource.CompletionProvider` :param model: a :obj:`~gi.repository.Gio.ListModel`