key.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. /* Return code for the extended mouse sequence */
  28. #define MCKEY_EXTENDED_MOUSE -3
  29. /* Return code for brackets of bracketed paste mode */
  30. #define MCKEY_BRACKETED_PASTING_START -4
  31. #define MCKEY_BRACKETED_PASTING_END -5
  32. /*** enums ***************************************************************************************/
  33. /*** structures declarations (and typedefs of structures)*****************************************/
  34. typedef struct
  35. {
  36. int code;
  37. const char *name;
  38. const char *longname;
  39. const char *shortcut;
  40. } key_code_name_t;
  41. struct Gpm_Event;
  42. /*** global variables defined in .c file *********************************************************/
  43. extern const key_code_name_t key_name_conv_tab[];
  44. extern int old_esc_mode_timeout;
  45. extern int double_click_speed;
  46. extern gboolean old_esc_mode;
  47. extern gboolean use_8th_bit_as_meta;
  48. extern int mou_auto_repeat;
  49. extern gboolean bracketed_pasting_in_progress;
  50. /*** declarations of public functions ************************************************************/
  51. gboolean define_sequence (int code, const char *seq, int action);
  52. void init_key (void);
  53. void init_key_input_fd (void);
  54. void done_key (void);
  55. long tty_keyname_to_keycode (const char *name, char **label);
  56. char *tty_keycode_to_keyname (const int keycode);
  57. /* mouse support */
  58. int tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block);
  59. gboolean is_idle (void);
  60. int tty_getch (void);
  61. /* While waiting for input, the program can select on more than one file */
  62. typedef int (*select_fn) (int fd, void *info);
  63. /* Channel manipulation */
  64. void add_select_channel (int fd, select_fn callback, void *info);
  65. void delete_select_channel (int fd);
  66. /* Activate/deactivate the channel checking */
  67. void channels_up (void);
  68. void channels_down (void);
  69. /* internally used in key.c, defined in keyxtra.c */
  70. void load_xtra_key_defines (void);
  71. /* Learn a single key */
  72. char *learn_key (void);
  73. /* Returns a key code (interpreted) */
  74. int get_key_code (int nodelay);
  75. /* Set keypad mode (xterm and linux console only) */
  76. void numeric_keypad_mode (void);
  77. void application_keypad_mode (void);
  78. /* Bracketed paste mode */
  79. void enable_bracketed_paste (void);
  80. void disable_bracketed_paste (void);
  81. /*** inline functions ****************************************************************************/
  82. static inline gboolean
  83. is_abort_char (int c)
  84. {
  85. return ((c == (int) ESC_CHAR) || (c == (int) KEY_F (10)));
  86. }
  87. #endif /* MC_KEY_H */