From 2f410f62e4d3a13a8f81da494037e5eb1ab21bb3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 27 Feb 2013 19:11:25 +0100 Subject: [PATCH] Add String Range::content() const --- src/editor.cc | 2 +- src/selection.cc | 5 +++++ src/selection.hh | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/editor.cc b/src/editor.cc index 77080312..6f3255ed 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -119,7 +119,7 @@ std::vector Editor::selections_content() const { std::vector contents; for (auto& sel : m_selections) - contents.push_back(m_buffer->string(sel.begin(), sel.end())); + contents.push_back(sel.content()); return contents; } diff --git a/src/selection.cc b/src/selection.cc index 04ebae81..7868fb15 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -24,6 +24,11 @@ BufferIterator Range::end() const return utf8::next(std::max(m_first, m_last)); } +String Range::content() const +{ + return m_first.buffer().string(begin(), end()); +} + void Range::check_invariant() const { #ifdef KAK_DEBUG diff --git a/src/selection.hh b/src/selection.hh index 294ecee1..9bf2065f 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -31,6 +31,8 @@ public: // returns max(first, last) + 1 BufferIterator end() const; + String content() const; + void check_invariant() const; private: BufferIterator m_first;