aboutsummaryrefslogtreecommitdiff
path: root/text-motions.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-01-13 19:41:56 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-01-13 23:01:09 +0100
commitff587fb25a56656a9a426a5086b47a5cf891092b (patch)
tree911915a3d8ecca9f48effe889bd069776d0f2472 /text-motions.c
parentcad4ad2c4e9de198ca78958b4db79886ffb81c56 (diff)
downloadvis-ff587fb25a56656a9a426a5086b47a5cf891092b.tar.gz
vis-ff587fb25a56656a9a426a5086b47a5cf891092b.tar.xz
Add new logical linewise movements
The column position is currently not correctly preserved when there are lines with multibyte characters involved spanning multiple screen lines. In general this might still be a bit fragile.
Diffstat (limited to 'text-motions.c')
-rw-r--r--text-motions.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/text-motions.c b/text-motions.c
index 3a970e8..00e3cc8 100644
--- a/text-motions.c
+++ b/text-motions.c
@@ -154,6 +154,15 @@ size_t text_line_next(Text *txt, size_t pos) {
return it.pos;
}
+size_t text_line_offset(Text *txt, size_t pos, size_t off) {
+ char c;
+ size_t bol = text_line_begin(txt, pos);
+ Iterator it = text_iterator_get(txt, bol);
+ while (off-- > 0 && text_iterator_byte_get(&it, &c) && c != '\r' && c != '\n')
+ text_iterator_byte_next(&it, NULL);
+ return it.pos;
+}
+
static size_t text_customword_start_next(Text *txt, size_t pos, int (*isboundry)(int)) {
char c;
Iterator it = text_iterator_get(txt, pos);