33 void init(
const char* title,
const char* src,
size_t len);
44 void initPlain(
const char* title,
const char* src,
size_t len);
49 void render(
bool partial)
override;
53 const char*
getName()
const override {
return "MarkdownView"; }
88 using CheckSaveFn = void (*)(
void* ud,
const char* cp437Source,
size_t len);
101 void mdRowInfo(uint16_t i,
const char*& text, uint16_t& len,
bool& first,
102 uint32_t& srcOff)
const;
112 static constexpr uint16_t MAX_TITLE_LEN = 64;
113 static constexpr uint16_t MAX_INTERACT = 256;
114 static constexpr size_t kLinkPoolCap = 8192;
126 char titleBuf_[MAX_TITLE_LEN];
129 uint16_t rowCount_ = 0;
130 uint16_t scrollRow_ = 0;
131 bool truncated_ =
false;
133 int textAreaWidth_ = 0;
134 int highlightRow_ = -1;
137 uint16_t interactCount_ = 0;
138 int interactSel_ = -1;
140 void* checkSaveUd_ =
nullptr;
147 uint16_t linkPoolLen_ = 0;
148 uint16_t inlineLinkCount_ = 0;
150 void addRow(
const char* text, uint16_t len, uint8_t font, uint8_t indent,
152 uint16_t visibleRowCount()
const;
153 void rewriteInlineLinks();
154 void drawStyledRow(
void* gfx,
const char* text, uint16_t len,
int x,
int yTop,
165MarkdownView*
showMarkdown(
const char* title,
const char* src,
size_t len);
174MarkdownView*
showPlainText(
const char* title,
const char* src,
size_t len);
Shared RAII wrappers for firmware resources.
Scrollable viewer that renders a Markdown source.
void initPlain(const char *title, const char *src, size_t len)
Loads a source as plain, unrendered text (no Markdown parsing).
uint16_t mdRowCount() const
const char * getFooterHint() const override
void cycleInteractive(int dir)
Move the interactive selection by dir (+1/-1), highlighting its row.
void selectMarker(uint16_t linkNum)
Highlight the row containing the inline marker "[linkNum]" and scroll it into view....
void fireCheckSave()
Run the persistence callback with the current source (if set).
void setCheckSave(CheckSaveFn fn, void *ud)
void addInteract(uint16_t row, Interact kind, uint16_t id, uint32_t srcOff)
void clearSelection()
Clear the current interactive selection.
const char * getName() const override
static constexpr uint32_t MAX_SOURCE
Source byte cap.
void init(const char *title, const char *src, size_t len)
Loads and lays out a Markdown source.
virtual void rebuildInteractive()
Rebuild the interactive-element list from the rendered rows. Base finds task-list checkboxes; subclas...
uint16_t interactiveCount() const
Number of interactive elements on the page.
void(*)(void *ud, const char *cp437Source, size_t len) CheckSaveFn
Persistence callback fired after a task-list checkbox toggles. Receives the full modified CP437 sourc...
void mdRowInfo(uint16_t i, const char *&text, uint16_t &len, bool &first, uint32_t &srcOff) const
InputResult onKey(char key) override
virtual void activateSelected()
Activate the selected element (Y). Base toggles checkboxes.
void appendParsed(const StyledLine &line)
Sink callback: wraps one parsed styled line into visual rows.
static constexpr uint16_t MAX_ROWS
Visual-row cap.
const InteractRef * selectedRef() const
InputResult onLongPress(char key) override
Interact
Interactive element kinds the view can select (4/6) and activate (Y).
bool flipCheckChar(uint32_t srcOff)
Toggle a checkbox state char in the source.
std::unique_ptr< T[], CapsFreeDeleter > PsramUniquePtr
Centralized key-code constants for cdc_views.
MarkdownView * showMarkdown(const char *title, const char *src, size_t len)
Parses and shows a Markdown source on the view stack.
MdLineKind
Block role of a styled line, used by the view to apply layout/markers.
MarkdownView * showPlainText(const char *title, const char *src, size_t len)
Shows a source as plain, unrendered text on the view stack.
One selectable interactive element discovered in the rendered rows.
uint16_t id
Link: 1-based marker number; Check/Submit: ordinal.
uint16_t row
Visual row index (highlight/scroll target).
uint32_t srcOff
Check: byte offset of the state char in the source; else 0.
One rendered logical line produced by the Markdown parser.