Class Completion

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class Completion extends ProxyInstance
Deprecated.
Rarely used API

GCompletion provides support for automatic completion of a string using any group of target strings. It is typically used for file name completion as is common in many UNIX shells.

A GCompletion is created using new_(CompletionFunc). Target items are added and removed with addItems(List), removeItems(List) and clearItems(). A completion attempt is requested with complete(String, String[]) or completeUtf8(String, String[]). When no longer needed, the GCompletion is freed with free().

Items in the completion can be simple strings (e.g. filenames), or pointers to arbitrary data structures. If data structures are used you must provide a GLib.CompletionFunc in new_(CompletionFunc), which retrieves the item’s string from the data structure. You can change the way in which strings are compared by setting a different GLib.CompletionStrncmpFunc in setCompare(CompletionStrncmpFunc).

GCompletion has been marked as deprecated, since this API is rarely used and not very actively maintained.

  • Constructor Details

    • Completion

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

      public Completion(Arena arena)
      Deprecated.
      Allocate a new Completion.
      Parameters:
      arena - to control the memory allocation scope
    • Completion

      public Completion()
      Deprecated.
      Allocate a new Completion. The memory is allocated with Arena.ofAuto().
    • Completion

      public Completion(List<MemorySegment> items, CompletionFunc func, String prefix, List<MemorySegment> cache, CompletionStrncmpFunc strncmpFunc, Arena arena)
      Deprecated.
      Allocate a new Completion with the fields set to the provided values.
      Parameters:
      items - value for the field items
      func - value for the field func
      prefix - value for the field prefix
      cache - value for the field cache
      strncmpFunc - value for the field strncmpFunc
      arena - to control the memory allocation scope
    • Completion

      public Completion(List<MemorySegment> items, CompletionFunc func, String prefix, List<MemorySegment> cache, CompletionStrncmpFunc strncmpFunc)
      Deprecated.
      Allocate a new Completion with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      items - value for the field items
      func - value for the field func
      prefix - value for the field prefix
      cache - value for the field cache
      strncmpFunc - value for the field strncmpFunc
  • Method Details

    • getMemoryLayout

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

      public List<MemorySegment> readItems()
      Deprecated.
      Read the value of the field items.
      Returns:
      The value of the field items
    • writeItems

      public void writeItems(List<MemorySegment> items)
      Deprecated.
      Write a value in the field items.
      Parameters:
      items - The new value for the field items
    • readFunc

      public @Nullable CompletionFunc readFunc()
      Deprecated.
      Read the value of the field func.
      Returns:
      The value of the field func
    • writeFunc

      public void writeFunc(@Nullable CompletionFunc func, Arena _arena)
      Deprecated.
      Write a value in the field func.
      Parameters:
      func - The new value for the field func
      _arena - to control the memory allocation scope
    • readPrefix

      public String readPrefix()
      Deprecated.
      Read the value of the field prefix.
      Returns:
      The value of the field prefix
    • writePrefix

      public void writePrefix(String prefix, Arena _arena)
      Deprecated.
      Write a value in the field prefix.
      Parameters:
      prefix - The new value for the field prefix
      _arena - to control the memory allocation scope
    • readCache

      public List<MemorySegment> readCache()
      Deprecated.
      Read the value of the field cache.
      Returns:
      The value of the field cache
    • writeCache

      public void writeCache(List<MemorySegment> cache)
      Deprecated.
      Write a value in the field cache.
      Parameters:
      cache - The new value for the field cache
    • readStrncmpFunc

      public @Nullable CompletionStrncmpFunc readStrncmpFunc()
      Deprecated.
      Read the value of the field strncmp_func.
      Returns:
      The value of the field strncmp_func
    • writeStrncmpFunc

      public void writeStrncmpFunc(@Nullable CompletionStrncmpFunc strncmpFunc, Arena _arena)
      Deprecated.
      Write a value in the field strncmp_func.
      Parameters:
      strncmpFunc - The new value for the field strncmp_func
      _arena - to control the memory allocation scope
    • new_

      @Deprecated public static Completion new_(@Nullable CompletionFunc func)
      Deprecated.
      Rarely used API
      Creates a new GCompletion.
      Parameters:
      func - the function to be called to return the string representing an item in the GCompletion, or null if strings are going to be used as the GCompletion items.
      Returns:
      the new GCompletion.
    • addItems

      @Deprecated public void addItems(List<MemorySegment> items)
      Deprecated.
      Rarely used API
      Adds items to the GCompletion.
      Parameters:
      items - the list of items to add.
    • clearItems

      @Deprecated public void clearItems()
      Deprecated.
      Rarely used API
      Removes all items from the GCompletion. The items are not freed, so if the memory was dynamically allocated, it should be freed after calling this function.
    • complete

      @Deprecated public List<MemorySegment> complete(String prefix, String[] newPrefix)
      Deprecated.
      Rarely used API
      Attempts to complete the string prefix using the GCompletion target items.
      Parameters:
      prefix - the prefix string, typically typed by the user, which is compared with each of the items.
      newPrefix - if non-null, returns the longest prefix which is common to all items that matched prefix, or null if no items matched prefix. This string should be freed when no longer needed.
      Returns:
      the list of items whose strings begin with prefix. This should not be changed.
    • completeUtf8

      @Deprecated public List<String> completeUtf8(String prefix, String[] newPrefix)
      Deprecated.
      Rarely used API

      Attempts to complete the string prefix using the GCompletion target items. In contrast to g_completion_complete(), this function returns the largest common prefix that is a valid UTF-8 string, omitting a possible common partial character.

      You should use this function instead of g_completion_complete() if your items are UTF-8 strings.

      Parameters:
      prefix - the prefix string, typically used by the user, which is compared with each of the items
      newPrefix - if non-null, returns the longest prefix which is common to all items that matched prefix, or null if no items matched prefix. This string should be freed when no longer needed.
      Returns:
      the list of items whose strings begin with prefix. This should not be changed.
      Since:
      2.4
    • free

      @Deprecated public void free()
      Deprecated.
      Rarely used API
      Frees all memory used by the GCompletion. The items are not freed, so if the memory was dynamically allocated, it should be freed after calling this function.
    • removeItems

      @Deprecated public void removeItems(List<MemorySegment> items)
      Deprecated.
      Rarely used API
      Removes items from a GCompletion. The items are not freed, so if the memory was dynamically allocated, free items with g_list_free_full() after calling this function.
      Parameters:
      items - the items to remove.
    • setCompare

      @Deprecated public void setCompare(@Nullable CompletionStrncmpFunc strncmpFunc)
      Deprecated.
      Rarely used API
      Sets the function to use for string comparisons. The default string comparison function is strncmp().
      Parameters:
      strncmpFunc - the string comparison function.