version 1.26, 2009/12/01 07:59:40 |
version 1.27, 2009/12/03 22:50:10 |
|
|
void tty_keys_add(struct tty *, const char *, int); |
void tty_keys_add(struct tty *, const char *, int); |
void tty_keys_free1(struct tty_key *); |
void tty_keys_free1(struct tty_key *); |
struct tty_key *tty_keys_find1( |
struct tty_key *tty_keys_find1( |
struct tty_key *, const char *, size_t, size_t *); |
struct tty_key *, const char *, size_t, size_t *); |
struct tty_key *tty_keys_find(struct tty *, const char *, size_t, size_t *); |
struct tty_key *tty_keys_find(struct tty *, const char *, size_t, size_t *); |
void tty_keys_callback(int, short, void *); |
void tty_keys_callback(int, short, void *); |
int tty_keys_mouse( |
int tty_keys_mouse( |
|
|
#define TTYKEY_RAW 0x1 |
#define TTYKEY_RAW 0x1 |
}; |
}; |
|
|
/* |
/* |
* Default key tables. Those flagged with TTYKEY_RAW are inserted directly, |
* Default key tables. Those flagged with TTYKEY_RAW are inserted directly, |
* otherwise they are looked up in terminfo(5). |
* otherwise they are looked up in terminfo(5). |
*/ |
*/ |
|
|
|
|
/* Use the child tree for the next character. */ |
/* Use the child tree for the next character. */ |
tkp = &tk->next; |
tkp = &tk->next; |
} else { |
} else { |
if (*s < tk->ch) |
if (*s < tk->ch) |
tkp = &tk->left; |
tkp = &tk->left; |
else if (*s > tk->ch) |
else if (*s > tk->ch) |
|
|
if (tk->right != NULL) |
if (tk->right != NULL) |
tty_keys_free1(tk->right); |
tty_keys_free1(tk->right); |
xfree(tk); |
xfree(tk); |
|
|
} |
} |
|
|
/* Lookup a key in the tree. */ |
/* Lookup a key in the tree. */ |
|
|
/* Start the timer and wait for expiry or more data. */ |
/* Start the timer and wait for expiry or more data. */ |
tv.tv_sec = 0; |
tv.tv_sec = 0; |
tv.tv_usec = ESCAPE_PERIOD * 1000L; |
tv.tv_usec = ESCAPE_PERIOD * 1000L; |
|
|
evtimer_del(&tty->key_timer); |
evtimer_del(&tty->key_timer); |
evtimer_set(&tty->key_timer, tty_keys_callback, tty); |
evtimer_set(&tty->key_timer, tty_keys_callback, tty); |
evtimer_add(&tty->key_timer, &tv); |
evtimer_add(&tty->key_timer, &tv); |
|
|
tty->flags |= TTY_ESCAPE; |
tty->flags |= TTY_ESCAPE; |
return (0); |
return (0); |
|
|
|
|
goto handle_key; |
goto handle_key; |
|
|
handle_key: |
handle_key: |
evtimer_del(&tty->key_timer); |
evtimer_del(&tty->key_timer); |
|
|
tty->key_callback(key, &mouse, tty->key_data); |
tty->key_callback(key, &mouse, tty->key_data); |
|
|
|
|
; |
; |
} |
} |
|
|
/* |
/* |
* Handle mouse key input. Returns 0 for success, -1 for failure, 1 for partial |
* Handle mouse key input. Returns 0 for success, -1 for failure, 1 for partial |
* (probably a mouse sequence but need more data). |
* (probably a mouse sequence but need more data). |
*/ |
*/ |
|
|
return (-1); |
return (-1); |
if (len == 2) |
if (len == 2) |
return (1); |
return (1); |
|
|
if (buf[2] != 'M') |
if (buf[2] != 'M') |
return (-1); |
return (-1); |
if (len == 3) |
if (len == 3) |