From 416785f53c1af30b7c4fbc1a9a22df046b90f009 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 15 Aug 2012 18:18:12 +0200 Subject: [PATCH] Add BufferIterator::clamp(bool avoid_eol) method --- src/buffer.hh | 2 ++ src/buffer_iterator.inl.hh | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/buffer.hh b/src/buffer.hh index a0d19836..0c57f851 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -61,6 +61,8 @@ public: BufferIterator& operator++ (); BufferIterator& operator-- (); + void clamp(bool avoid_eol); + bool is_begin() const; bool is_end() const; bool is_valid() const; diff --git a/src/buffer_iterator.inl.hh b/src/buffer_iterator.inl.hh index 56d7efa1..eb9d5bcb 100644 --- a/src/buffer_iterator.inl.hh +++ b/src/buffer_iterator.inl.hh @@ -28,6 +28,12 @@ inline bool BufferIterator::is_valid() const column() == m_buffer->m_lines.back().length())); } +inline void BufferIterator::clamp(bool avoid_eol) +{ + assert(m_buffer); + m_coord = m_buffer->clamp(m_coord, avoid_eol); +} + inline bool BufferIterator::operator==(const BufferIterator& iterator) const { assert(m_buffer == iterator.m_buffer);