3 * \brief Header: WInput widget
6 #ifndef MC__WIDGET_INPUT_H
7 #define MC__WIDGET_INPUT_H
9 #include "lib/keybind.h" /* global_keymap_t */
11 /*** typedefs(not structures) and defined constants **********************************************/
13 #define INPUT(x) ((WInput *)(x))
15 /* For history load-save functions */
16 #define INPUT_LAST_TEXT ((char *) 2)
18 /*** enums ***************************************************************************************/
22 WINPUTC_MAIN
, /* color used */
23 WINPUTC_MARK
, /* color for marked text */
24 WINPUTC_UNCHANGED
, /* color for inactive text (Is first keystroke) */
25 WINPUTC_HISTORY
, /* color for history list */
26 WINPUTC_COUNT_COLORS
/* count of used colors */
27 } input_colors_enum_t
;
29 /* completion flags */
32 INPUT_COMPLETE_FILENAMES
= 1 << 0,
33 INPUT_COMPLETE_HOSTNAMES
= 1 << 1,
34 INPUT_COMPLETE_COMMANDS
= 1 << 2,
35 INPUT_COMPLETE_VARIABLES
= 1 << 3,
36 INPUT_COMPLETE_USERNAMES
= 1 << 4,
37 INPUT_COMPLETE_CD
= 1 << 5,
38 INPUT_COMPLETE_SHELL_ESC
= 1 << 6,
40 INPUT_COMPLETE_DEFAULT
= INPUT_COMPLETE_FILENAMES
41 | INPUT_COMPLETE_HOSTNAMES
| INPUT_COMPLETE_VARIABLES
| INPUT_COMPLETE_USERNAMES
44 /*** structures declarations (and typedefs of structures)*****************************************/
46 typedef int input_colors_t
[WINPUTC_COUNT_COLORS
];
52 int point
; /* cursor position in the input line in characters */
53 int mark
; /* the mark position in characters */
54 gboolean highlight
; /* there is a selected block */
55 int term_first_shown
; /* column of the first shown character */
56 size_t current_max_size
; /* maximum length of input line (bytes) */
57 int field_width
; /* width of the editing field */
58 gboolean first
; /* is first keystroke? */
59 int disable_update
; /* do we want to skip updates? */
60 gboolean is_password
; /* is this a password input line? */
61 char *init_text
; /* initial text of input line */
62 char *buffer
; /* pointer to editing buffer */
63 char *history_name
; /* name of history for loading and saving */
64 GList
*history
; /* the history */
65 GList
*history_current
; /* current history item */
66 gboolean history_changed
; /* the history has changed */
67 gboolean need_push
; /* need to push the current Input on hist? */
68 gboolean strip_password
; /* need to strip password before placing string to history */
69 char **completions
; /* possible completions array */
70 input_complete_t completion_flags
;
71 char charbuf
[MB_LEN_MAX
]; /* buffer for multibytes characters */
72 size_t charpoint
; /* point to end of mulibyte sequence in charbuf */
73 WLabel
*label
; /* label associated with this input line*/
76 /*** global variables defined in .c file *********************************************************/
80 extern const global_keymap_t
*input_map
;
82 /*** declarations of public functions ************************************************************/
84 WInput
*input_new (int y
, int x
, const int *input_colors
,
85 int len
, const char *text
, const char *histname
,
86 input_complete_t completion_flags
);
87 /* callbac is public; needed for command line */
88 cb_ret_t
input_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
);
89 const int *input_get_default_colors (void);
90 void input_set_origin (WInput
* i
, int x
, int field_width
);
91 cb_ret_t
input_handle_char (WInput
* in
, int key
);
92 int input_key_is_in_map (WInput
* in
, int key
);
93 void input_assign_text (WInput
* in
, const char *text
);
94 void input_insert (WInput
* in
, const char *text
, gboolean insert_extra_space
);
95 void input_set_point (WInput
* in
, int pos
);
96 void input_update (WInput
* in
, gboolean clear_first
);
97 void input_enable_update (WInput
* in
);
98 void input_disable_update (WInput
* in
);
99 void input_clean (WInput
* in
);
100 void input_free_completions (WInput
* in
);
102 /*** inline functions ****************************************************************************/
104 #endif /* MC__WIDGET_INPUT_H */