Class Completion

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Completion extends GObject

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 CompletionProvider. There can be for example a provider to complete words (see CompletionWords), another provider for the completion of function names, etc. To add a provider, call addProvider(CompletionProvider).

The CompletionProposal interface represents a proposal.

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

Each View object is associated with a Completion instance. This instance can be obtained with View.getCompletion(). The View class contains also the View::show-completion signal.

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

  • Constructor Details

    • Completion

      public Completion(MemorySegment address)
      Create a Completion instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Completion

      public Completion()
      Create a new Completion.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Completion class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Completion asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • fuzzyHighlight

      public static @Nullable AttrList fuzzyHighlight(String haystack, String casefoldQuery)
      This will add <b> tags around matched characters in haystack based on casefoldQuery.
      Parameters:
      haystack - the string to be highlighted
      casefoldQuery - the typed-text used to highlight haystack
      Returns:
      a PangoAttrList or null
    • fuzzyMatch

      public static boolean fuzzyMatch(@Nullable String haystack, String casefoldNeedle, @Nullable Out<Integer> priority)

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

      Casefold your needle using GLib#utf8Casefold 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.
      casefoldNeedle - A g_utf8_casefold() version of the needle.
      priority - An optional location for the score of the match
      Returns:
      true if haystack matched casefoldNeedle, otherwise false.
    • addProvider

      public void addProvider(CompletionProvider provider)
      Adds a CompletionProvider to the list of providers to be queried for completion results.
      Parameters:
      provider - a GtkSourceCompletionProvider
    • blockInteractive

      public void blockInteractive()
    • getBuffer

      public Buffer getBuffer()
      Gets the connected View's Buffer
      Returns:
      A GtkSourceBuffer
    • getPageSize

      public int getPageSize()
    • getView

      public View getView()
      Gets the View that owns the Completion.
      Returns:
      A GtkSourceView
    • hide

      public void hide()

      Emits the "hide" signal.

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

    • removeProvider

      public void removeProvider(CompletionProvider provider)
      Removes a CompletionProvider previously added with addProvider(CompletionProvider).
      Parameters:
      provider - a GtkSourceCompletionProvider
    • setPageSize

      public void setPageSize(int pageSize)
    • show

      public void show()

      Emits the "show" signal.

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

    • unblockInteractive

      public void unblockInteractive()
    • onHide

      The "hide" signal is emitted when the completion window should be hidden.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitHide

      public void emitHide()
      Emits the "hide" signal. See onHide(Completion.HideCallback).
    • onProviderAdded

      The "provided-added" signal is emitted when a new provider is added to the completion.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitProviderAdded

      public void emitProviderAdded(@Nullable CompletionProvider provider)
      Emits the "provider-added" signal. See onProviderAdded(Completion.ProviderAddedCallback).
    • onProviderRemoved

      The "provided-removed" signal is emitted when a provider has been removed from the completion.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitProviderRemoved

      public void emitProviderRemoved(@Nullable CompletionProvider provider)
      Emits the "provider-removed" signal. See onProviderRemoved(Completion.ProviderRemovedCallback).
    • onShow

      The "show" signal is emitted when the completion window should be shown.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitShow

      public void emitShow()
      Emits the "show" signal. See onShow(Completion.ShowCallback).
    • builder

      public static Completion.Builder<? extends Completion.Builder> builder()
      A Completion.Builder object constructs a Completion with the specified properties. Use the various set...() methods to set properties, and finish construction with Completion.Builder.build().
      Returns:
      the builder object