]> git.neil.brown.name Git - edlib.git/commitdiff
Change render-line command to accept point in 'mark2' instead of 'ptp'.
authorNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 04:36:02 +0000 (15:36 +1100)
committerNeilBrown <neil@brown.name>
Thu, 26 Nov 2015 05:25:40 +0000 (16:25 +1100)
And get rid of point pointp stuff.

Signed-off-by: NeilBrown <neil@brown.name>
doc-text.c
render-complete.c
render-format.c
render-hex.c
render-lines.c

index dfbb6dae68c20bcaa3769391f053f4e0c6a61bd8..aeab50aca02f0ff8e0bec4d3b31205b13e02eb7a 100644 (file)
@@ -1591,16 +1591,15 @@ DEF_CMD(render_line)
         * include that between '<>'.
         */
        struct buf b;
-       struct point **ptp = ci->pointp;
-       struct doc *d;
+       struct doc *d = ci->home->data;
        struct mark *m = ci->mark;
+       struct mark *pm = ci->mark2; /* The location to render as focus */
        int o = ci->numeric;
        wint_t ch = WEOF;
        int chars = 0;
 
-       if (!m || !ptp)
+       if (!m)
                return -1;
-       d = (*ptp)->doc;
 
        buf_init(&b);
        while (1) {
@@ -1608,7 +1607,7 @@ DEF_CMD(render_line)
                int offset = m->ref.o;
                if (o >= 0 && b.len >= o)
                        break;
-               if (o == -1 && mark_same(d, m, &(*ptp)->m))
+               if (pm && mark_same(d, m, pm))
                        break;
                ch = mark_next(d, m);
                if (ch == WEOF)
index 1fd8a6f418c0df5873e92925edb740fc717d5b8b..81c67cb9f6618ac53e6c89b87292efae7d408fd3 100644 (file)
@@ -29,15 +29,16 @@ DEF_CMD(render_complete_line)
         */
        struct cmd_info ci2 = {0};
        struct complete_data *cd = ci->home->data;
-       struct doc *d;
+       struct pane *dp = doc_get_pane(ci->home);
+       struct doc *d = dp ? dp->data : NULL;
        int plen;
 
-       if (!ci->pointp || !ci->mark)
+       if (!d || !ci->mark)
                return -1;
-       d = (*ci->pointp)->doc;
+
        ci2.key = ci->key;
        ci2.mark = ci->mark;
-       ci2.pointp = ci->pointp;
+       ci2.mark2 = ci->mark2;
        ci2.focus = ci->home->parent;
        ci2.numeric = ci->numeric;
        if (key_handle(&ci2) == 0)
@@ -83,7 +84,6 @@ DEF_CMD(render_complete_prev)
 
        ci3.key= "render-line";
        ci3.focus = ci->home->parent;
-       ci3.pointp = ci->pointp;
        while (1) {
                int cmp;
 
@@ -174,7 +174,6 @@ DEF_CMD(complete_eol)
                ci2.key = "render-line";
                ci2.numeric = NO_NUMERIC;
                ci2.mark = ci->mark;
-               ci2.pointp = ci->pointp;
                ci2.focus = ci->focus;
                ci2.home = ci->home;
                if (render_complete_line_func(&ci2) < 0)
@@ -260,7 +259,6 @@ DEF_CMD(complete_return)
        ci2.focus = ci->home;
        ci2.home = ci->home;
        ci2.mark = &(*ci->pointp)->m;
-       ci2.pointp = ci->pointp;
        ci2.numeric = NO_NUMERIC;
        render_complete_line_func(&ci2);
        str = ci2.str;
index fcf6d6f95f06097d296ee3089ec22358b068c3b8..9f8f7e66c2a9734667ddefac855865b8ccd344a0 100644 (file)
@@ -27,20 +27,20 @@ DEF_CMD(render_line)
        char *body = pane_attr_get(ci->focus, "line-format");
        struct rf_data *rf = ci->home->data;
        struct buf ret;
-       struct doc *d;
+       struct pane *dp = doc_get_pane(ci->home);
+       struct doc *d = dp ? dp->data : NULL;
        struct mark *m = ci->mark;
+       struct mark *pm = ci->mark2;
        char *n;
        wint_t ch;
        int home;
        int field = 0;
 
-       if (!ci->pointp || !ci->mark)
+       if (!d || !ci->mark)
                return -1;
 
-       d = (*ci->pointp)->doc;
-       if (RPT_NUM(ci) < 0 &&
-           !mark_same(d, &(*ci->pointp)->m, m))
-               ci->numeric = NO_NUMERIC;
+       if (pm && !mark_same(d, pm, m))
+               pm = NULL;
        ch = doc_following(d, m);
        if (ch == WEOF) {
                ci->str = NULL;
@@ -52,8 +52,7 @@ DEF_CMD(render_line)
                body = "%+name";
        n = body;
        m->rpos = field - rf->home_field;
-       if (RPT_NUM(ci) < 0 &&
-           (*ci->pointp)->m.rpos == m->rpos)
+       if (pm && pm->rpos == m->rpos)
                goto endwhile;
        if (ci->numeric != NO_NUMERIC && ci->numeric >= 0 &&
            ret.len >= ci->numeric)
@@ -76,8 +75,7 @@ DEF_CMD(render_line)
                if (ci->numeric != NO_NUMERIC && ci->numeric >= 0 &&
                    ret.len >= ci->numeric)
                        break;
-               if (RPT_NUM(ci) < 0 &&
-                   (*ci->pointp)->m.rpos == m->rpos)
+               if (pm && pm->rpos == m->rpos)
                        break;
                n += 1;
                if (*n == '+') {
@@ -138,8 +136,7 @@ endwhile:
                rf->fields = field;
                rf->home_field = home;
                m->rpos = field + 1 - rf->home_field;
-               if (RPT_NUM(ci) < 0 &&
-                   (*ci->pointp)->m.rpos == m->rpos)
+               if (pm && pm->rpos == m->rpos)
                        ;
                else if (ci->numeric >= 0 && ci->numeric != NO_NUMERIC)
                        ;
index 265b3172931ed52e05ab7d29a2dd5ded12ac2e3f..3f43ad6370d89b13276bae04f8869cfc2da222f1 100644 (file)
@@ -121,17 +121,18 @@ DEF_CMD(render_hex_eol)
 DEF_CMD(render_line)
 {
        struct buf ret;
-       struct point **ptp = ci->pointp;
-       struct doc *d;
        struct cmd_info ci2 = {0};
        struct mark *m = NULL;
+       struct pane *dp = doc_get_pane(ci->home);
+       struct doc *d = dp ? dp->data : NULL;
+       struct mark *pm = ci->mark2;
        int pos;
        int i;
        char buf[10];
 
-       if (!ptp || !ci->mark)
+       if (!d || !ci->mark)
                return -1;
-       d = (*ptp)->doc;
+
        ci2.key = "CountLines";
        ci2.home = ci2.focus = ci->home;
        ci2.mark = ci->mark;
@@ -148,8 +149,7 @@ DEF_CMD(render_line)
                wint_t ch;
                struct mark *m2 = ci->mark;
 
-               if (ci->numeric == -1 &&
-                   mark_same(d, m2, &(*ptp)->m))
+               if (pm && mark_same(d, m2, pm))
                        goto done;
                if (ci->numeric >= 0 && ci->numeric != NO_NUMERIC &&
                    ci->numeric <= ret.len)
index 92ceaa1b16edbe4fa0dd24cc2e365fd65c78f03b..65fc91f381dd30386b662cbded6bfe64805e3749 100644 (file)
@@ -299,7 +299,6 @@ static struct mark *call_render_line(struct pane *p, struct point **ptp,
 
        ci.key = "render-line";
        ci.focus = p;
-       ci.pointp = ptp;
        ci.mark = mark_dup(&start->m, 0);
        ci.numeric = NO_NUMERIC;
        /* Allow for filling the rest of the pane, given that
@@ -340,7 +339,6 @@ static struct mark *call_render_line_offset(struct pane *p, struct point **ptp,
 
        ci.key = "render-line";
        ci.focus = p;
-       ci.pointp = ptp;
        ci.mark = mark_dup(&start->m, 0);
        ci.numeric = offset;
        if (key_handle(&ci) == 0) {
@@ -359,7 +357,7 @@ static int call_render_line_to_point(struct pane *p, struct point **ptp,
 
        ci.key = "render-line";
        ci.focus = p;
-       ci.pointp = ptp;
+       ci.mark2 = &(*ptp)->m;
        ci.mark = mark_dup(&start->m, 0);
        ci.numeric = -1;
        if (key_handle(&ci) == 0) {