gntentry.h
Go to the documentation of this file.
1
5 /*
6 * GNT - The GLib Ncurses Toolkit
7 *
8 * GNT is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
11 *
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 */
26
27 #ifndef GNT_ENTRY_H
28 #define GNT_ENTRY_H
29
30 #include "gntwidget.h"
31 #include "gnt.h"
32 #include "gntcolors.h"
33 #include "gntkeys.h"
34
35 #define GNT_TYPE_ENTRY (gnt_entry_get_gtype())
36 #define GNT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_ENTRY, GntEntry))
37 #define GNT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_ENTRY, GntEntryClass))
38 #define GNT_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_ENTRY))
39 #define GNT_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_ENTRY))
40 #define GNT_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_ENTRY, GntEntryClass))
41
42 #define GNT_ENTRY_FLAGS(obj) (GNT_ENTRY(obj)->priv.flags)
43 #define GNT_ENTRY_SET_FLAGS(obj, flags) (GNT_ENTRY_FLAGS(obj) |= flags)
44 #define GNT_ENTRY_UNSET_FLAGS(obj, flags) (GNT_ENTRY_FLAGS(obj) &= ~(flags))
45
46 #define ENTRY_CHAR '_' /* The character to use to fill in the blank places */
47
48 typedef struct _GntEntry GntEntry;
49 typedef struct _GntEntryPriv GntEntryPriv;
50 typedef struct _GntEntryClass GntEntryClass;
51 typedef struct _GntEntryKillRing GntEntryKillRing;
52 typedef struct _GntEntrySearch GntEntrySearch;
53
54 typedef enum
55 {
56 GNT_ENTRY_FLAG_ALPHA = 1 << 0, /* Only alpha */
57 GNT_ENTRY_FLAG_INT = 1 << 1, /* Only integer */
58 GNT_ENTRY_FLAG_NO_SPACE = 1 << 2, /* No blank space is allowed */
59 GNT_ENTRY_FLAG_NO_PUNCT = 1 << 3, /* No punctuations */
60 GNT_ENTRY_FLAG_MASK = 1 << 4, /* Mask the inputs */
61 } GntEntryFlag;
62
63 #define GNT_ENTRY_FLAG_ALL (GNT_ENTRY_FLAG_ALPHA | GNT_ENTRY_FLAG_INT)
64
65 struct _GntEntry
66 {
67 GntWidget parent;
68
69 GntEntryFlag flag;
70
71 char *start;
72 char *end;
73 char *scroll; /* Current scrolling position */
74 char *cursor; /* Cursor location */
75 /* 0 <= cursor - scroll < widget-width */
76
77 size_t buffer; /* Size of the buffer */
78
79 int max; /* 0 means infinite */
80 gboolean masked;
81
82 GList *history; /* History of the strings. User can use this by pressing ctrl+up/down */
83 int histlength; /* How long can the history be? */
84
85 GList *suggests; /* List of suggestions */
86 gboolean word; /* Are the suggestions for only a word, or for the whole thing? */
87 gboolean always; /* Should the list of suggestions show at all times, or only on tab-press? */
88 GntWidget *ddown; /* The dropdown with the suggested list */
89 GntEntryKillRing *killring;
90 GntEntrySearch *search;
91 };
92
93 struct _GntEntryClass
94 {
95 GntWidgetClass parent;
96
97 void (*text_changed)(GntEntry *entry);
98 void (*gnt_reserved1)(void);
99 void (*gnt_reserved2)(void);
100 void (*gnt_reserved3)(void);
101 void (*gnt_reserved4)(void);
102 };
103
104 G_BEGIN_DECLS
105
109 GType gnt_entry_get_gtype(void);
110
118 GntWidget * gnt_entry_new(const char *text);
119
126 void gnt_entry_set_max(GntEntry *entry, int max);
127
134 void gnt_entry_set_text(GntEntry *entry, const char *text);
135
142 void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag);
143
151 const char *gnt_entry_get_text(GntEntry *entry);
152
158 void gnt_entry_clear(GntEntry *entry);
159
166 void gnt_entry_set_masked(GntEntry *entry, gboolean set);
167
175 void gnt_entry_add_to_history(GntEntry *entry, const char *text);
176
183 void gnt_entry_set_history_length(GntEntry *entry, int num);
184
192 void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word);
193
201 void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always);
202
209 void gnt_entry_add_suggest(GntEntry *entry, const char *text);
210
217 void gnt_entry_remove_suggest(GntEntry *entry, const char *text);
218
219 G_END_DECLS
220
221 #endif /* GNT_ENTRY_H */
gnt_entry_get_text
const char * gnt_entry_get_text(GntEntry *entry)
Get the text in an entry box.
gnt_entry_clear
void gnt_entry_clear(GntEntry *entry)
Clear the text in the entry box.
gntcolors.h
Colors API.
gntwidget.h
Widget API.
gnt_entry_new
GntWidget * gnt_entry_new(const char *text)
Create a new GntEntry.
gnt.h
GNT API.
gnt_entry_set_masked
void gnt_entry_set_masked(GntEntry *entry, gboolean set)
Set whether the text in the entry box should be masked for display.
gnt_entry_get_gtype
G_BEGIN_DECLS GType gnt_entry_get_gtype(void)
gnt_entry_set_text
void gnt_entry_set_text(GntEntry *entry, const char *text)
Set the text in an entry box.
_GntEntry
Definition: gntentry.h:65
gnt_entry_set_always_suggest
void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always)
Set whether to always display the suggestions list, or only when the tab-completion key is pressed (t...
gntkeys.h
Keys API.
gnt_entry_set_max
void gnt_entry_set_max(GntEntry *entry, int max)
Set the maximum length of the text in the entry box.
gnt_entry_add_suggest
void gnt_entry_add_suggest(GntEntry *entry, const char *text)
Add an item to the suggestion list.
gnt_entry_remove_suggest
void gnt_entry_remove_suggest(GntEntry *entry, const char *text)
Remove an entry from the suggestion list.
gnt_entry_add_to_history
void gnt_entry_add_to_history(GntEntry *entry, const char *text)
Add a text to the history list for the text.
gnt_entry_set_history_length
void gnt_entry_set_history_length(GntEntry *entry, int num)
Set the length of history for the entry box.
_GntEntryClass
Definition: gntentry.h:93
_GntEntry::killring
GntEntryKillRing * killring
Definition: gntentry.h:89
_GntEntry::search
GntEntrySearch * search
Definition: gntentry.h:90
_GntWidgetClass
Definition: gntwidget.h:113
_GntWidget
Definition: gntwidget.h:98
gnt_entry_set_word_suggest
void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word)
Set whether the suggestions are for the entire entry box, or for each individual word in the entry bo...
gnt_entry_set_flag
void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag)
Set flags an entry box.