aboutsummaryrefslogtreecommitdiff
path: root/text-motions.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-05 07:29:27 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-05 07:29:27 +0200
commitc0b411255115569c63430d0162920b53747a917a (patch)
treeb13e741ed8478dc781045e0f4f9680e3e121da1f /text-motions.c
parentbbb3a3ba1f17ccc95f1e7778312a5915afca182d (diff)
downloadvis-c0b411255115569c63430d0162920b53747a917a.tar.gz
vis-c0b411255115569c63430d0162920b53747a917a.tar.xz
Add helper function which finds the start of the next line
Diffstat (limited to 'text-motions.c')
-rw-r--r--text-motions.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/text-motions.c b/text-motions.c
index 666e9db..fc87950 100644
--- a/text-motions.c
+++ b/text-motions.c
@@ -98,6 +98,16 @@ size_t text_line_end(Text *txt, size_t pos) {
return text_find_char_next(txt, pos, "\n", 1);
}
+size_t text_line_next(Text *txt, size_t pos) {
+ char c;
+ Iterator it = text_iterator_get(txt, pos);
+ while (text_iterator_byte_get(&it, &c) && c != '\n')
+ text_iterator_byte_next(&it, NULL);
+ if (text_iterator_byte_next(&it, &c) && c == '\r')
+ text_iterator_byte_next(&it, NULL);
+ return it.pos;
+}
+
size_t text_word_boundry_start_next(Text *txt, size_t pos, int (*isboundry)(int)) {
char c;
Iterator it = text_iterator_get(txt, pos);