From: NeilBrown Date: Fri, 23 Jun 2023 05:47:03 +0000 (+1000) Subject: renderline: allow Refresh to be handled. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=a479f7bde4bfb450c8cde7126d4eab0b360b20bc;p=edlib.git renderline: allow Refresh to be handled. If the requested z depth (at attach time) is >= 0, then Refresh messages will be sent. They can now be handled. The cursor pos for the refresh can now be set with renderline:set. This ->num is only used for Refresh. Signed-off-by: NeilBrown --- diff --git a/lib-renderline.c b/lib-renderline.c index 00f2b667..b8fa2991 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -47,6 +47,7 @@ struct rline_data { short curs_width; int scale; const char *line; + int curspos; }; enum { @@ -625,9 +626,10 @@ static void set_xypos(struct render_list *rlst, * The marked-up text to be processed has already been provided with * render-line:set. It is in rd->line; * ->num is <0, or an index into ->str where the cursor is, + * but is ignored for Refresh. which uses ->curspos for any cursor. * and the x,y co-ords will be stored in p->cx,p->cy - * If key is "render-line:draw", then send drawing commands, otherwise - * just perform measurements. + * If key is "render-line:draw" or "Refresh" then send drawing commands, + * otherwise just perform measurements. * If key is "render-line:findxy", then only measure until the position * in x,y is reached, then return an index into ->str of where we reached. * Store the attributes active at the time so they can be fetched later. @@ -638,9 +640,10 @@ DEF_CMD(renderline) struct rline_data *rd = p->data; struct pane *focus = ci->focus; const char *line = rd->line; - int dodraw = strcmp(ci->key, "render-line:draw") == 0; + int dodraw = (strcmp(ci->key, "render-line:draw") == 0 || + strcmp(ci->key, "Refresh") == 0); short posx; - short offset = ci->num; + short offset = strcmp(ci->key, "Refresh") == 0 ? rd->curspos : ci->num; int x = 0; int y = 0; const char *line_start; @@ -1133,6 +1136,7 @@ DEF_CMD(renderline_set) rd->line = cvt(strdup(ci->str)); else rd->line = NULL; + rd->curspos = ci->num; if (strcmp(rd->line ?:"", old ?:"") != 0 || (old && xyscale.x != rd->scale)) { pane_damaged(ci->home, DAMAGED_REFRESH); @@ -1164,6 +1168,7 @@ DEF_CMD(renderline_attach) if (!rl_map) { rl_map = key_alloc(); key_add(rl_map, "render-line:draw", &renderline); + key_add(rl_map, "Refresh", &renderline); key_add(rl_map, "render-line:measure", &renderline); key_add(rl_map, "render-line:findxy", &renderline); key_add(rl_map, "get-attr", &renderline_get); diff --git a/render-lines.c b/render-lines.c index e6a4ab8e..f9e20047 100644 --- a/render-lines.c +++ b/render-lines.c @@ -150,7 +150,7 @@ static void vmark_set(struct pane *p safe, struct mark *m safe, char *line safe) if (!m->mdata) m->mdata = call_ret(pane, "attach-renderline", p, -1); if (m->mdata) - pane_call(m->mdata, "render-line:set", p, 0, NULL, line); + pane_call(m->mdata, "render-line:set", p, -1, NULL, line); } static void vmark_invalidate(struct mark *m safe)