aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-03 16:19:17 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-03 16:19:17 +0200
commit3ef242ae90ed7c798b83e2765cb721ef64e7516d (patch)
treeb802b9dc18cfedafb79b6f016dd65d3d94e60f22
parenta217c08cb342772b2adbb0ccf9cb2d64550376fc (diff)
downloadvis-3ef242ae90ed7c798b83e2765cb721ef64e7516d.tar.gz
vis-3ef242ae90ed7c798b83e2765cb721ef64e7516d.tar.xz
Introduce a logical line as text-object
-rw-r--r--text-objects.c13
-rw-r--r--text-objects.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/text-objects.c b/text-objects.c
index 4063992..bce8b5b 100644
--- a/text-objects.c
+++ b/text-objects.c
@@ -41,6 +41,19 @@ Filerange text_object_word(Text *txt, size_t pos) {
return r;
}
+Filerange text_object_line(Text *txt, size_t pos) {
+ char c;
+ Filerange r;
+ r.start = text_line_begin(txt, pos);
+ Iterator it = text_iterator_get(txt, text_line_end(txt, pos));
+ if (text_iterator_byte_get(&it, &c) && c == '\n')
+ text_iterator_byte_next(&it, NULL);
+ if (text_iterator_byte_get(&it, &c) && c == '\r')
+ text_iterator_byte_next(&it, NULL);
+ r.end = it.pos;
+ return r;
+}
+
Filerange text_object_sentence(Text *txt, size_t pos) {
Filerange r;
r.start = text_sentence_prev(txt, pos);
diff --git a/text-objects.h b/text-objects.h
index 211e4e6..5b3895d 100644
--- a/text-objects.h
+++ b/text-objects.h
@@ -8,6 +8,7 @@
* be a whitespace include all neighbouring leading whitespaces and the following word. */
Filerange text_object_word(Text*, size_t pos);
Filerange text_object_word_boundry(Text*, size_t pos, int (*isboundry)(int));
+Filerange text_object_line(Text*, size_t pos);
Filerange text_object_sentence(Text*, size_t pos);
Filerange text_object_paragraph(Text*, size_t pos);