root/lib/widget/input.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 
   2 /** \file input.h
   3  *  \brief Header: WInput widget
   4  */
   5 
   6 #ifndef MC__WIDGET_INPUT_H
   7 #define MC__WIDGET_INPUT_H
   8 
   9 #include <limits.h>             /* MB_LEN_MAX */
  10 
  11 #include "lib/keybind.h"        /* global_keymap_t */
  12 
  13 /*** typedefs(not structures) and defined constants **********************************************/
  14 
  15 #define INPUT(x) ((WInput *)(x))
  16 
  17 /* For history load-save functions */
  18 #define INPUT_LAST_TEXT ((char *) 2)
  19 
  20 /*** enums ***************************************************************************************/
  21 
  22 typedef enum
  23 {
  24     WINPUTC_MAIN,               /* color used */
  25     WINPUTC_MARK,               /* color for marked text */
  26     WINPUTC_UNCHANGED,          /* color for inactive text (Is first keystroke) */
  27     WINPUTC_HISTORY,            /* color for history list */
  28     WINPUTC_COUNT_COLORS        /* count of used colors */
  29 } input_colors_enum_t;
  30 
  31 /* completion flags */
  32 typedef enum
  33 {
  34     INPUT_COMPLETE_NONE = 0,
  35     INPUT_COMPLETE_FILENAMES = 1 << 0,
  36     INPUT_COMPLETE_HOSTNAMES = 1 << 1,
  37     INPUT_COMPLETE_COMMANDS = 1 << 2,
  38     INPUT_COMPLETE_VARIABLES = 1 << 3,
  39     INPUT_COMPLETE_USERNAMES = 1 << 4,
  40     INPUT_COMPLETE_CD = 1 << 5,
  41     INPUT_COMPLETE_SHELL_ESC = 1 << 6,
  42 } input_complete_t;
  43 
  44 /*** structures declarations (and typedefs of structures)*****************************************/
  45 
  46 typedef int input_colors_t[WINPUTC_COUNT_COLORS];
  47 
  48 typedef struct
  49 {
  50     Widget widget;
  51     const int *color;
  52     int point;                  /* cursor position in the input line in characters */
  53     int mark;                   /* the mark position in characters; negative value means no marked text */
  54     int term_first_shown;       /* column of the first shown character */
  55     size_t current_max_size;    /* maximum length of input line (bytes) */
  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     gboolean init_from_history; /* init text will be get from history */
  60     char *buffer;               /* pointer to editing buffer */
  61     gboolean need_push;         /* need to push the current Input on hist? */
  62     gboolean strip_password;    /* need to strip password before placing string to history */
  63     char **completions;         /* possible completions array */
  64     input_complete_t completion_flags;
  65     char charbuf[MB_LEN_MAX];   /* buffer for multibytes characters */
  66     size_t charpoint;           /* point to end of mulibyte sequence in charbuf */
  67     WLabel *label;              /* label associated with this input line */
  68     struct input_history_t
  69     {
  70         char *name;             /* name of history for loading and saving */
  71         GList *list;            /* the history */
  72         GList *current;         /* current history item */
  73         gboolean changed;       /* the history has changed */
  74     } history;
  75 } WInput;
  76 
  77 /*** global variables defined in .c file *********************************************************/
  78 
  79 extern int quote;
  80 
  81 extern const global_keymap_t *input_map;
  82 
  83 /* Color styles for normal and command line input widgets */
  84 extern input_colors_t input_colors;
  85 
  86 /*** declarations of public functions ************************************************************/
  87 
  88 WInput *input_new (int y, int x, const int *colors,
  89                    int len, const char *text, const char *histname,
  90                    input_complete_t completion_flags);
  91 /* callbac is public; needed for command line */
  92 cb_ret_t input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
  93 void input_set_default_colors (void);
  94 cb_ret_t input_handle_char (WInput * in, int key);
  95 int input_key_is_in_map (WInput * in, int key);
  96 void input_assign_text (WInput * in, const char *text);
  97 gboolean input_is_empty (const WInput * in);
  98 void input_insert (WInput * in, const char *text, gboolean insert_extra_space);
  99 void input_set_point (WInput * in, int pos);
 100 void input_update (WInput * in, gboolean clear_first);
 101 void input_enable_update (WInput * in);
 102 void input_disable_update (WInput * in);
 103 void input_clean (WInput * in);
 104 void input_free_completions (WInput * in);
 105 
 106 /*** inline functions ****************************************************************************/
 107 
 108 #endif /* MC__WIDGET_INPUT_H */

/* [previous][next][first][last][top][bottom][index][help]  */