/* create spacer doc to be attached between each part */
p = call_ret(pane, "doc:from-text", p, 0, NULL, NULL, 0, NULL,
- "\n0123456789\n");
+ "0123456789\n");
if (!p)
goto out;
spacer = p;
point = vmark_new(p, MARK_POINT, NULL);
call("doc:set-ref", p, 1, point);
- doc_next(p, point);
call("doc:set-attr", p, 1, point, "markup:func", 0,
NULL, "doc:email:render-spacer");
mark_free(point);
return m->ref.docnum + 1;
}
+DEF_CMD(mp_get_boundary)
+{
+ /* return a mark past which rendering must not go. */
+ struct mark *m = ci->mark;
+
+ if (!m || !ci->comm2)
+ return Enoarg;
+ m = mark_dup(m);
+ call("doc:step-part", ci->home, ci->num, m);
+ comm_call(ci->comm2, "cb", ci->focus, 0, m);
+ return 1;
+}
+
struct mp_cb {
struct command c;
struct command *cb;
key_add(mp_map, "doc:get-attr", &mp_attr);
key_add(mp_map, "doc:set-attr", &mp_set_attr);
key_add(mp_map, "doc:step-part", &mp_step_part);
+ key_add(mp_map, "doc:get-boundary", &mp_get_boundary);
key_add(mp_map, "Close", &mp_close);
key_add(mp_map, "Free", &mp_free);
key_add(mp_map, "Notify:Close", &mp_notify_close);
struct pane *f = ci->focus;
struct mu_info *mu = ci->home->data;
struct mark *boundary = NULL;
+ struct mark *doc_boundary = NULL;
int count = 0;
int rpt = RPT_NUM(ci);
wint_t ch;
if (!m)
return Enoarg;
- if (!rpt)
+ if (!rpt) {
boundary = vmark_at_or_before(f, m, mu->view, ci->home);
+ doc_boundary = call_ret(mark, "doc:get-boundary", f, -1, m);
+ }
while ((ch = doc_prev(f, m)) != WEOF &&
(!is_eol(ch) || rpt > 0) &&
count < LARGE_LINE &&
- (!boundary || mark_ordered_not_same(boundary, m))) {
- if (rpt)
+ (!boundary || mark_ordered_not_same(boundary, m)) &&
+ (!doc_boundary || mark_ordered_not_same(doc_boundary, m))) {
+ if (rpt) {
boundary = vmark_at_or_before(f, m, mu->view, ci->home);
+ doc_boundary = call_ret(mark, "doc:get-boundary", f, -1, m);
+ }
rpt = 0;
count += 1;
}
- if (ch != WEOF && !is_eol(ch)) {
+ if (ch != WEOF && !is_eol(ch) &&
+ (!doc_boundary || !mark_same(doc_boundary, m))) {
/* Just cross the boundary, or the max count.
* Need to step back, and ensure there is a stable boundary
* here.
*/
+ mark_free(doc_boundary);
doc_next(f, m);
if (!boundary || !mark_same(boundary, m)) {
boundary = vmark_new(f, mu->view, ci->home);
}
return 1;
}
+ mark_free(doc_boundary);
if (ch == WEOF && rpt)
return Efail;
/* Found a '\n', so step forward over it for start-of-line. */
struct mark *m = ci->mark;
struct mark *pm = ci->mark2; /* The location to render as cursor */
struct mark *boundary, *start_boundary = NULL;
+ struct mark *doc_boundary;
int o = ci->num;
wint_t ch;
int chars = 0;
start_boundary = boundary;
boundary = vmark_next(boundary);
}
+ doc_boundary = call_ret(mark, "doc:get-boundary", focus, 1, m);
+
buf_init(&b);
call_comm("map-attr", focus, &ar.rtn, 0, m, "start-of-line");
while (1) {
}
if (boundary && mark_ordered_or_same(boundary, m))
break;
+ if (doc_boundary && mark_ordered_or_same(doc_boundary, m))
+ break;
if (ch == '<') {
if (o >= 0 && b.len+1 >= o) {
doc_prev(focus, m);
/* This boundary is no longer well-placed. */
mark_free(start_boundary);
+ mark_free(doc_boundary);
+
ret = comm_call(ci->comm2, "callback:render", focus, 0, NULL,
buf_final(&b));
free(b.b);