summaryrefslogtreecommitdiff
path: root/src/buffer_utils.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-07-28 09:41:47 +0100
committerMaxime Coste <frrrwww@gmail.com>2016-07-28 09:41:47 +0100
commita7005ec74be9eef4595031bfe9191cc8bd5a08e3 (patch)
tree497e00c33a89230efce4cc14b02868be7fc2eab6 /src/buffer_utils.hh
parent74c3f101cd60e213962026f0bb0235102f7bc833 (diff)
Add a char_length(Buffer&, const ByteCoord&, const ByteCoord&) util
Diffstat (limited to 'src/buffer_utils.hh')
-rw-r--r--src/buffer_utils.hh5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/buffer_utils.hh b/src/buffer_utils.hh
index a8226660..58192f31 100644
--- a/src/buffer_utils.hh
+++ b/src/buffer_utils.hh
@@ -31,6 +31,11 @@ inline CharCount char_length(const Buffer& buffer, const Selection& range)
buffer.iterator_at(buffer.char_next(range.max())));
}
+inline CharCount char_length(const Buffer& buffer, const ByteCoord& begin, const ByteCoord& end)
+{
+ return utf8::distance(buffer.iterator_at(begin), buffer.iterator_at(end));
+}
+
inline bool is_bol(ByteCoord coord)
{
return coord.column == 0;