Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "linux.h" | ||
2 | #include "parse.h" | ||
3 | #include "util/xstring.h" | ||
4 | |||
5 | 10 | ssize_t linux_parse_key(const char *buf, size_t length, KeyCode *k) | |
6 | { | ||
7 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 7 times.
|
10 | if (length < 3 || !mem_equal(buf, "\033[[", 3)) { |
8 | 3 | return term_parse_sequence(buf, length, k); | |
9 | } | ||
10 | |||
11 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
|
7 | if (unlikely(length == 3)) { |
12 | return TPARSE_PARTIAL_MATCH; | ||
13 | } | ||
14 | |||
15 | // Letters A-E represent keys F1-F5 | ||
16 | 6 | char c = buf[3]; | |
17 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
|
6 | if (c >= 'A' && c <= 'E') { |
18 | 5 | *k = KEY_F1 + (c - 'A'); | |
19 | 5 | return 4; | |
20 | } | ||
21 | |||
22 | return 0; | ||
23 | } | ||
24 |