2 * \brief Header: keyboard support routines
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: */
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 /* Return code for the extended mouse sequence */
37 #define MCKEY_EXTENDED_MOUSE -3
39 /* Return code for brackets of bracketed paste mode */
40 #define MCKEY_BRACKETED_PASTING_START -4
41 #define MCKEY_BRACKETED_PASTING_END -5
43 /*** enums ***************************************************************************************/
45 /*** structures declarations (and typedefs of structures)*****************************************/
57 /*** global variables defined in .c file *********************************************************/
59 extern const key_code_name_t key_name_conv_tab
[];
61 extern int old_esc_mode_timeout
;
63 extern int double_click_speed
;
64 extern int old_esc_mode
;
65 extern int use_8th_bit_as_meta
;
66 extern int mou_auto_repeat
;
68 extern gboolean bracketed_pasting_in_progress
;
70 /*** declarations of public functions ************************************************************/
72 gboolean
define_sequence (int code
, const char *seq
, int action
);
75 void init_key_input_fd (void);
78 long lookup_key (const char *name
, char **label
);
79 char *lookup_key_by_code (const int keycode
);
81 int tty_get_event (struct Gpm_Event
*event
, gboolean redo_event
, gboolean block
);
82 gboolean
is_idle (void);
85 /* While waiting for input, the program can select on more than one file */
86 typedef int (*select_fn
) (int fd
, void *info
);
88 /* Channel manipulation */
89 void add_select_channel (int fd
, select_fn callback
, void *info
);
90 void delete_select_channel (int fd
);
91 void remove_select_channel (int fd
);
93 /* Activate/deactivate the channel checking */
94 void channels_up (void);
95 void channels_down (void);
97 /* internally used in key.c, defined in keyxtra.c */
98 void load_xtra_key_defines (void);
100 /* Learn a single key */
101 char *learn_key (void);
103 /* Returns a key code (interpreted) */
104 int get_key_code (int nodelay
);
106 /* Set keypad mode (xterm and linux console only) */
107 void numeric_keypad_mode (void);
108 void application_keypad_mode (void);
110 /* Bracketed paste mode */
111 void enable_bracketed_paste (void);
112 void disable_bracketed_paste (void);
114 /*** inline functions ****************************************************************************/
116 static inline gboolean
117 is_abort_char (int c
)
119 return ((c
== (int) ESC_CHAR
) || (c
== (int) KEY_F (10)));
122 #endif /* MC_KEY_H */