skip to content
==> include/tui/paragraph.h <==
1/* @ajax/tui-paragraph: ratatui's Paragraph and its line composers (reflow.rs): WordWrapper, which
2 * breaks at whitespace and, with trim, drops leading whitespace of wrapped lines; and
3 * LineTruncator, which cuts each line at the width. */
4#ifndef TUI_PARAGRAPH_H
5#define TUI_PARAGRAPH_H
6
7#include "tui/block.h"
8
9enum { TUI_WRAP_NONE, TUI_WRAP_TRIM, TUI_WRAP_KEEP };
10
11typedef struct {
12    tui_text text;
13    const tui_block *block; /* optional */
14    tui_style style;
15    int wrap;                /* TUI_WRAP_* */
16    uint16_t scroll_y, scroll_x;
17    int8_t alignment;        /* TUI_ALIGN_LEFT by default (a line's own wins) */
18} tui_paragraph;
19
20static inline tui_paragraph tui_paragraph_new(tui_text t) {
21    tui_paragraph p = {0};
22    p.text = t;
23    p.alignment = TUI_ALIGN_LEFT;
24    return p;
25}
26
27void tui_paragraph_render(tui_arena *a, const tui_paragraph *p, tui_rect area, tui_buffer *buf);
28
29#endif