From: NeilBrown Date: Fri, 7 Jul 2023 03:13:11 +0000 (+1000) Subject: Track and report actual displayed size X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=9328a474fabba6176a667d6e5e2b7fcaf4b119ec;p=edlib.git Track and report actual displayed size render:reposition messages now contain more accurate columns information, and are generated whenever it is updated. Signed-off-by: NeilBrown --- diff --git a/DOC/Developer/06-rendering.md b/DOC/Developer/06-rendering.md index f51c2ed5..a49aa5aa 100644 --- a/DOC/Developer/06-rendering.md +++ b/DOC/Developer/06-rendering.md @@ -168,11 +168,17 @@ map mouse clicks to locations in the document. When "render-lines" determines the range of lines that will fit on the display is sends a "render:reposition" message to the whole stack with -marks for the start and end of the visible range. This message is -normally only sent when there is a change to report. However other -panes can request the information by sending "render:request:reposition" -which will cause the "render:reposition" message to be send on the next -refresh. +marks for the start and end of the visible range. The number of rows +and columns displays are also reported as num and num2. These can be +less than the height and width of the pane, but not more. The are +calculated at a different time to the start and end marks and so can +result in a separate "render:reposition" message which doesn't contain +the marks. + +This message is normally only sent when there is a change to report. +However other panes can request the information by sending +"render:request:reposition" which will cause the "render:reposition" +message to be send on the next refresh. "render-lines" listens for "doc:replaced" notification from the document and will update the display of anything that has changed. It also diff --git a/DOC/TODO.md b/DOC/TODO.md index ac0d3f94..a347b6e3 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -504,6 +504,7 @@ Module features ### doc-email +- [ ] if charset module doesn't load, things go very bad. (utf-8 failure) - [ ] use mimetypes.guess_type() to interpret filenames in email attachments?? - [ ] don't allow non-text email parts to appear as text. Maybe hex?? diff --git a/lib-renderline.c b/lib-renderline.c index b8fa2991..18ecc7ff 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -46,6 +46,7 @@ struct rline_data { const char *cursattr; short curs_width; int scale; + int width; const char *line; int curspos; }; @@ -1053,6 +1054,7 @@ DEF_CMD(renderline) * be out-of-sync with display manager. */ pane_resize(p, p->x, p->y, p->w, y); + rd->width = margin + twidth; attr_set_int(&p->attrs, "line-height", line_height); while (rlst) { struct render_list *r = rlst; @@ -1084,6 +1086,8 @@ DEF_CMD(renderline_get) snprintf(buf, sizeof(buf), "%d", rd->curs_width); else if (strcmp(ci->str, "xyattr") == 0) val = rd->xyattr; + else if (strcmp(ci->str, "width") == 0) + snprintf(buf, sizeof(buf), "%d", rd->width); else if (strcmp(ci->str, "cursattr") == 0) val = rd->cursattr; else diff --git a/lib-view.c b/lib-view.c index 87e08fb2..53fa807c 100644 --- a/lib-view.c +++ b/lib-view.c @@ -378,7 +378,7 @@ DEF_CMD(view_reposition) struct view_data *vd = ci->home->data; if (!ci->mark) - return Enoarg; + return Efallthrough; if (!vd->viewpoint || !mark_same(vd->viewpoint, ci->mark)) { pane_damaged(ci->home, DAMAGED_REFRESH); diff --git a/render-lines.c b/render-lines.c index 607f1627..d6747ec9 100644 --- a/render-lines.c +++ b/render-lines.c @@ -897,7 +897,7 @@ static int render(struct mark *pm, struct pane *p safe, draw_line(p, focus, m, -1, refresh_all); } if (m->mdata) { - int cols = m->mdata->x + m->mdata->w; + int cols = pane_attr_get_int(m->mdata, "width", 0); if (cols > rl->cols) rl->cols = cols; y = m->mdata->y + m->mdata->h; @@ -1272,6 +1272,8 @@ DEF_CMD(render_lines_refresh) struct pane *focus = ci->focus; struct rl_data *rl = p->data; struct mark *m, *pm = NULL; + int cols = rl->cols; + int lines = rl->lines; //pane_damaged(p, DAMAGED_VIEW); @@ -1283,6 +1285,8 @@ DEF_CMD(render_lines_refresh) return 1; rl->lines = render(pm, p, focus); + if (rl->lines != lines || rl->cols != cols) + call("render:reposition", focus, rl->lines, NULL, NULL, rl->cols); return 1; }