key.h 2.6 KB

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