uprava merge
[midnight-commander/osp/novacja3.git] / lib / widget / input.h
blobebecd5fba4acd474e29a862dd4e7836b84e61d78
2 /** \file input.h
3 * \brief Header: WInput widget
4 */
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 /* For history load-save functions */
14 #define INPUT_LAST_TEXT ((char *) 2)
16 /*** enums ***************************************************************************************/
18 typedef enum
20 WINPUTC_MAIN, /* color used */
21 WINPUTC_MARK, /* color for marked text */
22 WINPUTC_UNCHANGED, /* color for inactive text (Is first keystroke) */
23 WINPUTC_HISTORY, /* color for history list */
24 WINPUTC_COUNT_COLORS /* count of used colors */
25 } input_colors_enum_t;
27 /* completion flags */
28 typedef enum
30 INPUT_COMPLETE_FILENAMES = 1 << 0,
31 INPUT_COMPLETE_HOSTNAMES = 1 << 1,
32 INPUT_COMPLETE_COMMANDS = 1 << 2,
33 INPUT_COMPLETE_VARIABLES = 1 << 3,
34 INPUT_COMPLETE_USERNAMES = 1 << 4,
35 INPUT_COMPLETE_CD = 1 << 5,
36 INPUT_COMPLETE_SHELL_ESC = 1 << 6,
38 INPUT_COMPLETE_DEFAULT = INPUT_COMPLETE_FILENAMES
39 | INPUT_COMPLETE_HOSTNAMES | INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES
40 } input_complete_t;
42 /*** structures declarations (and typedefs of structures)*****************************************/
44 typedef int input_colors_t[WINPUTC_COUNT_COLORS];
46 typedef struct
48 Widget widget;
49 input_colors_t color;
50 int point; /* cursor position in the input line in characters */
51 int mark; /* the mark position in characters */
52 gboolean highlight; /* there is a selected block */
53 int term_first_shown; /* column of the first shown character */
54 size_t current_max_size; /* maximum length of input line (bytes) */
55 int field_width; /* width of the editing field */
56 gboolean first; /* is first keystroke? */
57 int disable_update; /* do we want to skip updates? */
58 gboolean is_password; /* is this a password input line? */
59 char *init_text; /* initial text of input line */
60 char *buffer; /* pointer to editing buffer */
61 char *history_name; /* name of history for loading and saving */
62 GList *history; /* the history */
63 gboolean history_changed; /* the history has changed */
64 gboolean need_push; /* need to push the current Input on hist? */
65 char **completions; /* possible completions array */
66 input_complete_t completion_flags;
67 char charbuf[MB_LEN_MAX]; /* buffer for multibytes characters */
68 size_t charpoint; /* point to end of mulibyte sequence in charbuf */
69 } WInput;
71 /*** global variables defined in .c file *********************************************************/
73 extern int quote;
75 extern const global_keymap_t *input_map;
77 /*** declarations of public functions ************************************************************/
79 WInput *input_new (int y, int x, const int *input_colors,
80 int len, const char *text, const char *histname,
81 input_complete_t completion_flags);
82 /* callbac is public; needed for command line */
83 cb_ret_t input_callback (Widget * w, widget_msg_t msg, int parm);
84 const int *input_get_default_colors (void);
85 void input_set_origin (WInput * i, int x, int field_width);
86 cb_ret_t input_handle_char (WInput * in, int key);
87 int input_key_is_in_map (WInput * in, int key);
88 void input_assign_text (WInput * in, const char *text);
89 void input_insert (WInput * in, const char *text, gboolean insert_extra_space);
90 void input_set_point (WInput * in, int pos);
91 void input_update (WInput * in, gboolean clear_first);
92 void input_enable_update (WInput * in);
93 void input_disable_update (WInput * in);
94 void input_clean (WInput * in);
95 void input_free_completions (WInput * in);
97 /*** inline functions ****************************************************************************/
99 #endif /* MC__WIDGET_INPUT_H */