diff options
Diffstat (limited to 'src/include/ipxe/keys.h')
-rw-r--r-- | src/include/ipxe/keys.h | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/include/ipxe/keys.h b/src/include/ipxe/keys.h index d15267a..2335691 100644 --- a/src/include/ipxe/keys.h +++ b/src/include/ipxe/keys.h @@ -49,19 +49,54 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ESC 0x1b /* - * Special keys outside the normal ASCII range - * + * Special keys outside the normal Unicode range * * The names are chosen to match those used by curses. The values are * chosen to facilitate easy conversion from a received ANSI escape * sequence to a KEY_XXX constant. */ -#define KEY_ANSI( n, terminator ) ( 0x100 * ( (n) + 1 ) + (terminator) ) -#define KEY_ANSI_N( key ) ( ( (key) / 0x100 ) - 1 ) +/** + * Minimum value for special keypresses + * + * This value is chosen to lie above the maximum Unicode code point + * value 0x10ffff. + */ +#define KEY_MIN 0x110000 + +/** + * Construct relative key value for special key + * + * @v key Key value + * @ret rkey Relative key value + */ +#define KEY_REL( key ) ( (key) - KEY_MIN ) + +/** + * Construct ANSI escape sequence key value + * + * @v n ANSI escape sequence numeric portion, or 0 for none + * @v terminator ANSI escape sequence terminating character + * @ret key Key value + */ +#define KEY_ANSI( n, terminator ) ( KEY_MIN + ( (n) << 8 ) + (terminator) ) + +/** + * Extract ANSI escape sequence numeric portion + * + * @v key Key value (or relative key value) + * @ret n ANSI escape sequence numeric portion, or 0 for none + */ +#define KEY_ANSI_N( key ) ( ( (key) >> 8 ) & 0xff ) + +/** + * Extract ANSI escape sequence terminating character + * + * @v key Key value (or relative key value) + * @ret terminator ANSI escape sequence terminating character + */ #define KEY_ANSI_TERMINATOR( key ) ( (key) & 0xff ) -#define KEY_MIN 0x101 #define KEY_UP KEY_ANSI ( 0, 'A' ) /**< Up arrow */ #define KEY_DOWN KEY_ANSI ( 0, 'B' ) /**< Down arrow */ #define KEY_RIGHT KEY_ANSI ( 0, 'C' ) /**< Right arrow */ |