summary refs log tree commit diff
path: root/nav.c
diff options
context:
space:
mode:
Diffstat (limited to 'nav.c')
-rw-r--r--nav.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/nav.c b/nav.c
index 8df829e..6d81ddd 100644
--- a/nav.c
+++ b/nav.c
@@ -51,26 +51,15 @@ size_t pg_lines(void) {
 }
 
 struct doc_line *nav_cur_line(struct nav_state *ns) {
-	return (struct doc_line *)&ns->histv[ns->cur_doc].txt.buf[ns->cur_ofs[ns->cur_doc]];
+	return doc_line_at(&ns->histv[ns->cur_doc], ns->cur_ofs[ns->cur_doc]);
 }
 
 int nav_line_up(struct nav_state *ns) {
-	if (ns->cur_ofs[ns->cur_doc] > 0) {
-		ns->cur_ofs[ns->cur_doc] -= nav_cur_line(ns)->prev + sizeof(struct doc_line); 
-		return 1;
-	} else {
-		return 0;
-	}
+	return !doc_line_prev(&ns->histv[ns->cur_doc], &ns->cur_ofs[ns->cur_doc]);
 }
 
 int nav_line_down(struct nav_state *ns) {
-	struct doc_line *l = nav_cur_line(ns);
-	if (ns->cur_ofs[ns->cur_doc] + sizeof(struct doc_line) + l->len < ns->histv[ns->cur_doc].txt.sz) {
-		ns->cur_ofs[ns->cur_doc] += l->len + sizeof(struct doc_line); 
-		return 1;
-	} else {
-		return 0;
-	}
+	return !doc_line_next(&ns->histv[ns->cur_doc], &ns->cur_ofs[ns->cur_doc]);
 }
 
 void nav_pg_up(struct nav_state *ns) {