aboutsummaryrefslogtreecommitdiff
path: root/text-motions.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-25 11:43:05 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-25 11:43:05 +0200
commitcf2d9645e703f37d96af372b67168989862c1478 (patch)
tree74210340647c1a45eab5513a1b9854e686f883e8 /text-motions.c
parent5d43998c54d35358d154ad99add19cd1130f9f3e (diff)
downloadvis-cf2d9645e703f37d96af372b67168989862c1478.tar.gz
vis-cf2d9645e703f37d96af372b67168989862c1478.tar.xz
Introduce text_line_lastchar
Diffstat (limited to 'text-motions.c')
-rw-r--r--text-motions.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/text-motions.c b/text-motions.c
index 69afcc7..85deab8 100644
--- a/text-motions.c
+++ b/text-motions.c
@@ -126,6 +126,14 @@ size_t text_line_finish(Text *txt, size_t pos) {
return it.pos;
}
+size_t text_line_lastchar(Text *txt, size_t pos) {
+ char c;
+ Iterator it = text_iterator_get(txt, text_line_end(txt, pos));
+ if (text_iterator_char_prev(&it, &c) && c == '\n')
+ text_iterator_byte_next(&it, NULL);
+ return it.pos;
+}
+
size_t text_line_end(Text *txt, size_t pos) {
char c;
Iterator it = text_iterator_get(txt, pos);