]> git.neil.brown.name Git - edlib.git/blobdiff - lib-renderline.c
TODO: clean out done items.
[edlib.git] / lib-renderline.c
index c5108de0b15a434f12a65cbd0f44e47a08cc59e7..e5d8169aaa951529a5b7c839ac2d17df2eeff07e 100644 (file)
@@ -63,7 +63,6 @@
  *                       recognised has "wrap-" stripped and is used for the
  *                       head and tail. Default is fg:blue,underline
  *  hide               - Text is hidden if cursor is not within range.
- *                       NOT YET IMPLEMENTED
  *
  * "nn" is measured in "points" which is 1/10 the nominal width of chars
  * in the default font size, which is called "10".  A positive value is
@@ -96,7 +95,7 @@ struct render_item {
                                 * it.
                                 */
        uint8_t         hide;   /* This and consecutive render_items
-                                * with the same hide nmber form a
+                                * with the same hide number form a
                                 * hidden extent which is visible when
                                 * the cursor is in it.
                                 */
@@ -256,8 +255,8 @@ static void parse_line(struct rline_data *rd safe)
                         * which should leave either a trailing comma, or an
                         * empty string.
                         */
-                       buf_append(&attr, ',');
                        old_len = attr.len;
+                       buf_append(&attr, ',');
                        foreach_attr(a, v, st, line) {
                                if (amatch(a, "centre") || amatch(a, "center") ||
                                    amatch(a, "ctab")) {
@@ -1044,6 +1043,7 @@ static int render_image(struct pane *p safe, struct pane *focus safe,
        struct xy xyscale = pane_scale(focus);
        int scale = xyscale.x;
        struct xy size= {-1, -1};
+       char mode[30] = "";
        const char *a, *v;
        const char *end;
 
@@ -1097,6 +1097,9 @@ static int render_image(struct pane *p safe, struct pane *focus safe,
                         */
                        map_offset = v - orig_line;
                        parse_map(v, &rows, &cols);
+                       if (rows > 0 && cols > 0)
+                               snprintf(mode, sizeof(mode),
+                                        ":%dx%d", cols, rows);
                }
        }
        pane_resize(p, (p->parent->w - width)/2, p->y, width, height);
@@ -1130,8 +1133,8 @@ static int render_image(struct pane *p safe, struct pane *focus safe,
        }
 
        if (fname && dodraw)
-               home_call(focus, "Draw:image", p, 5, NULL, fname,
-                         0, NULL, NULL, cols, rows);
+               home_call(focus, "Draw:image", p, 0, NULL, fname,
+                         0, NULL, mode);
 
        free(fname);
 
@@ -1352,7 +1355,7 @@ DEF_CMD(renderline_set)
        return 1;
 }
 
-DEF_CMD(renderline_close)
+DEF_CMD_CLOSED(renderline_close)
 {
        struct rline_data *rd = ci->home->data;
        struct render_item *ri = rd->content;
@@ -1389,7 +1392,6 @@ DEF_CMD(renderline_attach)
                key_add(rl_map, "get-attr", &renderline_get);
                key_add(rl_map, "render-line:set", &renderline_set);
                key_add(rl_map, "Close", &renderline_close);
-               key_add(rl_map, "Free", &edlib_do_free);
        }
 
        p = pane_register(ci->focus, ci->num, &renderline_handle.c);