gi-glib-2.0.30: GLib bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.GLib.Structs.Completion

Contents

- Exported types
- Methods
  - clearItems
  - completeUtf8
  - free
- Properties
  - cache
  - func
  - items
  - prefix
  - strncmpFunc

Description

`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 `Completion`.`new`(). Target items are added and removed with `Completion`.`add_items`(), `Completion`.`remove_items`() and `completionClearItems`. A completion attempt is requested with `Completion`.`complete`() or `completionCompleteUtf8`. When no longer needed, the `GCompletion` is freed with `completionFree`.

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 [type`gLib`.CompletionFunc] in `Completion`.`new`(), which retrieves the item’s string from the data structure. You can change the way in which strings are compared by setting a different [type`gLib`.CompletionStrncmpFunc] in `Completion`.`set_compare`().

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

Synopsis

- newtype Completion = Completion (ManagedPtr Completion)
- newZeroCompletion :: MonadIO m => m Completion
- completionClearItems :: (HasCallStack, MonadIO m) => Completion -> m ()
- completionCompleteUtf8 :: (HasCallStack, MonadIO m) => Completion -> Text -> Text -> m [Text]
- completionFree :: (HasCallStack, MonadIO m) => Completion -> m ()
- clearCompletionCache :: MonadIO m => Completion -> m ()
- getCompletionCache :: MonadIO m => Completion -> m [Ptr ()]
- setCompletionCache :: MonadIO m => Completion -> Ptr (GList (Ptr ())) -> m ()
- clearCompletionFunc :: MonadIO m => Completion -> m ()
- getCompletionFunc :: MonadIO m => Completion -> m (Maybe CompletionFunc)
- setCompletionFunc :: MonadIO m => Completion -> FunPtr C_CompletionFunc -> m ()
- clearCompletionItems :: MonadIO m => Completion -> m ()
- getCompletionItems :: MonadIO m => Completion -> m [Ptr ()]
- setCompletionItems :: MonadIO m => Completion -> Ptr (GList (Ptr ())) -> m ()
- clearCompletionPrefix :: MonadIO m => Completion -> m ()
- getCompletionPrefix :: MonadIO m => Completion -> m (Maybe Text)
- setCompletionPrefix :: MonadIO m => Completion -> CString -> m ()
- clearCompletionStrncmpFunc :: MonadIO m => Completion -> m ()
- getCompletionStrncmpFunc :: MonadIO m => Completion -> m (Maybe CompletionStrncmpFunc)
- setCompletionStrncmpFunc :: MonadIO m => Completion -> FunPtr C_CompletionStrncmpFunc -> m ()

# Exported types

newtype Completion Source #

Memory-managed wrapper type.

Constructors

Completion (ManagedPtr Completion) |

#### Instances

Instances details

Eq Completion Source # |
Instance details Defined in GI.GLib.Structs.Completion Methods (==) :: Completion -> Completion -> Bool Source # (/=) :: Completion -> Completion -> Bool Source #
BoxedPtr Completion Source # |
Instance details Defined in GI.GLib.Structs.Completion Methods boxedPtrCopy :: Completion -> IO Completion Source # boxedPtrFree :: Completion -> IO () Source #
CallocPtr Completion Source # |
Instance details Defined in GI.GLib.Structs.Completion Methods boxedPtrCalloc :: IO (Ptr Completion) Source #
ManagedPtrNewtype Completion Source # |
Instance details Defined in GI.GLib.Structs.Completion Methods toManagedPtr :: Completion -> ManagedPtr Completion Source #
tag ~ 'AttrSet => Constructible Completion tag Source # |
Instance details Defined in GI.GLib.Structs.Completion Methods new :: MonadIO m => (ManagedPtr Completion -> Completion) -> [AttrOp Completion tag] -> m Completion Source #

newZeroCompletion :: MonadIO m => m Completion Source #

Construct a `Completion` struct initialized to zero.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

clearItems, completeUtf8, free.

#### Getters

None.

#### Setters

None.

## clearItems

completionClearItems Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Completion | `cmp`: the `Completion`.
-> m () |

Deprecated: (Since version 2.26)Rarely used API

Removes all items from the `Completion`. The items are not freed, so if the memory was dynamically allocated, it should be freed after calling this function.

## completeUtf8

completionCompleteUtf8 Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Completion | `cmp`: the `Completion`
-> Text | `prefix`: the prefix string, typically used by the user, which is compared with each of the items
-> Text | `newPrefix`: if non-`Nothing`, returns the longest prefix which is common to all items that matched `prefix`, or `Nothing` if no items matched `prefix`. This string should be freed when no longer needed.
-> m [Text] | Returns: the list of items whose strings begin with `prefix`. This should not be changed.

Deprecated: (Since version 2.26)Rarely used API

Attempts to complete the string `prefix` using the `Completion` 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.

Since: 2.4

## free

completionFree Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Completion | `cmp`: the `Completion`.
-> m () |

Deprecated: (Since version 2.26)Rarely used API

Frees all memory used by the `Completion`. The items are not freed, so if the memory was dynamically allocated, it should be freed after calling this function.

# Properties

## cache

the list of items which begin with `prefix`.

clearCompletionCache :: MonadIO m => Completion -> m () Source #

Set the value of the “`cache`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #cache

getCompletionCache :: MonadIO m => Completion -> m [Ptr ()] Source #

Get the value of the “`cache`” field. When overloading is enabled, this is equivalent to

    get completion #cache

setCompletionCache :: MonadIO m => Completion -> Ptr (GList (Ptr ())) -> m () Source #

Set the value of the “`cache`” field. When overloading is enabled, this is equivalent to

    set completion [ #cache := value ]

## func

function which is called to get the string associated with a target item. It is `Nothing` if the target items are strings.

clearCompletionFunc :: MonadIO m => Completion -> m () Source #

Set the value of the “`func`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #func

getCompletionFunc :: MonadIO m => Completion -> m (Maybe CompletionFunc) Source #

Get the value of the “`func`” field. When overloading is enabled, this is equivalent to

    get completion #func

setCompletionFunc :: MonadIO m => Completion -> FunPtr C_CompletionFunc -> m () Source #

Set the value of the “`func`” field. When overloading is enabled, this is equivalent to

    set completion [ #func := value ]

## items

list of target items (strings or data structures).

clearCompletionItems :: MonadIO m => Completion -> m () Source #

Set the value of the “`items`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #items

getCompletionItems :: MonadIO m => Completion -> m [Ptr ()] Source #

Get the value of the “`items`” field. When overloading is enabled, this is equivalent to

    get completion #items

setCompletionItems :: MonadIO m => Completion -> Ptr (GList (Ptr ())) -> m () Source #

Set the value of the “`items`” field. When overloading is enabled, this is equivalent to

    set completion [ #items := value ]

## prefix

the last prefix passed to `g_completion_complete()` or `completionCompleteUtf8`.

clearCompletionPrefix :: MonadIO m => Completion -> m () Source #

Set the value of the “`prefix`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #prefix

getCompletionPrefix :: MonadIO m => Completion -> m (Maybe Text) Source #

Get the value of the “`prefix`” field. When overloading is enabled, this is equivalent to

    get completion #prefix

setCompletionPrefix :: MonadIO m => Completion -> CString -> m () Source #

Set the value of the “`prefix`” field. When overloading is enabled, this is equivalent to

    set completion [ #prefix := value ]

## strncmpFunc

The function to use when comparing strings. Use `g_completion_set_compare()` to modify this function.

clearCompletionStrncmpFunc :: MonadIO m => Completion -> m () Source #

Set the value of the “`strncmp_func`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #strncmpFunc

getCompletionStrncmpFunc :: MonadIO m => Completion -> m (Maybe CompletionStrncmpFunc) Source #

Get the value of the “`strncmp_func`” field. When overloading is enabled, this is equivalent to

    get completion #strncmpFunc

setCompletionStrncmpFunc :: MonadIO m => Completion -> FunPtr C_CompletionStrncmpFunc -> m () Source #

Set the value of the “`strncmp_func`” field. When overloading is enabled, this is equivalent to

    set completion [ #strncmpFunc := value ]