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