From: NeilBrown Date: Sun, 13 Aug 2023 06:25:55 +0000 (+1000) Subject: lib-renderline: factor out draw_wrap() X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=357875a1f403460711ddab1b83bf96b0b42375c2;p=edlib.git lib-renderline: factor out draw_wrap() Drawing the line-wrap markers doesn't need all the complexity of do_draw(), so factor it out into a separate function. Signed-off-by: NeilBrown --- diff --git a/lib-renderline.c b/lib-renderline.c index ae9a95dd..d0707d85 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -519,6 +519,19 @@ static inline void do_draw(struct pane *p safe, str[len] = tmp; } +static inline void draw_wrap(struct pane *p safe, + struct pane *focus safe, + char *str safe, + int x, int y) +{ + struct rline_data *rd = &p->data; + + home_call(focus, "Draw:text", p, + -1, NULL, str, + rd->scale, NULL, rd->wrap_attr, + x, y + rd->ascent); +} + static void add_split(struct render_item *ri safe, int split) { int i = ri->split_cnt; @@ -823,14 +836,11 @@ static void draw_line(struct pane *p safe, struct pane *focus safe, int offset) !ri->next->eol && ri->next->y != ri->y) { /* we are about to wrap - draw the markers */ if (*wrap_tail) - do_draw(p, focus, wrap_tail, -1, 0, -1, - rd->wrap_attr, - p->w - rd->tail_length, - y); + draw_wrap(p, focus, wrap_tail, + p->w - rd->tail_length, y); if (*wrap_head) - do_draw(p, focus, wrap_head, -1, 0, -1, - rd->wrap_attr, - 0, y + rd->line_height); + draw_wrap(p, focus, wrap_head, + 0, y + rd->line_height); } while (split < ri->split_cnt || @@ -838,15 +848,12 @@ static void draw_line(struct pane *p safe, struct pane *focus safe, int offset) /* line wrap here */ /* don't show head/tail for wrap-regions */ if (*wrap_tail /*&& !ri->wrap*/) - do_draw(p, focus, wrap_tail, -1, 0, -1, - rd->wrap_attr, - p->w - rd->tail_length, - y); + draw_wrap(p, focus, wrap_tail, + p->w - rd->tail_length, y); y += rd->line_height; if (*wrap_head /*&& !ri->wrap*/) - do_draw(p, focus, wrap_head, -1, 0, -1, - rd->wrap_attr, - 0, y); + draw_wrap(p, focus, wrap_head, + 0, y); if (ri->split_list && split < ri->split_cnt) { int end = ri->len; char *str = rd->line + ri->start + ri->split_list[split];