-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey_seq.h
More file actions
33 lines (31 loc) · 1.63 KB
/
key_seq.h
File metadata and controls
33 lines (31 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef KEY_SEQ_H
#define KEY_SEQ_H
/// \brief Converts a key code to its corresponding escape sequence based on modifier keys.
///
/// \param[in] code The key code (0-255) representing a specific key.
/// \arg 0-255: Valid key codes as defined in Linux input event codes.
/// \param[in] shift Flag indicating if the Shift modifier is active.
/// \arg 0: Shift is not pressed.
/// \arg 1: Shift is pressed.
/// \param[in] ctrl Flag indicating if the Control modifier is active.
/// \arg 0: Control is not pressed.
/// \arg 1: Control is pressed.
/// \param deckpam DECKPAM keypad mode
/// \arg 0: Normal mode.
/// \arg 1: DECKPAM mode.
///
/// \return A pointer to the corresponding escape sequence string.
/// \arg nullptr: If the key code is invalid (>255) or unsupported.
/// \arg Non-nullptr: A string representing the escape sequence for the key.
///
/// \details This function maps a key code to its corresponding escape sequence string,
/// taking into account the state of Shift and Control modifiers. The mapping is based
/// on standard terminal escape sequences for keys, including function keys, arrow keys,
/// and alphanumeric keys. The function uses three lookup tables: one for unmodified keys,
/// one for keys with Shift pressed, and one for keys with Control pressed.
///
/// \note The function does not support combinations of Shift and Control modifiers simultaneously.
/// \note Key codes are masked to 8 bits (0xFF) to ensure they fall within the valid range.
/// \note Modifier keys (e.g., Shift, Control) themselves return nullptr as they do not produce sequences.
const char *key_to_seq(int code, int shift, int ctrl, int deckpam);
#endif