4 #include "dialog.h" /* Widget */
9 INPUT_COMPLETE_FILENAMES
= 1<<0,
10 INPUT_COMPLETE_HOSTNAMES
= 1<<1,
11 INPUT_COMPLETE_COMMANDS
= 1<<2,
12 INPUT_COMPLETE_VARIABLES
= 1<<3,
13 INPUT_COMPLETE_USERNAMES
= 1<<4,
14 INPUT_COMPLETE_CD
= 1<<5,
15 INPUT_COMPLETE_SHELL_ESC
= 1<<6,
17 INPUT_COMPLETE_DEFAULT
= INPUT_COMPLETE_FILENAMES
18 | INPUT_COMPLETE_HOSTNAMES
19 | INPUT_COMPLETE_VARIABLES
20 | INPUT_COMPLETE_USERNAMES
21 } INPUT_COMPLETE_FLAGS
;
23 /* Please note that the first element in all the widgets is a */
24 /* widget variable of type Widget. We abuse this fact everywhere */
27 typedef int (*bcback
) (int);
29 typedef struct WButton
{
31 int action
; /* what to do when pressed */
32 int selected
; /* button state */
34 #define HIDDEN_BUTTON 0
35 #define NARROW_BUTTON 1
36 #define NORMAL_BUTTON 2
37 #define DEFPUSH_BUTTON 3
38 unsigned int flags
; /* button flags */
39 char *text
; /* text of button */
40 int hotkey
; /* hot KEY */
41 int hotpos
; /* offset hot KEY char in text */
42 bcback callback
; /* Callback function */
45 typedef struct WRadio
{
47 unsigned int state
; /* radio button state */
49 int count
; /* number of members */
50 const char **texts
; /* texts of labels */
53 typedef struct WCheck
{
57 #define C_CHANGE 0x0002
58 unsigned int state
; /* check button state */
59 char *text
; /* text of check button */
60 int hotkey
; /* hot KEY */
61 int hotpos
; /* offset hot KEY char in text */
64 typedef struct WGauge
{
71 GList
*history_get (const char *input_name
);
72 void history_put (const char *input_name
, GList
*h
);
73 char *show_hist (GList
*history
, int widget_y
, int widget_x
);
77 int point
; /* cursor position in the input line */
78 int mark
; /* The mark position */
79 int first_shown
; /* Index of the first shown character */
80 int current_max_len
; /* Maximum length of input line */
81 int field_len
; /* Length of the editing field */
82 int color
; /* color used */
83 int first
; /* Is first keystroke? */
84 int disable_update
; /* Do we want to skip updates? */
85 int is_password
; /* Is this a password input line? */
86 char *buffer
; /* pointer to editing buffer */
87 GList
*history
; /* The history */
88 int need_push
; /* need to push the current Input on hist? */
89 char **completions
; /* Possible completions array */
90 INPUT_COMPLETE_FLAGS completion_flags
; /* INPUT_COMPLETE* bitwise flags(complete.h) */
91 char *history_name
; /* name of history for loading and saving */
94 /* For history load-save functions */
95 #define INPUT_LAST_TEXT ((char *) 2)
99 int auto_adjust_cols
; /* compute widget.cols from strlen(text)? */
101 int transparent
; /* Paint in the default color fg/bg */
104 typedef struct WLEntry
{
105 char *text
; /* Text to display */
107 void *data
; /* Client information */
108 struct WLEntry
*next
;
109 struct WLEntry
*prev
;
113 typedef struct WListbox WListbox
;
114 typedef int (*lcback
) (WListbox
*);
116 /* Callback should return one of the following values */
118 LISTBOX_CONT
, /* continue */
119 LISTBOX_DONE
/* finish dialog */
124 WLEntry
*list
; /* Pointer to the circular double linked list. */
125 WLEntry
*top
; /* The first element displayed */
126 WLEntry
*current
; /* The current element displayed */
127 int pos
; /* Cur. pos, must be kept in sync with current */
128 int count
; /* Number of items in the listbox */
130 int height
; /* Size of the widget */
131 int allow_duplicates
; /* Do we allow duplicates on the list? */
132 int scrollbar
; /* Draw a scrollbar? */
133 lcback cback
; /* The callback function */
134 int cursor_x
, cursor_y
; /* Cache the values */
137 typedef struct WGroupbox
{
144 WButton
*button_new (int y
, int x
, int action
, int flags
, const char *text
,
146 WRadio
*radio_new (int y
, int x
, int count
, const char **text
);
147 WCheck
*check_new (int y
, int x
, int state
, const char *text
);
148 WInput
*input_new (int y
, int x
, int color
, int len
, const char *text
, const char *histname
, INPUT_COMPLETE_FLAGS completion_flags
);
149 WLabel
*label_new (int y
, int x
, const char *text
);
150 WGauge
*gauge_new (int y
, int x
, int shown
, int max
, int current
);
151 WListbox
*listbox_new (int x
, int y
, int width
, int height
, lcback callback
);
152 WGroupbox
*groupbox_new (int x
, int y
, int width
, int height
, const char *title
);
155 void winput_set_origin (WInput
*i
, int x
, int field_len
);
156 cb_ret_t
handle_char (WInput
*in
, int c_code
);
157 int is_in_input_map (WInput
*in
, int c_code
);
158 void update_input (WInput
*in
, int clear_first
);
159 void new_input (WInput
*in
);
160 int push_history (WInput
*in
, const char *text
);
161 void stuff (WInput
*in
, const char *text
, int insert_extra_space
);
162 void input_disable_update (WInput
*in
);
163 void input_set_prompt (WInput
*in
, int field_len
, const char *prompt
);
164 void input_enable_update (WInput
*in
);
165 void input_set_point (WInput
*in
, int pos
);
166 void input_show_cursor (WInput
*in
);
167 void assign_text (WInput
*in
, const char *text
);
168 cb_ret_t
input_callback (Widget
*, widget_msg_t msg
, int parm
);
171 void label_set_text (WLabel
*label
, const char *text
);
174 void gauge_set_value (WGauge
*g
, int max
, int current
);
175 void gauge_show (WGauge
*g
, int shown
);
178 const char *button_get_text (WButton
*b
);
179 void button_set_text (WButton
*b
, const char *text
);
181 /* Listbox manager */
182 WLEntry
*listbox_get_data (WListbox
*l
, int pos
);
184 /* search text int listbox entries */
185 WLEntry
*listbox_search_text (WListbox
*l
, const char *text
);
186 void listbox_select_entry (WListbox
*l
, WLEntry
*dest
);
187 void listbox_select_by_number (WListbox
*l
, int n
);
188 void listbox_select_last (WListbox
*l
, int set_top
);
189 void listbox_remove_current (WListbox
*l
, int force
);
190 void listbox_remove_list (WListbox
*l
);
191 void listbox_get_current (WListbox
*l
, char **string
, char **extra
);
194 LISTBOX_APPEND_AT_END
, /* append at the end */
195 LISTBOX_APPEND_BEFORE
, /* insert before current */
196 LISTBOX_APPEND_AFTER
, /* insert after current */
197 LISTBOX_APPEND_SORTED
/* insert alphabetically */
200 char *listbox_add_item (WListbox
*l
, enum append_pos pos
, int
201 hotkey
, const char *text
, void *data
);
203 /* Hintbar routines */
207 typedef void (*voidfn
)(void);
208 typedef void (*buttonbarfn
)(void *);
210 typedef struct WButtonBar WButtonBar
;
212 WButtonBar
*buttonbar_new (int visible
);
213 WButtonBar
*find_buttonbar (Dlg_head
*h
);
214 void buttonbar_clear_label (Dlg_head
*, int idx
);
215 void buttonbar_set_label (Dlg_head
*, int index
, const char *text
, voidfn
);
216 void buttonbar_set_label_data (Dlg_head
*h
, int idx
, const char *text
,
217 buttonbarfn cback
, void *data
);
218 void buttonbar_set_visible (WButtonBar
*, gboolean
);
219 void buttonbar_redraw (Dlg_head
*h
);
221 void free_completions (WInput
*);
222 void complete (WInput
*);