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.
13 DEF_CMD(test_render_prev)
15 struct mark *m = ci->mark;
20 if (doc_prev(ci->focus, m) == WEOF)
22 call("doc:EOL", ci->focus, -1, m);
26 DEF_CMD(test_render_line)
28 struct mark *m = ci->mark;
37 call("doc:EOL", ci->focus, 1, m, NULL, 1);
38 s = call_ret(str, "doc:get-str", ci->focus, 0, st, NULL, 0, m);
40 struct mark *m2 = mark_dup(st);
41 call("doc:char", ci->focus, ci->num, m2, NULL, 0, m);
44 if (s && ci->num < (int)utf8_strlen(s))
48 char *s2 = call_ret(str, "doc:get-str", ci->focus,
51 pm_offset = s2 ? strlen(s2) : 0;
54 ret = comm_call(ci->comm2, "cb", ci->focus, pm_offset, NULL, s);
59 static struct map *tmu_map safe;
60 DEF_LOOKUP_CMD(test_markup_handle, tmu_map);
66 ret = pane_register(ci->focus, 0, &test_markup_handle.c);
69 return comm_call(ci->comm2, "cb", ret);
74 call("attach-test-markup", ci->focus);
78 void edlib_init(struct pane *ed safe)
80 tmu_map = key_alloc();
82 key_add(tmu_map, "doc:render-line", &test_render_line);
83 key_add(tmu_map, "doc:render-line-prev", &test_render_prev);
85 call_comm("global-set-command", ed, &test_attach,
86 0, NULL, "attach-test-markup");
87 call_comm("global-set-command" ,ed, &test_enable,
88 0, NULL, "interactive-cmd-test-markup");