|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Syntax highlighting of one line of text: the spans of a line and the class of each, for the viewer to colour. More...
#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | text_hl_words_t |
| The verdict words, one list per class. Any list may be empty. More... | |
| struct | text_hl_unit_t |
| A unit of the table and the class of a number in it. More... | |
| struct | text_hl_span_t |
| A span of a line. More... | |
Macros | |
| #define | TEXT_HL_LABEL_CELLS 24u |
| Cells from column 0 a label's ":" or "=" stands in at most. | |
| #define | TEXT_HL_CLASS_ROWS(X) |
| Every class of a span, one row each: X(name, css, role). | |
| #define | TEXT_HL_CLASS_ENUM(name, css, role) |
| Expands a row of TEXT_HL_CLASS_ROWS to its enum entry. | |
| #define | TEXT_HL_UNIT_COUNT 20u |
| Rows of text_hl_units. | |
Enumerations | |
| enum | text_hl_class_t { TEXT_HL_CLASSES } |
| The class of a span, in the order of TEXT_HL_CLASS_ROWS. More... | |
| enum | text_hl_kind_t { TEXT_HL_KIND_TEXT = 0 , TEXT_HL_KIND_JSON = 1 , TEXT_HL_KIND_CSV = 2 , TEXT_HL_KIND_PLAIN = 3 } |
| How a file's lines are classed. The numbers are stable. More... | |
Functions | |
| 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. | |
| 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, a ".NEW" behind any of them taken off first; PLAIN for any other name. | |
| 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 taken off the front, then one pair of parentheses around it and a full stop behind it. | |
| const char * | text_hl_class_css (text_hl_class_t cls) |
| The style sheet's name of a class (TEXT_HL_CLASS_ROWS). | |
| text_hl_class_t | text_hl_unit_class (const char *unit, size_t len) |
| The class of a unit of the table. | |
Variables | |
| 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 mΩ Ω; mOhm for the reports of 0.22 and older. test_text_hl holds it to every unit the report formats of ui_text.def put behind a number. | |
Syntax highlighting of one line of text: the spans of a line and the class of each, for the viewer to colour.
A line is classed when it is drawn; nothing is stored. The spans cover the line from its first byte to its last, in order, without a gap; two neighbours never have the same class. A span starts and ends at an ASCII byte or at the line's ends, so it never splits a UTF-8 sequence.
Kinds, by the file's extension (text_hl_kind_of()):
TEXT every .TXT: the rules below, in this order:
Verdict words are the caller's: three lists of strings, one per class, which the screen builds from the report writers' text IDs in every language, so a report written in German on a panel showing English is classed the same, and a changed word in ui_text.def changes the classes with it. A word matches whole and in its case: "PASS" is no verdict in "PASSED" or as "pass". Where words overlap, the longest one at a place wins ("NICHT BESTANDEN" over "BESTANDEN"). Each string is matched by its core (text_hl_word_core()), so a writer's string with a label in front, parentheses around or a full stop behind gives the word itself.
Numbers: an optional sign, digits, and a "." with digits, at a place no letter, digit or "." is in front of, and ending at a place no "." with a digit follows. With a unit of the table behind, joined ("6.00V", "100mΩ") or after one space, number and unit are one span of the unit's class; a number without one is TEXT. A unit ends at a space, a punctuation mark or the line's end. A joined word that is no unit of the table ("6.00Volt", "5x") makes the whole no number: TEXT.
Pure C: no ui, no gfx, no text table.
SPDX-License-Identifier: MIT
| #define TEXT_HL_CLASS_ENUM | ( | name, | |
| css, | |||
| role ) |
Expands a row of TEXT_HL_CLASS_ROWS to its enum entry.
| #define TEXT_HL_CLASS_ROWS | ( | X | ) |
Every class of a span, one row each: X(name, css, role).
name is the class's enum name after TEXT_HL_; css a short name for the Wi-Fi page's style sheet; role the theme's colour role (ui_theme.h's ui_color_id_t) the screen and the page draw the class in. The rows' order gives the enum's numbers, which are stable: a new class goes at the end. This file and text_hl.c expand the first two columns only, so shared/files includes nothing of ui; a reader that expands role includes ui_theme.h. Light and dark palettes both hold every role.
| X | The row macro. |
| enum text_hl_class_t |
| enum text_hl_kind_t |
| const char * text_hl_class_css | ( | text_hl_class_t | cls | ) |
The style sheet's name of a class (TEXT_HL_CLASS_ROWS).
| cls | The class. |
| 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, a ".NEW" behind any of them taken off first; PLAIN for any other name.
| name | The file name; NULL is PLAIN. |
| 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.
With room for fewer spans than the line has, the last span the room holds is TEXT and reaches to the line's end.
| line | The line's bytes, without its line end. |
| len | Their count. |
| line_no | The line's index in the file, from 0. |
| kind | How the file is classed. |
| words | The verdict words; NULL for none. |
| out | Out: the spans. |
| cap | Room in out. |
cap 0. | text_hl_class_t text_hl_unit_class | ( | const char * | unit, |
| size_t | len ) |
The class of a unit of the table.
| unit | The unit's bytes. |
| len | Their count. |
| 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 taken off the front, then one pair of parentheses around it and a full stop behind it.
"Brown-out: not run" gives "not run", " (cut short)" "cut short", "Not run." "Not run".
| s | The string; NULL gives an empty word. |
| len | Out: bytes of the word. |
s.