]> git.neil.brown.name Git - edlib.git/commitdiff
lines: some improvements to page up/down
authorNeilBrown <neil@brown.name>
Sun, 24 Jan 2016 22:14:28 +0000 (09:14 +1100)
committerNeilBrown <neil@brown.name>
Sun, 24 Jan 2016 22:14:28 +0000 (09:14 +1100)
move-view-large assumed lines were '1' high.
Now it knows a bit about line height, but there are still some issues.

Signed-off-by: NeilBrown <neil@brown.name>
render-lines.c

index bff324304012893e601c2f4c4b0f0af450c58cc2..1085c5e8520347f822b9c3ddd6c4e3b3d756a952 100644 (file)
@@ -96,6 +96,7 @@ struct rl_data {
        struct command  type;
        int             typenum;
        struct pane     *pane;
+       int             line_height;
 };
 
 DEF_CMD(text_size_callback)
@@ -235,6 +236,7 @@ static void render_line(struct pane *p, char *line, int *yp, int dodraw,
                draw_some(p, &x, dodraw?y+ascent:-1, prefix, &s, "bold", 0, -1, -1);
        }
        rl->prefix_len = x;
+       rl->line_height = line_height;
 
        buf_init(&attr);
        buf_append(&attr, ' '); attr.len = 0;
@@ -840,13 +842,13 @@ DEF_CMD(render_lines_move)
        int rpt = RPT_NUM(ci);
        struct rl_data *rl = p->data;
        struct mark *top;
-       int pagesize = 1;
+       int pagesize = rl->line_height;
 
        top = vmark_first(p, rl->typenum);
        if (!top)
                return 0;
        if (strcmp(ci->key, "Move-View-Large") == 0)
-               pagesize = p->h - 2;
+               pagesize = p->h - 2 * rl->line_height;
        rpt *= pagesize;
 
        rl->ignore_point = 1;
@@ -887,9 +889,9 @@ DEF_CMD(render_lines_move)
                                break;
                        }
                        top = vmark_next(top);
-                       if ((rpt+pagesize-1)/pagesize !=
-                           (rpt+pagesize-y-1)/pagesize)
-                               /* Have cross a full page, can discard old lines */
+                       if ((rpt+pagesize-rl->line_height)/pagesize !=
+                           (rpt+pagesize-y-rl->line_height)/pagesize)
+                               /* Have crossed a full page, can discard old lines */
                                while ((old = vmark_first(p, rl->typenum)) != NULL &&
                                       old != top) {
                                        free(old->mdata);