aboutsummaryrefslogtreecommitdiff
path: root/text-motions.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-07-03 18:10:05 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-07-03 18:10:05 +0200
commite939ddc25927a1b0f03f3a878acfc1ffe167ff3f (patch)
treec98f6644e480dacfbdcc3dbb8eac2aa25aac0d8f /text-motions.c
parent506be16743cc5a049b9dcc640f2da74955f1ce2f (diff)
downloadvis-e939ddc25927a1b0f03f3a878acfc1ffe167ff3f.tar.gz
vis-e939ddc25927a1b0f03f3a878acfc1ffe167ff3f.tar.xz
Add movements to next/previous character within same line
These movements always keep the cursor on the same line and do not move over newlines.
Diffstat (limited to 'text-motions.c')
-rw-r--r--text-motions.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/text-motions.c b/text-motions.c
index 59b92e0..9089371 100644
--- a/text-motions.c
+++ b/text-motions.c
@@ -165,6 +165,24 @@ size_t text_line_offset(Text *txt, size_t pos, size_t off) {
return it.pos;
}
+size_t text_line_char_next(Text *txt, size_t pos) {
+ char c;
+ Iterator it = text_iterator_get(txt, pos);
+ if (!text_iterator_byte_get(&it, &c) || c == '\r' || c == '\n')
+ return pos;
+ if (!text_iterator_char_next(&it, &c) || c == '\r' || c == '\n')
+ return pos;
+ return it.pos;
+}
+
+size_t text_line_char_prev(Text *txt, size_t pos) {
+ char c;
+ Iterator it = text_iterator_get(txt, pos);
+ if (!text_iterator_char_prev(&it, &c) || c == '\n')
+ return pos;
+ 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);