dte test coverage


Directory: ./
File: src/terminal/style.h
Date: 2025-02-14 16:55:22
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 1 1 100.0%
Branches: 3 6 50.0%

Line Branch Exec Source
1 #ifndef TERMINAL_STYLE_H
2 #define TERMINAL_STYLE_H
3
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <sys/types.h>
7 #include "util/macros.h"
8 #include "util/ptr-array.h"
9
10 #define COLOR_STR_BUFSIZE 16
11 #define TERM_STYLE_BUFSIZE 128
12
13 enum {
14 ATTR_KEEP = 0x01,
15 ATTR_UNDERLINE = 0x02,
16 ATTR_REVERSE = 0x04,
17 ATTR_BLINK = 0x08,
18 ATTR_DIM = 0x10,
19 ATTR_BOLD = 0x20,
20 ATTR_INVIS = 0x40,
21 ATTR_ITALIC = 0x80,
22 ATTR_STRIKETHROUGH = 0x100,
23 };
24
25 typedef struct {
26 int32_t fg;
27 int32_t bg;
28 unsigned int attr;
29 } TermStyle;
30
31 116 static inline bool same_style(const TermStyle *a, const TermStyle *b)
32 {
33
3/6
✓ Branch 0 (2→3) taken 116 times.
✗ Branch 1 (2→5) not taken.
✓ Branch 2 (3→4) taken 116 times.
✗ Branch 3 (3→5) not taken.
✗ Branch 4 (4→5) not taken.
✓ Branch 5 (4→6) taken 116 times.
116 return a->fg == b->fg && a->bg == b->bg && a->attr == b->attr;
34 }
35
36 ssize_t parse_term_style(TermStyle *style, char **strs, size_t nstrs) NONNULL_ARGS WARN_UNUSED_RESULT;
37 size_t color_to_str(char buf[COLOR_STR_BUFSIZE], int32_t color) NONNULL_ARGS WARN_UNUSED_RESULT;
38 const char *term_style_to_string(char buf[TERM_STYLE_BUFSIZE], const TermStyle *style) NONNULL_ARGS_AND_RETURN;
39 void collect_colors_and_attributes(PointerArray *a, const char *prefix) NONNULL_ARGS;
40
41 #endif
42