dte test coverage


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 50.0% high: ≥ 85.0%
Coverage Exec / Excl / Total
Lines: 100.0% 10 / 0 / 10
Functions: 100.0% 4 / 0 / 4
Branches: 90.0% 9 / 0 / 10

src/terminal/cursor.h
Line Branch Exec Source
1 #ifndef TERMINAL_CURSOR_H
2 #define TERMINAL_CURSOR_H
3
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include "terminal/color.h"
7 #include "terminal/terminal.h"
8 #include "util/macros.h"
9 #include "util/ptr-array.h"
10 #include "util/string-view.h"
11
12 typedef enum {
13 CURSOR_MODE_DEFAULT, // Fallback, for modes left unspecified
14 CURSOR_MODE_INSERT, // Normal mode with `set overwrite false`
15 CURSOR_MODE_OVERWRITE, // Normal mode with `set overwrite true`
16 CURSOR_MODE_CMDLINE, // Command or search mode
17 NR_CURSOR_MODES,
18 } CursorInputMode;
19
20 9 static inline bool cursor_color_is_valid(int32_t c)
21 {
22
3/4
✓ Branch 2 → 3 taken 2 times.
✓ Branch 2 → 5 taken 7 times.
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
9 return c == COLOR_KEEP || c == COLOR_DEFAULT || color_is_rgb(c);
23 }
24
25 2 static inline bool cursor_type_is_valid(TermCursorType type)
26 {
27 2 return type >= CURSOR_DEFAULT && type <= CURSOR_KEEP;
28 }
29
30 5 static inline bool same_cursor(const TermCursorStyle *a, const TermCursorStyle *b)
31 {
32
4/4
✓ Branch 2 → 3 taken 4 times.
✓ Branch 2 → 4 taken 1 time.
✓ Branch 3 → 4 taken 1 time.
✓ Branch 3 → 5 taken 3 times.
5 return a->type == b->type && a->color == b->color;
33 }
34
35 4 static inline TermCursorStyle get_default_cursor_style(CursorInputMode mode)
36 {
37 4 bool is_default_mode = (mode == CURSOR_MODE_DEFAULT);
38 8 return (TermCursorStyle) {
39
2/2
✓ Branch 2 → 3 taken 3 times.
✓ Branch 2 → 4 taken 1 time.
4 .type = is_default_mode ? CURSOR_DEFAULT : CURSOR_KEEP,
40 .color = is_default_mode ? COLOR_DEFAULT : COLOR_KEEP,
41 };
42 }
43
44 const char *cursor_mode_to_str(CursorInputMode mode) RETURNS_NONNULL;
45 const char *cursor_type_to_str(TermCursorType type) RETURNS_NONNULL;
46 const char *cursor_color_to_str(char buf[static COLOR_STR_BUFSIZE], int32_t color) NONNULL_ARGS_AND_RETURN;
47 CursorInputMode cursor_mode_from_str(const char *name) NONNULL_ARGS;
48 TermCursorType cursor_type_from_str(const char *name) NONNULL_ARGS;
49 int32_t cursor_color_from_str(const char *str) NONNULL_ARGS;
50 void collect_cursor_modes(PointerArray *a, StringView prefix) NONNULL_ARGS;
51 void collect_cursor_types(PointerArray *a, StringView prefix) NONNULL_ARGS;
52 void collect_cursor_colors(PointerArray *a, StringView prefix) NONNULL_ARGS;
53
54 #endif
55