Skip to content

Commit

Permalink
Introduce a logical line as text-object
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Sep 3, 2014
1 parent a217c08 commit 3ef242a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions text-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions text-objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3ef242a

Please sign in to comment.