Refactored IPV4/IPV6 FTP connection setup code
[midnight-commander.git] / lib / tty / key.h
blob10b25b6e4776e594e7c638b1c3b7e70d1acef781
2 /** \file key.h
3 * \brief Header: keyboard support routines
4 */
6 #ifndef MC_KEY_H
7 #define MC_KEY_H
9 #include "lib/global.h" /* <glib.h> */
11 #include "tty.h" /* KEY_F macro */
13 gboolean define_sequence (int code, const char *seq, int action);
15 void init_key (void);
16 void init_key_input_fd (void);
17 void done_key (void);
19 long lookup_key (const char *name, char **label);
21 typedef struct {
22 int code;
23 const char *name;
24 const char *longname;
25 const char *shortcut;
26 } key_code_name_t;
28 extern const key_code_name_t key_name_conv_tab[];
30 extern int old_esc_mode_timeout;
32 /* mouse support */
33 struct Gpm_Event;
34 int tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block);
35 gboolean is_idle (void);
36 int tty_getch (void);
38 /* Possible return values from tty_get_event: */
39 #define EV_MOUSE -2
40 #define EV_NONE -1
43 * Internal representation of the key modifiers. It is used in the
44 * sequence tables and the keycodes in the mc sources.
46 #define KEY_M_SHIFT 0x1000
47 #define KEY_M_ALT 0x2000
48 #define KEY_M_CTRL 0x4000
49 #define KEY_M_MASK 0x7000
51 extern int alternate_plus_minus;
52 extern int double_click_speed;
53 extern int old_esc_mode;
54 extern int use_8th_bit_as_meta;
55 extern int mou_auto_repeat;
57 /* While waiting for input, the program can select on more than one file */
58 typedef int (*select_fn) (int fd, void *info);
60 /* Channel manipulation */
61 void add_select_channel (int fd, select_fn callback, void *info);
62 void delete_select_channel (int fd);
63 void remove_select_channel (int fd);
65 /* Activate/deactivate the channel checking */
66 void channels_up (void);
67 void channels_down (void);
69 #define XCTRL(x) (KEY_M_CTRL | ((x) & 0x1F))
70 #define ALT(x) (KEY_M_ALT | (unsigned int)(x))
72 static inline gboolean
73 is_abort_char (int c)
75 return ((c == ESC_CHAR) || (c == KEY_F (10)));
78 /* To define sequences and return codes */
79 #define MCKEY_NOACTION 0
80 #define MCKEY_ESCAPE 1
82 /* Return code for the mouse sequence */
83 #define MCKEY_MOUSE -2
86 /* internally used in key.c, defined in keyxtra.c */
87 void load_xtra_key_defines (void);
89 /* Learn a single key */
90 char *learn_key (void);
92 /* Returns a key code (interpreted) */
93 int get_key_code (int nodelay);
95 /* Set keypad mode (xterm and linux console only) */
96 void numeric_keypad_mode (void);
97 void application_keypad_mode (void);
99 #endif /* MC_KEY_H */