From fde466bde904764f1e5bb7baa067cc2e41897855 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 5 Aug 2006 12:15:11 +0300 Subject: [PATCH] terminal: Introduce macros for KBD_F1...KBD_F12 arithmetic. --- src/bfu/menu.c | 2 +- src/terminal/kbd.c | 2 +- src/terminal/kbd.h | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bfu/menu.c b/src/bfu/menu.c index c80bf4c5..dfd9a669 100644 --- a/src/bfu/menu.c +++ b/src/bfu/menu.c @@ -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; diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index 3d8d6730..229cf4de 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -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; } diff --git a/src/terminal/kbd.h b/src/terminal/kbd.h index d8d54629..8c88d349 100644 --- a/src/terminal/kbd.h +++ b/src/terminal/kbd.h @@ -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