Files
gnucash/libgnucash/app-utils/QuickFill.h
T

131 lines
5.2 KiB
C
Raw Normal View History

1998-02-04 20:52:55 +00:00
/********************************************************************\
* QuickFill.h -- the quickfill tree data structure *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
2000-05-15 00:04:46 +00:00
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
2005-11-17 05:35:02 +00:00
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
1998-02-04 20:52:55 +00:00
* *
\********************************************************************/
2005-11-02 03:32:36 +00:00
/** @addtogroup GUI
@{
*/
2004-05-31 14:57:31 +00:00
/** @addtogroup QuickFill
2005-11-02 03:32:36 +00:00
QuickFill is meant to be used by the GUI to auto-complete
(e.g. tab-complete) typed user input.
QuickFill is implemented as a hierarchical tree
of partial matching strings. The root of the tree contains
all of the strings that user input should be matched to.
Then, given a short string segment, QuickFill will return
2004-05-31 14:57:31 +00:00
a subtree containing only those strings that start with desired
substring. As additional letters are added to the substring,
QuickFill will thus narrow down to the unique matching string
2004-05-31 14:57:31 +00:00
(or to nothing if no match).
QuickFill works with national-language i18n'ed/l10n'ed multi-byte
and wide-char strings, as well as plain-old C-locale strings.
2004-05-31 14:57:31 +00:00
@{
2005-11-02 03:32:36 +00:00
*/
/**
2004-05-31 14:57:31 +00:00
@file QuickFill.h
@brief QuickFill is used to auto-complete typed user entries.
2004-05-31 14:57:31 +00:00
@author Copyright (C) 1997 Robin D. Clark
@author Copyright (C) 1998,2004 Linas Vepstas <linas@linas.org>
@author Copyright (C) 2000 Dave Peticolas
2004-05-31 03:29:43 +00:00
*/
2005-11-02 03:32:36 +00:00
#ifndef QUICKFILL_H
#define QUICKFILL_H
#include <glib.h>
typedef enum
{
QUICKFILL_LIFO,
QUICKFILL_ALPHA
} QuickFillSort;
1998-02-04 20:52:55 +00:00
typedef struct _QuickFill QuickFill;
1998-02-04 20:52:55 +00:00
2004-05-31 14:57:31 +00:00
/* PROTOTYPES ******************************************************/
1998-02-04 20:52:55 +00:00
QuickFill * gnc_quickfill_new (void);
void gnc_quickfill_destroy (QuickFill *qf);
2005-11-02 03:32:36 +00:00
void gnc_quickfill_purge (QuickFill *qf);
2004-05-31 03:29:43 +00:00
/** For the given node 'qf', return the best-guess matching string.
*/
const char * gnc_quickfill_string (QuickFill *qf);
2004-05-31 03:29:43 +00:00
/** Return the subnode of the tree whose strings all hold 'wc' as
* the next letter. That is, if 'qf' holds all strings starting
2004-05-31 03:29:43 +00:00
* with the letter 'a', and we ask for the letter 'b', then this
* routine will return the node holding all strings that start
* with "ab".
*
* The best-guess matching string can be retrieved with
2004-05-31 03:29:43 +00:00
* gnc_quickfill_string().
*/
2005-11-02 03:32:36 +00:00
QuickFill * gnc_quickfill_get_char_match (QuickFill *qf, gunichar c);
/** Return a subnode in the tree whose strings all match the
2004-05-31 03:29:43 +00:00
* string 'str' as the next substring. Thus, for example, if
* the argument 'qf' holds strings that start with "abc", and
2004-05-31 03:29:43 +00:00
* this routine is called with "def", then the returned node
* will hold strings that start with "abcdef".
2004-05-31 03:29:43 +00:00
*
* The best-guess matching string can be retrieved with
2004-05-31 03:29:43 +00:00
* gnc_quickfill_string().
*
* To convert a plain C-locale char * string to GdkWChar *,
* use the gnc_mbstowcs() routine.
*/
QuickFill * gnc_quickfill_get_string_match (QuickFill *qf,
const char *str);
/** Same as gnc_quickfill_get_string_match(), except that the
* string length is explicitly specified.
*/
QuickFill * gnc_quickfill_get_string_len_match (QuickFill *qf,
const char *str, int len);
/** Walk a 'unique' part of the QuickFill tree. This routine is
* typically used to assist in the tab-completion of strings.
* If the initial portion of the string is unique, but some later
2004-05-31 03:29:43 +00:00
* portion is not, this routine will advance to the first non-unique
* part of the string. If len is non-NULL, then *len will be set
* to the length of the unique portion of the string.
*
* Thus, for example, if the root node contains the strings
2004-05-31 03:29:43 +00:00
* "The Book" and "The Movie", then the returned len will be 4,
* and the returned node will distinguish "Book" and "Movie".
* Thus, for example, gnc_quickfill_get_char_match(.., 'B') on
2004-05-31 03:29:43 +00:00
* the result will identify "The Book".
*/
QuickFill * gnc_quickfill_get_unique_len_match (QuickFill *qf, int *len);
1998-02-04 20:52:55 +00:00
2004-05-31 03:29:43 +00:00
/** Add the string "text" to the collection of searchable strings. */
void gnc_quickfill_insert (QuickFill *root, const char *text,
QuickFillSort sort_code);
void gnc_quickfill_remove (QuickFill *root, const gchar *text,
QuickFillSort sort_code);
2005-11-02 03:32:36 +00:00
/** @} */
2004-05-31 14:57:31 +00:00
/** @} */
2001-07-03 06:49:39 +00:00
#endif /* QUICKFILL_H */