|
|
f725e3 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f725e3 |
From: Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f725e3 |
Date: Sat, 18 Jan 2014 16:57:35 +0100
|
|
|
f725e3 |
Subject: [PATCH] * grub-core/term/terminfo.c: Recognize keys F1-F12.
|
|
|
f725e3 |
|
|
|
f725e3 |
---
|
|
|
f725e3 |
grub-core/term/terminfo.c | 86 +++++++++++++++++++++++++++--------------------
|
|
|
f725e3 |
ChangeLog | 4 +++
|
|
|
f725e3 |
2 files changed, 54 insertions(+), 36 deletions(-)
|
|
|
f725e3 |
|
|
|
f725e3 |
diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c
|
|
|
f725e3 |
index 3d48b198fbd..f0d3e3debc6 100644
|
|
|
f725e3 |
--- a/grub-core/term/terminfo.c
|
|
|
f725e3 |
+++ b/grub-core/term/terminfo.c
|
|
|
f725e3 |
@@ -460,28 +460,31 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|
|
f725e3 |
{'@', GRUB_TERM_KEY_INSERT},
|
|
|
f725e3 |
};
|
|
|
f725e3 |
|
|
|
f725e3 |
- static struct
|
|
|
f725e3 |
- {
|
|
|
f725e3 |
- char key;
|
|
|
f725e3 |
- unsigned ascii;
|
|
|
f725e3 |
- }
|
|
|
f725e3 |
- four_code_table[] =
|
|
|
f725e3 |
+ static unsigned four_code_table[] =
|
|
|
f725e3 |
{
|
|
|
f725e3 |
- {'1', GRUB_TERM_KEY_HOME},
|
|
|
f725e3 |
- {'3', GRUB_TERM_KEY_DC},
|
|
|
f725e3 |
- {'5', GRUB_TERM_KEY_PPAGE},
|
|
|
f725e3 |
- {'6', GRUB_TERM_KEY_NPAGE},
|
|
|
f725e3 |
- {'7', GRUB_TERM_KEY_HOME},
|
|
|
f725e3 |
- {'8', GRUB_TERM_KEY_END}
|
|
|
f725e3 |
+ [1] = GRUB_TERM_KEY_HOME,
|
|
|
f725e3 |
+ [3] = GRUB_TERM_KEY_DC,
|
|
|
f725e3 |
+ [5] = GRUB_TERM_KEY_PPAGE,
|
|
|
f725e3 |
+ [6] = GRUB_TERM_KEY_NPAGE,
|
|
|
f725e3 |
+ [7] = GRUB_TERM_KEY_HOME,
|
|
|
f725e3 |
+ [8] = GRUB_TERM_KEY_END,
|
|
|
f725e3 |
+ [17] = GRUB_TERM_KEY_F6,
|
|
|
f725e3 |
+ [18] = GRUB_TERM_KEY_F7,
|
|
|
f725e3 |
+ [19] = GRUB_TERM_KEY_F8,
|
|
|
f725e3 |
+ [20] = GRUB_TERM_KEY_F9,
|
|
|
f725e3 |
+ [21] = GRUB_TERM_KEY_F10,
|
|
|
f725e3 |
+ [23] = GRUB_TERM_KEY_F11,
|
|
|
f725e3 |
+ [24] = GRUB_TERM_KEY_F12,
|
|
|
f725e3 |
};
|
|
|
f725e3 |
char fx_key[] =
|
|
|
f725e3 |
{ 'P', 'Q', 'w', 'x', 't', 'u',
|
|
|
f725e3 |
- 'q', 'r', 'p', 'M', 'A', 'B' };
|
|
|
f725e3 |
+ 'q', 'r', 'p', 'M', 'A', 'B', 'H', 'F' };
|
|
|
f725e3 |
unsigned fx_code[] =
|
|
|
f725e3 |
{ GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3,
|
|
|
f725e3 |
GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6,
|
|
|
f725e3 |
GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9,
|
|
|
f725e3 |
- GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12 };
|
|
|
f725e3 |
+ GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12,
|
|
|
f725e3 |
+ GRUB_TERM_KEY_HOME, GRUB_TERM_KEY_END };
|
|
|
f725e3 |
unsigned i;
|
|
|
f725e3 |
|
|
|
f725e3 |
if (c == '\e')
|
|
|
f725e3 |
@@ -492,19 +495,13 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|
|
f725e3 |
{
|
|
|
f725e3 |
CONTINUE_READ;
|
|
|
f725e3 |
|
|
|
f725e3 |
- switch (c)
|
|
|
f725e3 |
- {
|
|
|
f725e3 |
- case 'H':
|
|
|
f725e3 |
- keys[0] = GRUB_TERM_KEY_HOME;
|
|
|
f725e3 |
- *len = 1;
|
|
|
f725e3 |
- return;
|
|
|
f725e3 |
- case 'F':
|
|
|
f725e3 |
- keys[0] = GRUB_TERM_KEY_END;
|
|
|
f725e3 |
- *len = 1;
|
|
|
f725e3 |
- return;
|
|
|
f725e3 |
- default:
|
|
|
f725e3 |
- return;
|
|
|
f725e3 |
- }
|
|
|
f725e3 |
+ for (i = 0; i < ARRAY_SIZE (fx_key); i++)
|
|
|
f725e3 |
+ if (fx_key[i] == c)
|
|
|
f725e3 |
+ {
|
|
|
f725e3 |
+ keys[0] = fx_code[i];
|
|
|
f725e3 |
+ *len = 1;
|
|
|
f725e3 |
+ return;
|
|
|
f725e3 |
+ }
|
|
|
f725e3 |
}
|
|
|
f725e3 |
|
|
|
f725e3 |
if (c != '[')
|
|
|
f725e3 |
@@ -523,6 +520,15 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|
|
f725e3 |
|
|
|
f725e3 |
switch (c)
|
|
|
f725e3 |
{
|
|
|
f725e3 |
+ case '[':
|
|
|
f725e3 |
+ CONTINUE_READ;
|
|
|
f725e3 |
+ if (c >= 'A' && c <= 'E')
|
|
|
f725e3 |
+ {
|
|
|
f725e3 |
+ keys[0] = GRUB_TERM_KEY_F1 + c - 'A';
|
|
|
f725e3 |
+ *len = 1;
|
|
|
f725e3 |
+ return;
|
|
|
f725e3 |
+ }
|
|
|
f725e3 |
+ return;
|
|
|
f725e3 |
case 'O':
|
|
|
f725e3 |
CONTINUE_READ;
|
|
|
f725e3 |
for (i = 0; i < ARRAY_SIZE (fx_key); i++)
|
|
|
f725e3 |
@@ -555,18 +561,26 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|
|
f725e3 |
return;
|
|
|
f725e3 |
}
|
|
|
f725e3 |
|
|
|
f725e3 |
- default:
|
|
|
f725e3 |
- for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
|
|
|
f725e3 |
- if (four_code_table[i].key == c)
|
|
|
f725e3 |
+ case '1' ... '9':
|
|
|
f725e3 |
+ {
|
|
|
f725e3 |
+ unsigned val = c - '0';
|
|
|
f725e3 |
+ CONTINUE_READ;
|
|
|
f725e3 |
+ if (c >= '0' && c <= '9')
|
|
|
f725e3 |
{
|
|
|
f725e3 |
+ val = val * 10 + (c - '0');
|
|
|
f725e3 |
CONTINUE_READ;
|
|
|
f725e3 |
- if (c != '~')
|
|
|
f725e3 |
- return;
|
|
|
f725e3 |
- keys[0] = four_code_table[i].ascii;
|
|
|
f725e3 |
- *len = 1;
|
|
|
f725e3 |
- return;
|
|
|
f725e3 |
}
|
|
|
f725e3 |
- return;
|
|
|
f725e3 |
+ if (c != '~')
|
|
|
f725e3 |
+ return;
|
|
|
f725e3 |
+ if (val >= ARRAY_SIZE (four_code_table)
|
|
|
f725e3 |
+ || four_code_table[val] == 0)
|
|
|
f725e3 |
+ return;
|
|
|
f725e3 |
+ keys[0] = four_code_table[val];
|
|
|
f725e3 |
+ *len = 1;
|
|
|
f725e3 |
+ return;
|
|
|
f725e3 |
+ }
|
|
|
f725e3 |
+ default:
|
|
|
f725e3 |
+ return;
|
|
|
f725e3 |
}
|
|
|
f725e3 |
}
|
|
|
f725e3 |
#undef CONTINUE_READ
|
|
|
f725e3 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f725e3 |
index 9c3ef2e2150..bdfbf44da88 100644
|
|
|
f725e3 |
--- a/ChangeLog
|
|
|
f725e3 |
+++ b/ChangeLog
|
|
|
f725e3 |
@@ -1,3 +1,7 @@
|
|
|
f725e3 |
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f725e3 |
+
|
|
|
f725e3 |
+ * grub-core/term/terminfo.c: Recognize keys F1-F12.
|
|
|
f725e3 |
+
|
|
|
f725e3 |
2014-01-07 Andrey Borzenkov <arvidjaar@gmail.com>
|
|
|
f725e3 |
|
|
|
f725e3 |
* configure.ac: Add support for BUILD_LDFLAGS.
|