### Interface

# Pos Completer

#### Description [src]

    interface Pos.Completer : GObject.Object

Interface for completion engines.

Completion engines implement this interface so they can be used by the OSK to complete or correct user input. Users of this interface should fill the `PosCompleter:preedit` with user input and will get a list of possible completions in the `completions` property. Note that this can happen asynchronously as getting the completions can take time.

The completer can also instruct the user of this interface to commit a given text via the `PosCompleter::commit-string` signal. Implementations should emit this signal on word breaking characters to either take the user input as is or force “aggressive” autocorrection (picking a correction on the users behalf).

#### Prerequisite

In order to implement Completer, your type must inherit from`GObject`.

#### Implementations

- PosCompleterHunspell
- PosCompleterPipe
- PosCompleterPresage
- PosCompleterVarnam

#### Functions

###### pos_completer_capitalize_by_template

Returns a copy of completions with the capitalization of the strings set to match the capitalization in the template. Use with the preedit as template with completers which return only lower case completions.

###### pos_completer_error_quark

No description available.

###### pos_completer_find_prev_word_break

Scans `text` from the end and returns the last word break in bytes counted from the end of the string. The word break is the position of the last two words separated by `completion_end_symbols`.

#### Instance methods

###### pos_completer_feed_symbol

Feeds a symbol to be processed by the completer.

###### pos_completer_get_completions

Returns the current possible completions.

###### pos_completer_get_display_name

Get the completers display name.

###### pos_completer_get_name

Returns the completers name.

###### pos_completer_get_preedit

Returns the current preedit.

###### pos_completer_learn_accepted

No description available.

###### pos_completer_lookup_completion

Given a given completion string lookup what should actually be completed. This allows completers to e.g. provide the full word as completion “handle” and fill in just the last chars as actual completions.

###### pos_completer_set_language

Let the completer pick a language based on the given language code and region. If an error occurs `FALSE` is returned and `error` set to the error.

###### pos_completer_set_preedit

Sets the current preedit. The preedit is the current word under completion.

###### pos_completer_set_surrounding_text

Set the text before and after the current cursor position. This can be used by the completer to improve the prediction.

#### Properties

###### Pos.Completer:completions

The list of completions for a given preedit.

###### Pos.Completer:name

The name of this completer.

###### Pos.Completer:preedit

The preedit is not yet submitted text at the current cursor position.

#### Signals

###### Pos.Completer::commit-string

The completer wants the given text to be committed as is. This can happen when the completer encounters a word separating character (e.g. space). `preedit` will be set to empty in this case.

###### Pos.Completer::update

The completer changed it’s preedit to the given string and wants the given number of bytes before and after the preedit removed.

#### Interface structure

    struct PosCompleterInterface {
      GTypeInterface parent_iface;
      const char* (* get_name) (
        PosCompleter* self
      );
      gboolean (* feed_symbol) (
        PosCompleter* self,
        const char* symbol
      );
      const char* (* get_preedit) (
        PosCompleter* self
      );
      void (* set_preedit) (
        PosCompleter* self,
        const char* preedit
      );
      void (* set_surrounding_text) (
        PosCompleter* self,
        const char* before_text,
        const char* after_text
      );
      gboolean (* set_language) (
        PosCompleter* self,
        const char* lang,
        const char* region,
        GError** error
      );
      char* (* get_display_name) (
        PosCompleter* self
      );
      void (* learn_accepted) (
        PosCompleter* self,
        const char* word
      );
      const char* (* lookup_completion) (
        PosCompleter* self,
        const char* completion
      );

    }

No description available.

###### Interface members

`parent_iface`

    GTypeInterface

| No description available.

`get_name`

    const char* (* get_name) (
        PosCompleter* self
      )

| No description available.

`feed_symbol`

    gboolean (* feed_symbol) (
        PosCompleter* self,
        const char* symbol
      )

| No description available.

`get_preedit`

    const char* (* get_preedit) (
        PosCompleter* self
      )

| No description available.

`set_preedit`

    void (* set_preedit) (
        PosCompleter* self,
        const char* preedit
      )

| No description available.

`set_surrounding_text`

    void (* set_surrounding_text) (
        PosCompleter* self,
        const char* before_text,
        const char* after_text
      )

| No description available.

`set_language`

    gboolean (* set_language) (
        PosCompleter* self,
        const char* lang,
        const char* region,
        GError** error
      )

| No description available.

`get_display_name`

    char* (* get_display_name) (
        PosCompleter* self
      )

| No description available.

`learn_accepted`

    void (* learn_accepted) (
        PosCompleter* self,
        const char* word
      )

| No description available.

`lookup_completion`

    const char* (* lookup_completion) (
        PosCompleter* self,
        const char* completion
      )

| No description available.

#### Virtual methods

###### Pos.Completer.feed_symbol

Feeds a symbol to be processed by the completer.

###### Pos.Completer.get_display_name

Get the completers display name.

###### Pos.Completer.get_name

Returns the completers name.

###### Pos.Completer.get_preedit

Returns the current preedit.

###### Pos.Completer.learn_accepted

No description available.

###### Pos.Completer.lookup_completion

Given a given completion string lookup what should actually be completed. This allows completers to e.g. provide the full word as completion “handle” and fill in just the last chars as actual completions.

###### Pos.Completer.set_language

Let the completer pick a language based on the given language code and region. If an error occurs `FALSE` is returned and `error` set to the error.

###### Pos.Completer.set_preedit

Sets the current preedit. The preedit is the current word under completion.

###### Pos.Completer.set_surrounding_text

Set the text before and after the current cursor position. This can be used by the completer to improve the prediction.