summary refs log tree commit diff
path: root/doc.c
diff options
context:
space:
mode:
authorwrmr2024-11-06 00:04:05 -0500
committerwrmr2024-11-06 00:04:05 -0500
commit5fe796490718f84d20ff9c836ce75d5318d44c69 (patch)
tree87abe322bee07ff6d4f4231bb7e79f81be63094f /doc.c
parent837a9067c0ef2e0b3affbf7035788cd0e80ce7ba (diff)
add link number navigation
Diffstat (limited to 'doc.c')
-rw-r--r--doc.c10
1 files changed, 10 insertions, 0 deletions
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;
+}