30#define WRAP_NO_SPACE ((size_t)-1)
51 size_t line_start = 0, k = 0, lines = 0;
54 double at_space = 0.0;
55 double pre_space = 0.0;
65 emit(line_start, k, lines, cur, user);
76 if (cur + it->
width > max_width && k > line_start) {
83 emit(line_start, k, lines, cur, user);
94 emit(line_start, last_space, lines, pre_space, user);
95 line_start = last_space + 1;
99 emit(line_start, k, lines, cur, user);
118 if (emit && count > line_start)
119 emit(line_start, count, lines, cur, user);
141 for (k = first; k <
last; k++) {
179 if (!items || count == 0)
186 if (line_height > 0.0) {
187 double l = y / line_height;
188 if (l >= (
double)lines)
212 size_t s = first > sp->
lo ? first : sp->
lo;
219 for (k = first; k < s; k++)
222 for (k = s; k < e; k++)
251 if (!items || count == 0)
static N_GUI_MOUSE_EVENT last
the last event the widget was told of, and how many
void line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
draw a line
static void wrap_hit_line(size_t first, size_t last, size_t line, double width, void *user)
size_t n_wrap_layout(const n_wrap_item *items, size_t count, double max_width, n_wrap_emit emit, void *user)
Break items into lines no wider than max_width.
#define WRAP_NO_SPACE
no break point seen on the current line
size_t n_wrap_span_rects(const n_wrap_item *items, size_t count, double max_width, size_t lo, size_t hi, n_wrap_rect_emit emit, void *user)
The rectangles that cover the items [lo, hi): one per line the range touches, in order,...
static void wrap_span_line(size_t first, size_t last, size_t line, double width, void *user)
const n_wrap_item * items
const n_wrap_item * items
size_t n_wrap_index_at(const n_wrap_item *items, size_t count, double max_width, double line_height, double x, double y)
The item boundary nearest a point: the inverse of n_wrap_layout(), for turning a click or a drag into...
state for n_wrap_index_at's per-line callback
state for n_wrap_span_rects' per-line callback
Greedy word-wrap over pre-measured, styled items.
#define N_WRAP_SPACE
the item is a legal break point (typically a space); it is DROPPED when a line breaks there,...
void(* n_wrap_rect_emit)(size_t line, double x0, double x1, void *user)
Called once per line that a span covers, by n_wrap_span_rects().
#define N_WRAP_NEWLINE
the item is a hard line break; it ends the line and occupies no cell
double width
advance width in the caller's units (pixels, columns, ...)
unsigned int flags
N_WRAP_SPACE / N_WRAP_NEWLINE, or 0
void(* n_wrap_emit)(size_t first, size_t last, size_t line, double width, void *user)
Called once per laid-out line, in order.
One pre-measured layout item: a glyph, an emoji cell, an inline image, or a whole word,...