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