return doc_attr(d, NULL, 0, attr);
}
-static int docs_set_attr(struct point *p, char *attr, char *val)
-{
- return 0;
-}
-
static struct doc_operations docs_ops = {
.replace = docs_replace,
.step = docs_step,
.same_ref = docs_sameref,
.get_attr = docs_get_attr,
- .set_attr = docs_set_attr,
};
DEF_CMD(docs_open)
* after the point/mark. They fail at EOF.
*/
char *(*get_attr)(struct doc *d, struct mark *m, bool forward, char *attr);
- int (*set_attr)(struct point *pos, char *attr, char *val);
};
void doc_init(struct doc *d);
{
return d->ops->get_attr(d, m, forward, attr);
}
+
+static inline int doc_set_attr(struct point *pt, char *attr, char *val)
+{
+ struct cmd_info ci = {0};
+ struct doc *d = pt->doc;
+
+ ci.key = "doc:set-attr";
+ ci.pointp = &pt;
+ ci.str = attr;
+ ci.str2 = val;
+ return key_lookup(d->map, &ci);
+}
+
return attr_get_str(de->attrs, attr, -1);
}
-static int dir_set_attr(struct point *p, char *attr, char *val)
-{
- return 0;
-}
-
DEF_CMD(dir_destroy)
{
struct doc *d = (*ci->pointp)->doc;
.step = dir_step,
.same_ref = dir_sameref,
.get_attr = dir_get_attr,
- .set_attr = dir_set_attr,
};
DEF_CMD(dir_open)
return attr_get_str(c->attrs, attr, o);
}
-static int text_set_attr(struct point *p, char *attr, char *val)
+DEF_CMD(text_set_attr)
{
+ struct point *p = *ci->pointp;
+ char *attr = ci->str;
+ char *val = ci->str2;
struct text_chunk *c = p->m.ref.c;
struct text *t = container_of(p->doc, struct text, doc);
int o = p->m.ref.o;
.step = text_step,
.same_ref = text_sameref,
.get_attr = text_get_attr,
- .set_attr = text_set_attr,
};
#define LARGE_LINE 4096
key_add(text_map, "doc:set-ref", &text_set_ref);
key_add(text_map, "doc:save-file", &text_save_file);
key_add(text_map, "doc:reundo", &text_reundo);
+ key_add(text_map, "doc:set-attr", &text_set_attr);
}
do {
/* TEMP HACK - please fix */
- d->ops->set_attr(esi->end, "highlight", NULL);
+ doc_set_attr(esi->end, "highlight", NULL);
wch = mark_next(d, &esi->end->m);
if (wch == WEOF)
return 1;
doc_del_view((*ci->pointp)->doc, &esi->watch);
/* TEMP HACK - please fix */
- esi->target->point->doc->ops->set_attr(esi->end, "highlight", NULL);
+ doc_set_attr(esi->end, "highlight", NULL);
point_free(esi->end);
mark_free(esi->start);
while (esi->s) {
/* document has changed, retry search */
struct es_info *esi = container_of(ci->comm, struct es_info, watch);
struct cmd_info ci2 = {0};
- struct doc *d = esi->end->doc;
struct pane *p;
char *a, *pfx;
int ret;
}
/* TEMP HACK - please fix */
- d->ops->set_attr(esi->end, "highlight", NULL);
+ doc_set_attr(esi->end, "highlight", NULL);
ci2.pointp = &esi->end;
ci2.mark = mark_dup(esi->start, 1);
ci2.str = doc_getstr(*ci->pointp, NULL);
} else if (ci2.extra > 0) {
point_to_mark(esi->end, ci2.mark);
/* TEMP HACK - please fix */
- d->ops->set_attr(esi->end, "highlight","fg:red,inverse");
+ doc_set_attr(esi->end, "highlight","fg:red,inverse");
ci2.key = "Move-View-Pos";
ci2.focus = esi->target;
key_handle_focus(&ci2);