1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

terminal: Introduce macros for KBD_F1...KBD_F12 arithmetic.

This commit is contained in:
Kalle Olavi Niemitalo 2006-08-05 12:15:11 +03:00 committed by Miciah Dashiel Butler Masters
parent 6052fa12d8
commit fde466bde9
3 changed files with 5 additions and 2 deletions

View File

@ -950,7 +950,7 @@ menu_kbd_handler(struct menu *menu, struct term_event *ev)
{
int key = get_kbd_key(ev);
if ((key >= KBD_F1 && key <= KBD_F12)
if (is_kbd_fkey(key)
|| check_kbd_modifier(ev, KBD_MOD_ALT)) {
delete_window_ev(win, ev);
return;

View File

@ -670,7 +670,7 @@ decode_terminal_escape_sequence(struct itrm *itrm, struct interlink_event *ev)
if (itrm->in.queue.len >= 4
&& itrm->in.queue.data[3] >= 'A'
&& itrm->in.queue.data[3] <= 'L') {
kbd.key = KBD_F1 + itrm->in.queue.data[3] - 'A';
kbd.key = number_to_kbd_fkey(itrm->in.queue.data[3] - 'A' + 1);
set_kbd_interlink_event(ev, kbd.key, kbd.modifier);
return 4;
}

View File

@ -42,6 +42,9 @@ struct interlink_event_keyboard {
#define KBD_F10 0x129
#define KBD_F11 0x12a
#define KBD_F12 0x12b
static inline int is_kbd_fkey(int key) { return key >= KBD_F1 && key <= KBD_F12; }
#define number_to_kbd_fkey(num) ((num) + KBD_F1 - 1)
#define kbd_fkey_to_number(key) ((key) - KBD_F1 + 1)
#define KBD_CTRL_C 0x200