GtkSourceCompletionContext

GtkSourceCompletionContext — The context of a completion

Functions

Properties

gboolean busy Read
GtkSourceCompletion * completion Read / Write / Construct Only
gboolean empty Read

Types and Values

Object Hierarchy

    GEnum
    ╰── GtkSourceCompletionActivation
    GObject
    ╰── GtkSourceCompletionContext

Implemented Interfaces

GtkSourceCompletionContext implements GListModel.

Includes

#include <gtksourceview/gtksource.h>

Description

GtkSourceCompletionContext contains information about an attept to display completion proposals to the user based on typed text in the GtkSourceView.

When typing, GtkSourceCompletion may use registered GtkSourceCompletionProvider to determine if there may be results which could be displayed. If so, a GtkSourceCompletionContext is created with information that is provided to the GtkSourceCompletionProvider to populate results which might be useful to the user.

GtkSourceCompletionProvider are expected to provide GListModel with GtkSourceCompletionProposal which may be joined together in a list of results for the user. They are also responsible for how the contents are displayed using GtkSourceCompletionCell which allows for some level of customization.

Functions

gtk_source_completion_context_get_activation ()

GtkSourceCompletionActivation
gtk_source_completion_context_get_activation
                               (GtkSourceCompletionContext *self);

Gets the mode for which the context was activated.

Parameters

Since: 5.0


gtk_source_completion_context_get_bounds ()

gboolean
gtk_source_completion_context_get_bounds
                               (GtkSourceCompletionContext *self,
                                GtkTextIter *begin,
                                GtkTextIter *end);

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-NULL, it will be set to the start position of the current word being completed.

If end is non-NULL, it will be set to the insertion cursor for the current word being completed.

Parameters

self

an GtkSourceCompletionContext

 

begin

a GtkTextIter.

[out][optional]

end

a GtkTextIter.

[out][optional]

Returns

TRUE if the marks are still valid and begin or end was set.

Since: 5.0


gtk_source_completion_context_get_buffer ()

GtkSourceBuffer *
gtk_source_completion_context_get_buffer
                               (GtkSourceCompletionContext *self);

Gets the underlying buffer used by the context.

This is a convenience function to get the buffer via the GtkSourceCompletion property.

Parameters

Returns

a GtkTextBuffer or NULL.

[transfer none][nullable]

Since: 5.0


gtk_source_completion_context_get_busy ()

gboolean
gtk_source_completion_context_get_busy
                               (GtkSourceCompletionContext *self);

Gets the "busy" property. This is set to TRUE while the completion context is actively fetching proposals from registered GtkSourceCompletionProvider's.

Parameters

Returns

TRUE if the context is busy

Since: 5.0


gtk_source_completion_context_get_completion ()

GtkSourceCompletion *
gtk_source_completion_context_get_completion
                               (GtkSourceCompletionContext *self);

Gets the GtkSourceCompletion that created the context.

Parameters

Returns

an GtkSourceCompletion or NULL.

[transfer none][nullable]

Since: 5.0


gtk_source_completion_context_get_empty ()

gboolean
gtk_source_completion_context_get_empty
                               (GtkSourceCompletionContext *self);

Checks if any proposals have been provided to the context.

Out of convenience, this function will return TRUE if self is NULL.

Parameters

Returns

TRUE if there are no proposals in the context

Since: 5.0


gtk_source_completion_context_get_language ()

GtkSourceLanguage *
gtk_source_completion_context_get_language
                               (GtkSourceCompletionContext *self);

Gets the language of the underlying buffer, if any.

Parameters

Returns

a GtkSourceLanguage or NULL.

[nullable][transfer none]

Since: 5.0


gtk_source_completion_context_get_start_iter ()

void
gtk_source_completion_context_get_start_iter
                               (GtkSourceCompletionContext *self,
                                GtkTextIter *iter);

gtk_source_completion_context_get_view ()

GtkSourceView *
gtk_source_completion_context_get_view
                               (GtkSourceCompletionContext *self);

Gets the text view for the context.

Parameters

Returns

a GtkSourceView or NULL.

[nullable][transfer none]

Since: 5.0


gtk_source_completion_context_get_word ()

char *
gtk_source_completion_context_get_word
                               (GtkSourceCompletionContext *self);

Gets the word that is being completed up to the position of the insert mark.

Parameters

Returns

a string containing the current word.

[transfer full]

Since: 5.0


gtk_source_completion_context_set_proposals_for_provider ()

void
gtk_source_completion_context_set_proposals_for_provider
                               (GtkSourceCompletionContext *self,
                                GtkSourceCompletionProvider *provider,
                                GListModel *results);

This function allows providers to update their results for a context outside of a call to gtk_source_completion_provider_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.

Parameters

self

an GtkSourceCompletionContext

 

provider

an GtkSourceCompletionProvider

 

results

a GListModel or NULL.

[nullable]

Since: 5.0

Types and Values

enum GtkSourceCompletionActivation

Members

GTK_SOURCE_COMPLETION_ACTIVATION_NONE

   

GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE

   

GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED

   

GtkSourceCompletionContext

typedef struct _GtkSourceCompletionContext GtkSourceCompletionContext;

Property Details

The “busy” property

  “busy”                     gboolean

The "busy" property is TRUE while the completion context is populating completion proposals.

Owner: GtkSourceCompletionContext

Flags: Read

Default value: FALSE

Since: 5.0


The “completion” property

  “completion”               GtkSourceCompletion *

The "completion" is the GtkSourceCompletion that was used to create the context.

Owner: GtkSourceCompletionContext

Flags: Read / Write / Construct Only

Since: 5.0


The “empty” property

  “empty”                    gboolean

The "empty" property is TRUE when there are no results.

It will be notified when the first result is added or the last result is removed.

Owner: GtkSourceCompletionContext

Flags: Read

Default value: TRUE

Since: 5.0

See Also

GtkSourceCompletion, GtkSourceCompletionProvider, and GtkSourceCompletionProposal.