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