|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Full-book reader: per-chapter text extraction, word-wrap, pagination. More...
Go to the source code of this file.
Data Structures | |
| struct | sh_fold_t |
| One typographic-Unicode -> ASCII substitution. More... | |
Enumerations | |
| enum | sh_u8_t : uint32_t { k_sh_u8_ascii = 0x80U , k_sh_u8_lead2 = 0xC0U , k_sh_u8_lead3 = 0xE0U , k_sh_u8_lead4 = 0xF0U , k_sh_u8_mask2 = 0xE0U , k_sh_u8_mask3 = 0xF0U , k_sh_u8_mask4 = 0xF8U , k_sh_u8_data2 = 0x1FU , k_sh_u8_data3 = 0x0FU , k_sh_u8_cont = 0x3FU , k_sh_u8_repl = 0xFFFDU } |
| UTF-8 lead/continuation masks. More... | |
| enum | sh_u8_shift_t : uint8_t { k_sh_u8_sh6 = 6U , k_sh_u8_sh12 = 12U } |
| Continuation-byte shifts. More... | |
| enum | sh_content_const_t : uint32_t { k_sh_content_min = 1200U } |
| Front-matter skip threshold. More... | |
Functions | |
| static size_t | sh_utf8_decode (const uint8_t *s, size_t n, uint32_t *cp) |
Decode one UTF-8 sequence at s; sets cp, returns bytes consumed. | |
| static const char * | sh_fold_lookup (uint32_t cp) |
ASCII replacement for code point cp; "" to drop it. | |
| static void | sh_ascii_fold (void) |
| Fold sh_state_t::text in place from UTF-8 to ASCII. | |
| static size_t | sh_skip_word (size_t i) |
Skip the next word in the text at i; returns the index past it. | |
| static size_t | sh_wrap_line (size_t i, int32_t chars, size_t *ls, size_t *le) |
Wrap one line from i; store [*ls,*le); return the next index. | |
| static void | sh_reader_wrap (int32_t chars) |
| Greedy word-wrap sh_state_t::text into sh_state_t::lines. | |
| static uint32_t | sh_lines_per_page (void) |
| Reader lines that fit on one page. | |
| void | sh_reader_load_chapter (uint32_t chapter) |
| Load + wrap a chapter into the reader working set. | |
| uint32_t | sh_reader_first_content (void) |
| First chapter with substantial prose (skips title/imprint front matter). | |
| void | sh_reader_render (void) |
| Render the current reader page. | |
| bool | sh_reader_turn (int32_t dir) |
Turn the reader page by dir (-1/+1) across chapters; returns changed. | |
| void | sh_reader_prefetch_adjacent (void) |
| Read-ahead warm the adjacent chapters into the page cache (#207). | |
Variables | |
| static const sh_fold_t | k_sh_fold [] |
| Punctuation the ASCII bitmap font cannot draw, folded to ASCII. | |
Full-book reader: per-chapter text extraction, word-wrap, pagination.
Reads the open book chapter by chapter. For the current chapter it pulls the plain text (book_chapter_text), folds typographic Unicode the bitmap font cannot draw to ASCII, greedily word-wraps to the panel width, and paginates. Page turns advance within a chapter and cross chapter boundaries in either direction, so the whole book reads continuously – not just one chapter.
[Ring 6 / App] {World: NS}
Definition in file sh_reader.c.
| enum sh_content_const_t : uint32_t |
Front-matter skip threshold.
| Enumerator | |
|---|---|
| k_sh_content_min | Min chars to treat a chapter as readable prose. |
Definition at line 194 of file sh_reader.c.
| enum sh_u8_shift_t : uint8_t |
Continuation-byte shifts.
| Enumerator | |
|---|---|
| k_sh_u8_sh6 | One continuation byte. |
| k_sh_u8_sh12 | Two continuation bytes. |
Definition at line 59 of file sh_reader.c.
| enum sh_u8_t : uint32_t |
UTF-8 lead/continuation masks.
Definition at line 44 of file sh_reader.c.
|
static |
Fold sh_state_t::text in place from UTF-8 to ASCII.
Definition at line 97 of file sh_reader.c.
References g_sh, k_sh_u8_ascii, sh_fold_lookup(), and sh_utf8_decode().
Referenced by sh_reader_load_chapter().
|
static |
ASCII replacement for code point cp; "" to drop it.
Definition at line 86 of file sh_reader.c.
References k_sh_fold.
Referenced by sh_ascii_fold().
|
static |
Reader lines that fit on one page.
Definition at line 172 of file sh_reader.c.
References k_sh_bar_h, k_sh_fb_h, and k_sh_line_h.
Referenced by sh_reader_load_chapter(), and sh_reader_render().
| uint32_t sh_reader_first_content | ( | void | ) |
First chapter with substantial prose (skips title/imprint front matter).
Definition at line 198 of file sh_reader.c.
References g_sh, k_ra8_ok, k_sh_content_min, and sh_book_chapter_text().
Referenced by sh_start_reading().
| void sh_reader_load_chapter | ( | uint32_t | chapter | ) |
Load + wrap a chapter into the reader working set.
Definition at line 177 of file sh_reader.c.
References g_sh, k_ra8_ok, k_sh_fb_w, k_sh_pad, sh_ascii_fold(), sh_book_chapter_text(), sh_cells(), sh_lines_per_page(), and sh_reader_wrap().
Referenced by sh_reader_turn(), sh_start_reading(), and sh_tap_toc().
| void sh_reader_prefetch_adjacent | ( | void | ) |
Read-ahead warm the adjacent chapters into the page cache (#207).
Called in the reader's flush-idle window (after the panel flush, before the next input poll): a within-chapter page turn reads no new cache bytes (the chapter text is pre-extracted into sh_state_t::text), so the only demand faults happen when a turn crosses a chapter boundary. This warms chapter N+1 (forward reading) and N-1 (a back-flip) via book_src_prefetch_chapter() so that crossing finds them resident. Best-effort and transparent (warming never changes rendered output); a no-op unless a demand-paged .rabook is open.
Definition at line 282 of file sh_reader.c.
References book_src_prefetch_chapter(), g_sh, and k_sh_fmt_rabook.
Referenced by sh_present().
| void sh_reader_render | ( | void | ) |
Render the current reader page.
Definition at line 210 of file sh_reader.c.
References g_sh, k_sh_bar_h, k_sh_card_pad, k_sh_col_card, k_sh_col_ink, k_sh_line_h, k_sh_linebuf, k_sh_pad, memcpy(), ra8_gfx_clear(), ra8_gfx_font_8x16, ra8_gfx_text_out(), sh_fmt_uint(), sh_lines_per_page(), and sh_titlebar().
Referenced by sh_present().
| bool sh_reader_turn | ( | int32_t | dir | ) |
Turn the reader page by dir (-1/+1) across chapters; returns changed.
Definition at line 254 of file sh_reader.c.
References g_sh, and sh_reader_load_chapter().
Referenced by sh_demo_step(), sh_handle_button(), and sh_tap_reader().
|
static |
Greedy word-wrap sh_state_t::text into sh_state_t::lines.
Definition at line 154 of file sh_reader.c.
References g_sh, k_sh_max_lines, and sh_wrap_line().
Referenced by sh_reader_load_chapter().
|
static |
Skip the next word in the text at i; returns the index past it.
Definition at line 117 of file sh_reader.c.
References g_sh.
Referenced by sh_wrap_line().
|
static |
Decode one UTF-8 sequence at s; sets cp, returns bytes consumed.
Definition at line 65 of file sh_reader.c.
References k_sh_u8_ascii, k_sh_u8_cont, k_sh_u8_data2, k_sh_u8_data3, k_sh_u8_lead2, k_sh_u8_lead3, k_sh_u8_lead4, k_sh_u8_mask2, k_sh_u8_mask3, k_sh_u8_mask4, k_sh_u8_repl, k_sh_u8_sh12, and k_sh_u8_sh6.
Referenced by sh_ascii_fold().
|
static |
Wrap one line from i; store [*ls,*le); return the next index.
Definition at line 126 of file sh_reader.c.
References g_sh, and sh_skip_word().
Referenced by sh_reader_wrap().
|
static |
Punctuation the ASCII bitmap font cannot draw, folded to ASCII.
Definition at line 35 of file sh_reader.c.
Referenced by sh_fold_lookup().