diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-24 18:43:18 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-24 18:47:49 +0200 |
| commit | 0329e4aee01778f67c718cd827daa6bcfcef45f7 (patch) | |
| tree | 97ce154441c51598e5e7ae486965c5733694fddd /text-motions.c | |
| parent | 511337a68cf7329e08397631c48199641441d086 (diff) | |
| download | vis-0329e4aee01778f67c718cd827daa6bcfcef45f7.tar.gz vis-0329e4aee01778f67c718cd827daa6bcfcef45f7.tar.xz | |
text-motion: introduce text_line_{up,down}
Diffstat (limited to 'text-motions.c')
| -rw-r--r-- | text-motions.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/text-motions.c b/text-motions.c index 9089371..43077e9 100644 --- a/text-motions.c +++ b/text-motions.c @@ -183,6 +183,18 @@ size_t text_line_char_prev(Text *txt, size_t pos) { return it.pos; } +size_t text_line_up(Text *txt, size_t pos) { + size_t bol = text_line_begin(txt, pos); + size_t prev = text_line_prev(txt, bol); + return text_line_offset(txt, prev, pos - bol); +} + +size_t text_line_down(Text *txt, size_t pos) { + size_t bol = text_line_begin(txt, pos); + size_t next = text_line_next(txt, bol); + return text_line_offset(txt, next, pos - bol); +} + static size_t text_customword_start_next(Text *txt, size_t pos, int (*isboundry)(int)) { char c; Iterator it = text_iterator_get(txt, pos); |
