struct rline_data {
short prefix_len;
- const char *xyattr;
const char *cursattr;
short curs_width;
int scale;
const char *xypos = NULL;
const char *ret_xypos = NULL;
const char *xyattr = NULL;
+ char *ret_xyattr = NULL;
const char *cursattr = NULL;
/* want_xypos becomes 2 when the pos is found */
int want_xypos = strcmp(ci->key, "render-line:findxy") == 0;
* At that time ret_xypos is set, to be used to provide return value.
* This might happen when y exceeds ypos, or we hit end-of-page.
*/
- if (want_xypos) {
- free((void*)rd->xyattr);
- rd->xyattr = NULL;
- }
+
while (*line && y < p->h && !end_of_page) {
if (mwidth <= 0) {
posx = -1;
if (want_xypos == 1 && xypos) {
- rd->xyattr = xyattr ? strdup(xyattr) : NULL;
+ ret_xyattr = xyattr ? strdup(xyattr) : NULL;
ret_xypos = xypos;
want_xypos = 2;
}
&wrap_margin, NULL, &xypos, &xyattr, &cursattr);
if (want_xypos == 1) {
- rd->xyattr = xyattr ? strdup(xyattr) : NULL;
+ ret_xyattr = xyattr ? strdup(xyattr) : NULL;
ret_xypos = xypos ?: line;
want_xypos = 2;
}
free(r);
}
if (want_xypos) {
+ int pos = 0;
if (ret_xypos)
- return ret_xypos - line_start + 1;
- else
- return 1;
+ pos = ret_xypos - line_start;
+ comm_call(ci->comm2, "cb", ci->focus, pos, NULL, ret_xyattr);
+ free(ret_xyattr);
+ return pos + 1;
+
} else
return end_of_page ? 2 : 1;
}
snprintf(buf, sizeof(buf), "%d", rd->prefix_len);
else if (strcmp(ci->str, "curs_width") == 0)
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)
{
struct rline_data *rd = &ci->home->data;
- free((void*)rd->xyattr);
free((void*)rd->line);
- rd->xyattr = NULL;
return 1;
}
/* Returns offset of posx,posy */
static int find_xy_line(struct pane *p safe, struct pane *focus safe,
- struct mark *mk safe, short posx, short posy)
+ struct mark *mk safe, short posx, short posy,
+ const char **xyattr)
{
struct pane *hp = mk->mdata;
- int ret = 0;
-
- if (hp) {
- ret = pane_call(hp,
- "render-line:findxy",
- focus,
- -1, NULL, NULL,
- 0, NULL, NULL,
- posx - hp->x, posy - hp->y);
- }
+ struct call_return cr;
+
+ if (!hp)
+ return -1;
+ cr = pane_call_ret(all, hp,
+ "render-line:findxy",
+ focus,
+ -1, NULL, NULL,
+ 0, NULL, NULL,
+ posx - hp->x, posy - hp->y);
+ if (xyattr)
+ *xyattr = cr.s;
/* xypos */
- return ret > 0 ? (ret - 1) : -1;
+ return cr.ret > 0 ? (cr.ret - 1) : -1;
}
static void draw_line(struct pane *p safe, struct pane *focus safe,
struct pane *focus = ci->focus;
struct rl_data *rl = p->data;
const char *action = ci->str;
+ const char *xyattr = NULL;
struct mark *m;
struct mark *m2 = NULL;
struct xy cih;
action = NULL;
cih.y = m->mdata->y;
}
- xypos = find_xy_line(p, focus, m, cih.x, cih.y);
+ xypos = find_xy_line(p, focus, m, cih.x, cih.y, &xyattr);
if (xypos >= 0) {
m2 = call_render_line_offset(focus, m, xypos);
if (m2) {
}
}
if (m2) {
- char *tag, *xyattr;
+ char *tag;
- if (action) {
- xyattr = pane_attr_get(m->mdata, "xyattr");
+ if (action && xyattr) {
tag = get_action_tag(action, xyattr);
if (tag) {
int x, y;
goto done;
xypos = find_xy_line(p, focus, start, rl->target_x,
- rl->target_y + start->mdata->y);
+ rl->target_y + start->mdata->y, NULL);
if (xypos < 0)
goto done;