Blame docs/reference/glib/html/glib-Automatic-String-Completion.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>Automatic String Completion: GLib Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GLib Reference Manual">
Packit ae235b
<link rel="up" href="deprecated.html" title="Deprecated APIs">
Packit ae235b
<link rel="prev" href="glib-Relations-and-Tuples.html" title="Relations and Tuples">
Packit ae235b
<link rel="next" href="tools.html" title="GLib Tools">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Automatic String Completion

Packit ae235b

Automatic String Completion — support for automatic completion using a group

Packit ae235b
                    of target strings

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GCompletion *
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_new ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gchar *
Packit ae235b
Packit ae235b
Packit ae235b
(*GCompletionFunc) ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_add_items ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_remove_items ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_clear_items ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GList *
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_complete ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GList *
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_complete_utf8 ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_set_compare ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gint
Packit ae235b
Packit ae235b
Packit ae235b
(*GCompletionStrncmpFunc) ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_completion_free ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
struct
Packit ae235b
GCompletion
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <gmodule.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

GCompletion provides support for automatic completion of a string

Packit ae235b
using any group of target strings. It is typically used for file
Packit ae235b
name completion as is common in many UNIX shells.

Packit ae235b

A GCompletion is created using g_completion_new(). Target items are

Packit ae235b
added and removed with g_completion_add_items(),
Packit ae235b
g_completion_remove_items() and g_completion_clear_items(). A
Packit ae235b
completion attempt is requested with g_completion_complete() or
Packit ae235b
g_completion_complete_utf8(). When no longer needed, the
Packit ae235b
GCompletion is freed with g_completion_free().

Packit ae235b

Items in the completion can be simple strings (e.g. filenames), or

Packit ae235b
pointers to arbitrary data structures. If data structures are used
Packit ae235b
you must provide a GCompletionFunc in g_completion_new(), which
Packit ae235b
retrieves the item's string from the data structure. You can change
Packit ae235b
the way in which strings are compared by setting a different
Packit ae235b
GCompletionStrncmpFunc in g_completion_set_compare().

Packit ae235b

GCompletion has been marked as deprecated, since this API is rarely

Packit ae235b
used and not very actively maintained.

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

g_completion_new ()

Packit ae235b
GCompletion *
Packit ae235b
g_completion_new (GCompletionFunc func);
Packit ae235b

g_completion_new is deprecated and should not be used in newly-written code.

Packit ae235b

Creates a new GCompletion.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

func

Packit ae235b

the function to be called to return the string representing

Packit ae235b
an item in the GCompletion, or NULL if strings are going to
Packit ae235b
be used as the GCompletion items.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the new GCompletion.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

GCompletionFunc ()

Packit ae235b
gchar *
Packit ae235b
(*GCompletionFunc) (gpointer Param1);
Packit ae235b

Specifies the type of the function passed to g_completion_new(). It

Packit ae235b
should return the string corresponding to the given target item.
Packit ae235b
This is used when you use data structures as GCompletion items.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Param1

Packit ae235b

the completion item.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the string corresponding to the item.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_completion_add_items ()

Packit ae235b
void
Packit ae235b
g_completion_add_items (GCompletion *cmp,
Packit ae235b
                        GList *items);
Packit ae235b
Packit ae235b

g_completion_add_items has been deprecated since version 2.26 and should not be used in newly-written code.

Packit ae235b

Rarely used API

Packit ae235b
Packit ae235b

Adds items to the GCompletion.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmp

Packit ae235b

the GCompletion.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

items

Packit ae235b

the list of items to add.

Packit ae235b
[transfer none]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_completion_remove_items ()

Packit ae235b
void
Packit ae235b
g_completion_remove_items (GCompletion *cmp,
Packit ae235b
                           GList *items);
Packit ae235b
Packit ae235b

g_completion_remove_items has been deprecated since version 2.26 and should not be used in newly-written code.

Packit ae235b

Rarely used API

Packit ae235b
Packit ae235b

Removes items from a GCompletion. The items are not freed, so if the memory

Packit ae235b
was dynamically allocated, free items
Packit ae235b
 with g_list_free_full() after calling
Packit ae235b
this function.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmp

Packit ae235b

the GCompletion.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

items

Packit ae235b

the items to remove.

Packit ae235b
[transfer none]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_completion_clear_items ()

Packit ae235b
void
Packit ae235b
g_completion_clear_items (GCompletion *cmp);
Packit ae235b
Packit ae235b

g_completion_clear_items has been deprecated since version 2.26 and should not be used in newly-written code.

Packit ae235b

Rarely used API

Packit ae235b
Packit ae235b

Removes all items from the GCompletion. The items are not freed, so if the

Packit ae235b
memory was dynamically allocated, it should be freed after calling this
Packit ae235b
function.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmp

Packit ae235b

the GCompletion.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_completion_complete ()

Packit ae235b
GList *
Packit ae235b
g_completion_complete (GCompletion *cmp,
Packit ae235b
                       const gchar *prefix,
Packit ae235b
                       gchar **new_prefix);
Packit ae235b
Packit ae235b

g_completion_complete has been deprecated since version 2.26 and should not be used in newly-written code.

Packit ae235b

Rarely used API

