]> git.neil.brown.name Git - edlib.git/commitdiff
Track and report actual displayed size
authorNeilBrown <neil@brown.name>
Fri, 7 Jul 2023 03:13:11 +0000 (13:13 +1000)
committerNeilBrown <neil@brown.name>
Wed, 12 Jul 2023 22:17:52 +0000 (08:17 +1000)
render:reposition messages now contain more accurate columns
information, and are generated whenever it is updated.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/Developer/06-rendering.md
DOC/TODO.md
lib-renderline.c
lib-view.c
render-lines.c

index f51c2ed59a0317438fe0eb4f25dc5dbb5483dfd0..a49aa5aab581bc667cf841e6d68e35c8d0c661a8 100644 (file)
@@ -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
index ac0d3f940b72a42f08620aff110483faf42c7311..a347b6e31ff5a0c14b7266ff5098f0eed145c37b 100644 (file)
@@ -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??
 
index b8fa299107ef45b71c8061e11f158e7c3a613bc0..18ecc7ff72ae8e7b401b98e8f88237e801b0ebee 100644 (file)
@@ -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
index 87e08fb2d40f9ca1cb19c7f808511b78d3e79fa6..53fa807c6edf5f45174efb862aa352fae4a475e2 100644 (file)
@@ -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);
index 607f162707d377cef4b53ac8f6ffcd79e7af3fd1..d6747ec9ccbfb57061ef3ee62781abf164892ef2 100644 (file)
@@ -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;
 }