1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-28 03:06:20 -04:00

terminal: New type term_event_modifier_T.

KBD_MOD_NONE and related constants are now also visible in GDB.
This commit is contained in:
Kalle Olavi Niemitalo 2006-08-13 19:41:46 +03:00 committed by Kalle Olavi Niemitalo
parent f290ff5608
commit c8584a1c7e
4 changed files with 29 additions and 15 deletions

View File

@ -49,7 +49,7 @@ struct terminal_interlink {
* ELinks sees e.g. ESC U+00F6 as 0x1B 0xC3 0xB6 and
* converts it to Alt-0xC3 0xB6, attaching the
* modifier to the first byte only. */
int modifier;
term_event_modifier_T modifier;
} utf_8;
/* This is the queue of events as coming from the other ELinks instance
@ -133,7 +133,8 @@ term_send_event(struct terminal *term, struct term_event *ev)
}
static void
term_send_ucs(struct terminal *term, unicode_val_T u, int modifier)
term_send_ucs(struct terminal *term, unicode_val_T u,
term_event_modifier_T modifier)
{
#ifdef CONFIG_UTF_8
struct term_event ev;
@ -277,7 +278,7 @@ handle_interlink_event(struct terminal *term, struct interlink_event *ilev)
{
int utf8_io = -1;
int key = ilev->info.keyboard.key;
int modifier = ilev->info.keyboard.modifier;
term_event_modifier_T modifier = ilev->info.keyboard.modifier;
if (key >= 0x100)
key = -key;

View File

@ -71,19 +71,21 @@ set_mouse_interlink_event(struct interlink_event *ev, int x, int y, unsigned int
}
static inline void
set_kbd_term_event(struct term_event *ev, int key, int modifier)
set_kbd_term_event(struct term_event *ev, int key,
term_event_modifier_T modifier)
{
memset(ev, 0, sizeof(*ev));
ev->ev = EVENT_KBD;
kbd_set(&ev->info.keyboard, key, modifier);
}
/* @key can be either a 8-bit byte or a value from enum term_event_special_key.
/* @key can be either an 8-bit byte or a value from enum term_event_special_key.
* In the latter case, this function negates the value, unless it is KBD_UNDEF.
* For example, key == KBD_ENTER results in ev->info.keyboard.key = -KBD_ENTER.
* This mapping keeps the interlink protocol compatible with ELinks 0.11. */
static inline void
set_kbd_interlink_event(struct interlink_event *ev, int key, int modifier)
set_kbd_interlink_event(struct interlink_event *ev, int key,
term_event_modifier_T modifier)
{
memset(ev, 0, sizeof(*ev));
ev->ev = EVENT_KBD;

View File

@ -841,8 +841,14 @@ decode_terminal_application_key(struct itrm *itrm, struct interlink_event *ev)
}
/* Initialize *@ev to match the byte @key received from the terminal.
* Actually, @key could also be a value from enum term_event_special_key;
* but callers that use those values generally don't need the mapping
* provided by this function, so they call set_kbd_interlink_event()
* directly. */
static void
set_kbd_event(struct interlink_event *ev, int key, int modifier)
set_kbd_event(struct interlink_event *ev,
int key, term_event_modifier_T modifier)
{
switch (key) {
case ASCII_TAB:

View File

@ -14,9 +14,18 @@ struct itrm;
* parts of ELinks already require the existence of uint32_t. */
typedef int32_t term_event_key_T;
/* Values for term_event_keyboard.modifier and
* interlink_event_keyboard.modifier */
typedef enum {
KBD_MOD_NONE = 0,
KBD_MOD_SHIFT = 1,
KBD_MOD_CTRL = 2,
KBD_MOD_ALT = 4
} term_event_modifier_T;
struct term_event_keyboard {
term_event_key_T key;
int modifier;
term_event_modifier_T modifier;
};
struct interlink_event_keyboard {
@ -26,6 +35,9 @@ struct interlink_event_keyboard {
* Values >= 0x100 are special; absolute values of constants
* from enum term_event_special_key, e.g. -KBD_ENTER. */
int key;
/* The values are from term_event_modifier_T, but the type
* must be int so that the representation remains compatible
* with ELinks 0.11. */
int modifier;
};
@ -77,13 +89,6 @@ static inline int is_kbd_fkey(term_event_key_T key) { return key <= KBD_F1 && ke
* which charset it is in, see the definition of term_event_key_T. */
#define is_kbd_character(key) ((key) >= 0)
/* Values for term_event_keyboard.modifier and
* interlink_event_keyboard.modifier */
#define KBD_MOD_NONE 0
#define KBD_MOD_SHIFT 1
#define KBD_MOD_CTRL 2
#define KBD_MOD_ALT 4
void
handle_trm(int std_in, int std_out, int sock_in, int sock_out, int ctl_in,
void *init_string, int init_len, int remote);