input.h 3.8 KB

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