2009-02-05 21:28:18 +03:00
|
|
|
/** \file key.h
|
|
|
|
* \brief Header: keyboard support routines
|
|
|
|
*/
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
#ifndef MC__KEY_H
|
|
|
|
#define MC__KEY_H
|
2009-05-24 13:39:14 +04:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
#include "lib/global.h" /* <glib.h> */
|
|
|
|
#include "tty.h" /* KEY_F macro */
|
2009-05-24 13:39:14 +04:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
2009-05-24 13:39:14 +04:00
|
|
|
|
2009-06-19 21:33:41 +04:00
|
|
|
/* Possible return values from tty_get_event: */
|
1998-02-27 07:54:42 +03:00
|
|
|
#define EV_MOUSE -2
|
|
|
|
#define EV_NONE -1
|
|
|
|
|
2002-12-21 10:34:49 +03:00
|
|
|
/*
|
|
|
|
* Internal representation of the key modifiers. It is used in the
|
2002-12-21 11:43:15 +03:00
|
|
|
* sequence tables and the keycodes in the mc sources.
|
2002-12-21 10:34:49 +03:00
|
|
|
*/
|
|
|
|
#define KEY_M_SHIFT 0x1000
|
|
|
|
#define KEY_M_ALT 0x2000
|
|
|
|
#define KEY_M_CTRL 0x4000
|
|
|
|
#define KEY_M_MASK 0x7000
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
#define XCTRL(x) (KEY_M_CTRL | ((x) & 0x1F))
|
|
|
|
#define ALT(x) (KEY_M_ALT | (unsigned int)(x))
|
|
|
|
|
|
|
|
/* To define sequences and return codes */
|
|
|
|
#define MCKEY_NOACTION 0
|
|
|
|
#define MCKEY_ESCAPE 1
|
|
|
|
|
|
|
|
/* Return code for the mouse sequence */
|
|
|
|
#define MCKEY_MOUSE -2
|
|
|
|
|
2011-11-09 16:09:43 +04:00
|
|
|
/* Return code for the extended mouse sequence */
|
|
|
|
#define MCKEY_EXTENDED_MOUSE -3
|
|
|
|
|
2013-10-01 13:31:13 +04:00
|
|
|
/* Return code for brackets of bracketed paste mode */
|
|
|
|
#define MCKEY_BRACKETED_PASTING_START -4
|
|
|
|
#define MCKEY_BRACKETED_PASTING_END -5
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int code;
|
|
|
|
const char *name;
|
|
|
|
const char *longname;
|
|
|
|
const char *shortcut;
|
|
|
|
} key_code_name_t;
|
|
|
|
|
|
|
|
struct Gpm_Event;
|
|
|
|
|
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
|
|
|
extern const key_code_name_t key_name_conv_tab[];
|
|
|
|
|
|
|
|
extern int old_esc_mode_timeout;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
extern int double_click_speed;
|
2016-11-25 09:17:03 +03:00
|
|
|
extern gboolean old_esc_mode;
|
|
|
|
extern gboolean use_8th_bit_as_meta;
|
2009-05-26 18:48:21 +04:00
|
|
|
extern int mou_auto_repeat;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2013-10-01 13:31:13 +04:00
|
|
|
extern gboolean bracketed_pasting_in_progress;
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
|
|
|
gboolean define_sequence (int code, const char *seq, int action);
|
|
|
|
|
|
|
|
void init_key (void);
|
|
|
|
void init_key_input_fd (void);
|
|
|
|
void done_key (void);
|
|
|
|
|
2023-04-15 15:19:05 +03:00
|
|
|
long tty_keyname_to_keycode (const char *name, char **label);
|
|
|
|
char *tty_keycode_to_keyname (const int keycode);
|
2010-11-08 13:21:45 +03:00
|
|
|
/* mouse support */
|
|
|
|
int tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block);
|
|
|
|
gboolean is_idle (void);
|
|
|
|
int tty_getch (void);
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* While waiting for input, the program can select on more than one file */
|
2009-07-04 14:48:39 +04:00
|
|
|
typedef int (*select_fn) (int fd, void *info);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Channel manipulation */
|
2009-09-17 02:07:04 +04:00
|
|
|
void add_select_channel (int fd, select_fn callback, void *info);
|
1998-02-27 07:54:42 +03:00
|
|
|
void delete_select_channel (int fd);
|
|
|
|
|
|
|
|
/* Activate/deactivate the channel checking */
|
|
|
|
void channels_up (void);
|
|
|
|
void channels_down (void);
|
|
|
|
|
1998-05-20 06:19:17 +04:00
|
|
|
/* internally used in key.c, defined in keyxtra.c */
|
|
|
|
void load_xtra_key_defines (void);
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Learn a single key */
|
|
|
|
char *learn_key (void);
|
|
|
|
|
|
|
|
/* Returns a key code (interpreted) */
|
|
|
|
int get_key_code (int nodelay);
|
|
|
|
|
1998-04-01 02:36:24 +04:00
|
|
|
/* Set keypad mode (xterm and linux console only) */
|
2001-11-15 02:20:37 +03:00
|
|
|
void numeric_keypad_mode (void);
|
|
|
|
void application_keypad_mode (void);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2013-10-01 13:31:13 +04:00
|
|
|
/* Bracketed paste mode */
|
|
|
|
void enable_bracketed_paste (void);
|
|
|
|
void disable_bracketed_paste (void);
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** inline functions ****************************************************************************/
|
|
|
|
|
|
|
|
static inline gboolean
|
|
|
|
is_abort_char (int c)
|
|
|
|
{
|
2011-09-14 02:07:31 +04:00
|
|
|
return ((c == (int) ESC_CHAR) || (c == (int) KEY_F (10)));
|
2010-11-08 13:21:45 +03:00
|
|
|
}
|
|
|
|
|
2009-09-17 02:07:04 +04:00
|
|
|
#endif /* MC_KEY_H */
|