key.h 2.3 KB

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