From a7005ec74be9eef4595031bfe9191cc8bd5a08e3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 28 Jul 2016 09:41:47 +0100 Subject: Add a char_length(Buffer&, const ByteCoord&, const ByteCoord&) util --- src/buffer_utils.hh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/buffer_utils.hh') 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; -- cgit v1.2.3