key.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /** \file key.h
  2. * \brief Header: keyboard support routines
  3. */
  4. #ifndef MC__KEY_H
  5. #define MC__KEY_H
  6. #include "lib/global.h" /* <glib.h> */
  7. #include "tty.h" /* KEY_F macro */
  8. /*** typedefs(not structures) and defined constants **********************************************/
  9. /* Possible return values from tty_get_event: */
  10. #define EV_MOUSE -2
  11. #define EV_NONE -1
  12. /*
  13. * Internal representation of the key modifiers. It is used in the
  14. * sequence tables and the keycodes in the mc sources.
  15. */
  16. #define KEY_M_SHIFT 0x1000
  17. #define KEY_M_ALT 0x2000
  18. #define KEY_M_CTRL 0x4000
  19. #define KEY_M_MASK 0x7000
  20. #define XCTRL(x) (KEY_M_CTRL | ((x) & 0x1F))
  21. #define ALT(x) (KEY_M_ALT | (unsigned int)(x))
  22. /* To define sequences and return codes */
  23. #define MCKEY_NOACTION 0
  24. #define MCKEY_ESCAPE 1
  25. /* Return code for the mouse sequence */
  26. #define MCKEY_MOUSE -2
  27. /*** enums ***************************************************************************************/
  28. /*** structures declarations (and typedefs of structures)*****************************************/
  29. typedef struct
  30. {
  31. int code;
  32. const char *name;
  33. const char *longname;
  34. const char *shortcut;
  35. } key_code_name_t;
  36. struct Gpm_Event;
  37. /*** global variables defined in .c file *********************************************************/
  38. extern const key_code_name_t key_name_conv_tab[];
  39. extern int old_esc_mode_timeout;
  40. extern int alternate_plus_minus;
  41. extern int double_click_speed;
  42. extern int old_esc_mode;
  43. extern int use_8th_bit_as_meta;
  44. extern int mou_auto_repeat;
  45. /*** declarations of public functions ************************************************************/
  46. gboolean define_sequence (int code, const char *seq, int action);
  47. void init_key (void);
  48. void init_key_input_fd (void);
  49. void done_key (void);
  50. long lookup_key (const char *name, char **label);
  51. /* mouse support */
  52. int tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block);
  53. gboolean is_idle (void);
  54. int tty_getch (void);
  55. /* While waiting for input, the program can select on more than one file */
  56. typedef int (*select_fn) (int fd, void *info);
  57. /* Channel manipulation */
  58. void add_select_channel (int fd, select_fn callback, void *info);
  59. void delete_select_channel (int fd);
  60. void remove_select_channel (int fd);
  61. /* Activate/deactivate the channel checking */
  62. void channels_up (void);
  63. void channels_down (void);
  64. /* internally used in key.c, defined in keyxtra.c */
  65. void load_xtra_key_defines (void);
  66. /* Learn a single key */
  67. char *learn_key (void);
  68. /* Returns a key code (interpreted) */
  69. int get_key_code (int nodelay);
  70. /* Set keypad mode (xterm and linux console only) */
  71. void numeric_keypad_mode (void);
  72. void application_keypad_mode (void);
  73. /*** inline functions ****************************************************************************/
  74. static inline gboolean
  75. is_abort_char (int c)
  76. {
  77. return ((c == ESC_CHAR) || (c == KEY_F (10)));
  78. }
  79. #endif /* MC_KEY_H */