Packit ae235b
Packit ae235b

Attempts to complete the string prefix

Packit ae235b
 using the GCompletion
Packit ae235b
target items.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmp

Packit ae235b

the GCompletion.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

prefix

Packit ae235b

the prefix string, typically typed by the user, which is

Packit ae235b
compared with each of the items.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

new_prefix

Packit ae235b

if non-NULL, returns the longest prefix which is

Packit ae235b
common to all items that matched prefix
Packit ae235b
, or NULL if
Packit ae235b
no items matched prefix
Packit ae235b
.  This string should be freed
Packit ae235b
when no longer needed.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the list of items whose strings begin with

Packit ae235b
prefix
Packit ae235b
. This should not be changed. 

Packit ae235b

[transfer none]

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_completion_complete_utf8 ()

Packit ae235b
GList *
Packit ae235b
g_completion_complete_utf8 (GCompletion *cmp,
Packit ae235b
                            const gchar *prefix,
Packit ae235b
                            gchar **new_prefix);
Packit ae235b
Packit ae235b

g_completion_complete_utf8 has been deprecated since version 2.26 and should not be used in newly-written code.

Packit ae235b

Rarely used API

Packit ae235b
Packit ae235b

Attempts to complete the string prefix

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

Packit ae235b

You should use this function instead of g_completion_complete() if your

Packit ae235b
items are UTF-8 strings.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmp

Packit ae235b

the GCompletion

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

prefix

Packit ae235b

the prefix string, typically used by the user, which is compared

Packit ae235b
with each of the items

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

new_prefix

Packit ae235b

if non-NULL, returns the longest prefix which is common to all

Packit ae235b
items that matched prefix
Packit ae235b
, or NULL if no items matched prefix
Packit ae235b
.
Packit ae235b
This string should be freed when no longer needed.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the list of items whose strings begin with prefix

Packit ae235b
. This should
Packit ae235b
not be changed. 

Packit ae235b

[element-type utf8][transfer none]

Packit ae235b
Packit ae235b

Since: 2.4

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_completion_set_compare ()

Packit ae235b
void
Packit ae235b
g_completion_set_compare (GCompletion *cmp,
Packit ae235b
                          GCompletionStrncmpFunc strncmp_func);
Packit ae235b
Packit ae235b

g_completion_set_compare has been deprecated since version 2.26 and should not be used in newly-written code.

Packit ae235b

Rarely used API

Packit ae235b
Packit ae235b

Sets the function to use for string comparisons. The default string

Packit ae235b
comparison function is strncmp().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmp

Packit ae235b

a GCompletion.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

strncmp_func

Packit ae235b

the string comparison function.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

GCompletionStrncmpFunc ()

Packit ae235b
gint
Packit ae235b
(*GCompletionStrncmpFunc) (const gchar *s1,
Packit ae235b
                           const gchar *s2,
Packit ae235b
                           gsize n);
Packit ae235b

Specifies the type of the function passed to

Packit ae235b
g_completion_set_compare(). This is used when you use strings as
Packit ae235b
GCompletion items.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

s1

Packit ae235b

string to compare with s2

Packit ae235b
.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

s2

Packit ae235b

string to compare with s1

Packit ae235b
.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

n

Packit ae235b

maximal number of bytes to compare.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

an integer less than, equal to, or greater than zero if

Packit ae235b
the first n
Packit ae235b
bytes of s1
Packit ae235b
is found, respectively, to be
Packit ae235b
less than, to match, or to be greater than the first n
Packit ae235b
bytes of s2
Packit ae235b
.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_completion_free ()

Packit ae235b
void
Packit ae235b
g_completion_free (GCompletion *cmp);
Packit ae235b
Packit ae235b

g_completion_free has been deprecated since version 2.26 and should not be used in newly-written code.

Packit ae235b

Rarely used API

Packit ae235b
Packit ae235b

Frees all memory used by the GCompletion. The items are not freed, so if

Packit ae235b
the memory was dynamically allocated, it should be freed after calling this
Packit ae235b
function.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

cmp

Packit ae235b

the GCompletion.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

struct GCompletion

Packit ae235b
struct GCompletion {
Packit ae235b
  GList* items;
Packit ae235b
  GCompletionFunc func;
Packit ae235b
 
Packit ae235b
  gchar* prefix;
Packit ae235b
  GList* cache;
Packit ae235b
  GCompletionStrncmpFunc strncmp_func;
Packit ae235b
};
Packit ae235b
Packit ae235b

The data structure used for automatic completion.

Packit ae235b
Packit ae235b

Members

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

GList *items;

Packit ae235b

list of target items (strings or data structures).

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

GCompletionFunc func;

Packit ae235b

function which is called to get the string associated with a

Packit ae235b
target item. It is NULL if the target items are strings.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

gchar *prefix;

Packit ae235b

the last prefix passed to g_completion_complete() or

Packit ae235b
g_completion_complete_utf8().

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

GList *cache;

Packit ae235b

the list of items which begin with prefix

Packit ae235b
.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

GCompletionStrncmpFunc strncmp_func;

Packit ae235b

The function to use when comparing strings. Use

Packit ae235b
g_completion_set_compare() to modify this function.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>