GtkSource.Completion

g GObject.Object GObject.Object GtkSource.Completion GtkSource.Completion GObject.Object->GtkSource.Completion

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

fuzzy_highlight (haystack, casefold_query)

class

fuzzy_match (haystack, casefold_needle)

add_provider (provider)

block_interactive ()

get_buffer ()

get_page_size ()

get_view ()

hide ()

remove_provider (provider)

set_page_size (page_size)

show ()

unblock_interactive ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

buffer

Gtk.TextView

r

The buffer for the view

page-size

int

r/w/en

Number of rows to display to the user

remember-info-visibility

bool

r/w

Remember Info Visibility

select-on-show

bool

r/w

Select on Show

show-icons

bool

r/w

If icons should be shown in the completion results

view

GtkSource.View

r/w/co

The text view for which to provide completion

Signals

Inherited:

GObject.Object (1)

Name

Short Description

hide

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

provider-added

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

provider-removed

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

show

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

Fields

Inherited:

GObject.Object (1)

Class Details

class GtkSource.Completion(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GtkSource.CompletionClass

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 [iface`CompletionProvider`]. There can be for example a provider to complete words (see [class`CompletionWords`]), another provider for the completion of function names, etc. To add a provider, call [method`Completion`.add_provider].

The [iface`CompletionProposal`] interface represents a proposal.

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

Each [class`View`] object is associated with a [class`Completion`] instance. This instance can be obtained with [method`View`.get_completion]. The [class`View`] class contains also the [signal`View`:py:func:::show-completion<GtkSource.Completion.signals.show_completion>] signal.

A same [iface`CompletionProvider`] object can be used for several GtkSourceCompletion’s.

classmethod fuzzy_highlight(haystack, casefold_query)
Parameters:
  • haystack (str) – the string to be highlighted

  • casefold_query (str) – the typed-text used to highlight haystack

Returns:

a Pango.AttrList or None

Return type:

Pango.AttrList or None

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

classmethod fuzzy_match(haystack, casefold_needle)
Parameters:
Returns:

True if haystack matched casefold_needle, otherwise False.

priority:

An optional location for the score of the match

Return type:

(bool, priority: int)

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

Casefold your needle using [func`GLib`.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.

add_provider(provider)
Parameters:

provider (GtkSource.CompletionProvider) – a GtkSource.CompletionProvider

Adds a [iface`CompletionProvider`] to the list of providers to be queried for completion results.

block_interactive()
get_buffer()
Returns:

A GtkSource.Buffer

Return type:

GtkSource.Buffer

Gets the connected [class`View`]’s [class`Buffer`]

get_page_size()
Return type:

int

get_view()
Returns:

A GtkSource.View

Return type:

GtkSource.View

Gets the [class`View`] that owns the [class`Completion`].

hide()

Emits the “hide” signal.

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

remove_provider(provider)
Parameters:

provider (GtkSource.CompletionProvider) – a GtkSource.CompletionProvider

Removes a [iface`CompletionProvider`] previously added with [method`Completion`.add_provider].

set_page_size(page_size)
Parameters:

page_size (int) –

show()

Emits the “show” signal.

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

unblock_interactive()

Signal Details

GtkSource.Completion.signals.hide(completion)
Signal Name:

hide

Flags:

RUN_LAST, ACTION

Parameters:

completion (GtkSource.Completion) – The object which received the signal

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

GtkSource.Completion.signals.provider_added(completion, provider)
Signal Name:

provider-added

Flags:

RUN_LAST

Parameters:

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

GtkSource.Completion.signals.provider_removed(completion, provider)
Signal Name:

provider-removed

Flags:

RUN_LAST

Parameters:

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

GtkSource.Completion.signals.show(completion)
Signal Name:

show

Flags:

RUN_LAST, ACTION

Parameters:

completion (GtkSource.Completion) – The object which received the signal

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

Property Details

GtkSource.Completion.props.buffer
Name:

buffer

Type:

Gtk.TextView

Default Value:

None

Flags:

READABLE

The Gtk.TextBuffer for the GtkSource.Completion :view. This is a convenience property for providers.

GtkSource.Completion.props.page_size
Name:

page-size

Type:

int

Default Value:

5

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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

GtkSource.Completion.props.remember_info_visibility
Name:

remember-info-visibility

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

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

GtkSource.Completion.props.select_on_show
Name:

select-on-show

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

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

GtkSource.Completion.props.show_icons
Name:

show-icons

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

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

GtkSource.Completion.props.view
Name:

view

Type:

GtkSource.View

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The “view” property is the Gtk.TextView for which this GtkSource.Completion is providing completion features.