2 * Copyright Neil Brown ©2023 <neil@brown.name>
3 * May be distributed under terms of GPLv2 - see file:COPYING
5 * This is a replacement for lib-markup which uses each line
6 * of the document as verbatim markup. This is for testing only.
12 DEF_CMD(test_render_prev)
14 struct mark *m = ci->mark;
19 if (doc_prev(ci->focus, m) == WEOF)
21 call("doc:EOL", ci->focus, -1, m);
25 DEF_CMD(test_render_line)
27 struct mark *m = ci->mark;
36 call("doc:EOL", ci->focus, 1, m, NULL, 1);
37 s = call_ret(str, "doc:get-str", ci->focus, 0, st, NULL, 0, m);
39 struct mark *m2 = mark_dup(st);
40 call("doc:char", ci->focus, ci->num, m2, NULL, 0, m);
43 if (s && ci->num < (int)utf8_strlen(s))
47 char *s2 = call_ret(str, "doc:get-str", ci->focus,
50 pm_offset = s2 ? strlen(s2) : 0;
53 ret = comm_call(ci->comm2, "cb", ci->focus, pm_offset, NULL, s);
58 static struct map *tmu_map safe;
59 DEF_LOOKUP_CMD(test_markup_handle, tmu_map);
65 ret = pane_register(ci->focus, 0, &test_markup_handle.c);
68 return comm_call(ci->comm2, "cb", ret);
73 call("attach-test-markup", ci->focus);
77 void edlib_init(struct pane *ed safe)
79 tmu_map = key_alloc();
81 key_add(tmu_map, "doc:render-line", &test_render_line);
82 key_add(tmu_map, "doc:render-line-prev", &test_render_prev);
84 call_comm("global-set-command", ed, &test_attach,
85 0, NULL, "attach-test-markup");
86 call_comm("global-set-command" ,ed, &test_enable,
87 0, NULL, "interactive-cmd-test-markup");