GtkSourceCompletion

GtkSourceCompletion — Main Completion Object

Functions

Properties

GtkTextView * buffer Read
guint page-size Read / Write
gboolean remember-info-visibility Read / Write
gboolean select-on-show Read / Write
gboolean show-icons Read / Write
GtkSourceView * view Read / Write / Construct Only

Signals

void hide Action
void provider-added Run Last
void provider-removed Run Last
void show Action

Types and Values

Object Hierarchy

    GObject
    ╰── GtkSourceCompletion

Includes

#include <gtksourceview/gtksource.h>

Description

The completion system helps the user when he/she 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 GtkSourceCompletionProvider. There can be for example a provider to complete words (see GtkSourceCompletionWords), another provider for the completion of function names, etc. To add a provider, call gtk_source_completion_add_provider().

When several providers match, they are all shown in the completion window, but one can switch between providers: see the “move-page” signal. It is also possible to activate the first proposals with key bindings, see the “accelerators” property.

The GtkSourceCompletionProposal interface represents a proposal.

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

Each GtkSourceView object is associated with a GtkSourceCompletion instance. This instance can be obtained with gtk_source_view_get_completion(). The GtkSourceView class contains also the “show-completion” signal.

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

Functions

gtk_source_completion_get_view ()

GtkSourceView *
gtk_source_completion_get_view (GtkSourceCompletion *self);

Gets the GtkSourceView that owns the GtkSourceCompletion.

Parameters

Returns

A GtkSourceView.

[transfer none]

Since: 5.0


gtk_source_completion_get_buffer ()

GtkSourceBuffer *
gtk_source_completion_get_buffer (GtkSourceCompletion *self);

Gets the connected GtkSourceView's GtkSourceBuffer

Parameters

Returns

A GtkSourceBuffer.

[transfer none]

Since: 5.0


gtk_source_completion_show ()

void
gtk_source_completion_show (GtkSourceCompletion *self);

Emits the "show" signal.

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

Parameters

self

an GtkSourceCompletion

 

Since: 5.0


gtk_source_completion_hide ()

void
gtk_source_completion_hide (GtkSourceCompletion *self);

Emits the "hide" signal.

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

Parameters

self

an GtkSourceCompletion

 

Since: 5.0


gtk_source_completion_add_provider ()

void
gtk_source_completion_add_provider (GtkSourceCompletion *self,
                                    GtkSourceCompletionProvider *provider);

Adds an GtkSourceCompletionProvider to the list of providers to be queried for completion results.

Parameters

Since: 5.0


gtk_source_completion_remove_provider ()

void
gtk_source_completion_remove_provider (GtkSourceCompletion *self,
                                       GtkSourceCompletionProvider *provider);

Removes an GtkSourceCompletionProvider previously added with gtk_source_completion_add_provider().

Parameters

Since: 5.0


gtk_source_completion_block_interactive ()

void
gtk_source_completion_block_interactive
                               (GtkSourceCompletion *self);

gtk_source_completion_unblock_interactive ()

void
gtk_source_completion_unblock_interactive
                               (GtkSourceCompletion *self);

gtk_source_completion_get_page_size ()

guint
gtk_source_completion_get_page_size (GtkSourceCompletion *self);

gtk_source_completion_set_page_size ()

void
gtk_source_completion_set_page_size (GtkSourceCompletion *self,
                                     guint page_size);

gtk_source_completion_fuzzy_match ()

gboolean
gtk_source_completion_fuzzy_match (const char *haystack,
                                   const char *casefold_needle,
                                   guint *priority);

This helper function can do a fuzzy match for you giving a haystack and casefolded needle. Casefold your needle using g_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

haystack

the string to be searched.

[nullable]

casefold_needle

A g_utf8_casefold() version of the needle.

 

priority

An optional location for the score of the match.

[out][allow-none]

Returns

TRUE if haystack matched casefold_needle , otherwise FALSE.

Since: 5.0


gtk_source_completion_fuzzy_highlight ()

PangoAttrList *
gtk_source_completion_fuzzy_highlight (const char *haystack,
                                       const char *casefold_query);

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

Parameters

haystack

the string to be highlighted

 

casefold_query

the typed-text used to highlight haystack

 

Returns

a PangoAttrList or NULL.

[transfer full][nullable]

Since: 5.0

Types and Values

GtkSourceCompletion

typedef struct _GtkSourceCompletion GtkSourceCompletion;

Property Details

The “buffer” property

  “buffer”                   GtkTextView *

The GtkTextBuffer for the “view”. This is a convenience property for providers.

Owner: GtkSourceCompletion

Flags: Read

Since: 5.0


The “page-size” property

  “page-size”                guint

The number of rows to display to the user before scrolling.

Owner: GtkSourceCompletion

Flags: Read / Write

Allowed values: [1,32]

Default value: 5

Since: 5.0


The “remember-info-visibility” property

  “remember-info-visibility” gboolean

Determines whether the visibility of the info window should be saved when the completion is hidden, and restored when the completion is shown again.

Owner: GtkSourceCompletion

Flags: Read / Write

Default value: FALSE


The “select-on-show” property

  “select-on-show”           gboolean

Determines whether the first proposal should be selected when the completion is first shown.

Owner: GtkSourceCompletion

Flags: Read / Write

Default value: FALSE


The “show-icons” property

  “show-icons”               gboolean

The "show-icons" property denotes if icons should be displayed within the list of completions presented to the user.

Owner: GtkSourceCompletion

Flags: Read / Write

Default value: TRUE


The “view” property

  “view”                     GtkSourceView *

The "view" property is the GtkTextView for which this GtkSourceCompletion is providing completion features.

Owner: GtkSourceCompletion

Flags: Read / Write / Construct Only

Since: 5.0

Signal Details

The “hide” signal

void
user_function (GtkSourceCompletion *self,
               gpointer             user_data)

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

Parameters

self

an GtkSourceCompletion

 

user_data

user data set when the signal handler was connected.

 

Flags: Action

Since: 5.0


The “provider-added” signal

void
user_function (GtkSourceCompletion         *self,
               GtkSourceCompletionProvider *provider,
               gpointer                     user_data)

The "provided-added" signal is emitted when a new provider is added to the completion.

Parameters

self

an ideCompletion

 

provider

an GtkSourceCompletionProvider

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

Since: 5.0


The “provider-removed” signal

void
user_function (GtkSourceCompletion         *self,
               GtkSourceCompletionProvider *provider,
               gpointer                     user_data)

The "provided-removed" signal is emitted when a provider has been removed from the completion.

Parameters

self

an ideCompletion

 

provider

an GtkSourceCompletionProvider

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

Since: 5.0


The “show” signal

void
user_function (GtkSourceCompletion *self,
               gpointer             user_data)

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

Parameters

self

an GtkSourceCompletion

 

user_data

user data set when the signal handler was connected.

 

Flags: Action

Since: 5.0