From 5fe796490718f84d20ff9c836ce75d5318d44c69 Mon Sep 17 00:00:00 2001 From: wrmr Date: Wed, 6 Nov 2024 00:04:05 -0500 Subject: add link number navigation --- doc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'doc.c') diff --git a/doc.c b/doc.c index 89ff756..d41db7c 100644 --- a/doc.c +++ b/doc.c @@ -17,6 +17,7 @@ void doc_init(struct doc *d) { .len = 0, }; d->latest = 0; + d->linkc = 0; } void doc_fini(struct doc *d) { @@ -89,3 +90,12 @@ int doc_line_next(struct doc *d, size_t *ofs) { return -1; } } + +const char *doc_get_link(struct doc *d, unsigned short lnk) { + size_t l = 1; + for (size_t i = 0; i < d->lnk.sz; i++) { + if (l == lnk) return &d->lnk.buf[i]; + if (d->lnk.buf[i] == 0) l++; + } + return NULL; +} -- cgit 1.4.1-2-gfad0