'R' - place on right if full width isn't used
'T' - place at top if full height isn't used
'B' - place at bottom if full height isn't used.
-- (x,y) gives a number of rows and cols to overlay on the image for
- the purpose of cursor positioning. If these are positive and
- p->cx,cy are not negative, draw a cursor at p->cx,cy highlighting
- the relevant cell.
+ Also a suffix ":NNxNN" will be parse and the two numbers used
+ to give number of rows and cols to overlay on the image for
+ the purpose of cursor positioning. If these are present and
+ p->cx,cy are not negative, draw a cursor at p->cx,cy highlighting
+ the relevant cell.
## all-displays
* 'T' - place at top if full height isn't used
* 'B' - place at bottom if full height isn't used.
*
- * If 'x' and 'y' are both positive, draw cursor box at
- * p->cx, p->cy of a size so that 'x' will fit across and
- * 'y' will fit down.
+ * Also a suffix ":NNxNN" will be parse and the two numbers used
+ * to give number of rows and cols to overlay on the image for
+ * the purpose of cursor positioning. If these are present and
+ * p->cx,cy are not negative, draw a cursor at p->cx,cy highlighting
+ * the relevant cell.
*/
struct pane *p = ci->home;
struct display_data *dd = p->data;
buf = malloc(h * w * 4);
MagickExportImagePixels(wd, 0, 0, w, h, "RGBA", CharPixel, buf);
- if (ci->x > 0 && ci->y > 0 && ci->focus->cx >= 0) {
+ if (ci->focus->cx >= 0 && strchr(mode, ':')) {
/* We want a cursor */
cx = x + ci->focus->cx;
cy = y + ci->focus->cy;
* 'T' - place at top if full height isn't used
* 'B' - place at bottom if full height isn't used.
*
- * If 'x' and 'y' are both positive, draw cursor box at
- * p->cx, p->cy of a size so that 'x' will fit across and
- * 'y' will fit down.
+ * Also a suffix ":NNxNN" will be parse and the two numbers used
+ * to give number of rows and cols to overlay on the image for
+ * the purpose of cursor positioning. If these are present and
+ * p->cx,cy are not negative, draw a cursor at p->cx,cy highlighting
+ * the relevant cell.
*/
struct xcb_data *xd = ci->home->data;
const char *mode = ci->str2 ?: "";
cairo_surface_destroy(surface);
free(buf);
- if (ci->x > 0 && ci->y > 0 && ci->focus->cx >= 0) {
+ if (ci->focus->cx >= 0) {
struct pane *p = ci->focus;
- cairo_rectangle(ps->ctx, p->cx + xo, p->cy + yo,
- w/ci->x, h/ci->y);
- cairo_set_line_width(ps->ctx, 1.0);
- cairo_set_source_rgb(ps->ctx, 1.0, 0.0, 0.0);
- cairo_stroke(ps->ctx);
+ int rows, cols;
+ char *cl = strchr(mode, ':');
+ if (cl && sscanf(cl, ":%dx%d", &cols, &rows) == 2) {
+ cairo_rectangle(ps->ctx, p->cx + xo, p->cy + yo,
+ w/cols, h/rows);
+ cairo_set_line_width(ps->ctx, 1.0);
+ cairo_set_source_rgb(ps->ctx, 1.0, 0.0, 0.0);
+ cairo_stroke(ps->ctx);
+ }
}
DestroyMagickWand(wd);
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;
*/
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);
if (fname && dodraw)
home_call(focus, "Draw:image", p, 0, NULL, fname,
- 0, NULL, NULL, cols, rows);
+ 0, NULL, mode);
free(fname);
return True
- def handle_image(self, key, focus, str1, str2, xy, **a):
+ def handle_image(self, key, focus, str1, str2, **a):
"handle:Draw:image"
self.damaged(edlib.DAMAGED_POSTORDER)
# 'str1' identifies the image. Options are:
# 'T' - place at top if full height isn't used
# 'B' - place at bottom if full height isn't used.
#
- # xy gives a number of rows and cols to overlay on the image
- # for the purpose of cursor positioning. If these are positive
- # and focus.cx,cy are not negative, draw a cursor at cx,cy
- # highlighting the relevant cell.
+ # Also a suffix ":NNxNN" will be parse and the two numbers used
+ # to give number of rows and cols to overlay on the image for
+ # the purpose of cursor positioning. If these are present and
+ # focus.cx,cy are not negative, draw a cursor at cx,cy highlighting
+ # the relevant cell.
if not str1:
return edlib.Enoarg
mode = str2 if str2 else ""
Gdk.cairo_set_source_pixbuf(cr, scale, x + xo, y + yo)
cr.paint()
- (rows,cols) = xy
+ (rows,cols) = (-1,-1)
+ if ':' in mode:
+ rc = mode[mode.rindex(':')+1:].split('x')
+ try:
+ (rows,cols) = (int(rc[0]), int(rc[1]))
+ except ValueError:
+ pass
+ except IndexError:
+ pass
if rows > 0 and cols > 0 and focus.cx >= 0:
cr.rectangle(focus.cx + xo, focus.cy + yo,
w/rows, h/cols)