Moved CSI key registration code to be private to CSI driver
This commit is contained in:
parent
e3eca8d51a
commit
d7358c43af
122
driver-csi.c
122
driver-csi.c
|
@ -12,6 +12,8 @@ struct keyinfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
termkey_t *tk;
|
||||||
|
|
||||||
// There are 32 C0 codes
|
// There are 32 C0 codes
|
||||||
struct keyinfo c0[32];
|
struct keyinfo c0[32];
|
||||||
|
|
||||||
|
@ -24,10 +26,22 @@ typedef struct {
|
||||||
struct keyinfo *csifuncs;
|
struct keyinfo *csifuncs;
|
||||||
} termkey_csi;
|
} termkey_csi;
|
||||||
|
|
||||||
|
static termkey_keysym register_c0(termkey_csi *csi, termkey_keysym sym, unsigned char ctrl, const char *name);
|
||||||
|
static termkey_keysym register_csi_ss3(termkey_csi *csi, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name);
|
||||||
|
static termkey_keysym register_ss3kpalt(termkey_csi *csi, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name, char kpalt);
|
||||||
|
static termkey_keysym register_csifunc(termkey_csi *csi, termkey_type type, termkey_keysym sym, int number, const char *name);
|
||||||
|
|
||||||
|
static termkey_keysym register_c0_full(termkey_csi *csi, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char ctrl, const char *name);
|
||||||
|
static termkey_keysym register_csi_ss3_full(termkey_csi *csi, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name);
|
||||||
|
static termkey_keysym register_ss3kpalt_full(termkey_csi *csi, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name, char kpalt);
|
||||||
|
static termkey_keysym register_csifunc_full(termkey_csi *csi, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, int number, const char *name);
|
||||||
|
|
||||||
static void *new_driver(termkey_t *tk)
|
static void *new_driver(termkey_t *tk)
|
||||||
{
|
{
|
||||||
termkey_csi *csi = malloc(sizeof *csi);
|
termkey_csi *csi = malloc(sizeof *csi);
|
||||||
|
|
||||||
|
csi->tk = tk;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < 32; i++) {
|
for(i = 0; i < 32; i++) {
|
||||||
|
@ -47,6 +61,74 @@ static void *new_driver(termkey_t *tk)
|
||||||
for(i = 0; i < csi->ncsifuncs; i++)
|
for(i = 0; i < csi->ncsifuncs; i++)
|
||||||
csi->csifuncs[i].sym = TERMKEY_SYM_UNKNOWN;
|
csi->csifuncs[i].sym = TERMKEY_SYM_UNKNOWN;
|
||||||
|
|
||||||
|
register_c0(csi, TERMKEY_SYM_BACKSPACE, 0x08, "Backspace");
|
||||||
|
register_c0(csi, TERMKEY_SYM_TAB, 0x09, "Tab");
|
||||||
|
register_c0(csi, TERMKEY_SYM_ENTER, 0x0d, "Enter");
|
||||||
|
register_c0(csi, TERMKEY_SYM_ESCAPE, 0x1b, "Escape");
|
||||||
|
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_UP, 'A', "Up");
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_DOWN, 'B', "Down");
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_RIGHT, 'C', "Right");
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_LEFT, 'D', "Left");
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_BEGIN, 'E', "Begin");
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_END, 'F', "End");
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_HOME, 'H', "Home");
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_FUNCTION, 1, 'P', NULL);
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_FUNCTION, 2, 'Q', NULL);
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_FUNCTION, 3, 'R', NULL);
|
||||||
|
register_csi_ss3(csi, TERMKEY_TYPE_FUNCTION, 4, 'S', NULL);
|
||||||
|
|
||||||
|
register_csi_ss3_full(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_TAB, TERMKEY_KEYMOD_SHIFT, TERMKEY_KEYMOD_SHIFT, 'Z', NULL);
|
||||||
|
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPENTER, 'M', "KPEnter", 0);
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPEQUALS, 'X', "KPEquals", '=');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPMULT, 'j', "KPMult", '*');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPPLUS, 'k', "KPPlus", '+');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPCOMMA, 'l', "KPComma", ',');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPMINUS, 'm', "KPMinus", '-');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPPERIOD, 'n', "KPPeriod", '.');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPDIV, 'o', "KPDiv", '/');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP0, 'p', "KP0", '0');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP1, 'q', "KP1", '1');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP2, 'r', "KP2", '2');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP3, 's', "KP3", '3');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP4, 't', "KP4", '4');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP5, 'u', "KP5", '5');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP6, 'v', "KP6", '6');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP7, 'w', "KP7", '7');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP8, 'x', "KP8", '8');
|
||||||
|
register_ss3kpalt(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP9, 'y', "KP9", '9');
|
||||||
|
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_FIND, 1, "Find");
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_INSERT, 2, "Insert");
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_DELETE, 3, "Delete");
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_SELECT, 4, "Select");
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEUP, 5, "PageUp");
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEDOWN, 6, "PageDown");
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_HOME, 7, "Home");
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_END, 8, "End");
|
||||||
|
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 1, 11, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 2, 12, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 3, 13, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 4, 14, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 5, 15, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 6, 17, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 7, 18, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 8, 19, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 9, 20, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 10, 21, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 11, 23, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 12, 24, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 13, 25, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 14, 26, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 15, 28, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 16, 29, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 17, 31, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 18, 32, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 19, 33, NULL);
|
||||||
|
register_csifunc(csi, TERMKEY_TYPE_FUNCTION, 20, 34, NULL);
|
||||||
|
|
||||||
return csi;
|
return csi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,22 +557,20 @@ static termkey_result getkey(termkey_t *tk, termkey_key *key)
|
||||||
return TERMKEY_SYM_NONE;
|
return TERMKEY_SYM_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_c0(termkey_t *tk, termkey_keysym sym, unsigned char ctrl, const char *name)
|
static termkey_keysym register_c0(termkey_csi *csi, termkey_keysym sym, unsigned char ctrl, const char *name)
|
||||||
{
|
{
|
||||||
return termkey_register_c0_full(tk, sym, 0, 0, ctrl, name);
|
return register_c0_full(csi, sym, 0, 0, ctrl, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_c0_full(termkey_t *tk, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char ctrl, const char *name)
|
static termkey_keysym register_c0_full(termkey_csi *csi, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char ctrl, const char *name)
|
||||||
{
|
{
|
||||||
termkey_csi *csi = tk->driver_info;
|
|
||||||
|
|
||||||
if(ctrl >= 0x20) {
|
if(ctrl >= 0x20) {
|
||||||
fprintf(stderr, "Cannot register C0 key at ctrl 0x%02x - out of bounds\n", ctrl);
|
fprintf(stderr, "Cannot register C0 key at ctrl 0x%02x - out of bounds\n", ctrl);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name)
|
if(name)
|
||||||
sym = termkey_register_keyname(tk, sym, name);
|
sym = termkey_register_keyname(csi->tk, sym, name);
|
||||||
|
|
||||||
csi->c0[ctrl].sym = sym;
|
csi->c0[ctrl].sym = sym;
|
||||||
csi->c0[ctrl].modifier_set = modifier_set;
|
csi->c0[ctrl].modifier_set = modifier_set;
|
||||||
|
@ -499,22 +579,20 @@ termkey_keysym termkey_register_c0_full(termkey_t *tk, termkey_keysym sym, int m
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_csi_ss3(termkey_t *tk, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name)
|
static termkey_keysym register_csi_ss3(termkey_csi *csi, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name)
|
||||||
{
|
{
|
||||||
return termkey_register_csi_ss3_full(tk, type, sym, 0, 0, cmd, name);
|
return register_csi_ss3_full(csi, type, sym, 0, 0, cmd, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_csi_ss3_full(termkey_t *tk, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name)
|
static termkey_keysym register_csi_ss3_full(termkey_csi *csi, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name)
|
||||||
{
|
{
|
||||||
termkey_csi *csi = tk->driver_info;
|
|
||||||
|
|
||||||
if(cmd < 0x40 || cmd >= 0x80) {
|
if(cmd < 0x40 || cmd >= 0x80) {
|
||||||
fprintf(stderr, "Cannot register CSI/SS3 key at cmd 0x%02x - out of bounds\n", cmd);
|
fprintf(stderr, "Cannot register CSI/SS3 key at cmd 0x%02x - out of bounds\n", cmd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name)
|
if(name)
|
||||||
sym = termkey_register_keyname(tk, sym, name);
|
sym = termkey_register_keyname(csi->tk, sym, name);
|
||||||
|
|
||||||
csi->csi_ss3s[cmd - 0x40].type = type;
|
csi->csi_ss3s[cmd - 0x40].type = type;
|
||||||
csi->csi_ss3s[cmd - 0x40].sym = sym;
|
csi->csi_ss3s[cmd - 0x40].sym = sym;
|
||||||
|
@ -524,22 +602,20 @@ termkey_keysym termkey_register_csi_ss3_full(termkey_t *tk, termkey_type type, t
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_ss3kpalt(termkey_t *tk, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name, char kpalt)
|
static termkey_keysym register_ss3kpalt(termkey_csi *csi, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name, char kpalt)
|
||||||
{
|
{
|
||||||
return termkey_register_ss3kpalt_full(tk, type, sym, 0, 0, cmd, name, kpalt);
|
return register_ss3kpalt_full(csi, type, sym, 0, 0, cmd, name, kpalt);
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_ss3kpalt_full(termkey_t *tk, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name, char kpalt)
|
static termkey_keysym register_ss3kpalt_full(termkey_csi *csi, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name, char kpalt)
|
||||||
{
|
{
|
||||||
termkey_csi *csi = tk->driver_info;
|
|
||||||
|
|
||||||
if(cmd < 0x40 || cmd >= 0x80) {
|
if(cmd < 0x40 || cmd >= 0x80) {
|
||||||
fprintf(stderr, "Cannot register SS3 key at cmd 0x%02x - out of bounds\n", cmd);
|
fprintf(stderr, "Cannot register SS3 key at cmd 0x%02x - out of bounds\n", cmd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name)
|
if(name)
|
||||||
sym = termkey_register_keyname(tk, sym, name);
|
sym = termkey_register_keyname(csi->tk, sym, name);
|
||||||
|
|
||||||
csi->ss3s[cmd - 0x40].type = type;
|
csi->ss3s[cmd - 0x40].type = type;
|
||||||
csi->ss3s[cmd - 0x40].sym = sym;
|
csi->ss3s[cmd - 0x40].sym = sym;
|
||||||
|
@ -550,17 +626,15 @@ termkey_keysym termkey_register_ss3kpalt_full(termkey_t *tk, termkey_type type,
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_csifunc(termkey_t *tk, termkey_type type, termkey_keysym sym, int number, const char *name)
|
static termkey_keysym register_csifunc(termkey_csi *csi, termkey_type type, termkey_keysym sym, int number, const char *name)
|
||||||
{
|
{
|
||||||
return termkey_register_csifunc_full(tk, type, sym, 0, 0, number, name);
|
return register_csifunc_full(csi, type, sym, 0, 0, number, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
termkey_keysym termkey_register_csifunc_full(termkey_t *tk, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, int number, const char *name)
|
static termkey_keysym register_csifunc_full(termkey_csi *csi, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, int number, const char *name)
|
||||||
{
|
{
|
||||||
termkey_csi *csi = tk->driver_info;
|
|
||||||
|
|
||||||
if(name)
|
if(name)
|
||||||
sym = termkey_register_keyname(tk, sym, name);
|
sym = termkey_register_keyname(csi->tk, sym, name);
|
||||||
|
|
||||||
if(number >= csi->ncsifuncs) {
|
if(number >= csi->ncsifuncs) {
|
||||||
struct keyinfo *new_csifuncs = realloc(csi->csifuncs, sizeof(new_csifuncs[0]) * (number + 1));
|
struct keyinfo *new_csifuncs = realloc(csi->csifuncs, sizeof(new_csifuncs[0]) * (number + 1));
|
||||||
|
|
70
termkey.c
70
termkey.c
|
@ -65,79 +65,9 @@ termkey_t *termkey_new_full(int fd, int flags, size_t buffsize, int waittime)
|
||||||
|
|
||||||
// Special built-in names
|
// Special built-in names
|
||||||
termkey_register_keyname(tk, TERMKEY_SYM_NONE, "NONE");
|
termkey_register_keyname(tk, TERMKEY_SYM_NONE, "NONE");
|
||||||
|
|
||||||
termkey_register_c0(tk, TERMKEY_SYM_BACKSPACE, 0x08, "Backspace");
|
|
||||||
termkey_register_c0(tk, TERMKEY_SYM_TAB, 0x09, "Tab");
|
|
||||||
termkey_register_c0(tk, TERMKEY_SYM_ENTER, 0x0d, "Enter");
|
|
||||||
termkey_register_c0(tk, TERMKEY_SYM_ESCAPE, 0x1b, "Escape");
|
|
||||||
|
|
||||||
// G1
|
|
||||||
termkey_register_keyname(tk, TERMKEY_SYM_SPACE, "Space");
|
termkey_register_keyname(tk, TERMKEY_SYM_SPACE, "Space");
|
||||||
termkey_register_keyname(tk, TERMKEY_SYM_DEL, "DEL");
|
termkey_register_keyname(tk, TERMKEY_SYM_DEL, "DEL");
|
||||||
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_UP, 'A', "Up");
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_DOWN, 'B', "Down");
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_RIGHT, 'C', "Right");
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_LEFT, 'D', "Left");
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_BEGIN, 'E', "Begin");
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_END, 'F', "End");
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_HOME, 'H', "Home");
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_FUNCTION, 1, 'P', NULL);
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_FUNCTION, 2, 'Q', NULL);
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_FUNCTION, 3, 'R', NULL);
|
|
||||||
termkey_register_csi_ss3(tk, TERMKEY_TYPE_FUNCTION, 4, 'S', NULL);
|
|
||||||
|
|
||||||
termkey_register_csi_ss3_full(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_TAB, TERMKEY_KEYMOD_SHIFT, TERMKEY_KEYMOD_SHIFT, 'Z', NULL);
|
|
||||||
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPENTER, 'M', "KPEnter", 0);
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPEQUALS, 'X', "KPEquals", '=');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPMULT, 'j', "KPMult", '*');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPPLUS, 'k', "KPPlus", '+');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPCOMMA, 'l', "KPComma", ',');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPMINUS, 'm', "KPMinus", '-');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPPERIOD, 'n', "KPPeriod", '.');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPDIV, 'o', "KPDiv", '/');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP0, 'p', "KP0", '0');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP1, 'q', "KP1", '1');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP2, 'r', "KP2", '2');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP3, 's', "KP3", '3');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP4, 't', "KP4", '4');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP5, 'u', "KP5", '5');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP6, 'v', "KP6", '6');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP7, 'w', "KP7", '7');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP8, 'x', "KP8", '8');
|
|
||||||
termkey_register_ss3kpalt(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP9, 'y', "KP9", '9');
|
|
||||||
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_FIND, 1, "Find");
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_INSERT, 2, "Insert");
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_DELETE, 3, "Delete");
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_SELECT, 4, "Select");
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEUP, 5, "PageUp");
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEDOWN, 6, "PageDown");
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_HOME, 7, "Home");
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_END, 8, "End");
|
|
||||||
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 1, 11, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 2, 12, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 3, 13, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 4, 14, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 5, 15, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 6, 17, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 7, 18, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 8, 19, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 9, 20, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 10, 21, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 11, 23, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 12, 24, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 13, 25, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 14, 26, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 15, 28, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 16, 29, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 17, 31, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 18, 32, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 19, 33, NULL);
|
|
||||||
termkey_register_csifunc(tk, TERMKEY_TYPE_FUNCTION, 20, 34, NULL);
|
|
||||||
|
|
||||||
if(!(flags & TERMKEY_FLAG_NOTERMIOS)) {
|
if(!(flags & TERMKEY_FLAG_NOTERMIOS)) {
|
||||||
struct termios termios;
|
struct termios termios;
|
||||||
if(tcgetattr(fd, &termios) == 0) {
|
if(tcgetattr(fd, &termios) == 0) {
|
||||||
|
|
11
termkey.h
11
termkey.h
|
@ -118,20 +118,9 @@ void termkey_pushinput(termkey_t *tk, unsigned char *input, size_t inputle
|
||||||
|
|
||||||
termkey_result termkey_advisereadable(termkey_t *tk);
|
termkey_result termkey_advisereadable(termkey_t *tk);
|
||||||
|
|
||||||
// Registration of keys and names
|
|
||||||
termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym sym, const char *name);
|
termkey_keysym termkey_register_keyname(termkey_t *tk, termkey_keysym sym, const char *name);
|
||||||
const char *termkey_get_keyname(termkey_t *tk, termkey_keysym sym);
|
const char *termkey_get_keyname(termkey_t *tk, termkey_keysym sym);
|
||||||
|
|
||||||
termkey_keysym termkey_register_c0(termkey_t *tk, termkey_keysym sym, unsigned char ctrl, const char *name);
|
|
||||||
termkey_keysym termkey_register_csi_ss3(termkey_t *tk, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name);
|
|
||||||
termkey_keysym termkey_register_ss3kpalt(termkey_t *tk, termkey_type type, termkey_keysym sym, unsigned char cmd, const char *name, char kpalt);
|
|
||||||
termkey_keysym termkey_register_csifunc(termkey_t *tk, termkey_type type, termkey_keysym sym, int number, const char *name);
|
|
||||||
|
|
||||||
termkey_keysym termkey_register_c0_full(termkey_t *tk, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char ctrl, const char *name);
|
|
||||||
termkey_keysym termkey_register_csi_ss3_full(termkey_t *tk, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name);
|
|
||||||
termkey_keysym termkey_register_ss3kpalt_full(termkey_t *tk, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, unsigned char cmd, const char *name, char kpalt);
|
|
||||||
termkey_keysym termkey_register_csifunc_full(termkey_t *tk, termkey_type type, termkey_keysym sym, int modifier_set, int modifier_mask, int number, const char *name);
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TERMKEY_FORMAT_LONGMOD = 1,
|
TERMKEY_FORMAT_LONGMOD = 1,
|
||||||
TERMKEY_FORMAT_CARETCTRL = 2,
|
TERMKEY_FORMAT_CARETCTRL = 2,
|
||||||
|
|
Loading…
Reference in New Issue