2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
/** \file input.h
|
|
|
|
* \brief Header: WInput widget
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MC__WIDGET_INPUT_H
|
|
|
|
#define MC__WIDGET_INPUT_H
|
|
|
|
|
2011-02-16 18:19:48 +03:00
|
|
|
#include "lib/keybind.h" /* global_keymap_t */
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
2012-10-11 12:25:07 +04:00
|
|
|
#define INPUT(x) ((WInput *)(x))
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
/* For history load-save functions */
|
|
|
|
#define INPUT_LAST_TEXT ((char *) 2)
|
|
|
|
|
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
WINPUTC_MAIN, /* color used */
|
|
|
|
WINPUTC_MARK, /* color for marked text */
|
|
|
|
WINPUTC_UNCHANGED, /* color for inactive text (Is first keystroke) */
|
|
|
|
WINPUTC_HISTORY, /* color for history list */
|
|
|
|
WINPUTC_COUNT_COLORS /* count of used colors */
|
|
|
|
} input_colors_enum_t;
|
|
|
|
|
|
|
|
/* completion flags */
|
|
|
|
typedef enum
|
|
|
|
{
|
2013-01-25 18:29:15 +04:00
|
|
|
INPUT_COMPLETE_NONE = 0,
|
2010-11-12 11:03:57 +03:00
|
|
|
INPUT_COMPLETE_FILENAMES = 1 << 0,
|
|
|
|
INPUT_COMPLETE_HOSTNAMES = 1 << 1,
|
|
|
|
INPUT_COMPLETE_COMMANDS = 1 << 2,
|
|
|
|
INPUT_COMPLETE_VARIABLES = 1 << 3,
|
|
|
|
INPUT_COMPLETE_USERNAMES = 1 << 4,
|
|
|
|
INPUT_COMPLETE_CD = 1 << 5,
|
|
|
|
INPUT_COMPLETE_SHELL_ESC = 1 << 6,
|
|
|
|
} input_complete_t;
|
|
|
|
|
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
|
|
|
typedef int input_colors_t[WINPUTC_COUNT_COLORS];
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Widget widget;
|
2011-05-03 17:24:56 +04:00
|
|
|
input_colors_t color;
|
2010-11-22 17:15:28 +03:00
|
|
|
int point; /* cursor position in the input line in characters */
|
|
|
|
int mark; /* the mark position in characters */
|
|
|
|
gboolean highlight; /* there is a selected block */
|
|
|
|
int term_first_shown; /* column of the first shown character */
|
|
|
|
size_t current_max_size; /* maximum length of input line (bytes) */
|
|
|
|
gboolean first; /* is first keystroke? */
|
|
|
|
int disable_update; /* do we want to skip updates? */
|
|
|
|
gboolean is_password; /* is this a password input line? */
|
2013-09-21 14:53:39 +04:00
|
|
|
gboolean init_from_history; /* init text will be get from history */
|
2010-11-22 17:15:28 +03:00
|
|
|
char *buffer; /* pointer to editing buffer */
|
|
|
|
gboolean need_push; /* need to push the current Input on hist? */
|
2012-04-05 13:51:06 +04:00
|
|
|
gboolean strip_password; /* need to strip password before placing string to history */
|
2010-11-22 17:15:28 +03:00
|
|
|
char **completions; /* possible completions array */
|
2010-11-12 11:03:57 +03:00
|
|
|
input_complete_t completion_flags;
|
2010-11-22 17:15:28 +03:00
|
|
|
char charbuf[MB_LEN_MAX]; /* buffer for multibytes characters */
|
|
|
|
size_t charpoint; /* point to end of mulibyte sequence in charbuf */
|
2012-11-20 13:27:10 +04:00
|
|
|
WLabel *label; /* label associated with this input line */
|
2013-11-05 13:52:13 +04:00
|
|
|
struct input_history_t
|
|
|
|
{
|
|
|
|
char *name; /* name of history for loading and saving */
|
|
|
|
GList *list; /* the history */
|
|
|
|
GList *current; /* current history item */
|
|
|
|
gboolean changed; /* the history has changed */
|
|
|
|
} history;
|
2010-11-12 11:03:57 +03:00
|
|
|
} WInput;
|
|
|
|
|
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
2010-11-22 14:45:18 +03:00
|
|
|
extern int quote;
|
|
|
|
|
2011-02-16 18:19:48 +03:00
|
|
|
extern const global_keymap_t *input_map;
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
|
|
|
WInput *input_new (int y, int x, const int *input_colors,
|
|
|
|
int len, const char *text, const char *histname,
|
|
|
|
input_complete_t completion_flags);
|
|
|
|
/* callbac is public; needed for command line */
|
2012-06-26 11:52:21 +04:00
|
|
|
cb_ret_t input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
|
2010-11-12 11:03:57 +03:00
|
|
|
const int *input_get_default_colors (void);
|
|
|
|
cb_ret_t input_handle_char (WInput * in, int key);
|
|
|
|
int input_key_is_in_map (WInput * in, int key);
|
|
|
|
void input_assign_text (WInput * in, const char *text);
|
|
|
|
void input_insert (WInput * in, const char *text, gboolean insert_extra_space);
|
|
|
|
void input_set_point (WInput * in, int pos);
|
|
|
|
void input_update (WInput * in, gboolean clear_first);
|
|
|
|
void input_enable_update (WInput * in);
|
|
|
|
void input_disable_update (WInput * in);
|
|
|
|
void input_clean (WInput * in);
|
|
|
|
void input_free_completions (WInput * in);
|
|
|
|
|
|
|
|
/*** inline functions ****************************************************************************/
|
|
|
|
|
|
|
|
#endif /* MC__WIDGET_INPUT_H */
|