41typedef enum : uint8_t {
54typedef enum : uint16_t {
66typedef enum : uint32_t {
108 return (c ==
' ') || (c ==
'\t') || (c ==
'\n') || (c ==
'\r') || (c ==
'\f');
135 return (
char)(((c >=
'A') && (c <=
'Z')) ? (c + (
'a' -
'A')) : c);
164 if ((s ==
nullptr) || (lit ==
nullptr)) {
168 for (; (k < len) && (lit[k] !=
'\0'); ++k) {
173 return (k == len) && (lit[k] ==
'\0');
205 const size_t sl =
strlen(sub);
207 if ((s ==
nullptr) || (sl == 0U) || (sl > len)) {
211 for (
size_t i = 0U; (i + sl) <= len; ++i) {
214 for (
size_t j = 0U; j < sl; ++j) {
273 if ((c >=
'0') && (c <=
'9')) {
274 const int value = (int)c - (
int)
'0';
275 return (uint8_t)value;
278 if ((l >=
'a') && (l <=
'f')) {
280 return (uint8_t)value;
315 for (
size_t i = 0U; i < len; ++i) {
326 for (
size_t i = 0U; i < len; ++i) {
368 if ((s ==
nullptr) || (len == 0U)) {
436 while ((*i < len) && (s[*i] >=
'0') && (s[*i] <=
'9')) {
437 const int digit = (int)s[*i] - (
int)
'0';
443 if ((*i < len) && (s[*i] ==
'.')) {
448 while ((*i < len) && (s[*i] >=
'0') && (s[*i] <=
'9') && (fd < (
size_t)
k_priv_fs_frac)) {
449 const int digit = (int)s[*i] - (
int)
'0';
450 hund += (uint32_t)digit * place;
457 while ((*i < len) && (s[*i] >=
'0') && (s[*i] <=
'9')) {
532 const size_t rem = len - i;
538 if ((rem == 1U) && (s[i] ==
'%')) {
580 out->
set = (uint8_t)(out->
set | setbit);
581 out->
style = (uint8_t)(on ? (out->
style | stylebit) : (out->
style & (uint8_t)~stylebit));
780 while ((semi < len) && (s[semi] !=
';')) {
784 while ((colon < semi) && (s[colon] !=
':')) {
788 size_t plen = colon - i;
790 size_t vlen = semi - (colon + 1U);
792 if ((plen > 0U) && (vlen > 0U)) {
807 if ((decls ==
nullptr) || (out ==
nullptr)) {
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
size_t strlen(const char *s)
Calculate string length.
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
static uint8_t internal_hex_val(char c)
Hex value of one ASCII digit, or k_priv_hex_base if not a hex digit.
static bool internal_ci_contains(const char *s, size_t len, const char *sub)
Case-insensitive "span contains substring @p sub" (bounded scan).
priv_css_hex_t
Hex-colour parsing constants (#rgb / #rrggbb).
@ k_priv_hex_chan
Bits per colour channel.
@ k_priv_hex6_len
#rrggbb digit count.
@ k_priv_hex3_len
#rgb short-form digit count.
@ k_priv_hex_base
Base + "not a hex digit" sentinel.
@ k_priv_hex_nib
Bits per hex nibble.
@ k_priv_hex_a10
Value of hex 'a'/'A'.
ra8_err_t ra8_css_parse_inline(const char *decls, uint32_t len, ra8_css_style_t *out)
Parse an inline style="..." declaration body into one style.
static uint32_t internal_parse_hex_color(const char *s, size_t len)
Parse rgb / rrggbb hex digits (no #) to 0xRRGGBB, or invalid.
static uint16_t internal_fs_whole(uint32_t hund)
Clamp a hundredths value to a whole number in [0, k_priv_fs_max].
static uint32_t internal_parse_color(const char *s, size_t len)
Parse a CSS colour value (#rgb / #rrggbb / a named keyword).
void priv_reflow_css_parse_decls(const char *s, size_t len, ra8_css_style_t *out)
Parse a prop:value; ... declaration body (no braces) into out.
char priv_reflow_css_lower(char c)
ASCII-fold one byte to lower case.
static bool internal_apply_emphasis(const char *prop, size_t plen, const char *val, size_t vlen, ra8_css_style_t *out)
Apply a boolean-emphasis property (font-weight/style/decoration); false if other.
const char * priv_reflow_css_trim(const char *s, size_t *len)
Trim leading + trailing whitespace from s[0..*len); returns start.
priv_css_fs_t
font-size parsing constants (decimal + unit scaling).
@ k_priv_fs_pct1
Hundredths scale; 1em in percent.
@ k_priv_fs_dec
Decimal base.
@ k_priv_fs_frac
Fractional digits kept.
@ k_priv_fs_max
Clamp for a parsed font-size number.
@ k_priv_fs_ulen
Length of the "px" / "em" unit suffix.
bool priv_reflow_css_ci_eq(const char *s, size_t len, const char *lit)
Case-insensitive compare of span s[0..len) against NUL literal lit.
bool priv_reflow_css_is_ws(char c)
True for CSS whitespace (space / tab / newline / CR / FF).
static bool internal_parse_fontsize(const char *s, size_t len, uint16_t *out_val, uint8_t *out_unit)
Parse Npx / N% / Nem (N may be fractional) into value + unit.
static void internal_apply_decl(const char *prop, size_t plen, const char *val, size_t vlen, ra8_css_style_t *out)
Apply one trimmed prop:value pair to out, setting the matching bit.
priv_css_color_t
Common named CSS colours + the "not a colour" sentinel.
@ k_priv_col_black
CSS black.
@ k_priv_col_blue
CSS blue.
@ k_priv_col_maroon
CSS maroon.
@ k_priv_col_gray
CSS gray / grey.
@ k_priv_col_silver
CSS silver.
@ k_priv_col_navy
CSS navy.
@ k_priv_col_white
CSS white.
@ k_priv_col_green
CSS green.
@ k_priv_col_invalid
Sentinel: not a parseable colour.
static void internal_apply_align(const char *val, size_t vlen, ra8_css_style_t *out)
Apply a parsed text-align value to out.
static uint32_t internal_scan_hundredths(const char *s, size_t len, size_t *i, bool *any)
Scan a decimal number into hundredths (e.g.
static void internal_set_emphasis(ra8_css_style_t *out, uint8_t setbit, uint8_t stylebit, bool on)
Set or clear stylebit in out, marking setbit as present.
Minimal content-CSS cascade for the reflow ereader engine (#111).
@ k_ra8_css_set_fontsize
font-size was declared.
@ k_ra8_css_set_underline
text-decoration was declared.
@ k_ra8_css_set_align
text-align was declared.
@ k_ra8_css_set_display
display was declared.
@ k_ra8_css_set_bold
font-weight was declared.
@ k_ra8_css_set_italic
font-style was declared.
@ k_ra8_css_set_color
color was declared.
@ k_ra8_css_font_px
Value is an absolute pixel size.
@ k_ra8_css_font_pct
Value is a percentage of inherited px.
Cross-TU surface for the split content-CSS cascade (#111).
@ k_reflow_align_center
Centred.
@ k_reflow_align_justify
Justified (last line left-aligned).
@ k_reflow_align_right
Right-aligned.
@ k_reflow_align_left
Left (default, ragged right).
@ k_reflow_style_italic
Italic face.
@ k_reflow_style_bold
Bold face.
@ k_reflow_style_underline
Underlined run.
A declared or computed style: a presence mask plus property values.
uint16_t font_val
font-size number: px or % (valid iff set & fontsize).
uint8_t font_unit
ra8_css_font_unit_t (valid iff set & fontsize).
uint8_t display
1 = display:none (valid iff set & display).
uint8_t style
reflow_font_style_t bit VALUES (bold/italic/ul).
uint8_t set
ra8_css_set_t bitmask: which properties are present.
uint32_t color
0xRRGGBB text colour (valid iff set & color).
uint8_t align
reflow_align_t (valid iff set & align).