rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
text_hl.h
Go to the documentation of this file.
1
56
57#pragma once
58
59#include <stddef.h>
60#include <stdint.h>
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
67#define TEXT_HL_LABEL_CELLS 24u
68
82#define TEXT_HL_CLASS_ROWS(X) \
83 X(TEXT, "tx", UI_C_TEXT) /* plain text */ \
84 X(HEADING, "hd", UI_C_ACCENT) /* a title or section heading */ \
85 X(LABEL, "lb", UI_C_TEXT_DIM) /* "Label:" or "name =" */ \
86 X(OK, "ok", UI_C_OK) /* a word of the OK list */ \
87 X(FAIL, "fl", UI_C_DANGER) /* a word of the FAIL list */ \
88 X(WARN, "wn", UI_C_WARN) /* a word of the WARN list */ \
89 X(VOLT, "vo", UI_C_VOLT) /* a number in V or mV */ \
90 X(CURR, "cu", UI_C_CURR) /* a number in A or mA */ \
91 X(POWER, "pw", UI_C_POWER) /* a number in W */ \
92 X(RATE, "rt", UI_C_RPM) /* a number in rpm or Hz */ \
93 X(UNIT, "un", UI_C_TEAL) /* a number in another unit */ \
94 X(COMMENT, "cm", UI_C_TEXT_FAINT) /* "#" to the line's end */ \
95 X(HEX, "hx", UI_C_TEXT_DIM) /* register, checksum, journal */ \
96 X(KEY, "ky", UI_C_TEXT_DIM) /* a JSON key */ \
97 X(NUMBER, "nm", UI_C_TEAL) /* a JSON number */ \
98 X(LITERAL, "lt", UI_C_LILAC) /* JSON true, false, null */ \
99 X(PUNCT, "pu", UI_C_TEXT_FAINT) /* JSON marks, CSV delimiters */ \
100 X(CSV_HEAD, "ch", UI_C_ACCENT) /* a CSV header cell */
101
103#define TEXT_HL_CLASS_ENUM(name, css, role) TEXT_HL_##name,
104
110
118
120typedef struct {
121 const char *const *ok;
122 size_t ok_n;
123 const char *const *fail;
124 size_t fail_n;
125 const char *const *warn;
126 size_t warn_n;
128
130typedef struct {
131 const char *unit;
134
136#define TEXT_HL_UNIT_COUNT 20u
137
145
147typedef struct {
148 uint32_t start;
149 uint32_t len;
150 uint8_t cls;
152
168size_t text_hl_line(const char *line, size_t len, size_t line_no,
169 text_hl_kind_t kind, const text_hl_words_t *words,
170 text_hl_span_t *out, size_t cap);
171
180text_hl_kind_t text_hl_kind_of(const char *name);
181
194const char *text_hl_word_core(const char *s, size_t *len);
195
202const char *text_hl_class_css(text_hl_class_t cls);
203
212text_hl_class_t text_hl_unit_class(const char *unit, size_t len);
213
214#ifdef __cplusplus
215}
216#endif
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
A span of a line.
Definition text_hl.h:147
uint32_t start
Definition text_hl.h:148
uint32_t len
Definition text_hl.h:149
uint8_t cls
Definition text_hl.h:150
A unit of the table and the class of a number in it.
Definition text_hl.h:130
text_hl_class_t cls
Definition text_hl.h:132
const char * unit
Definition text_hl.h:131
The verdict words, one list per class. Any list may be empty.
Definition text_hl.h:120
const char *const * ok
Definition text_hl.h:121
size_t warn_n
Definition text_hl.h:126
size_t fail_n
Definition text_hl.h:124
size_t ok_n
Definition text_hl.h:122
const char *const * fail
Definition text_hl.h:123
const char *const * warn
Definition text_hl.h:125
text_hl_class_t
The class of a span, in the order of TEXT_HL_CLASS_ROWS.
Definition text_hl.h:106
@ TEXT_HL_CLASSES
Definition text_hl.h:108
const char * text_hl_word_core(const char *s, size_t *len)
The word a writer's string gives: spaces taken off both ends, a "Label:" and the spaces after it take...
Definition text_hl.c:184
#define TEXT_HL_UNIT_COUNT
Rows of text_hl_units.
Definition text_hl.h:136
text_hl_kind_t
How a file's lines are classed. The numbers are stable.
Definition text_hl.h:112
@ TEXT_HL_KIND_JSON
Definition text_hl.h:114
@ TEXT_HL_KIND_TEXT
Definition text_hl.h:113
@ TEXT_HL_KIND_PLAIN
Definition text_hl.h:116
@ TEXT_HL_KIND_CSV
Definition text_hl.h:115
#define TEXT_HL_CLASS_ROWS(X)
Every class of a span, one row each: X(name, css, role).
Definition text_hl.h:82
const char * text_hl_class_css(text_hl_class_t cls)
The style sheet's name of a class (TEXT_HL_CLASS_ROWS).
Definition text_hl.c:276
text_hl_kind_t text_hl_kind_of(const char *name)
How a file is classed, by its name: ".json" JSON, ".csv" CSV, ".txt" TEXT, in any case,...
Definition text_hl.c:769
size_t text_hl_line(const char *line, size_t len, size_t line_no, text_hl_kind_t kind, const text_hl_words_t *words, text_hl_span_t *out, size_t cap)
The spans of one line.
Definition text_hl.c:700
#define TEXT_HL_CLASS_ENUM(name, css, role)
Expands a row of TEXT_HL_CLASS_ROWS to its enum entry.
Definition text_hl.h:103
const text_hl_unit_t text_hl_units[TEXT_HL_UNIT_COUNT]
The units a number may carry, case as written: V mV A mA W rpm Hz us ms s /s deg Grad % mOhm B kB MB ...
Definition text_hl.c:27
text_hl_class_t text_hl_unit_class(const char *unit, size_t len)
The class of a unit of the table.
Definition text_hl.c:262