[patch 05/11] terminal: Introduce macros for KBD_F1...KBD_F12 arithmetic.

Kalle Olavi Niemitalo <[email protected]>
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
05 (text/x-patch, 1.8 KB)
terminal: Introduce macros for KBD_F1...KBD_F12 arithmetic.

---
commit e36246f2dd33a9fe8d373c4245b1a00129ea6ea5
tree aeb37ebd1538a3c02fdbda12c3c9ff578874feb4
parent 1857d69c9c6b51ceee5ee8611a0fba8fb1f1777b
author Kalle Olavi Niemitalo <[email protected]> Sat, 05 Aug 2006 12:15:11 +0300
committer Kalle Olavi Niemitalo <[email protected]> Sat, 05 Aug 2006 20:09:34 +0300

 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 c80bf4c..dfd9a66 100644
--- a/src/bfu/menu.c
+++ b/src/bfu/menu.c
@@ -950,7 +950,7 @@ menu_kbd_handler(struct menu *menu, stru
 		{
 			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 3d8d673..229cf4d 100644
--- a/src/terminal/kbd.c
+++ b/src/terminal/kbd.c
@@ -670,7 +670,7 @@ decode_terminal_escape_sequence(struct i
 		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 d8d5462..8c88d34 100644
--- a/src/terminal/kbd.h
+++ b/src/terminal/kbd.h
@@ -42,6 +42,9 @@ #define KBD_F9		0x128
 #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
signature.asc (application/pgp-signature, 188 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFE1N9bHm9IGt60eMgRAv7kAKC2SCnre0ASgMQh9maDwY5MXEo3sQCgzhVQ
MCHz7jnaGVXDJ1ac+IIv5m0=
=vj+J
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.